[PATCH] ath10k: add report MIC error for sdio chip

2019-05-27 Thread Wen Gong
Firmware will report flag with HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR
if MIC error, the flag will be used in mac80211.

ieee80211_rx_h_michael_mic_verify will check the flag and start TKIP
countermeasures.

Now countermeasure tests pass both with WPA only and WPA2/WPA mixed
mode.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/htt_rx.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c 
b/drivers/net/wireless/ath/ath10k/htt_rx.c
index a20ea27..c0b0061 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -2101,7 +2101,9 @@ static bool ath10k_htt_rx_proc_rx_ind_hl(struct 
ath10k_htt *htt,
num_mpdu_ranges);
 
if (mpdu_ranges->mpdu_range_status !=
-   HTT_RX_IND_MPDU_STATUS_OK) {
+   HTT_RX_IND_MPDU_STATUS_OK &&
+   mpdu_ranges->mpdu_range_status !=
+   HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR) {
ath10k_warn(ar, "MPDU range status: %d\n",
mpdu_ranges->mpdu_range_status);
goto err;
@@ -2162,6 +2164,9 @@ static bool ath10k_htt_rx_proc_rx_ind_hl(struct 
ath10k_htt *htt,
   RX_FLAG_MMIC_STRIPPED;
}
 
+   if (mpdu_ranges->mpdu_range_status == 
HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR)
+   rx_status->flag |= RX_FLAG_MMIC_ERROR;
+
ieee80211_rx_ni(ar->hw, skb);
 
/* We have delivered the skb to the upper layers (mac80211) so we
-- 
1.9.1



RE: [PATCH] ath10k: add support for simulate crash on SDIO chip

2019-05-27 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Nicolas
> Boichat
> Sent: Monday, April 29, 2019 1:21 PM
> To: Wen Gong 
> Cc: Claire Chang ; linux-wirel...@vger.kernel.org;
> ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH] ath10k: add support for simulate crash on SDIO
> chip
> 
> Err, so you consider _any_ CPU interrupt to be caused by the FW
> crashing? Is that correct? If so, please at least add a comment.
> 
> Otherwise, maybe you should run this only if
> MBOX_CPU_STATUS_ENABLE_ASSERT_MASK is set in cpu_int_status?
> 
> > return ret;
> >  }
> >

Hi Nicolas,
New patch has uploaded for the change
https://patchwork.kernel.org/patch/10921341/
[v2] ath10k: add support for simulate crash on SDIO chip

https://patchwork.kernel.org/patch/10955189/
[v3] ath10k: add support for firmware crash recovery on SDIO chip


[PATCH v3] ath10k: add support for firmware crash recovery on SDIO chip

2019-05-22 Thread Wen Gong
The command to simulate firmware crash:
echo soft > /sys/kernel/debug/ieee80211/phy0/ath10k/simulate_fw_crash

It will send WMI_FORCE_FW_HANG_ASSERT to firmware, then it will trigger
CPU interrupt status register for SDIO chip, ath10k driver need to
configure it while enable SDIO interrupt, otherwise ath10k driver will
not get the assert error info.

After this change, it will success for simulate firmware crash.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
v3: change commit log title
v2: add MBOX_CPU_STATUS_ENABLE_ASSERT_MASK for fw assert check
 drivers/net/wireless/ath/ath10k/hw.h   |  1 +
 drivers/net/wireless/ath/ath10k/sdio.c | 10 --
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 7131499..60521ed 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -1095,6 +1095,7 @@ struct ath10k_hw_ops {
 #define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x0819
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_CPU_STATUS_ENABLE_ASSERT_MASK 0x0001
 #define MBOX_ERROR_STATUS_ENABLE_ADDRESS   0x081a
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x0002
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index fae56c6..1a3a7bf 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -850,6 +850,10 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k 
*ar)
 
 out:
mutex_unlock(_data->mtx);
+   if (cpu_int_status & MBOX_CPU_STATUS_ENABLE_ASSERT_MASK) {
+   ath10k_err(ar, "firmware crashed!\n");
+   queue_work(ar->workqueue, >restart_work);
+   }
return ret;
 }
 
@@ -1495,8 +1499,10 @@ static int ath10k_sdio_hif_enable_intrs(struct ath10k 
*ar)
regs->int_status_en |=
FIELD_PREP(MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK, 1);
 
-   /* Set up the CPU Interrupt status Register */
-   regs->cpu_int_status_en = 0;
+   /* Set up the CPU Interrupt Status Register, enable CPU sourced 
interrupt #0
+* #0 is used for report assertion from target
+*/
+   regs->cpu_int_status_en = 
FIELD_PREP(MBOX_CPU_STATUS_ENABLE_ASSERT_MASK, 1);
 
/* Set up the Error Interrupt status Register */
regs->err_int_status_en =
-- 
1.9.1



RE: [PATCH v2] ath10k: add support for simulate crash on SDIO chip

2019-05-22 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Claire
> Chang
> Sent: Wednesday, May 15, 2019 10:53 AM
> To: Wen Gong 
> Cc: open list:NETWORKING DRIVERS (WIRELESS)  wirel...@vger.kernel.org>; ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH v2] ath10k: add support for simulate crash on SDIO
> chip
> 
> Tested-by: Claire Chang 
> 
> If this patch adds support for detecting the real firmware assert,
> maybe the title should be "add support for _crash recovery_ on SDIO
> chip"
Yes, seems this title is more appropriate.
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: change firmware file name for UTF mode of SDIO/USB

2019-05-14 Thread Wen Gong
Firmware name for UTF mode of SDIO has changed from utf-2.bin to
utf-sdio-2.bin, so it need to change in ath10k, otherwise it will
fail for UTF mode.

After change the name in ath10k, it will success for UTF mode of
SDIO/USB.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/hw.h   |  2 ++
 drivers/net/wireless/ath/ath10k/testmode.c | 17 -
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 7131499..d4fc13d 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -151,6 +151,8 @@ enum qca9377_chip_id_rev {
 #define ATH10K_FW_UTF_FILE "utf.bin"
 #define ATH10K_FW_UTF_API2_FILE"utf-2.bin"
 
+#define ATH10K_FW_UTF_FILE_BASE"utf"
+
 /* includes also the null byte */
 #define ATH10K_FIRMWARE_MAGIC   "QCA-ATH10K"
 #define ATH10K_BOARD_MAGIC  "QCA-ATH10K-BOARD"
diff --git a/drivers/net/wireless/ath/ath10k/testmode.c 
b/drivers/net/wireless/ath/ath10k/testmode.c
index 6433ff1..da9c596 100644
--- a/drivers/net/wireless/ath/ath10k/testmode.c
+++ b/drivers/net/wireless/ath/ath10k/testmode.c
@@ -174,8 +174,23 @@ static int ath10k_tm_fetch_firmware(struct ath10k *ar)
 {
struct ath10k_fw_components *utf_mode_fw;
int ret;
+   char fw_name[100];
+   int fw_api2 = 2;
+
+   switch (ar->hif.bus) {
+   case ATH10K_BUS_SDIO:
+   case ATH10K_BUS_USB:
+   scnprintf(fw_name, sizeof(fw_name), "%s-%s-%d.bin",
+ ATH10K_FW_UTF_FILE_BASE, ath10k_bus_str(ar->hif.bus),
+ fw_api2);
+   break;
+   default:
+   scnprintf(fw_name, sizeof(fw_name), "%s-%d.bin",
+ ATH10K_FW_UTF_FILE_BASE, fw_api2);
+   break;
+   }
 
-   ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_UTF_API2_FILE,
+   ret = ath10k_core_fetch_firmware_api_n(ar, fw_name,
   
>testmode.utf_mode_fw.fw_file);
if (ret == 0) {
ath10k_dbg(ar, ATH10K_DBG_TESTMODE, "testmode using fw utf api 
2");
-- 
1.9.1



RE: [PATCH] ath10k: remove mmc_hw_reset while hif power down

2019-05-06 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Grant
> Grundler
> Sent: Saturday, May 4, 2019 2:01 AM
> To: Wen Gong 
> Cc: linux-wirel...@vger.kernel.org; ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH] ath10k: remove mmc_hw_reset while hif power
> down
> 
> [repeating comments I made in the gerrit review for Chrome OS :
> https://chromium-
> review.googlesource.com/c/chromiumos/third_party/kernel/+/1585667
> ]
> 
> On Sat, Apr 27, 2019 at 7:17 PM Wen Gong  wrote:
> >
> > For sdio 3.0 chip, the clock will drop from 200M Hz to 50M Hz after load
> > ath10k driver, it is because mmc_hw_reset will reset the sdio's power,
> > then mmc will consider it as sdio 2.0 and drop the clock.
> 
> Wen,
> 5468e784c0600551ca03263f5255a375c05f88e7 commit message gives
> reasons
> for adding the mmc_hw_reset() call. The commit message for removing
> gives different reason for removal. Both are good but second one is
> incomplete.
> 
> The commit message for removal should ALSO explain why adding this
> call wasn't necessary in the first place OR move the call to a
> different code path.
> 
> > Remove mmc_hw_reset will avoid the drop of clock.
> 
> This commit message makes it clear the original patch introduced a new
> problem. But the original patch fixed a different problem and that
> this proposed change seems likely to re-introduce and the commit
> message should explain why that isn't true (or how the original was
> fixed differently)
Hi Grant,
The mmc_hw_reset's effect depends on the hardware layout/configure
software's behavior, recently it will effect the clock of sdio for the platform
I used. And it will still work well without mmc_hw_reset for the platform I
Used currently. 
If sdio cannot work on other platform, I think it can add flag in 
ath10k_hw_params_list for the platform to call the mmc_hw_reset depends
on the flag.
> 
> cheers,
> grant


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: ath10k: Two missing sdio patches

2019-05-05 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Erik
> Stromdahl
> Sent: Sunday, May 5, 2019 10:23 PM
> To: kv...@codeaurora.org; wg...@codeaurora.org;
> ath10k@lists.infradead.org
> Subject: [EXT] ath10k: Two missing sdio patches
> 
> Hej Kalle, Wen,
> 
> I see there are lots of SDIO patches coming in to the mailing ath10k list, 
> great!
> 
> I while back I submitted two patches that adds an inline wrapper for an htt
> op.
> 
> patchwork:
> https://patchwork.kernel.org/project/linux-wireless/list/?series=97099
> 
> Without these patches I get a panic due to calling a NULL pointer callback
> with SDIO.
> 
> It is the htt->tx_ops->htt_h2t_aggr_cfg_msg() in ath10k_htt_setup() that
> causes the panic.
> 
> Kalle:
> I notice that you don't have these patches in your pending-sdio-usb branch.
> 
> Wen:
> Do you have any other patch that fixes this issue (I can't see how it can work
> without
> these patches unless you have some other fix)?
> 
Hi Erik,
I do not have other patch to fix the issue.
The patch change the ath10k_htt_h2t_aggr_cfg_msg to 
htt->tx_ops->htt_h2t_aggr_cfg_msg in ath10k_htt_setup.
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/drivers/net/wireless/ath/ath10k/htt.c?id=5cbb117477501df2f8b3a384b042b08cd7174c92
I used chromeos which does not include the upper patch.
> --
> Erik
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: add peer id check in ath10k_peer_find_by_id

2019-04-30 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Kalle Valo
> Sent: Tuesday, April 30, 2019 5:37 PM
> To: Nicolas Boichat 
> Cc: Claire Chang ; linux-wirel...@vger.kernel.org;
> ath10k@lists.infradead.org; Wen Gong 
> Subject: [EXT] Re: [PATCH] ath10k: add peer id check in
> ath10k_peer_find_by_id
> >> --- a/drivers/net/wireless/ath/ath10k/txrx.c
> >> +++ b/drivers/net/wireless/ath/ath10k/txrx.c
> >> @@ -157,6 +157,9 @@ struct ath10k_peer
> *ath10k_peer_find_by_id(struct ath10k *ar, int peer_id)
> >>  {
> >> struct ath10k_peer *peer;
> >>
> >> +   if (peer_id >= sizeof(peer->peer_ids) * BITS_PER_BYTE)
> >
> > I'd use >= BITS_PER_TYPE(peer->peer_ids).
> 
> Nice, I didn't know about that. Wen, please submit v2 using this.
> 
> --
> Kalle Valo
Yes, 
I have send v2 yesterday:
[PATCH v2] ath10k: add peer id check in ath10k_peer_find_by_id
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2] ath10k: add peer id check in ath10k_peer_find_by_id

2019-04-29 Thread Wen Gong
For some SDIO chip, the peer id is 65535 for MPDU with error status,
then test_bit will trigger buffer overflow for peer's memory, if kasan
enabled, it will report error.

Reason is when station is in disconnecting status, firmware do not delete
the peer info since it not disconnected completely, meanwhile some AP will
still send data packet to station, then hardware will receive the packet
and send to firmware, firmware's logic will report peer id of 65535 for
MPDU with error status.

Add check for overflow the size of peer's peer_ids will avoid the buffer
overflow access.

Call trace of kasan:
dump_backtrace+0x0/0x2ec
show_stack+0x20/0x2c
__dump_stack+0x20/0x28
dump_stack+0xc8/0xec
print_address_description+0x74/0x240
kasan_report+0x250/0x26c
__asan_report_load8_noabort+0x20/0x2c
ath10k_peer_find_by_id+0x180/0x1e4 [ath10k_core]
ath10k_htt_t2h_msg_handler+0x100c/0x2fd4 [ath10k_core]
ath10k_htt_htc_t2h_msg_handler+0x20/0x34 [ath10k_core]
ath10k_sdio_irq_handler+0xcc8/0x1678 [ath10k_sdio]
process_sdio_pending_irqs+0xec/0x370
sdio_run_irqs+0x68/0xe4
sdio_irq_work+0x1c/0x28
process_one_work+0x3d8/0x8b0
worker_thread+0x508/0x7cc
kthread+0x24c/0x264
ret_from_fork+0x10/0x18

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
v2: changed from BITS_PER_BYTE to BITS_PER_TYPE
 drivers/net/wireless/ath/ath10k/txrx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/txrx.c 
b/drivers/net/wireless/ath/ath10k/txrx.c
index 23606b6..3b837b8 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -157,6 +157,9 @@ struct ath10k_peer *ath10k_peer_find_by_id(struct ath10k 
*ar, int peer_id)
 {
struct ath10k_peer *peer;
 
+   if (peer_id >= BITS_PER_TYPE(peer->peer_ids))
+   return NULL;
+
lockdep_assert_held(>data_lock);
 
list_for_each_entry(peer, >peers, list)
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2] ath10k: add support for simulate crash on SDIO chip

2019-04-29 Thread Wen Gong
The command to simulate firmware crash:
echo soft > /sys/kernel/debug/ieee80211/phy0/ath10k/simulate_fw_crash

It will send WMI_FORCE_FW_HANG_ASSERT to firmware, then it will trigger
CPU interrupt status register for SDIO chip, ath10k driver need to
configure it while enable SDIO interrupt, otherwise ath10k driver will
not get the assert error info.

After this change, it will success for simulate firmware crash.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
v2: add MBOX_CPU_STATUS_ENABLE_ASSERT_MASK for fw assert check
 drivers/net/wireless/ath/ath10k/hw.h   |  1 +
 drivers/net/wireless/ath/ath10k/sdio.c | 10 --
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 7131499..60521ed 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -1095,6 +1095,7 @@ struct ath10k_hw_ops {
 #define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x0819
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_CPU_STATUS_ENABLE_ASSERT_MASK 0x0001
 #define MBOX_ERROR_STATUS_ENABLE_ADDRESS   0x081a
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x0002
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index fae56c6..1a3a7bf 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -850,6 +850,10 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k 
*ar)
 
 out:
mutex_unlock(_data->mtx);
+   if (cpu_int_status & MBOX_CPU_STATUS_ENABLE_ASSERT_MASK) {
+   ath10k_err(ar, "firmware crashed!\n");
+   queue_work(ar->workqueue, >restart_work);
+   }
return ret;
 }
 
@@ -1495,8 +1499,10 @@ static int ath10k_sdio_hif_enable_intrs(struct ath10k 
*ar)
regs->int_status_en |=
FIELD_PREP(MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK, 1);
 
-   /* Set up the CPU Interrupt status Register */
-   regs->cpu_int_status_en = 0;
+   /* Set up the CPU Interrupt Status Register, enable CPU sourced 
interrupt #0
+* #0 is used for report assertion from target
+*/
+   regs->cpu_int_status_en = 
FIELD_PREP(MBOX_CPU_STATUS_ENABLE_ASSERT_MASK, 1);
 
/* Set up the Error Interrupt status Register */
regs->err_int_status_en =
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: remove mmc_hw_reset while hif power down

2019-04-27 Thread Wen Gong
For sdio 3.0 chip, the clock will drop from 200M Hz to 50M Hz after load
ath10k driver, it is because mmc_hw_reset will reset the sdio's power,
then mmc will consider it as sdio 2.0 and drop the clock.

Remove mmc_hw_reset will avoid the drop of clock.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/sdio.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index fae56c6..f1d2af8 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1433,10 +1433,6 @@ static void ath10k_sdio_hif_power_down(struct ath10k *ar)
return;
}
 
-   ret = mmc_hw_reset(ar_sdio->func->card->host);
-   if (ret)
-   ath10k_warn(ar, "unable to reset sdio: %d\n", ret);
-
sdio_release_host(ar_sdio->func);
 
ar_sdio->is_disabled = true;
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH v2] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-21 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Wen Gong
> Sent: Friday, April 12, 2019 4:53 PM
> To: ath10k@lists.infradead.org
> Cc: linux-wirel...@vger.kernel.org
> Subject: [EXT] [PATCH v2] ath10k: Remove ATH10K_STATE_RESTARTED in
> simulate fw crash
> @@ -554,6 +555,9 @@ static ssize_t ath10k_write_simulate_fw_crash(struct
> + sscanf(buf, "%s %s", buf_cmd, buf_flag);
> + ath10k_info(ar, "buf_cmd:%s, buf_flag:%s\n", buf_cmd, buf_flag);
> +
> + wait_ready = !strcmp(buf_cmd, "wait-ready");
>   mutex_lock(>conf_mutex);
> 
> - if (ar->state != ATH10K_STATE_ON &&
> - ar->state != ATH10K_STATE_RESTARTED) {
> + if ((!wait_ready &&
> +  ar->state != ATH10K_STATE_ON &&
> +  ar->state != ATH10K_STATE_RESTARTED) ||
> + (wait_ready &&
> +  ar->state != ATH10K_STATE_ON)) {
>   ret = -ENETDOWN;
>   goto exit;
>   }
> 

Hi Michał,

Do you have any comments for the patch v2?

> 1.9.1
> 
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: add support for simulate crash on SDIO chip

2019-04-16 Thread Wen Gong
The command to simulate firmware crash:
echo soft > /sys/kernel/debug/ieee80211/phy0/ath10k/simulate_fw_crash

It will send WMI_FORCE_FW_HANG_ASSERT to firmware, then it will trigger
CPU interrupt status register for SDIO chip, ath10k driver need to
configure it while enable SDIO interrupt, otherwise ath10k driver will
not get the assert error info.

After this change, it will success for simulate firmware crash.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/hw.h   | 1 +
 drivers/net/wireless/ath/ath10k/sdio.c | 8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 7131499..60521ed 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -1095,6 +1095,7 @@ struct ath10k_hw_ops {
 #define MBOX_CPU_INT_STATUS_ENABLE_ADDRESS 0x0819
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_LSB 0
 #define MBOX_CPU_INT_STATUS_ENABLE_BIT_MASK0x00ff
+#define MBOX_CPU_STATUS_ENABLE_ASSERT_MASK 0x0001
 #define MBOX_ERROR_STATUS_ENABLE_ADDRESS   0x081a
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_LSB  1
 #define MBOX_ERROR_STATUS_ENABLE_RX_UNDERFLOW_MASK 0x0002
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index fae56c6..78a2f3b 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -850,6 +850,8 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k *ar)
 
 out:
mutex_unlock(_data->mtx);
+   ath10k_err(ar, "firmware crashed!\n");
+   queue_work(ar->workqueue, >restart_work);
return ret;
 }
 
@@ -1495,8 +1497,10 @@ static int ath10k_sdio_hif_enable_intrs(struct ath10k 
*ar)
regs->int_status_en |=
FIELD_PREP(MBOX_INT_STATUS_ENABLE_MBOX_DATA_MASK, 1);
 
-   /* Set up the CPU Interrupt status Register */
-   regs->cpu_int_status_en = 0;
+   /* Set up the CPU Interrupt Status Register, enable CPU sourced 
interrupt #0
+* #0 is used for report assertion from target
+*/
+   regs->cpu_int_status_en = 
FIELD_PREP(MBOX_CPU_STATUS_ENABLE_ASSERT_MASK, 1);
 
/* Set up the Error Interrupt status Register */
regs->err_int_status_en =
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-12 Thread Wen Gong
When test simulate firmware crash, it is easy to trigger error.
command:
echo soft > /sys/kernel/debug/ieee80211/phyxx/ath10k/simulate_fw_crash.

If input more than two times continuously, then it will have error.
Error message:
ath10k_pci :02:00.0: failed to set vdev 1 RX wake policy: -108
ath10k_pci :02:00.0: device is wedged, will not restart

It is because the state has not changed to ATH10K_STATE_ON immediately,
then it will have more than two simulate crash process running meanwhile,
and complete/wakeup some field twice, it destroy the normal recovery
process.

add flag wait-ready for this command:
echo soft wait-ready > 
/sys/kernel/debug/ieee80211/phyxx/ath10k/simulate_fw_crash

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

Signed-off-by: Wen Gong 
---
v2: add wait-ready flag
 drivers/net/wireless/ath/ath10k/debug.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 15964b3..04a20b8 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -534,7 +534,8 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file 
*file,
"`soft` - this will send WMI_FORCE_FW_HANG_ASSERT to firmware 
if FW supports that command.\n"
"`hard` - this will send to firmware command with illegal 
parameters causing firmware crash.\n"
"`assert` - this will send special illegal parameter to 
firmware to cause assert failure and crash.\n"
-   "`hw-restart` - this will simply queue hw restart without fw/hw 
actually crashing.\n";
+   "`hw-restart` - this will simply queue hw restart without fw/hw 
actually crashing.\n"
+   "`soft wait-ready` `hard wait-ready` `assert wait-ready` 
`hw-restart wait-ready` - cmd only execuate when state is ATH10K_STATE_ON.\n";
 
return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
 }
@@ -554,6 +555,9 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file 
*file,
char buf[32] = {0};
ssize_t rc;
int ret;
+   char buf_cmd[32] = {0};
+   char buf_flag[32] = {0};
+   bool wait_ready;
 
/* filter partial writes and invalid commands */
if (*ppos != 0 || count >= sizeof(buf) || count == 0)
@@ -567,18 +571,25 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file 
*file,
if (buf[*ppos - 1] == '\n')
buf[*ppos - 1] = '\0';
 
+   sscanf(buf, "%s %s", buf_cmd, buf_flag);
+   ath10k_info(ar, "buf_cmd:%s, buf_flag:%s\n", buf_cmd, buf_flag);
+
+   wait_ready = !strcmp(buf_cmd, "wait-ready");
mutex_lock(>conf_mutex);
 
-   if (ar->state != ATH10K_STATE_ON &&
-   ar->state != ATH10K_STATE_RESTARTED) {
+   if ((!wait_ready &&
+ar->state != ATH10K_STATE_ON &&
+ar->state != ATH10K_STATE_RESTARTED) ||
+   (wait_ready &&
+ar->state != ATH10K_STATE_ON)) {
ret = -ENETDOWN;
goto exit;
}
 
-   if (!strcmp(buf, "soft")) {
+   if (!strcmp(buf_cmd, "soft")) {
ath10k_info(ar, "simulating soft firmware crash\n");
ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
-   } else if (!strcmp(buf, "hard")) {
+   } else if (!strcmp(buf_cmd, "hard")) {
ath10k_info(ar, "simulating hard firmware crash\n");
/* 0x7fff is vdev id, and it is always out of range for all
 * firmware variants in order to force a firmware crash.
@@ -586,10 +597,10 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file 
*file,
ret = ath10k_wmi_vdev_set_param(ar, 0x7fff,

ar->wmi.vdev_param->rts_threshold,
0);
-   } else if (!strcmp(buf, "assert")) {
+   } else if (!strcmp(buf_cmd, "assert")) {
ath10k_info(ar, "simulating firmware assert crash\n");
ret = ath10k_debug_fw_assert(ar);
-   } else if (!strcmp(buf, "hw-restart")) {
+   } else if (!strcmp(buf_cmd, "hw-restart")) {
ath10k_info(ar, "user requested hw restart\n");
queue_work(ar->workqueue, >restart_work);
ret = 0;
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: change swap mail box config for UTF mode of SDIO

2019-04-09 Thread Wen Gong
For SDIO chip, it does not have HTT connect step in boot phase of UTF
mode, so it does not need the swap configuration for UTF mode, otherwise
it will trigger UTF load fail. For normal mode, it is swap between HTT
and WMI, for UTF mode, it does not have HTT, so it can not swap between
HTT and WMI.

Disable swap mail box for UTF mode will let UTF mode load success.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/core.c | 11 ---
 drivers/net/wireless/ath/ath10k/sdio.c |  5 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 835b8de..79a238c 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -629,7 +629,7 @@ static void ath10k_send_suspend_complete(struct ath10k *ar)
complete(>target_suspend);
 }
 
-static void ath10k_init_sdio(struct ath10k *ar)
+static void ath10k_init_sdio(struct ath10k *ar, enum ath10k_firmware_mode mode)
 {
u32 param = 0;
 
@@ -646,7 +646,12 @@ static void ath10k_init_sdio(struct ath10k *ar)
 * not big enough for mac80211 / native wifi frames. disable it
 */
param &= ~HI_ACS_FLAGS_ALT_DATA_CREDIT_SIZE;
-   param |= HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET;
+
+   if (mode == ATH10K_FIRMWARE_MODE_UTF)
+   param &= ~HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET;
+   else
+   param |= HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_SET;
+
ath10k_bmi_write32(ar, hi_acs_flags, param);
 
/* Explicitly set fwlog prints to zero as target may turn it on
@@ -2501,7 +2506,7 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
goto err;
 
if (ar->hif.bus == ATH10K_BUS_SDIO)
-   ath10k_init_sdio(ar);
+   ath10k_init_sdio(ar, mode);
}
 
ar->htc.htc_ops.target_send_suspend_complete =
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index fae56c6..bfb125b 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1637,7 +1637,12 @@ static int ath10k_sdio_hif_swap_mailbox(struct ath10k 
*ar)
ath10k_dbg(ar, ATH10K_DBG_SDIO,
   "sdio mailbox swap service enabled\n");
ar_sdio->swap_mbox = true;
+   } else {
+   ath10k_dbg(ar, ATH10K_DBG_SDIO,
+   "sdio mailbox swap service disabled\n");
+   ar_sdio->swap_mbox = false;
}
+
return 0;
 }
 
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-09 Thread Wen Gong
> -Original Message-
> From: Brian Norris 
> Sent: Wednesday, April 10, 2019 7:25 AM
> To: Wen Gong 
> Cc: Michał Kazior ; Wen Gong
> ; linux-wireless ;
> ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in
> simulate fw crash
> 
> On Mon, Apr 8, 2019 at 10:09 PM Wen Gong 
> wrote:
> > > From: Michał Kazior 
> > > To satisfy both I would suggest you either expose ar->state via
> > > debugfs and make your test procedure wait for that to get back into ON
> > > state before simulating a crash again, or to extend the set of current
> > > simulate_fw_crash commands (currently just: soft, hard, assert,
> > > hw-restart) to something that allows expressing the intent whether
> > > crash-in-crash prevention is intended (your case) or not (my original
> > > case).
> > >
> > > This could be for example something like this:
> > >   echo soft wait-ready > simulate_fw_crash
> > >
> > > The "wait-ready" extra keyword would imply crash-in-crash prevention.
> > > This would keep existing tools working (both behavior and syntax) and
> > > would allow your test case to be implemented.
> > >
> > Is it easy to change your existing tools?
> > I want to change it to: echo soft skip-ready > simulate_fw_crash
> > The "skip-ready" extra keyword would imply crash-in-crash, *not*
> prevention.
> > My test tools is hard to change.
> 
> In case you're talking about the test framework we run for ChromeOS
> validation, no, it's not hard at all to change. As long as there's a
> good reason.
> 
> I haven't closely followed this, but judging by the above summary,
> it's probably more reasonable for our test framework to only simulate
> FW crashes after the driver returns to "ready" (or at least, if we do
> crash-in-crash, don't expect the driver to recover?). I expect we can
> work with whatever mechanism you implement for that (exposing the
> "state", or providing a new simulate_fw_crash mode).
> 

If ChromeOS is easy to change tool, 
I think I will change the mechanism of the simulate_fw_crash.
Then all tools will work normally.

> Brian
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-08 Thread Wen Gong
> From: Michał Kazior 
> Sent: Tuesday, April 9, 2019 1:27 AM
> To: Wen Gong 
> Cc: Wen Gong ; linux-wireless  wirel...@vger.kernel.org>; ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in
> simulate fw crash
> 
> > > Hi Michal,
> > > There have a stress test case for the simulate fw crash, it will simulate 
> > > fw
> > > crash
> > > in a very short time for each test, this will trigger the stress test 
> > > fail.
> > > The simulate fw crash process should not be run parallel, after this 
> > > patch,
> the
> > > Stress test case will pass.
> > > >
> >
> > Hi Michał,
> > Do you have some new comments?
> 
> My original use case was to be able to exercise the driver's
> robustness in handling nested fw crashes, IOW crash-within-a-crash.
> 
> Your test case, as far as I understand, intends to perform
> consecutive, non-nested fw crash simulation stress test.
> 
> Both of these are mutually exclusive and your patch fixes your test
> case at the expense of breaking my original case.
> 
> To satisfy both I would suggest you either expose ar->state via
> debugfs and make your test procedure wait for that to get back into ON
> state before simulating a crash again, or to extend the set of current
> simulate_fw_crash commands (currently just: soft, hard, assert,
> hw-restart) to something that allows expressing the intent whether
> crash-in-crash prevention is intended (your case) or not (my original
> case).
> 
> This could be for example something like this:
>   echo soft wait-ready > simulate_fw_crash
> 
> The "wait-ready" extra keyword would imply crash-in-crash prevention.
> This would keep existing tools working (both behavior and syntax) and
> would allow your test case to be implemented.
> 
Is it easy to change your existing tools?
I want to change it to: echo soft skip-ready > simulate_fw_crash
The "skip-ready" extra keyword would imply crash-in-crash, *not* prevention.
My test tools is hard to change.

> 
> Michał
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-08 Thread Wen Gong




> -Original Message-
> From: Wen Gong
> Sent: Monday, April 1, 2019 2:11 PM
> To: 'Michał Kazior' 
> Cc: Wen Gong ; linux-wireless  wirel...@vger.kernel.org>; ath10k@lists.infradead.org
> Subject: RE: [EXT] Re: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in
> simulate fw crash
> 
> >
> > If it's still bothering you then please consider a crash counter
> > threshold so that, e.g. after 5 crash-while-restarting it's going to
> > give up. However I doubt it's worth the effort. My experience tells me
> > firmware crashes during recovery are rarely, if at all, transient.
> >
> > The simulated fw crash is not representative here. It's a mere tool to
> > test driver code.
> >
> Hi Michal,
> There have a stress test case for the simulate fw crash, it will simulate fw
> crash
> in a very short time for each test, this will trigger the stress test fail.
> The simulate fw crash process should not be run parallel, after this patch, 
> the
> Stress test case will pass.
> >

Hi Michał,
Do you have some new comments?

> > Michał
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: add peer id check in ath10k_peer_find_by_id

2019-04-02 Thread Wen Gong
For some SDIO chip, the peer id is 65535 for MPDU with error status,
then test_bit will trigger buffer overflow for peer's memory, if kasan
enabled, it will report error.

Add check for overflow the size of peer's peer_ids will avoid the buffer
overflow access.

Call trace of kasan:
dump_backtrace+0x0/0x2ec
show_stack+0x20/0x2c
__dump_stack+0x20/0x28
dump_stack+0xc8/0xec
print_address_description+0x74/0x240
kasan_report+0x250/0x26c
__asan_report_load8_noabort+0x20/0x2c
ath10k_peer_find_by_id+0x180/0x1e4 [ath10k_core]
ath10k_htt_t2h_msg_handler+0x100c/0x2fd4 [ath10k_core]
ath10k_htt_htc_t2h_msg_handler+0x20/0x34 [ath10k_core]
ath10k_sdio_irq_handler+0xcc8/0x1678 [ath10k_sdio]
process_sdio_pending_irqs+0xec/0x370
sdio_run_irqs+0x68/0xe4
sdio_irq_work+0x1c/0x28
process_one_work+0x3d8/0x8b0
worker_thread+0x508/0x7cc
kthread+0x24c/0x264
ret_from_fork+0x10/0x18

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-7-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/txrx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/txrx.c 
b/drivers/net/wireless/ath/ath10k/txrx.c
index 23606b6..33de9e1 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -157,6 +157,9 @@ struct ath10k_peer *ath10k_peer_find_by_id(struct ath10k 
*ar, int peer_id)
 {
struct ath10k_peer *peer;
 
+   if (peer_id >= sizeof(peer->peer_ids) * BITS_PER_BYTE)
+   return NULL;
+
lockdep_assert_held(>data_lock);
 
list_for_each_entry(peer, >peers, list)
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-04-01 Thread Wen Gong
> -Original Message-
> From: Michał Kazior 
> Sent: Monday, January 7, 2019 4:36 PM
> To: Wen Gong 
> Cc: Wen Gong ; linux-wireless  wirel...@vger.kernel.org>; ath10k@lists.infradead.org
> Subject: [EXT] Re: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in
> simulate fw crash
> That's actually a feature, not a bug. If firmware crashes while driver
> is restarting after a crash then its likely going to fail again and
> again causing a crash-restart loop which can affect system performance
> and responsiveness. It's better to give up and let the system admin
> take over.
> 
> If it's still bothering you then please consider a crash counter
> threshold so that, e.g. after 5 crash-while-restarting it's going to
> give up. However I doubt it's worth the effort. My experience tells me
> firmware crashes during recovery are rarely, if at all, transient.
> 
> The simulated fw crash is not representative here. It's a mere tool to
> test driver code.
> 
Hi Michal,
There have a stress test case for the simulate fw crash, it will simulate fw 
crash
in a very short time for each test, this will trigger the stress test fail.
The simulate fw crash process should not be run parallel, after this patch, the
Stress test case will pass.
> 
> Michał
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: remove the calibration data fetch for sdio

2019-02-17 Thread Wen Gong
The calibration data fetch will trigger sdio error, then sdio will
become fail untill reboot system.

If happens when run ifconfig wlan down, then ifconfig wlan up will
fail untill reboot system.Remove it fix the ifconfig wlan issue.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-5-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/debug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 15964b3..c33a51f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1263,6 +1263,9 @@ static int ath10k_debug_cal_data_fetch(struct ath10k *ar)
if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN))
return -EINVAL;
 
+   if (ar->hw_params.cal_data_len == 0)
+   return -EOPNOTSUPP;
+
hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
 
ret = ath10k_hif_diag_read(ar, hi_addr, , sizeof(addr));
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: reduce transmit msdu count

2019-01-31 Thread Wen Gong
From: Alagu Sankar 

Reduce the transmit MSDU count for SDIO, to match with the descriptors
as used by the firmware. This also acts as a high watermark level for
transmit. Too many packets to the firmware results in transmit overflow
interrupt.

It only affect SDIO chip, it will not cause functionaly changes to
other hardware.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-5-QCARMSWP-1.

Signed-off-by: Alagu Sankar 
Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/core.c| 6 +-
 drivers/net/wireless/ath/ath10k/hw.h  | 1 +
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 22cbe9a..fee4ec1 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2309,7 +2309,11 @@ static int ath10k_core_init_firmware_features(struct 
ath10k *ar)
ar->max_num_stations = TARGET_TLV_NUM_STATIONS;
ar->max_num_vdevs = TARGET_TLV_NUM_VDEVS;
ar->max_num_tdls_vdevs = TARGET_TLV_NUM_TDLS_VDEVS;
-   ar->htt.max_num_pending_tx = TARGET_TLV_NUM_MSDU_DESC;
+   if (ar->hif.bus == ATH10K_BUS_SDIO)
+   ar->htt.max_num_pending_tx =
+   TARGET_TLV_NUM_MSDU_DESC_HL;
+   else
+   ar->htt.max_num_pending_tx = TARGET_TLV_NUM_MSDU_DESC;
ar->wow.max_num_patterns = TARGET_TLV_NUM_WOW_PATTERNS;
ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
WMI_STAT_PEER;
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index 1b5da27..c012523 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -724,6 +724,7 @@ struct ath10k_hw_ops {
 #define TARGET_TLV_NUM_TDLS_VDEVS  1
 #define TARGET_TLV_NUM_TIDS((TARGET_TLV_NUM_PEERS) * 2)
 #define TARGET_TLV_NUM_MSDU_DESC   (1024 + 32)
+#define TARGET_TLV_NUM_MSDU_DESC_HL64
 #define TARGET_TLV_NUM_WOW_PATTERNS22
 #define TARGET_TLV_MGMT_NUM_MSDU_DESC  (50)
 
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index ad4114a..35fb852 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -1611,7 +1611,7 @@ static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct 
ath10k *ar)
cfg->rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(0);
cfg->vow_config = __cpu_to_le32(0);
cfg->gtk_offload_max_vdev = __cpu_to_le32(2);
-   cfg->num_msdu_desc = __cpu_to_le32(TARGET_TLV_NUM_MSDU_DESC);
+   cfg->num_msdu_desc = __cpu_to_le32(ar->htt.max_num_pending_tx);
cfg->max_frag_entries = __cpu_to_le32(2);
cfg->num_tdls_vdevs = __cpu_to_le32(TARGET_TLV_NUM_TDLS_VDEVS);
cfg->num_tdls_conn_table_entries = __cpu_to_le32(0x20);
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: Change swap mail box check after htc ready

2019-01-29 Thread Wen Gong
The swap box flag of firmware is not set before htc ready, then it
will not set swap box flag in ath10k driver, and it will let swap
box setting not same between firmware and ath10k driver, then it
will trigger firmware assert failure.

Check the flag and set swap box after htc ready will fix the firmware
assert failure.

Tested with QCA6174 SDIO with firmware
WLAN.RMH.4.4.1-5-QCARMSWP-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/core.c |  6 ++
 drivers/net/wireless/ath/ath10k/hif.h  |  9 
 drivers/net/wireless/ath/ath10k/sdio.c | 38 --
 3 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 22cbe9a..55fa521 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2534,6 +2534,12 @@ int ath10k_core_start(struct ath10k *ar, enum 
ath10k_firmware_mode mode,
goto err_hif_stop;
}
 
+   status = ath10k_hif_swap_mailbox(ar);
+   if (status) {
+   ath10k_err(ar, "failed to swap mailbox: %d\n", status);
+   goto err_hif_stop;
+   }
+
if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
status = ath10k_htt_connect(>htt);
if (status) {
diff --git a/drivers/net/wireless/ath/ath10k/hif.h 
b/drivers/net/wireless/ath/ath10k/hif.h
index 1a59ea0..5f7f1e0 100644
--- a/drivers/net/wireless/ath/ath10k/hif.h
+++ b/drivers/net/wireless/ath/ath10k/hif.h
@@ -59,6 +59,8 @@ struct ath10k_hif_ops {
 */
void (*stop)(struct ath10k *ar);
 
+   int (*swap_mailbox)(struct ath10k *ar);
+
int (*map_service_to_pipe)(struct ath10k *ar, u16 service_id,
   u8 *ul_pipe, u8 *dl_pipe);
 
@@ -139,6 +141,13 @@ static inline void ath10k_hif_stop(struct ath10k *ar)
return ar->hif.ops->stop(ar);
 }
 
+static inline int ath10k_hif_swap_mailbox(struct ath10k *ar)
+{
+   if (ar->hif.ops->swap_mailbox)
+   return ar->hif.ops->swap_mailbox(ar);
+   return 0;
+}
+
 static inline int ath10k_hif_map_service_to_pipe(struct ath10k *ar,
 u16 service_id,
 u8 *ul_pipe, u8 *dl_pipe)
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c 
b/drivers/net/wireless/ath/ath10k/sdio.c
index 983ecfe..334a147 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -1615,12 +1615,33 @@ static int ath10k_sdio_hif_diag_write_mem(struct ath10k 
*ar, u32 address,
return 0;
 }
 
+static int ath10k_sdio_hif_swap_mailbox(struct ath10k *ar)
+{
+   struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar);
+   u32 addr, val;
+   int ret = 0;
+
+   addr = host_interest_item_address(HI_ITEM(hi_acs_flags));
+
+   ret = ath10k_sdio_hif_diag_read32(ar, addr, );
+   if (ret) {
+   ath10k_warn(ar, "unable to read hi_acs_flags : %d\n", ret);
+   return ret;
+   }
+
+   if (val & HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_FW_ACK) {
+   ath10k_dbg(ar, ATH10K_DBG_SDIO,
+  "sdio mailbox swap service enabled\n");
+   ar_sdio->swap_mbox = true;
+   }
+   return 0;
+}
+
 /* HIF start/stop */
 
 static int ath10k_sdio_hif_start(struct ath10k *ar)
 {
struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar);
-   u32 addr, val;
int ret;
 
/* Sleep 20 ms before HIF interrupts are disabled.
@@ -1654,20 +1675,6 @@ static int ath10k_sdio_hif_start(struct ath10k *ar)
if (ret)
ath10k_warn(ar, "failed to enable sdio interrupts: %d\n", ret);
 
-   addr = host_interest_item_address(HI_ITEM(hi_acs_flags));
-
-   ret = ath10k_sdio_hif_diag_read32(ar, addr, );
-   if (ret) {
-   ath10k_warn(ar, "unable to read hi_acs_flags address: %d\n", 
ret);
-   return ret;
-   }
-
-   if (val & HI_ACS_FLAGS_SDIO_SWAP_MAILBOX_FW_ACK) {
-   ath10k_dbg(ar, ATH10K_DBG_SDIO,
-  "sdio mailbox swap service enabled\n");
-   ar_sdio->swap_mbox = true;
-   }
-
/* Enable sleep and then disable it again */
ret = ath10k_sdio_hif_set_mbox_sleep(ar, true);
if (ret)
@@ -1898,6 +1905,7 @@ static void ath10k_sdio_hif_send_complete_check(struct 
ath10k *ar,
.exchange_bmi_msg   = ath10k_sdio_bmi_exchange_msg,
.start  = ath10k_sdio_hif_start,
.stop   = ath10k_sdio_hif_stop,
+   .swap_mailbox   = ath10k_sdio_hif_swap_mailbox,
.map_service_to_pipe= ath10k_sdio_hif_map_service_to_pipe,
.get_default_pipe   = ath10k_sdio_hif_get_default_pipe,
.send_complete_check= ath10k_s

RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-01-08 Thread Wen Gong
> >
> > > > It is because the state has not changed to ATH10K_STATE_ON
> > > > immediately, then it will have more than two simulate crash
> > > > process running meanwhile, and complete/wakeup some field twice,
> > > > it destroy the normal recovery process.
> > >
> > > This was intended to allow testing not only firmware crash path (and
> > > recovery) but also firmware crash while recovering from a firmware crash.
> > >
> > If firmware is recovering from crash, then simulate a new crash will trigger
> error.
> > So remove it.
> 
> That's actually a feature, not a bug. If firmware crashes while driver is
> restarting after a crash then its likely going to fail again and again 
> causing a
> crash-restart loop which can affect system performance and responsiveness.
> It's better to give up and let the system admin take over.
> 
> If it's still bothering you then please consider a crash counter threshold so
> that, e.g. after 5 crash-while-restarting it's going to give up. However I 
> doubt
> it's worth the effort. My experience tells me firmware crashes during
> recovery are rarely, if at all, transient.
> 
> The simulated fw crash is not representative here. It's a mere tool to test
> driver code.

The simulated fw crash is only a tool for user to trigger fw crash with command,
This change's purpose is to disallow user to trigger fw crash if the fw is not 
in a
Normal state.

If the fw is in recovering state triggered by user's command or by fw, then it 
will
disallow user to run command to trigger fw crash again until fw become to a 
normal
State.

> 
> 
> Michał
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2019-01-06 Thread Wen Gong
> > It is because the state has not changed to ATH10K_STATE_ON
> > immediately, then it will have more than two simulate crash process
> > running meanwhile, and complete/wakeup some field twice, it destroy
> > the normal recovery process.
> 
> This was intended to allow testing not only firmware crash path (and
> recovery) but also firmware crash while recovering from a firmware crash.
> 
If firmware is recovering from crash, then simulate a new crash will trigger 
error.
So remove it.
> 
> Michał
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k
___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [PATCH] ath10k: support PCIe enter L1 state

2018-11-14 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Brian
> Norris
> Sent: Thursday, November 15, 2018 8:29 AM
> To: Wen Gong 
> Cc: linux-wirel...@vger.kernel.org; ath10k@lists.infradead.org
> Subject: [EXTERNAL] Re: [PATCH] ath10k: support PCIe enter L1 state
> 
> Hi Wen,
> 
> >
> > Signed-off-by: Wen Gong 
> 
> Is there some reason L1 was disabled in the first place? Wa
s it known to be
> unreliable?
> 
Hi Brian,
It is a BUG for power, and it is not considered this BUG before.
So this change will fix the bug.

> Brian
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: Remove ATH10K_STATE_RESTARTED in simulate fw crash

2018-11-13 Thread Wen Gong
When test simulate firmware crash, it is easy to trigger error.
command:
echo soft > /sys/kernel/debug/ieee80211/phyxx/ath10k/simulate_fw_crash.

If input more than two times continuously, then it will have error.
Error message:
ath10k_pci :02:00.0: failed to set vdev 1 RX wake policy: -108
ath10k_pci :02:00.0: device is wedged, will not restart

It is because the state has not changed to ATH10K_STATE_ON immediately,
then it will have more than two simulate crash process running meanwhile,
and complete/wakeup some field twice, it destroy the normal recovery
process.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index ada29a4..dc8700b 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -569,8 +569,7 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file 
*file,
 
mutex_lock(>conf_mutex);
 
-   if (ar->state != ATH10K_STATE_ON &&
-   ar->state != ATH10K_STATE_RESTARTED) {
+   if (ar->state != ATH10K_STATE_ON) {
ret = -ENETDOWN;
goto exit;
}
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: support PCIe enter L1 state

2018-11-13 Thread Wen Gong
QCA6174A/QCA9377 PCIe chips support PCIe L1 and L1SS, and indicate the
L1/L1SS capabilities in PCI configuration space. Currently ath10k driver
write target PCIe config flags to disallow HW enter into L1, this leads
some HW modules are still powered up even when both system PCIe RC and
QCA6174A/QCA9377 endpoint decides to enter into L1 or L1SS.

This cause ~12 mA power drain of bottom power consumption for all scenarios.
Fix this issue by removing the drive code to write PCIe config flags.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/pci.c | 21 -
 1 file changed, 21 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index af2cf55..549da7a 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -2301,7 +2301,6 @@ int ath10k_pci_init_config(struct ath10k *ar)
u32 pcie_state_targ_addr = 0;
u32 pipe_cfg_targ_addr = 0;
u32 svc_to_pipe_map = 0;
-   u32 pcie_config_flags = 0;
u32 ealloc_value;
u32 ealloc_targ_addr;
u32 flag2_value;
@@ -2374,26 +2373,6 @@ int ath10k_pci_init_config(struct ath10k *ar)
return ret;
}
 
-   ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr +
- offsetof(struct pcie_state,
-  config_flags)),
-_config_flags);
-   if (ret != 0) {
-   ath10k_err(ar, "Failed to get pcie config_flags: %d\n", ret);
-   return ret;
-   }
-
-   pcie_config_flags &= ~PCIE_CONFIG_FLAG_ENABLE_L1;
-
-   ret = ath10k_pci_diag_write32(ar, (pcie_state_targ_addr +
-  offsetof(struct pcie_state,
-   config_flags)),
- pcie_config_flags);
-   if (ret != 0) {
-   ath10k_err(ar, "Failed to write pcie config_flags: %d\n", ret);
-   return ret;
-   }
-
/* configure early allocation */
ealloc_targ_addr = host_interest_item_address(HI_ITEM(hi_early_alloc));
 
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: Add peer flush in ath10k_flush for STATION

2018-10-08 Thread Wen Gong
In the noisy environment, if there are packets in the queue and can't
send out, the suspend timing will be more than 5 seconds due to the wait,
flush the queue to optimize the suspend timing, and let the upper layer to
retry the packets after resume.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

Signed-off-by: Wen Gong 
 drivers/net/wireless/ath/ath10k/mac.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 97548f9..8df3cec 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6814,9 +6814,20 @@ static void ath10k_flush(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 u32 queues, bool drop)
 {
struct ath10k *ar = hw->priv;
-
-   if (drop)
+   struct ath10k_vif *arvif;
+   u32 bitmap;
+
+   if (drop) {
+   if (vif->type == NL80211_IFTYPE_STATION) {
+   bitmap = ~(1 << WMI_MGMT_TID);
+   list_for_each_entry(arvif, >arvifs, list) {
+   if (arvif->vdev_type == WMI_VDEV_TYPE_STA)
+   ath10k_wmi_peer_flush(ar, 
arvif->vdev_id,
+ arvif->bssid, 
bitmap);
+   }
+   }
return;
+   }
 
mutex_lock(>conf_mutex);
ath10k_mac_wait_tx_complete(ar);
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-09-05 Thread Wen Gong

On 2018-09-05 07:43, Grant Grundler wrote:
On Mon, Sep 3, 2018 at 6:35 AM Toke Høiland-Jørgensen  
wrote:


Johannes Berg  writes:



> Grant's data shows a significant difference between 6 and 7 for both
> latency and throughput:


Minor nit: this is wgong's data more thoughtfully processed.




wgong: can you confirm (a) I've entered the data correctly in the
spreadsheet and (b) you've labeled the data sets correctly when you
generated the data?
If either of us made a mistake, it would be good to know. :)


yes, the data is the test result from flent tool.

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH v3] ath10k: support NET_DETECT WoWLAN feature

2018-09-04 Thread Wen Gong

On 2018-09-04 19:43, Kalle Valo wrote:

Wen Gong  writes:


> +enum wmi_nlo_cipher_algorithm {
> +  WMI_NLO_CIPHER_ALGO_NONE   = 0x00,
> +  WMI_NLO_CIPHER_ALGO_WEP40  = 0x01,
> +  WMI_NLO_CIPHER_ALGO_TKIP   = 0x02,
> +  WMI_NLO_CIPHER_ALGO_CCMP   = 0x04,
> +  WMI_NLO_CIPHER_ALGO_WEP104 = 0x05,
> +  WMI_NLO_CIPHER_ALGO_BIP= 0x06,
> +  WMI_NLO_CIPHER_ALGO_WPA_USE_GROUP  = 0x100,
> +  WMI_NLO_CIPHER_ALGO_RSN_USE_GROUP  = 0x100,

Two defines with the same value 0x100, is this really correct?


Yes, it is an interface between host driver /firmware.


Yeah, I know it's an interface between the host driver and the firmware
but it does not make any sense and is just confusing. Either of them
should be dropped.

yes, either of them can be dropped.

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


RE: [EXTERNAL] Re: [PATCH v3] ath10k: support NET_DETECT WoWLAN feature

2018-09-04 Thread Wen Gong


> -Original Message-
> From: ath10k  On Behalf Of Kalle Valo
> Sent: Tuesday, September 4, 2018 5:15 PM
> To: Wen Gong 
> Cc: linux-wirel...@vger.kernel.org; ath10k@lists.infradead.org
> Subject: [EXTERNAL] Re: [PATCH v3] ath10k: support NET_DETECT WoWLAN
> feature
> 
> Wen Gong  writes:
> 
> > For WoWLAN support, it expect to support wake up based on discovery of
> [...]
> 
> > +   channel_list = (u32 *)ptr;
> > +   for (i = 0; i < cmd->num_of_channels; i++)
> > +   channel_list[i] = pno->a_networks[0].channels[i];
> 
> channel_list does not look endian safe to me, I'll change this to use __le32.
Yes, __le32 is more safe.

> > +enum wmi_nlo_cipher_algorithm {
> > +   WMI_NLO_CIPHER_ALGO_NONE   = 0x00,
> > +   WMI_NLO_CIPHER_ALGO_WEP40  = 0x01,
> > +   WMI_NLO_CIPHER_ALGO_TKIP   = 0x02,
> > +   WMI_NLO_CIPHER_ALGO_CCMP   = 0x04,
> > +   WMI_NLO_CIPHER_ALGO_WEP104 = 0x05,
> > +   WMI_NLO_CIPHER_ALGO_BIP= 0x06,
> > +   WMI_NLO_CIPHER_ALGO_WPA_USE_GROUP  = 0x100,
> > +   WMI_NLO_CIPHER_ALGO_RSN_USE_GROUP  = 0x100,
> 
> Two defines with the same value 0x100, is this really correct?

Yes, it is an interface between host driver /firmware.

> --
> Kalle Valo
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH] ath10k: Add waiting htt tx complete before wow enable

2018-08-28 Thread Wen Gong
If there have some tx packets pending in firmware, and then system
enter suspend, firmware will fail for wow enable. This will trigger
mac80211 to stop ath10k and download firmware again, then it is
non-wow suspend.

After add the waiting htt tx complete, then firmware will have some
time window to send or flush the pending tx packets.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/mac.c | 22 +-
 drivers/net/wireless/ath/ath10k/mac.h |  1 +
 drivers/net/wireless/ath/ath10k/wow.c |  2 ++
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 95243b4..4cd33c9 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6717,23 +6717,17 @@ static int ath10k_mac_op_set_frag_threshold(struct 
ieee80211_hw *hw, u32 value)
return -EOPNOTSUPP;
 }
 
-static void ath10k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-u32 queues, bool drop)
+void ath10k_mac_wait_tx_complete(struct ath10k *ar)
 {
-   struct ath10k *ar = hw->priv;
bool skip;
long time_left;
 
/* mac80211 doesn't care if we really xmit queued frames or not
 * we'll collect those frames either way if we stop/delete vdevs
 */
-   if (drop)
-   return;
-
-   mutex_lock(>conf_mutex);
 
if (ar->state == ATH10K_STATE_WEDGED)
-   goto skip;
+   return;
 
time_left = wait_event_timeout(ar->htt.empty_tx_wq, ({
bool empty;
@@ -6752,8 +6746,18 @@ static void ath10k_flush(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
if (time_left == 0 || skip)
ath10k_warn(ar, "failed to flush transmit queue (skip %i 
ar-state %i): %ld\n",
skip, ar->state, time_left);
+}
 
-skip:
+static void ath10k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+u32 queues, bool drop)
+{
+   struct ath10k *ar = hw->priv;
+
+   if (drop)
+   return;
+
+   mutex_lock(>conf_mutex);
+   ath10k_mac_wait_tx_complete(ar);
mutex_unlock(>conf_mutex);
 }
 
diff --git a/drivers/net/wireless/ath/ath10k/mac.h 
b/drivers/net/wireless/ath/ath10k/mac.h
index 81f8d6c..570493d 100644
--- a/drivers/net/wireless/ath/ath10k/mac.h
+++ b/drivers/net/wireless/ath/ath10k/mac.h
@@ -82,6 +82,7 @@ struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar,
u16 peer_id,
u8 tid);
 int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val);
+void ath10k_mac_wait_tx_complete(struct ath10k *ar);
 
 static inline void ath10k_tx_h_seq_no(struct ieee80211_vif *vif,
  struct sk_buff *skb)
diff --git a/drivers/net/wireless/ath/ath10k/wow.c 
b/drivers/net/wireless/ath/ath10k/wow.c
index a6b179f..af444df 100644
--- a/drivers/net/wireless/ath/ath10k/wow.c
+++ b/drivers/net/wireless/ath/ath10k/wow.c
@@ -374,6 +374,8 @@ int ath10k_wow_op_suspend(struct ieee80211_hw *hw,
goto cleanup;
}
 
+   ath10k_mac_wait_tx_complete(ar);
+
ret = ath10k_wow_enable(ar);
if (ret) {
ath10k_warn(ar, "failed to start wow: %d\n", ret);
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v3] ath10k: support NET_DETECT WoWLAN feature

2018-08-16 Thread Wen Gong
For WoWLAN support, it expect to support wake up based on discovery of
one or more known SSIDs. This is the WIPHY_WOWLAN_NET_DETECT feature,
which shows up as an NL80211 feature flag.

With an upgrade iw, this shows up in 'iw phy' as:
WoWLAN support:
* wake up on network detection, up to 16 match sets
And it can use command:
"iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412
matches ssid foo" to configure the parameters of net detect.

Firmware will do scan by the configured parameters after suspend and
wakeup if it found matched SSIDs. Tested with QCA6174 hw3.0 with
firmware WLAN.RM.4.4.1-00110-QCARMSWPZ-1.

Signed-off-by: Wen Gong 
---
V3:
-fix the waring of alloc with no test
 drivers/net/wireless/ath/ath10k/core.h|   1 +
 drivers/net/wireless/ath/ath10k/mac.c |  12 ++
 drivers/net/wireless/ath/ath10k/wmi-ops.h |  21 +++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 180 +++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 226 ++
 drivers/net/wireless/ath/ath10k/wmi.h |  57 
 drivers/net/wireless/ath/ath10k/wow.c | 174 +++
 7 files changed, 670 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 427ee57..7885462 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -904,6 +904,7 @@ struct ath10k {
u32 high_5ghz_chan;
bool ani_enabled;
 
+   bool nlo_enabled;
bool p2p;
 
struct {
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 95243b4..ba9b9af 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8361,6 +8361,18 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   if (test_bit(WMI_SERVICE_NLO, ar->wmi.svc_map)) {
+   ar->hw->wiphy->max_sched_scan_reqs = 1;
+   ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_match_sets   = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH;
+   ar->hw->wiphy->max_sched_scan_plans = 
WMI_PNO_MAX_SCHED_SCAN_PLANS;
+   ar->hw->wiphy->max_sched_scan_plan_interval =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_INT;
+   ar->hw->wiphy->max_sched_scan_plan_iterations =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_ITRNS;
+   }
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_data_size = sizeof(struct ath10k_txq);
diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h 
b/drivers/net/wireless/ath/ath10k/wmi-ops.h
index 5ecce04..68fff3a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -208,6 +208,9 @@ struct wmi_ops {
   u32 fw_feature_bitmap);
int (*get_vdev_subtype)(struct ath10k *ar,
enum wmi_vdev_subtype subtype);
+   struct sk_buff *(*gen_wow_config_pno)(struct ath10k *ar,
+ u32 vdev_id,
+ struct wmi_pno_scan_req 
*pno_scan);
struct sk_buff *(*gen_pdev_bss_chan_info_req)
(struct ath10k *ar,
 enum wmi_bss_survey_req_type type);
@@ -1349,6 +1352,24 @@ struct wmi_ops {
 }
 
 static inline int
+ath10k_wmi_wow_config_pno(struct ath10k *ar, u32 vdev_id,
+ struct wmi_pno_scan_req  *pno_scan)
+{
+   struct sk_buff *skb;
+   u32 cmd_id;
+
+   if (!ar->wmi.ops->gen_wow_config_pno)
+   return -EOPNOTSUPP;
+
+   skb = ar->wmi.ops->gen_wow_config_pno(ar, vdev_id, pno_scan);
+   if (IS_ERR(skb))
+   return PTR_ERR(skb);
+
+   cmd_id = ar->wmi.cmd->network_list_offload_config_cmdid;
+   return ath10k_wmi_cmd_send(ar, skb, cmd_id);
+}
+
+static inline int
 ath10k_wmi_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
enum wmi_tdls_state state)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index b04f86f..e74f222 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -3239,7 +3239,6 @@ static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 
uapsd_queues, u8 sp)
tlv->tag = 
__cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
tlv->len = __cpu_to_le16(si

[PATCH v2] ath10k: support NET_DETECT WoWLAN feature

2018-08-15 Thread Wen Gong
For WoWLAN support, it expect to support wake up based on discovery of
one or more known SSIDs. This is the WIPHY_WOWLAN_NET_DETECT feature,
which shows up as an NL80211 feature flag.

With an upgrade iw, this shows up in 'iw phy' as:
WoWLAN support:
* wake up on network detection, up to 16 match sets
And it can use command:
"iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412
matches ssid foo" to configure the parameters of net detect.

Firmware will do scan by the configured parameters after suspend and
wakeup if it found matched SSIDs. Tested with QCA6174 hw3.0 with
firmware WLAN.RM.4.4.1-00110-QCARMSWPZ-1.

Signed-off-by: Wen Gong 
---
V2:
-fix the waring of endian
 drivers/net/wireless/ath/ath10k/core.h|   1 +
 drivers/net/wireless/ath/ath10k/mac.c |  12 ++
 drivers/net/wireless/ath/ath10k/wmi-ops.h |  21 +++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 180 +++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 226 ++
 drivers/net/wireless/ath/ath10k/wmi.h |  57 
 drivers/net/wireless/ath/ath10k/wow.c | 168 ++
 7 files changed, 664 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 427ee57..7885462 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -904,6 +904,7 @@ struct ath10k {
u32 high_5ghz_chan;
bool ani_enabled;
 
+   bool nlo_enabled;
bool p2p;
 
struct {
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 95243b4..ba9b9af 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8361,6 +8361,18 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   if (test_bit(WMI_SERVICE_NLO, ar->wmi.svc_map)) {
+   ar->hw->wiphy->max_sched_scan_reqs = 1;
+   ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_match_sets   = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH;
+   ar->hw->wiphy->max_sched_scan_plans = 
WMI_PNO_MAX_SCHED_SCAN_PLANS;
+   ar->hw->wiphy->max_sched_scan_plan_interval =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_INT;
+   ar->hw->wiphy->max_sched_scan_plan_iterations =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_ITRNS;
+   }
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_data_size = sizeof(struct ath10k_txq);
diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h 
b/drivers/net/wireless/ath/ath10k/wmi-ops.h
index 5ecce04..68fff3a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -208,6 +208,9 @@ struct wmi_ops {
   u32 fw_feature_bitmap);
int (*get_vdev_subtype)(struct ath10k *ar,
enum wmi_vdev_subtype subtype);
+   struct sk_buff *(*gen_wow_config_pno)(struct ath10k *ar,
+ u32 vdev_id,
+ struct wmi_pno_scan_req 
*pno_scan);
struct sk_buff *(*gen_pdev_bss_chan_info_req)
(struct ath10k *ar,
 enum wmi_bss_survey_req_type type);
@@ -1349,6 +1352,24 @@ struct wmi_ops {
 }
 
 static inline int
+ath10k_wmi_wow_config_pno(struct ath10k *ar, u32 vdev_id,
+ struct wmi_pno_scan_req  *pno_scan)
+{
+   struct sk_buff *skb;
+   u32 cmd_id;
+
+   if (!ar->wmi.ops->gen_wow_config_pno)
+   return -EOPNOTSUPP;
+
+   skb = ar->wmi.ops->gen_wow_config_pno(ar, vdev_id, pno_scan);
+   if (IS_ERR(skb))
+   return PTR_ERR(skb);
+
+   cmd_id = ar->wmi.cmd->network_list_offload_config_cmdid;
+   return ath10k_wmi_cmd_send(ar, skb, cmd_id);
+}
+
+static inline int
 ath10k_wmi_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
enum wmi_tdls_state state)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index b04f86f..e74f222 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -3239,7 +3239,6 @@ static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 
uapsd_queues, u8 sp)
tlv->tag = 
__cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
tlv->len = __cpu_to_le16(sizeof

RE: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-08-13 Thread Wen Gong
> -Original Message-
> From: Toke Høiland-Jørgensen 
> Sent: Monday, August 13, 2018 7:18 PM
> To: Wen Gong ; Wen Gong
> ; ath10k@lists.infradead.org;
> johan...@sipsolutions.net
> Cc: linux-wirel...@vger.kernel.org
> Subject: RE: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi
> chips
> 
> Wen Gong  writes:
> 
> > Hi Toke,
> >
> > I have tested with your method for shift 6/8/10/7 all twice time in
> > open air environment.
> 
> Great, thanks!
> 
> > Shift 6:
> > wgong@wgong-Latitude-E5440-1:~/flent$ flent -H 192.168.1.7 -t
> > "sk_pacing_shift6" tcp_nup --test-parameter upload_streams=1
> 
> Just to be sure: You are running this on your laptop? And that laptop has the
> ath10k and the modified kernel you are testing? Is 192.168.1.7 the AP or
> another device?
Hi Toke,
Yes, I run on my laptop(Dell LATITUDE E5440 + QCA6174 PCI wireless card) in 
open air environment,
Kernel is 4.18.0-rc2-wt-ath+ #2 SMP which is built myself.
The mac80211.ko/ath10k is built with the 2 patches.
192.168.1.7 is another device(PC installed with 4.4.0-116-generic 
#140~14.04.1-Ubuntu)
> 
> I'd like to see what happens when the link is fully saturated my multiple
> streams as well. Could you repeat the tests with upload_streams=5, please?
> And if you could share the .flent.gz files (upload them somewhere, or email
> me off-list), that would be useful as well :)

Test result with upload_streams=5:

sk_pacing_shift6:
wgong@wgong-Latitude-E5440-1:~/flent/5stream$ flent -H 192.168.1.7 -t 
"sk_pacing_shift6" tcp_nup --test-parameter upload_streams=5
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-14T105332.356811.sk_pacing_shift6.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift6' (at 2018-08-14 02:53:32.356811):

   avg   median  # data pts
 Ping (ms) ICMP :20.4613.85 ms  350
 TCP upload avg :66.3068.71 Mbits/s 301
 TCP upload sum :   331.49   343.55 Mbits/s 301
 TCP upload::1  :60.8064.65 Mbits/s 202
 TCP upload::2  :77.7282.89 Mbits/s 211
 TCP upload::3  :60.5256.09 Mbits/s 202
 TCP upload::4  :67.3973.56 Mbits/s 204
 TCP upload::5  :65.0671.97 Mbits/s 201
wgong@wgong-Latitude-E5440-1:~/flent/5stream$ flent -H 192.168.1.7 -t 
"sk_pacing_shift6" tcp_nup --test-parameter upload_streams=5
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-14T105554.583603.sk_pacing_shift6.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift6' (at 2018-08-14 02:55:54.583603):

   avg   median  # data pts
 Ping (ms) ICMP :20.8613.80 ms  350
 TCP upload avg :75.8883.17 Mbits/s 301
 TCP upload sum :   379.42   415.84 Mbits/s 301
 TCP upload::1  :82.0790.73 Mbits/s 225
 TCP upload::2  :74.0878.29 Mbits/s 204
 TCP upload::3  :70.4475.65 Mbits/s 217
 TCP upload::4  :82.7092.86 Mbits/s 223
 TCP upload::5  :70.1376.87 Mbits/s 210

sk_pacing_shift7:
wgong@wgong-Latitude-E5440-1:~/flent/5stream$ flent -H 192.168.1.7 -t 
"sk_pacing_shift7" tcp_nup --test-parameter upload_streams=5
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-14T105759.169367.sk_pacing_shift7.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift7' (at 2018-08-14 02:57:59.169367):

   avg   median  # data pts
 Ping (ms) ICMP :24.6615.55 ms  350
 TCP upload avg :65.3372.83 Mbits/s 301
 TCP upload sum :   326.67   363.10 Mbits/s 301
 TCP upload::1  :77.6092.93 Mbits/s 214
 TCP upload::2  :67.2275.95 Mbits/s 213
 TCP upload::3  :65.8174.54 Mbits/s 205
 TCP upload::4  :63.0670.37 Mbits/s 207
 TCP upload::5  :52.9855.78 Mbits/s 198
wgong@wgong-Latitude-E5440-1:~/flent/5stream$ flent -H 192.168.1.7 -t 
"sk_pacing_shift7" tcp_nup --test-parameter upload_streams=5
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-14T105923.620572.sk_pacing_shift7.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift7' (at 2018-08-14 02:59:23.620572):

   avg   median  # data pts
 Ping (ms) ICMP

[PATCH] ath10k: support NET_DETECT WoWLAN feature

2018-08-13 Thread Wen Gong
For WoWLAN support, it expect to support wake up based on discovery of
one or more known SSIDs. This is the WIPHY_WOWLAN_NET_DETECT feature,
which shows up as an NL80211 feature flag.

With an upgrade iw, this shows up in 'iw phy' as:
WoWLAN support:
* wake up on network detection, up to 16 match sets
And it can use command:
"iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412
matches ssid foo" to configure the parameters of net detect.

Firmware will do scan by the configured parameters after suspend and
wakeup if it found matched SSIDs. Tested with QCA6174 hw3.0 with
firmware WLAN.RM.4.4.1-00110-QCARMSWPZ-1.

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/core.h|   1 +
 drivers/net/wireless/ath/ath10k/mac.c |  12 ++
 drivers/net/wireless/ath/ath10k/wmi-ops.h |  21 +++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 178 ++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 226 ++
 drivers/net/wireless/ath/ath10k/wmi.h |  57 
 drivers/net/wireless/ath/ath10k/wow.c | 168 ++
 7 files changed, 662 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index 427ee57..7885462 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -904,6 +904,7 @@ struct ath10k {
u32 high_5ghz_chan;
bool ani_enabled;
 
+   bool nlo_enabled;
bool p2p;
 
struct {
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index f31ae3b..423f67a 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8348,6 +8348,18 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   if (test_bit(WMI_SERVICE_NLO, ar->wmi.svc_map)) {
+   ar->hw->wiphy->max_sched_scan_reqs = 1;
+   ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_match_sets   = WMI_PNO_MAX_SUPP_NETWORKS;
+   ar->hw->wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH;
+   ar->hw->wiphy->max_sched_scan_plans = 
WMI_PNO_MAX_SCHED_SCAN_PLANS;
+   ar->hw->wiphy->max_sched_scan_plan_interval =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_INT;
+   ar->hw->wiphy->max_sched_scan_plan_iterations =
+   WMI_PNO_MAX_SCHED_SCAN_PLAN_ITRNS;
+   }
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_data_size = sizeof(struct ath10k_txq);
diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h 
b/drivers/net/wireless/ath/ath10k/wmi-ops.h
index 5ecce04..68fff3a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -208,6 +208,9 @@ struct wmi_ops {
   u32 fw_feature_bitmap);
int (*get_vdev_subtype)(struct ath10k *ar,
enum wmi_vdev_subtype subtype);
+   struct sk_buff *(*gen_wow_config_pno)(struct ath10k *ar,
+ u32 vdev_id,
+ struct wmi_pno_scan_req 
*pno_scan);
struct sk_buff *(*gen_pdev_bss_chan_info_req)
(struct ath10k *ar,
 enum wmi_bss_survey_req_type type);
@@ -1349,6 +1352,24 @@ struct wmi_ops {
 }
 
 static inline int
+ath10k_wmi_wow_config_pno(struct ath10k *ar, u32 vdev_id,
+ struct wmi_pno_scan_req  *pno_scan)
+{
+   struct sk_buff *skb;
+   u32 cmd_id;
+
+   if (!ar->wmi.ops->gen_wow_config_pno)
+   return -EOPNOTSUPP;
+
+   skb = ar->wmi.ops->gen_wow_config_pno(ar, vdev_id, pno_scan);
+   if (IS_ERR(skb))
+   return PTR_ERR(skb);
+
+   cmd_id = ar->wmi.cmd->network_list_offload_config_cmdid;
+   return ath10k_wmi_cmd_send(ar, skb, cmd_id);
+}
+
+static inline int
 ath10k_wmi_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
enum wmi_tdls_state state)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c 
b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index 8c49a26..c4060d7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -3237,7 +3237,6 @@ static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 
uapsd_queues, u8 sp)
tlv->tag = 
__cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
tlv->len = __cpu_to_le16(sizeof(*cmd));
cmd = (void *)tlv->

RE: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-08-12 Thread Wen Gong
> -Original Message-
> From: Toke Høiland-Jørgensen 
> Sent: Friday, August 10, 2018 9:18 PM
> To: Wen Gong ; Wen Gong
> ; ath10k@lists.infradead.org;
> johan...@sipsolutions.net
> Cc: linux-wirel...@vger.kernel.org
> Subject: RE: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi
> chips
> 
> Wen Gong  writes:
> 
> >>
> > Hi Toke,
> > Could you give the command line for the latency test?
> > https://flent.org/intro.html#quick-start
> > I used the command but test failed:
> > flent tcp_download -p 1 -l 60 -H 192.168.1.5 -t
> > text-to-be-included-in-plot -o file1.png error loading plotter: unable to 
> > find
> plot configuration "1"
> 
> Try something like:
> 
> 
> flent -H 192.168.1.5 -t "sk_pacing_shift 7" tcp_nup --test-parameter
> upload_streams=1
> 
> 
> This will note the value of sk_pacing_shift you are testing in the data file 
> (so
> change that as appropriate), and you can vary the number of TCP streams by
> changing the upload_streams parameter.
> 
> Note that in this case I'm assuming you are running Flent on the device with
> the kernel you are trying to test, so you want a TCP transfer going
> *from* the device. If not, change "tcp_nup" to "tcp_ndown" and
> "upload_streams" to "download_streams". Upload is netperf TCP_STREAM
> test, and download is TCP_MAERTS.
> 
> When running the above command you'll get a summary output on the
> terminal that you can paste on the list; and also a data file to plot things 
> form.
> For instance, you can do something like 'flent -p ping_cdf *.flent.gz' to get 
> a
> CDF plot of all your test results afterwards. You are also very welcome to
> send me the .flent.gz data files and I'll take a look to make sure everything
> looks reasonable :)
> 
> -Toke

Hi Toke,

I have tested with your method for shift 6/8/10/7 all twice time in open air 
environment.
Shift 6:
wgong@wgong-Latitude-E5440-1:~/flent$ flent -H 192.168.1.7 -t 
"sk_pacing_shift6" tcp_nup --test-parameter upload_streams=1
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-13T110414.699512.sk_pacing_shift6.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift6' (at 2018-08-13 03:04:14.699512):

   avg   median  # data pts
 Ping (ms) ICMP : 9.91 4.99 ms  350
 TCP upload avg :   242.48   262.43 Mbits/s 301
 TCP upload sum :   242.48   262.43 Mbits/s 301
 TCP upload::1  :   242.48   263.34 Mbits/s 271
wgong@wgong-Latitude-E5440-1:~/flent$ flent -H 192.168.1.7 -t 
"sk_pacing_shift6" tcp_nup --test-parameter upload_streams=1
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-13T113317.074077.sk_pacing_shift6.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift6' (at 2018-08-13 03:33:17.074077):

   avg   median  # data pts
 Ping (ms) ICMP : 7.75 5.30 ms  350
 TCP upload avg :   239.17   250.84 Mbits/s 301
 TCP upload sum :   239.17   250.84 Mbits/s 301
 TCP upload::1  :   239.17   255.03 Mbits/s 266

Shift 8:
wgong@wgong-Latitude-E5440-1:~/flent$ flent -H 192.168.1.7 -t 
"sk_pacing_shift8" tcp_nup --test-parameter upload_streams=1
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-13T121433.187781.sk_pacing_shift8.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift8' (at 2018-08-13 04:14:33.187781):

   avg   median  # data pts
 Ping (ms) ICMP :17.12 7.07 ms  350
 TCP upload avg :   180.05   185.82 Mbits/s 301
 TCP upload sum :   180.05   185.82 Mbits/s 301
 TCP upload::1  :   180.05   189.41 Mbits/s 253
wgong@wgong-Latitude-E5440-1:~/flent$ flent -H 192.168.1.7 -t 
"sk_pacing_shift8" tcp_nup --test-parameter upload_streams=1
Started Flent 1.2.2 using Python 2.7.12.
Starting tcp_nup test. Expected run time: 70 seconds.
Data file written to 
./tcp_nup-2018-08-13T121602.382575.sk_pacing_shift8.flent.gz.
Summary of tcp_nup test run 'sk_pacing_shift8' (at 2018-08-13 04:16:02.382575):

   avg   median  # data pts
 Ping (ms) ICMP :13.90 5.89 ms  350
 TCP upload avg :   207.56   228.16 Mbits/s 301
 TCP upload sum :   207.56   228.16 Mbits/s 301
 TCP upload::1  :   207.56   228.11 Mbits/s 259

Shift 10:
wgong@wgong-Latit

RE: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-08-10 Thread Wen Gong
> -Original Message-
> From: ath10k  On Behalf Of Toke
> Høiland-Jørgensen
> Sent: Wednesday, August 8, 2018 6:44 PM
> To: Wen Gong ; ath10k@lists.infradead.org;
> johan...@sipsolutions.net
> Cc: linux-wirel...@vger.kernel.org
> Subject: Re: [PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi
> chips
> 
> Wen Gong  writes:
> 
> > Upstream kernel has an interface to help adjust sk_pacing_shift to
> > help improve TCP UL throughput.
> > The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
> > WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
> > VHT80 TCP UL throughput testing result shows 6 is the optimal.
> > Overwrite the sk_pacing_shift to 6 in ath10k driver for QCA6174/9377 PCI.
> >
> > Tested with QCA6174 PCI with firmware
> > WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377
> PCI.
> > It's not a regression with new firmware releases.
> >
> > There have 2 test result of different settings:
> >
> > ARM CPU based device with QCA6174A PCI with different
> > sk_pacing_shift:
> >
> >  sk_pacing_shift  throughput(Mbps) CPU utilization
> >  6500(-P5)  ~75% idle, Focus on CPU1: ~14%idle
> >  7454(-P5)  ~80% idle, Focus on CPU1: ~4%idle
> >  8   288~90% idle, Focus on CPU1: ~35%idle
> >  9  ~200~92% idle, Focus on CPU1: ~50%idle
> >
> > 5G TCP UL VTH80 on X86 platform with QCA6174A PCI with
> > sk_packing_shift set to 6:
> >
> >   tcp_limit_output_bytesthroughput(Mbps)
> >  default(262144)+1 Stream 336
> >  default(262144)+2 Streams558
> >  default(262144)+3 Streams584
> >  default(262144)+4 Streams602
> >  default(262144)+5 Streams598
> >  changed(2621440)+1 Stream598
> >  changed(2621440)+2 Streams   601
> 
> You still haven't provided any latency numbers for these tests, which makes
> it impossible to verify that setting sk_pacing_shift to 6 is the right 
> tradeoff.
> 
> As I said before, from your numbers I suspect the right setting is actually 7,
> which would be 10-20ms less latency under load; way more important than
> ~50 Mbps...
> 
Hi Toke,
Could you give the command line for the latency test?
https://flent.org/intro.html#quick-start
I used the command but test failed:
flent tcp_download -p 1 -l 60 -H 192.168.1.5 -t text-to-be-included-in-plot -o 
file1.png
error loading plotter: unable to find plot configuration "1"

> -Toke
> 
> ___
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-08-08 Thread Wen Gong
Upstream kernel has an interface to help adjust sk_pacing_shift to help
improve TCP UL throughput.
The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
VHT80 TCP UL throughput testing result shows 6 is the optimal.
Overwrite the sk_pacing_shift to 6 in ath10k driver for QCA6174/9377 PCI.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

There have 2 test result of different settings:

ARM CPU based device with QCA6174A PCI with different
sk_pacing_shift:

 sk_pacing_shift  throughput(Mbps) CPU utilization
 6500(-P5)  ~75% idle, Focus on CPU1: ~14%idle
 7454(-P5)  ~80% idle, Focus on CPU1: ~4%idle
 8   288~90% idle, Focus on CPU1: ~35%idle
 9  ~200~92% idle, Focus on CPU1: ~50%idle

5G TCP UL VTH80 on X86 platform with QCA6174A PCI with sk_packing_shift
set to 6:

  tcp_limit_output_bytesthroughput(Mbps)
 default(262144)+1 Stream 336
 default(262144)+2 Streams558
 default(262144)+3 Streams584
 default(262144)+4 Streams602
 default(262144)+5 Streams598
 changed(2621440)+1 Stream598
 changed(2621440)+2 Streams   601

Signed-off-by: Wen Gong 
---
V2:
-add the optimal for configurable for each hardware type
 drivers/net/wireless/ath/ath10k/core.c | 6 ++
 drivers/net/wireless/ath/ath10k/hw.h   | 6 ++
 drivers/net/wireless/ath/ath10k/mac.c  | 3 +++
 3 files changed, 15 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 85c58eb..fbd13ec 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -189,6 +189,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_6174,
},
{
.id = QCA6174_HW_2_1_VERSION,
@@ -221,6 +222,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_6174,
},
{
.id = QCA6174_HW_3_0_VERSION,
@@ -253,6 +255,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_6174,
},
{
.id = QCA6174_HW_3_2_VERSION,
@@ -288,6 +291,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_6174,
},
{
.id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -443,6 +447,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_9377,
},
{
.id = QCA9377_HW_1_1_DEV_VERSION,
@@ -477,6 +482,7 @@
.per_ce_irq = false,
.shadow_reg_support = false,
.rri_on_ddr = false,
+   .tx_sk_pacing_shift = SK_PACING_SHIFT_9377,
},
{
.id = QCA4019_HW_1_0_DEV_VERSION,
diff --git a/drivers/net/wireless/ath/ath10k/hw.h 
b/drivers/net/wireless/ath/ath10k/hw.h
index a274bd8..1f956d6 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -161,6 +161,9 @@ enum qca9377_chip_id_rev {
 
 #define REG_DUMP_COUNT_QCA988X 60
 
+#define SK_PACING_SHIFT_6174 6
+#define SK_PACING_SHIFT_9377 6
+
 struct ath10k_fw_ie {
__le32 id;
__le32 len;
@@ -589,6 +592,9 @@ struct ath10k_hw_params {
 
/* Number of bytes to be the offset for each FFT sample */
int spectral_bin_offset;
+
+   /* Number of shift to override the default value of ieee80211_hw*/
+   u8 tx_sk_pacing_shift;
 };
 
 struct htt_rx_desc;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 95243b4..4f2c07f 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8361,6 +8361,9 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   if (ar->hw_params.tx_sk_pacing_shift != 0)
+   ar->hw->tx_sk_pacing_shift = ar->hw_params.tx_sk_pacing_shift;
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_

[PATCH v2 0/2] Change sk_pacing_shift in ieee80211_hw for best tx throughput

2018-08-08 Thread Wen Gong
Add a field for ath10k to adjust the sk_pacing_shift, mac80211 set
the default value to 8, and ath10k will change it to 6. Then mac80211
will use the changed value 6 as sk_pacing_shift since 6 is the best
value for tx throughput by test result.

Wen Gong (2):
  mac80211: Change sk_pacing_shift saved to ieee80211_hw
  ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

 drivers/net/wireless/ath/ath10k/core.c | 6 ++
 drivers/net/wireless/ath/ath10k/hw.h   | 3 +++
 drivers/net/wireless/ath/ath10k/mac.c  | 4 
 include/net/mac80211.h | 5 +
 net/mac80211/main.c| 2 ++
 net/mac80211/tx.c  | 2 +-
 6 files changed, 21 insertions(+), 1 deletion(-)

-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2 1/2] mac80211: Change sk_pacing_shift saved to ieee80211_hw

2018-08-08 Thread Wen Gong
Add the skb_pacing_shift adjustment, this change make it
configurable for other driver. If no other driver set it, then
mac8011 will use the default value.

Signed-off-by: Wen Gong 
---
V2:
-add the description for tx_sk_pacing_shift
 include/net/mac80211.h | 5 +
 net/mac80211/main.c| 2 ++
 net/mac80211/tx.c  | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5790f55..9804d65 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2290,6 +2290,10 @@ enum ieee80211_hw_flags {
  * supported by HW.
  * @max_nan_de_entries: maximum number of NAN DE functions supported by the
  * device.
+ *
+ * @tx_sk_pacing_shift: The TCP stack allow more than a single ms of data
+ * to be queued in the stack. The value is a bit-shift of 1 second, e.g. 8
+ * is ~4ms of queued data. It only affects local TCP sockets.
  */
 struct ieee80211_hw {
struct ieee80211_conf conf;
@@ -2325,6 +2329,7 @@ struct ieee80211_hw {
u8 n_cipher_schemes;
const struct ieee80211_cipher_scheme *cipher_schemes;
u8 max_nan_de_entries;
+   u8 tx_sk_pacing_shift;
 };
 
 static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 4fb2709..23490fa 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -594,6 +594,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t 
priv_data_len,
local->ops = ops;
local->use_chanctx = use_chanctx;
 
+   local->hw.tx_sk_pacing_shift = 8;
+
/* set up some defaults */
local->hw.queues = 1;
local->hw.max_rates = 1;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 6a79d56..80855a8 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3601,7 +3601,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 * second, so 8 is ~4ms of queued data. Only affects local TCP
 * sockets.
 */
-   sk_pacing_shift_update(skb->sk, 8);
+   sk_pacing_shift_update(skb->sk, 
sdata->local->hw.tx_sk_pacing_shift);
 
fast_tx = rcu_dereference(sta->fast_tx);
 
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-07-27 Thread Wen Gong

On 2018-07-26 21:02, Michał Kazior wrote:

On 26 July 2018 at 13:45, Toke Høiland-Jørgensen  wrote:

Wen Gong  writes:

Upstream kernel has an interface to help adjust sk_pacing_shift to 
help

improve TCP UL throughput.
The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
VHT80 TCP UL throughput testing result shows 6 is the optimal.
Overwrite the sk_pacing_shift to 6 in ath10k driver.


When I tested this, a pacing shift of 8 was quite close to optimal as
well for ath10k. Why are you getting different results?


Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 
PCI.

It's not a regression with new firmware releases.

There have 2 test result of different settings:

ARM CPU based device with QCA6174A PCI with different
sk_pacing_shift:


Different firmware releases have different tx buffering
characteristics. In some 10.2 firmware running on QCA9888 you can have
up to 5ms of delayed aggregation. Ideally sk_pacing_shift should be
adjusted per firmware release. Maybe this should become part of the
ath10k firmware wrapping "fw features" stuff?

recently we do not want to do like this since no test data for each 
firmware.


Michał


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-07-27 Thread Wen Gong

On 2018-07-26 19:45, Toke Høiland-Jørgensen wrote:

Wen Gong  writes:

Upstream kernel has an interface to help adjust sk_pacing_shift to 
help

improve TCP UL throughput.
The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
VHT80 TCP UL throughput testing result shows 6 is the optimal.
Overwrite the sk_pacing_shift to 6 in ath10k driver.


When I tested this, a pacing shift of 8 was quite close to optimal as
well for ath10k. Why are you getting different results?


the default value is still 8 in the patch:
https://patchwork.kernel.org/patch/10545361/

In my test, pacing shift 6 is better than 8.
The test is for ath10k/11AC WiFi chips.
Test result is show in the commit logs before.



Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 
PCI.

It's not a regression with new firmware releases.

There have 2 test result of different settings:

ARM CPU based device with QCA6174A PCI with different
sk_pacing_shift:

 sk_pacing_shift  throughput(Mbps) CPU utilization
 6500(-P5)  ~75% idle, Focus on CPU1: ~14%idle
 7454(-P5)  ~80% idle, Focus on CPU1: ~4%idle
 8   288~90% idle, Focus on CPU1: ~35%idle
 9  ~200~92% idle, Focus on CPU1: ~50%idle


Your tests do not include latency values; please try running a test 
that

also measures latency. The tcp_nup test in Flent (https://flent.org)
will do that, for instance. Also, is this a single TCP flow?



It is not a single TCP flow, it is 500Mbps with 5 flows.

below is result show in commit log before:
5G TCP UL VTH80 on X86 platform with QCA6174A PCI with sk_packing_shift
set to 6:

  tcp_limit_output_bytesthroughput(Mbps)
 default(262144)+1 Stream 336
 default(262144)+2 Streams558
 default(262144)+3 Streams584
 default(262144)+4 Streams602
 default(262144)+5 Streams598
 changed(2621440)+1 Stream598
 changed(2621440)+2 Streams   601


-Toke


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH 1/2] mac80211: Save sk_pacing_shift to ieee80211_hw

2018-07-27 Thread Wen Gong

Thanks,
I will add description of tx_sk_pacing_shift as below and sent next 
patch.

*
* @tx_sk_pacing_shift: The TCP stack allow more than a single ms of data
* to be queued in the stack. The value is a bit-shift of 1 second, 
e.g. 8

* is ~4ms of queued data. It only affects local TCP sockets.
*/

On 2018-07-26 22:52, kbuild test robot wrote:

Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on v4.18-rc6 next-20180725]
[if your patch is applied to the wrong git tree, please drop us a note
to help improve the system]

url:
https://github.com/0day-ci/linux/commits/Wen-Gong/Change-sk_pacing_shift-in-ieee80211_hw-for-best-tx-throughput/20180726-190055
base:
https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git
master
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   WARNING: convert(1) not found, for SVG to PDF conversion install
ImageMagick (https://www.imagemagick.org)
   mm/mempool.c:228: warning: Function parameter or member 'pool' not
described in 'mempool_init'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.ibss' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.connect' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.keys' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.ie' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.ie_len' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.bssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.ssid' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.default_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.default_mgmt_key' not described in 'wireless_dev'
   include/net/cfg80211.h:4381: warning: Function parameter or member
'wext.prev_bssid_valid' not described in 'wireless_dev'
   include/net/mac80211.h:2329: warning: Function parameter or member
'radiotap_timestamp.units_pos' not described in 'ieee80211_hw'
   include/net/mac80211.h:2329: warning: Function parameter or member
'radiotap_timestamp.accuracy' not described in 'ieee80211_hw'
include/net/mac80211.h:2329: warning: Function parameter or member 
'tx_sk_pacing_shift' not described in 'ieee80211_hw'

   include/net/mac80211.h:977: warning: Function parameter or member
'control.rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.rts_cts_rate_idx' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.use_rts' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.use_cts_prot' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.short_preamble' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.skip_table' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.jiffies' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.vif' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.hw_key' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.flags' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'control.enqueue_time' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'ack' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'ack.cookie' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'status.rates' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'status.ack_signal' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'status.ampdu_ack_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'status.ampdu_len' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or member
'status.antenna' not described in 'ieee80211_tx_info'
   include/net/mac80211.h:977: warning: Function parameter or 

[PATCH 0/2] Change sk_pacing_shift in ieee80211_hw for best tx throughput

2018-07-26 Thread Wen Gong
Add a field for ath10k to adjust the sk_pacing_shift, mac80211 set
the default value to 8, and ath10k will change it to 6. Then mac80211
will use the changed value 6 as sk_pacing_shift since 6 is the best
value for tx throughput by test result.

Wen Gong (2):
  mac80211: Change sk_pacing_shift saved to ieee80211_hw
  ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

 drivers/net/wireless/ath/ath10k/mac.c | 2 ++
 include/net/mac80211.h| 1 +
 net/mac80211/main.c   | 2 ++
 net/mac80211/tx.c | 2 +-
 4 files changed, 6 insertions(+), 1 deletion(-)

-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-07-26 Thread Wen Gong
Upstream kernel has an interface to help adjust sk_pacing_shift to help
improve TCP UL throughput.
The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
VHT80 TCP UL throughput testing result shows 6 is the optimal.
Overwrite the sk_pacing_shift to 6 in ath10k driver.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

There have 2 test result of different settings:

ARM CPU based device with QCA6174A PCI with different
sk_pacing_shift:

 sk_pacing_shift  throughput(Mbps) CPU utilization
 6500(-P5)  ~75% idle, Focus on CPU1: ~14%idle
 7454(-P5)  ~80% idle, Focus on CPU1: ~4%idle
 8   288~90% idle, Focus on CPU1: ~35%idle
 9  ~200~92% idle, Focus on CPU1: ~50%idle

5G TCP UL VTH80 on X86 platform with QCA6174A PCI with sk_packing_shift
set to 6:

  tcp_limit_output_bytesthroughput(Mbps)
 default(262144)+1 Stream 336
 default(262144)+2 Streams558
 default(262144)+3 Streams584
 default(262144)+4 Streams602
 default(262144)+5 Streams598
 changed(2621440)+1 Stream598
 changed(2621440)+2 Streams   601

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/mac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index f31ae3b..40d24c1 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8348,6 +8348,8 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   ar->hw->tx_sk_pacing_shift = 6;
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_data_size = sizeof(struct ath10k_txq);
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH 1/2] mac80211: Save sk_pacing_shift to ieee80211_hw

2018-07-26 Thread Wen Gong
Add the skb_pacing_shirt adjustment, but this change make it
configurable for other driver. If no other driver set it, then
mac8011 will use the default value.

Signed-off-by: Wen Gong 
---
 include/net/mac80211.h | 1 +
 net/mac80211/main.c| 2 ++
 net/mac80211/tx.c  | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 851a5e1..f600d08 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2279,6 +2279,7 @@ struct ieee80211_hw {
u8 n_cipher_schemes;
const struct ieee80211_cipher_scheme *cipher_schemes;
u8 max_nan_de_entries;
+   u8 tx_sk_pacing_shift;
 };
 
 static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index fb73451..72dce49 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -584,6 +584,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t 
priv_data_len,
local->ops = ops;
local->use_chanctx = use_chanctx;
 
+   local->hw.tx_sk_pacing_shift = 8;
+
/* set up some defaults */
local->hw.queues = 1;
local->hw.max_rates = 1;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 44b5dfe..a2d61b9 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3596,7 +3596,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 * second, so 8 is ~4ms of queued data. Only affects local TCP
 * sockets.
 */
-   sk_pacing_shift_update(skb->sk, 8);
+   sk_pacing_shift_update(skb->sk, 
sdata->local->hw.tx_sk_pacing_shift);
 
fast_tx = rcu_dereference(sta->fast_tx);
 
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH 0/2] Change sk_pacing_shift in ieee80211_hw for best tx throughput

2018-07-26 Thread Wen Gong
From: Wen Gong 

Add a field for ath10k to adjust the sk_pacing_shift, mac80211 set
the default value to 8, and ath10k will change it to 6. Then mac80211
will use the changed value 6 as sk_pacing_shift since 6 is the best
value for tx throughput by test result.

Wen Gong (2):
  mac80211: Change sk_pacing_shift saved to ieee80211_hw
  ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

 drivers/net/wireless/ath/ath10k/mac.c | 2 ++
 include/net/mac80211.h| 1 +
 net/mac80211/main.c   | 2 ++
 net/mac80211/tx.c | 2 +-
 4 files changed, 6 insertions(+), 1 deletion(-)

-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH 2/2] ath10k: Set sk_pacing_shift to 6 for 11AC WiFi chips

2018-07-26 Thread Wen Gong
From: Wen Gong 

Upstream kernel has an interface to help adjust sk_pacing_shift to help
improve TCP UL throughput.
The sk_pacing_shift is 8 in mac80211, this is based on test with 11N
WiFi chips with ath9k. For QCA6174/QCA9377 PCI 11AC chips, the 11AC
VHT80 TCP UL throughput testing result shows 6 is the optimal.
Overwrite the sk_pacing_shift to 6 in ath10k driver.

Tested with QCA6174 PCI with firmware
WLAN.RM.4.4.1-00109-QCARMSWPZ-1, but this will also affect QCA9377 PCI.
It's not a regression with new firmware releases.

There have 2 test result of different settings:

ARM CPU based device with QCA6174A PCI with different
sk_pacing_shift:

 sk_pacing_shift  throughput(Mbps) CPU utilization
 6500(-P5)  ~75% idle, Focus on CPU1: ~14%idle
 7454(-P5)  ~80% idle, Focus on CPU1: ~4%idle
 8   288~90% idle, Focus on CPU1: ~35%idle
 9  ~200~92% idle, Focus on CPU1: ~50%idle

5G TCP UL VTH80 on X86 platform with QCA6174A PCI with sk_packing_shift
set to 6:

  tcp_limit_output_bytesthroughput(Mbps)
 default(262144)+1 Stream 336
 default(262144)+2 Streams558
 default(262144)+3 Streams584
 default(262144)+4 Streams602
 default(262144)+5 Streams598
 changed(2621440)+1 Stream598
 changed(2621440)+2 Streams   601

Signed-off-by: Wen Gong 
---
 drivers/net/wireless/ath/ath10k/mac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index f31ae3b..40d24c1 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8348,6 +8348,8 @@ int ath10k_mac_register(struct ath10k *ar)
ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+   ar->hw->tx_sk_pacing_shift = 6;
+
ar->hw->vif_data_size = sizeof(struct ath10k_vif);
ar->hw->sta_data_size = sizeof(struct ath10k_sta);
ar->hw->txq_data_size = sizeof(struct ath10k_txq);
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH 1/2] mac80211: Save sk_pacing_shift to ieee80211_hw

2018-07-26 Thread Wen Gong
From: Wen Gong 

Add the skb_pacing_shirt adjustment, but this change make it
configurable for other driver. If no other driver set it, then
mac8011 will use the default value.

Signed-off-by: Wen Gong 
---
 include/net/mac80211.h | 1 +
 net/mac80211/main.c| 2 ++
 net/mac80211/tx.c  | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 851a5e1..f600d08 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2279,6 +2279,7 @@ struct ieee80211_hw {
u8 n_cipher_schemes;
const struct ieee80211_cipher_scheme *cipher_schemes;
u8 max_nan_de_entries;
+   u8 tx_sk_pacing_shift;
 };
 
 static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index fb73451..72dce49 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -584,6 +584,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t 
priv_data_len,
local->ops = ops;
local->use_chanctx = use_chanctx;
 
+   local->hw.tx_sk_pacing_shift = 8;
+
/* set up some defaults */
local->hw.queues = 1;
local->hw.max_rates = 1;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 44b5dfe..a2d61b9 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3596,7 +3596,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 * second, so 8 is ~4ms of queued data. Only affects local TCP
 * sockets.
 */
-   sk_pacing_shift_update(skb->sk, 8);
+   sk_pacing_shift_update(skb->sk, 
sdata->local->hw.tx_sk_pacing_shift);
 
fast_tx = rcu_dereference(sta->fast_tx);
 
-- 
1.9.1


___
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k


[PATCH v2] ath10k: Convert wow pattern from 802.3 to 802.11

2018-04-11 Thread Wen Gong
When trying to set wow wakeup patterns it fails with this command:

iw phyxx wowlan enable patterns offset xx+ IP address xx.xx.xx.xx

The reason is that the wow pattern from upper layer is in 802.3 format
for this case, it need to convert it to 802.11 format. The input
offset parameter is used for 802.3, but the actual offset firmware
need depends on rx_decap_mode, so that it needs to be recalculated.
Pattern of 802.3 packet is not same with 802.11 packet. If the
rx_decap_mode is ATH10K_HW_TXRX_NATIVE_WIFI, then firmware will
receive data packet with 802.11 format from hardware.

Tested with QCA6174 hw3.0 with firmware
WLAN.RM.4.4.1-00099-QCARMSWPZ-1, but this will also affect QCA9377.
This has always failed, so it's not a regression with new firmware
releases.

Signed-off-by: Wen Gong <wg...@codeaurora.org>
---

V2: 
-Move the convert graph from commit message to code.

 drivers/net/wireless/ath/ath10k/wmi.h |   4 +
 drivers/net/wireless/ath/ath10k/wow.c | 139 --
 2 files changed, 137 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index c7b30ed..389f9c7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -6724,6 +6724,10 @@ struct wmi_wow_ev_arg {
 #define WOW_MIN_PATTERN_SIZE   1
 #define WOW_MAX_PATTERN_SIZE   148
 #define WOW_MAX_PKT_OFFSET 128
+#define WOW_HDR_LEN(sizeof(struct ieee80211_hdr_3addr) + \
+   sizeof(struct rfc1042_hdr))
+#define WOW_MAX_REDUCE (WOW_HDR_LEN - sizeof(struct ethhdr) - \
+   offsetof(struct ieee80211_hdr_3addr, addr1))
 
 enum wmi_tdls_state {
WMI_TDLS_DISABLE,
diff --git a/drivers/net/wireless/ath/ath10k/wow.c 
b/drivers/net/wireless/ath/ath10k/wow.c
index c4cbccb..60eeaae 100644
--- a/drivers/net/wireless/ath/ath10k/wow.c
+++ b/drivers/net/wireless/ath/ath10k/wow.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -76,6 +77,109 @@ static int ath10k_wow_cleanup(struct ath10k *ar)
return 0;
 }
 
+/**
+ * Convert a 802.3 format to a 802.11 format.
+ * ++---+++
+ * 802.3:  |dest mac(6B)|src mac(6B)|type(2B)| body...|
+ * ++---+++
+ *|__ |___|  |
+ *   |||  |
+ * +--+++---+---+---+
+ * 802.11: |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body...  |
+ * +--+++---+---+---+
+ */
+static void ath10k_wow_convert_8023_to_80211
+   (struct cfg80211_pkt_pattern *new,
+   const struct cfg80211_pkt_pattern *old)
+{
+   u8 hdr_8023_pattern[ETH_HLEN] = {};
+   u8 hdr_8023_bit_mask[ETH_HLEN] = {};
+   u8 hdr_80211_pattern[WOW_HDR_LEN] = {};
+   u8 hdr_80211_bit_mask[WOW_HDR_LEN] = {};
+
+   int total_len = old->pkt_offset + old->pattern_len;
+   int hdr_80211_end_offset;
+
+   struct ieee80211_hdr_3addr *new_hdr_pattern =
+   (struct ieee80211_hdr_3addr *)hdr_80211_pattern;
+   struct ieee80211_hdr_3addr *new_hdr_mask =
+   (struct ieee80211_hdr_3addr *)hdr_80211_bit_mask;
+   struct ethhdr *old_hdr_pattern = (struct ethhdr *)hdr_8023_pattern;
+   struct ethhdr *old_hdr_mask = (struct ethhdr *)hdr_8023_bit_mask;
+   int hdr_len = sizeof(*new_hdr_pattern);
+
+   struct rfc1042_hdr *new_rfc_pattern =
+   (struct rfc1042_hdr *)(hdr_80211_pattern + hdr_len);
+   struct rfc1042_hdr *new_rfc_mask =
+   (struct rfc1042_hdr *)(hdr_80211_bit_mask + hdr_len);
+   int rfc_len = sizeof(*new_rfc_pattern);
+
+   memcpy(hdr_8023_pattern + old->pkt_offset,
+  old->pattern, ETH_HLEN - old->pkt_offset);
+   memcpy(hdr_8023_bit_mask + old->pkt_offset,
+  old->mask, ETH_HLEN - old->pkt_offset);
+
+   /* Copy destination address */
+   memcpy(new_hdr_pattern->addr1, old_hdr_pattern->h_dest, ETH_ALEN);
+   memcpy(new_hdr_mask->addr1, old_hdr_mask->h_dest, ETH_ALEN);
+
+   /* Copy source address */
+   memcpy(new_hdr_pattern->addr3, old_hdr_pattern->h_source, ETH_ALEN);
+   memcpy(new_hdr_mask->addr3, old_hdr_mask->h_source, ETH_ALEN);
+
+   /* Copy logic link type */
+   memcpy(_rfc_pattern->snap_type,
+  _hdr_pattern->h_proto,
+  sizeof(old_hdr_pattern->h_proto));
+   memcpy(_rfc_mask->snap_type,
+   

Re: [PATCH] ath10k: Convert wow pattern from 802.3 to 802.11

2018-04-11 Thread Wen Gong

Hi,

I will move the convert graph from comments to code and send Patch V2.
And new graph like this:
/**
+ * Convert a 802.3 format to a 802.11 format.
+ * ++---+++
+ * 802.3:  |dest mac(6B)|src mac(6B)|type(2B)| body...    |
+ * ++---+++
+ *    |__ |___    |  |
+ *   |    |    |  |
+ * 
+--+++---+---+---+
+ * 802.11: |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body... 
 |
+ * 
+--+++---+---+---+

+ */
+static void ath10k_wow_convert_8023_to_80211
+    (struct cfg80211_pkt_pattern *new,
+    const struct cfg80211_pkt_pattern *old)


And the 444 bytes on stack will remain since the comments is: "we can go 
with this until somebody runs into a real problem"


On 2018-04-12 07:13, Brian Norris wrote:

Hi,

On Fri, Mar 30, 2018 at 11:18:19AM +0800, Wen Gong wrote:

When trying to set wow wakeup patterns it fails with this command:

iw phyxx wowlan enable patterns offset xx+ IP address xx.xx.xx.xx

The reason is that the wow pattern from upper layer is in 802.3 format
for this case, it need to convert it to 802.11 format. The input
offset parameter is used for 802.3, but the actual offset firmware
need depends on rx_decap_mode, so that it needs to be recalculated.
Pattern of 802.3 packet is not same with 802.11 packet. If the
rx_decap_mode is ATH10K_HW_TXRX_NATIVE_WIFI, then firmware will
receive data packet with 802.11 format from hardware.

Convert graph:
---
802.3  |dest mac(6B)|src mac(6B)|type(2B)| body...|
 |__ |___|_  |___
|| | |
802.11 |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body...  |
---


It feels like this could go into the code comments? Or at least some
short version of it. (But hey, text is cheap, and who doesn't love 
ASCII

art?)



Tested with QCA6174 hw3.0 with firmware
WLAN.RM.4.4.1-00099-QCARMSWPZ-1, but this will also affect QCA9377.
This has always failed, so it's not a regression with new firmware
releases.

Signed-off-by: Wen Gong <wg...@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/wmi.h |   4 ++
 drivers/net/wireless/ath/ath10k/wow.c | 128 
--

 2 files changed, 126 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h

index c7b30ed..389f9c7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -6724,6 +6724,10 @@ struct wmi_wow_ev_arg {
 #define WOW_MIN_PATTERN_SIZE   1
 #define WOW_MAX_PATTERN_SIZE   148
 #define WOW_MAX_PKT_OFFSET 128
+#define WOW_HDR_LEN(sizeof(struct ieee80211_hdr_3addr) + \
+   sizeof(struct rfc1042_hdr))
+#define WOW_MAX_REDUCE (WOW_HDR_LEN - sizeof(struct ethhdr) - \
+   offsetof(struct ieee80211_hdr_3addr, addr1))

 enum wmi_tdls_state {
WMI_TDLS_DISABLE,
diff --git a/drivers/net/wireless/ath/ath10k/wow.c 
b/drivers/net/wireless/ath/ath10k/wow.c

index c4cbccb..9b56a41 100644
--- a/drivers/net/wireless/ath/ath10k/wow.c
+++ b/drivers/net/wireless/ath/ath10k/wow.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software 
for any
  * purpose with or without fee is hereby granted, provided that the 
above

@@ -76,6 +77,98 @@ static int ath10k_wow_cleanup(struct ath10k *ar)
return 0;
 }

+static void ath10k_wow_convert_8023_to_80211
+   (struct cfg80211_pkt_pattern *new,
+   const struct cfg80211_pkt_pattern *old)
+{
+   u8 hdr_8023_pattern[ETH_HLEN] = {};
+   u8 hdr_8023_bit_mask[ETH_HLEN] = {};
+   u8 hdr_80211_pattern[WOW_HDR_LEN] = {};
+   u8 hdr_80211_bit_mask[WOW_HDR_LEN] = {};
+
+   int total_len = old->pkt_offset + old->pattern_len;
+   int hdr_80211_end_offset;
+
+   struct ieee80211_hdr_3addr *new_hdr_pattern =
+   (struct ieee80211_hdr_3addr *)hdr_80211_pattern;
+   struct ieee80211_hdr_3addr *new_hdr_mask =
+   (struct ieee80211_hdr_3addr *)hdr_80211_bit_mask;
+   struct ethhdr *old_hdr_pattern = (struct ethhdr *)hdr_8023_pattern;
+   struct ethhdr *old_hdr_mask = (struct ethhdr *)hdr_8023_bit_mask;
+   int hdr_len = sizeof(*new_hdr_pattern);
+
+   struct rfc1042_hdr *new_rfc_pattern =
+   (struct rfc1042_hdr *)(hdr_80211_pattern + hdr_len);
+   

RE: [PATCH] ath10k: Convert wow pattern from 802.3 to 802.11

2018-04-11 Thread Wen Gong
Hi,

I will move the convert graph from comments to code.
And new graph like this:
/**
+ * Convert a 802.3 format to a 802.11 format.
+ * ++---+++
+ * 802.3:  |dest mac(6B)|src mac(6B)|type(2B)| body...|
+ * ++---+++
+ *|__ |___|  |
+ *   |||  |
+ * +--+++---+---+---+
+ * 802.11: |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body...  |
+ * +--+++---+---+---+
+ */
+static void ath10k_wow_convert_8023_to_80211
+   (struct cfg80211_pkt_pattern *new,
+   const struct cfg80211_pkt_pattern *old)


And the 444 bytes on stack will remain since the comments is: "we can go with 
this until somebody runs into a real problem"

Thanks
Gong Wen

> -Original Message-
> From: ath10k [mailto:ath10k-boun...@lists.infradead.org] On Behalf Of
> Brian Norris
> Sent: Thursday, April 12, 2018 7:13 AM
> To: Wen Gong <wg...@codeaurora.org>
> Cc: linux-wirel...@vger.kernel.org; ath10k@lists.infradead.org
> Subject: Re: [PATCH] ath10k: Convert wow pattern from 802.3 to 802.11
> 
> Hi,
> 
> On Fri, Mar 30, 2018 at 11:18:19AM +0800, Wen Gong wrote:
> > When trying to set wow wakeup patterns it fails with this command:
> >
> > iw phyxx wowlan enable patterns offset xx+ IP address xx.xx.xx.xx
> >
> > The reason is that the wow pattern from upper layer is in 802.3 format
> > for this case, it need to convert it to 802.11 format. The input
> > offset parameter is used for 802.3, but the actual offset firmware
> > need depends on rx_decap_mode, so that it needs to be recalculated.
> > Pattern of 802.3 packet is not same with 802.11 packet. If the
> > rx_decap_mode is ATH10K_HW_TXRX_NATIVE_WIFI, then firmware will
> > receive data packet with 802.11 format from hardware.
> >
> > Convert graph:
> > ---
> > 802.3  |dest mac(6B)|src mac(6B)|type(2B)| body...|
> >  |__ |___|_  |___
> > || | |
> > 802.11 |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body...  |
> > --
> > -
> 
> It feels like this could go into the code comments? Or at least some short
> version of it. (But hey, text is cheap, and who doesn't love ASCII
> art?)
> 
> >
> > Tested with QCA6174 hw3.0 with firmware
> > WLAN.RM.4.4.1-00099-QCARMSWPZ-1, but this will also affect QCA9377.
> > This has always failed, so it's not a regression with new firmware
> > releases.
> >
> > Signed-off-by: Wen Gong <wg...@codeaurora.org>
> > ---
> >  drivers/net/wireless/ath/ath10k/wmi.h |   4 ++
> >  drivers/net/wireless/ath/ath10k/wow.c | 128
> > --
> >  2 files changed, 126 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath10k/wmi.h
> > b/drivers/net/wireless/ath/ath10k/wmi.h
> > index c7b30ed..389f9c7 100644
> > --- a/drivers/net/wireless/ath/ath10k/wmi.h
> > +++ b/drivers/net/wireless/ath/ath10k/wmi.h
> > @@ -6724,6 +6724,10 @@ struct wmi_wow_ev_arg {
> >  #define WOW_MIN_PATTERN_SIZE   1
> >  #define WOW_MAX_PATTERN_SIZE   148
> >  #define WOW_MAX_PKT_OFFSET 128
> > +#define WOW_HDR_LEN(sizeof(struct ieee80211_hdr_3addr) + \
> > +   sizeof(struct rfc1042_hdr))
> > +#define WOW_MAX_REDUCE (WOW_HDR_LEN - sizeof(struct
> ethhdr) - \
> > +   offsetof(struct ieee80211_hdr_3addr, addr1))
> >
> >  enum wmi_tdls_state {
> > WMI_TDLS_DISABLE,
> > diff --git a/drivers/net/wireless/ath/ath10k/wow.c
> > b/drivers/net/wireless/ath/ath10k/wow.c
> > index c4cbccb..9b56a41 100644
> > --- a/drivers/net/wireless/ath/ath10k/wow.c
> > +++ b/drivers/net/wireless/ath/ath10k/wow.c
> > @@ -1,5 +1,6 @@
> >  /*
> >   * Copyright (c) 2015-2017 Qualcomm Atheros, Inc.
> > + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> >   *
> >   * Permission to use, copy, modify, and/or distribute this software for any
> >   * purpose with or without fee is hereby granted, provided that the
> > above @@ -76,6 +77,98 @@ static int ath10k_wow_cleanup(struct ath10k
> *ar)
> > return 0;
> >  }
> >
> &

[PATCH] ath10k: Convert wow pattern from 802.3 to 802.11

2018-03-29 Thread Wen Gong
When trying to set wow wakeup patterns it fails with this command:

iw phyxx wowlan enable patterns offset xx+ IP address xx.xx.xx.xx

The reason is that the wow pattern from upper layer is in 802.3 format
for this case, it need to convert it to 802.11 format. The input
offset parameter is used for 802.3, but the actual offset firmware
need depends on rx_decap_mode, so that it needs to be recalculated.
Pattern of 802.3 packet is not same with 802.11 packet. If the
rx_decap_mode is ATH10K_HW_TXRX_NATIVE_WIFI, then firmware will
receive data packet with 802.11 format from hardware.

Convert graph:
---
802.3  |dest mac(6B)|src mac(6B)|type(2B)| body...|
 |__ |___|_  |___
|| | |
802.11 |4B|dest mac(6B)| 6B |src mac(6B)|  8B  |type(2B)|  body...  |
---

Tested with QCA6174 hw3.0 with firmware
WLAN.RM.4.4.1-00099-QCARMSWPZ-1, but this will also affect QCA9377.
This has always failed, so it's not a regression with new firmware
releases.

Signed-off-by: Wen Gong <wg...@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/wmi.h |   4 ++
 drivers/net/wireless/ath/ath10k/wow.c | 128 --
 2 files changed, 126 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.h 
b/drivers/net/wireless/ath/ath10k/wmi.h
index c7b30ed..389f9c7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -6724,6 +6724,10 @@ struct wmi_wow_ev_arg {
 #define WOW_MIN_PATTERN_SIZE   1
 #define WOW_MAX_PATTERN_SIZE   148
 #define WOW_MAX_PKT_OFFSET 128
+#define WOW_HDR_LEN(sizeof(struct ieee80211_hdr_3addr) + \
+   sizeof(struct rfc1042_hdr))
+#define WOW_MAX_REDUCE (WOW_HDR_LEN - sizeof(struct ethhdr) - \
+   offsetof(struct ieee80211_hdr_3addr, addr1))
 
 enum wmi_tdls_state {
WMI_TDLS_DISABLE,
diff --git a/drivers/net/wireless/ath/ath10k/wow.c 
b/drivers/net/wireless/ath/ath10k/wow.c
index c4cbccb..9b56a41 100644
--- a/drivers/net/wireless/ath/ath10k/wow.c
+++ b/drivers/net/wireless/ath/ath10k/wow.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -76,6 +77,98 @@ static int ath10k_wow_cleanup(struct ath10k *ar)
return 0;
 }
 
+static void ath10k_wow_convert_8023_to_80211
+   (struct cfg80211_pkt_pattern *new,
+   const struct cfg80211_pkt_pattern *old)
+{
+   u8 hdr_8023_pattern[ETH_HLEN] = {};
+   u8 hdr_8023_bit_mask[ETH_HLEN] = {};
+   u8 hdr_80211_pattern[WOW_HDR_LEN] = {};
+   u8 hdr_80211_bit_mask[WOW_HDR_LEN] = {};
+
+   int total_len = old->pkt_offset + old->pattern_len;
+   int hdr_80211_end_offset;
+
+   struct ieee80211_hdr_3addr *new_hdr_pattern =
+   (struct ieee80211_hdr_3addr *)hdr_80211_pattern;
+   struct ieee80211_hdr_3addr *new_hdr_mask =
+   (struct ieee80211_hdr_3addr *)hdr_80211_bit_mask;
+   struct ethhdr *old_hdr_pattern = (struct ethhdr *)hdr_8023_pattern;
+   struct ethhdr *old_hdr_mask = (struct ethhdr *)hdr_8023_bit_mask;
+   int hdr_len = sizeof(*new_hdr_pattern);
+
+   struct rfc1042_hdr *new_rfc_pattern =
+   (struct rfc1042_hdr *)(hdr_80211_pattern + hdr_len);
+   struct rfc1042_hdr *new_rfc_mask =
+   (struct rfc1042_hdr *)(hdr_80211_bit_mask + hdr_len);
+   int rfc_len = sizeof(*new_rfc_pattern);
+
+   memcpy(hdr_8023_pattern + old->pkt_offset,
+  old->pattern, ETH_HLEN - old->pkt_offset);
+   memcpy(hdr_8023_bit_mask + old->pkt_offset,
+  old->mask, ETH_HLEN - old->pkt_offset);
+
+   /* Copy destination address */
+   memcpy(new_hdr_pattern->addr1, old_hdr_pattern->h_dest, ETH_ALEN);
+   memcpy(new_hdr_mask->addr1, old_hdr_mask->h_dest, ETH_ALEN);
+
+   /* Copy source address */
+   memcpy(new_hdr_pattern->addr3, old_hdr_pattern->h_source, ETH_ALEN);
+   memcpy(new_hdr_mask->addr3, old_hdr_mask->h_source, ETH_ALEN);
+
+   /* Copy logic link type */
+   memcpy(_rfc_pattern->snap_type,
+  _hdr_pattern->h_proto,
+  sizeof(old_hdr_pattern->h_proto));
+   memcpy(_rfc_mask->snap_type,
+  _hdr_mask->h_proto,
+  sizeof(old_hdr_mask->h_proto));
+
+   /* Caculate new pkt_offset */
+   if (old->pkt_offset < ETH_ALEN)
+   new->pkt_offset = old->pkt_offset +
+   offsetof(struct ieee80211_h

<    1   2   3   4