RE: regulatory.db file for ath10k

2017-12-12 Thread Manikanta Pubbisetty
Please CC linux wireless when posting queries on cfg/mac80211.

At least, I have not had any issues in interface bring up after the latest 
regulatory.db change, I have tested it with vanilla ath.git and it worked even 
without regulatory.db file.
If you may want to refer, Johannes submitted a patch[1] for converting db.txt 
to firmware file format.

[1] https://patchwork.kernel.org/patch/9992477/ 

mkp

>-Original Message-
>From: ath10k [mailto:ath10k-boun...@lists.infradead.org] On Behalf Of
>KAVITA MATHUR
>Sent: Wednesday, December 13, 2017 12:02 PM
>To: ath...@lists.infradead.org
>Subject: regulatory.db file for ath10k
>
>hi,
>
>wifi interface is not up with ath10k driver due to missing regulatory.db.I have
>taken ath10k latest driver code from backports and ath10k git on 12 Dec.
>
>
>
>Loading modules backported from Linux version v3.18-239930-g135da6d
>Backport generated by backports.git v4.14-rc2-1-35-g3d13478 ath10k_pci
>0002:03:00.0: pci irq legacy oper_irq_mode 1 irq_mode 0 reset_mode 0
>cfg80211: failed to load regulatory.db
>ath10k_pci 0002:03:00.0: qca988x hw2.0 target 0x4100016c chip_id 0x043222ff
>sub : ath10k_pci 0002:03:00.0: kconfig debug 0 debugfs 0 tracing 0 dfs
>0 testmode 0 ath10k_pci 0002:03:00.0: firmware ver 10.2.4.70.66 api 5 features
>no-p2p,raw-mode,mfp,allows-mesh-bcast crc32 c2dd2ad5 ath10k_pci
>0002:03:00.0: board_file api 1 bmi_id N/A crc32 bebc7c08 ath10k_pci
>0002:03:00.0: htt-ver 2.1 wmi-op 5 htt-op 2 cal otp max-sta 128 raw 0 hwcrypto
>1
>
>wifi
>root@CDOT:/# IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready device
>wlan0 entered promiscuous mode device wlan0 left promiscuous mode
>br-lan: port 2(wlan0) entered disabled state
>
>How to generate regulatory.db file or is it available to use it directly? 
>Please
>help me to fix it.
>
>
>
>
>
>
>
>
>Thanks & Regards,
>कविता माथुर Kavita Mathur
>वरिष्ठ अनुसंधान अभियंता  Senior Research Engineer
>सी-डॉट  C-DOT
>इलैक्ट्रॉनिक्स सिटी फेज़ I Electronics City Phase I
>होसूर रोड, बेंगलूरु   Hosur Road, Bengaluru – 560100
>फोन  Ph 080-28529896
>Disclaimer:
>--
>This email and any files transmitted with it
>
>
>___
>ath10k mailing list
>ath...@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/ath10k


Re: [PATCH] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

2017-12-12 Thread Wright Feng

Hi Kalle,

On 2017/12/12 下午 08:57, Kalle Valo wrote:

Wright Feng  writes:


For legacy chips w/o CLM blob files, kernel with user helper function
enables returns -EAGAIN when we request_firmware() for blob file:
"request_firmware() -> _request_firmware() -> fw_load_from_user_helper()
-> _request_firmware_load() -> retval=-EAGAIN"
We should do one more retry


Who says that we should do one more retry?


and continue brcmf_c_process_clm_blob if getting -EAGAIN from
request_firmware function.

Signed-off-by: Wright Feng 


[...]


@@ -180,11 +183,18 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
return err;
}
  
-	err = request_firmware(, clm_name, dev);

+   do {
+   err = request_firmware(, clm_name, dev);
+   } while (err == -EAGAIN && retries++ < CLM_LOAD_RETRIES);


This looks like a REALLY ugly workaround, please think three times
before submitting something like this. And if you still decide to submit
it, put a good effort on the commit log to explain why the hack would be
acceptable.

Have you investigated why you are getting the -EGAIN, user space not
ready during boot or something like that?
I didn't notice below commit 76098b36b5db ("firmware: send -EINTR on 
signal abort on fallback mechanism") has been merged on July 2017, sorry 
for that.


Before commit 76098b36b5db, user helper sent -EAGAIN for all errors 
including "getting interrupted" and "file not found". The one more retry 
was for the sysfs got interrupted, and what we expected was the driver 
should get "-EAGAIN" when clm blob file was not found for legacy wifi chip.
Since commit 76098b36b5db changed the error code for interrupted, I will 
remove the retry mechanism and keep remaining change for Patch v2. 
Thanks for the review.


commit 76098b36b5db1a509e5af94128b08f950692c7f8
Author: Luis R. Rodriguez 
Date:   Thu Jul 20 13:13:39 2017 -0700

firmware: send -EINTR on signal abort on fallback mechanism

Right now we send -EAGAIN to a syfs write which got interrupted.
Userspace can't tell what happened though, send -EINTR if we
were killed due to a signal so userspace can tell things apart.

This is only applicable to the fallback mechanism.

Regards,
Wright


Re: mmotm 2017-12-12-16-32 uploaded (net/wireless certs)

2017-12-12 Thread Randy Dunlap
On 12/12/2017 04:32 PM, a...@linux-foundation.org wrote:
> The mm-of-the-moment snapshot 2017-12-12-16-32 has been uploaded to
> 
>http://www.ozlabs.org/~akpm/mmotm/
> 
> mmotm-readme.txt says
> 
> README for mm-of-the-moment:
> 
> http://www.ozlabs.org/~akpm/mmotm/
> 
> This is a snapshot of my -mm patch queue.  Uploaded at random hopefully
> more than once a week.
> 
> You will need quilt to apply these patches to the latest Linus release (4.x
> or 4.x-rcY).  The series file is in broken-out.tar.gz and is duplicated in
> http://ozlabs.org/~akpm/mmotm/series

on i386:

  GEN net/wireless/shipped-certs.c
  CC  net/wireless/extra-certs.o
../net/wireless/Makefile:27: recipe for target 'net/wireless/shipped-certs.c' 
failed
make[3]: *** [net/wireless/shipped-certs.c] Error 1
make[3]: *** Waiting for unfinished jobs
../scripts/Makefile.build:569: recipe for target 'net/wireless' failed
make[2]: *** [net/wireless] Error 2



CFG80211 is set but MAC80211 is not.

Full randconfig file is attached.
-- 
~Randy
#
# Automatically generated file; DO NOT EDIT.
# Linux/i386 4.15.0-rc3-mm1 Kernel Configuration
#
# CONFIG_64BIT is not set
CONFIG_X86_32=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf32-i386"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_BITS_MAX=16
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_X86_32_LAZY_GS=y
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=3
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_CONSTRUCTORS=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y

#
# General setup
#
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
CONFIG_KERNEL_LZO=y
# CONFIG_KERNEL_LZ4 is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# CONFIG_SYSVIPC is not set
CONFIG_POSIX_MQUEUE=y
CONFIG_POSIX_MQUEUE_SYSCTL=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_USELIB=y
# CONFIG_AUDIT is not set
CONFIG_HAVE_ARCH_AUDITSYSCALL=y

#
# IRQ subsystem
#
CONFIG_GENERIC_IRQ_PROBE=y
CONFIG_GENERIC_IRQ_SHOW=y
CONFIG_GENERIC_IRQ_CHIP=y
CONFIG_IRQ_DOMAIN=y
CONFIG_IRQ_DOMAIN_HIERARCHY=y
CONFIG_GENERIC_MSI_IRQ=y
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR=y
CONFIG_GENERIC_IRQ_RESERVATION_MODE=y
CONFIG_IRQ_DOMAIN_DEBUG=y
CONFIG_IRQ_FORCED_THREADING=y
CONFIG_SPARSE_IRQ=y
# CONFIG_GENERIC_IRQ_DEBUGFS is not set
CONFIG_CLOCKSOURCE_WATCHDOG=y
CONFIG_ARCH_CLOCKSOURCE_DATA=y
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
CONFIG_GENERIC_TIME_VSYSCALL=y
CONFIG_GENERIC_CLOCKEVENTS=y
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
CONFIG_GENERIC_CMOS_UPDATE=y

#
# Timers subsystem
#
CONFIG_TICK_ONESHOT=y
CONFIG_NO_HZ_COMMON=y
# CONFIG_HZ_PERIODIC is not set
CONFIG_NO_HZ_IDLE=y
# CONFIG_NO_HZ is not set
# CONFIG_HIGH_RES_TIMERS is not set

#
# CPU/Task time and stats accounting
#
CONFIG_TICK_CPU_ACCOUNTING=y
# CONFIG_IRQ_TIME_ACCOUNTING is not set
# CONFIG_CPU_ISOLATION is not set

#
# RCU Subsystem
#
CONFIG_TINY_RCU=y
# CONFIG_RCU_EXPERT is not set
CONFIG_SRCU=y
CONFIG_TINY_SRCU=y
CONFIG_TASKS_RCU=y
# CONFIG_RCU_STALL_COMMON is not set
# CONFIG_RCU_NEED_SEGCBLIST is not set
# CONFIG_BUILD_BIN2C is not set
# CONFIG_IKCONFIG is not set
CONFIG_LOG_BUF_SHIFT=17
CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=13
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
CONFIG_CGROUPS=y
# CONFIG_MEMCG is not set
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
# CONFIG_CFS_BANDWIDTH is not set
CONFIG_RT_GROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_RDMA=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
# CONFIG_CGROUP_CPUACCT is not set
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_BPF=y
CONFIG_CGROUP_DEBUG=y
CONFIG_SOCK_CGROUP_DATA=y
CONFIG_SCHED_AUTOGROUP=y
# CONFIG_SYSFS_DEPRECATED is not set
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y

Re: [PATCH v2 1/2] dt: bindings: add new dt entry for ath10k calibration variant

2017-12-12 Thread Rob Herring
On Fri, Dec 08, 2017 at 11:37:41AM +0100, Sven Eckelmann wrote:
> The bus + bmi-chip-id + bmi-board-id is not enough to identify the correct
> board data file on QCA4019 based devices. Multiple different boards share
> the same values. Only the original reference designs can currently be
> identified and loaded from the board-2.bin. But these will not result in
> the correct calibration data when combined with the pre-calibration data
> from the device.
> 
> An additional "variant" information has to be provided (via SMBIOS or DT)
> to select the correct board data for a design which was modified by an ODM.
> 
> Signed-off-by: Sven Eckelmann 
> ---
>  Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Rob Herring   


[PATCH 3/9] wil6210: add platform capabilities bitmap

2017-12-12 Thread Maya Erez
Add get_capa callback to platform ops to allow reading the platform
capabilities.
Supported capabilities:
- Keeping 11ad connection during suspend
- T_POWER_ON 0 support
- Usage of external clock

Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c | 15 ---
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 10 ++
 drivers/net/wireless/ath/wil6210/wil6210.h  |  5 +
 drivers/net/wireless/ath/wil6210/wil_platform.h |  9 -
 4 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 5d69796..bafd8d5 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -773,9 +773,8 @@ void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
struct wiphy *wiphy = wil_to_wiphy(wil);
 
wil->keep_radio_on_during_sleep =
-   wil->platform_ops.keep_radio_on_during_sleep &&
-   wil->platform_ops.keep_radio_on_during_sleep(
-   wil->platform_handle) &&
+   test_bit(WIL_PLATFORM_CAPA_RADIO_ON_IN_SUSPEND,
+wil->platform_capa) &&
test_bit(WMI_FW_CAPABILITY_D3_SUSPEND, wil->fw_capabilities);
 
wil_info(wil, "keep_radio_on_during_sleep (%d)\n",
@@ -1008,6 +1007,16 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
if (wil->hw_version == HW_VER_UNKNOWN)
return -ENODEV;
 
+   if (test_bit(WIL_PLATFORM_CAPA_T_PWR_ON_0, wil->platform_capa)) {
+   wil_dbg_misc(wil, "Notify FW to set T_POWER_ON=0\n");
+   wil_s(wil, RGF_USER_USAGE_8, BIT_USER_SUPPORT_T_POWER_ON_0);
+   }
+
+   if (test_bit(WIL_PLATFORM_CAPA_EXT_CLK, wil->platform_capa)) {
+   wil_dbg_misc(wil, "Notify FW on ext clock configuration\n");
+   wil_s(wil, RGF_USER_USAGE_8, BIT_USER_EXT_CLK);
+   }
+
if (wil->platform_ops.notify) {
rc = wil->platform_ops.notify(wil->platform_handle,
  WIL_PLATFORM_EVT_PRE_RESET);
diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index d4bb0bd..dc84001 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -43,9 +43,11 @@ void wil_set_capabilities(struct wil6210_priv *wil)
u32 jtag_id = wil_r(wil, RGF_USER_JTAG_DEV_ID);
u8 chip_revision = (wil_r(wil, RGF_USER_REVISION_ID) &
RGF_USER_REVISION_ID_MASK);
+   int platform_capa;
 
bitmap_zero(wil->hw_capabilities, hw_capability_last);
bitmap_zero(wil->fw_capabilities, WMI_FW_CAPABILITY_MAX);
+   bitmap_zero(wil->platform_capa, WIL_PLATFORM_CAPA_MAX);
wil->wil_fw_name = ftm_mode ? WIL_FW_NAME_FTM_DEFAULT :
   WIL_FW_NAME_DEFAULT;
wil->chip_revision = chip_revision;
@@ -81,6 +83,14 @@ void wil_set_capabilities(struct wil6210_priv *wil)
 
wil_info(wil, "Board hardware is %s\n", wil->hw_name);
 
+   /* Get platform capabilities */
+   if (wil->platform_ops.get_capa) {
+   platform_capa =
+   wil->platform_ops.get_capa(wil->platform_handle);
+   memcpy(wil->platform_capa, _capa,
+  min(sizeof(wil->platform_capa), sizeof(platform_capa)));
+   }
+
/* extract FW capabilities from file without loading the FW */
wil_request_firmware(wil, wil->wil_fw_name, false);
wil_refresh_fw_capabilities(wil);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index db68209..f2bb55e 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -161,6 +161,10 @@ struct RGF_ICR {
 #define RGF_USER_USAGE_6   (0x880018)
#define BIT_USER_OOB_MODE   BIT(31)
#define BIT_USER_OOB_R2_MODEBIT(30)
+#define RGF_USER_USAGE_8   (0x880020)
+   #define BIT_USER_PREVENT_DEEP_SLEEP BIT(0)
+   #define BIT_USER_SUPPORT_T_POWER_ON_0   BIT(1)
+   #define BIT_USER_EXT_CLKBIT(2)
 #define RGF_USER_HW_MACHINE_STATE  (0x8801dc)
#define HW_MACHINE_BOOT_DONE(0x3fd)
 #define RGF_USER_USER_CPU_0(0x8801e0)
@@ -643,6 +647,7 @@ struct wil6210_priv {
const char *wil_fw_name;
DECLARE_BITMAP(hw_capabilities, hw_capability_last);
DECLARE_BITMAP(fw_capabilities, WMI_FW_CAPABILITY_MAX);
+   DECLARE_BITMAP(platform_capa, WIL_PLATFORM_CAPA_MAX);
u8 n_mids; /* number of additional MIDs as reported by FW */
u32 recovery_count; /* num of FW recovery attempts in a short time */
u32 recovery_state; /* FW recovery state machine */
diff --git 

[PATCH 8/9] wil6210: remove leftover "FIXME"s

2017-12-12 Thread Maya Erez
From: Dedy Lansky 

"FIXME: IRQ mask debug" and "FIXME: interrupts enabled - for debug"
can be removed because wil6210_debug_irq_mask() is now considered
production feature.

"FIXME FW can transmit only ucast frames to peer" and "FIXME real
ring_id instead of hard coded 0" can be removed because FW/HW already
support multicast transmission.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/interrupt.c | 2 +-
 drivers/net/wireless/ath/wil6210/wil6210.h   | 2 +-
 drivers/net/wireless/ath/wil6210/wmi.c   | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/interrupt.c 
b/drivers/net/wireless/ath/wil6210/interrupt.c
index 5cf3417..dcf87a7 100644
--- a/drivers/net/wireless/ath/wil6210/interrupt.c
+++ b/drivers/net/wireless/ath/wil6210/interrupt.c
@@ -565,7 +565,7 @@ static irqreturn_t wil6210_hardirq(int irq, void *cookie)
if (unlikely((pseudo_cause == 0) || ((pseudo_cause & 0xff) == 0xff)))
return IRQ_NONE;
 
-   /* FIXME: IRQ mask debug */
+   /* IRQ mask debug */
if (unlikely(wil6210_debug_irq_mask(wil, pseudo_cause)))
return IRQ_NONE;
 
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index ca5abbd..703e09e 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -439,7 +439,7 @@ enum { /* for wil6210_priv.status */
wil_status_fwconnected,
wil_status_dontscan,
wil_status_mbox_ready, /* MBOX structures ready */
-   wil_status_irqen, /* FIXME: interrupts enabled - for debug */
+   wil_status_irqen, /* interrupts enabled - for debug */
wil_status_napi_en, /* NAPI enabled protected by wil->mutex */
wil_status_resetting, /* reset in progress */
wil_status_suspending, /* suspend in progress */
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index ed7cdb7..4d7fb47 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -811,8 +811,6 @@ static void wmi_evt_connect(struct wil6210_priv *wil, int 
id, void *d, int len)
}
}
 
-   /* FIXME FW can transmit only ucast frames to peer */
-   /* FIXME real ring_id instead of hard coded 0 */
ether_addr_copy(wil->sta[evt->cid].addr, evt->bssid);
wil->sta[evt->cid].status = wil_sta_conn_pending;
 
-- 
1.9.1



[PATCH 5/9] wil6210: prevent parallel suspend and dump collection

2017-12-12 Thread Maya Erez
Suspend and crash dump operations can happen simultaneously
in case there is a FW assert during the suspend procedure
or when SSR calls all the devices crashdump callbacks.

To prevent that, a new flag is added, indicating that the
dumps collection is in progress, in order to allow the
suspend/reset decline if the dumps collection already started.

Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c   | 33 +--
 drivers/net/wireless/ath/wil6210/pm.c | 17 
 drivers/net/wireless/ath/wil6210/wil6210.h|  1 +
 drivers/net/wireless/ath/wil6210/wil_crash_dump.c | 11 
 4 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 7a8f8c2..aa6f9c4 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -998,6 +998,7 @@ static void wil_pre_fw_config(struct wil6210_priv *wil)
 int wil_reset(struct wil6210_priv *wil, bool load_fw)
 {
int rc;
+   unsigned long status_flags = BIT(wil_status_resetting);
 
wil_dbg_misc(wil, "reset\n");
 
@@ -1037,6 +1038,14 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
}
 
set_bit(wil_status_resetting, wil->status);
+   if (test_bit(wil_status_collecting_dumps, wil->status)) {
+   /* Device collects crash dump, cancel the reset.
+* following crash dump collection, reset would take place.
+*/
+   wil_dbg_misc(wil, "reject reset while collecting crash dump\n");
+   rc = -EBUSY;
+   goto out;
+   }
 
cancel_work_sync(>disconnect_worker);
wil6210_disconnect(wil, NULL, WLAN_REASON_DEAUTH_LEAVING, false);
@@ -1051,7 +1060,11 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
 
/* prevent NAPI from being scheduled and prevent wmi commands */
mutex_lock(>wmi_mutex);
-   bitmap_zero(wil->status, wil_status_last);
+   if (test_bit(wil_status_suspending, wil->status))
+   status_flags |= BIT(wil_status_suspending);
+   bitmap_and(wil->status, wil->status, _flags,
+  wil_status_last);
+   wil_dbg_misc(wil, "wil->status (0x%lx)\n", *wil->status);
mutex_unlock(>wmi_mutex);
 
wil_mask_irq(wil);
@@ -1069,14 +1082,14 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
wil_rx_fini(wil);
if (rc) {
wil_bl_crash_info(wil, true);
-   return rc;
+   goto out;
}
 
rc = wil_get_bl_info(wil);
if (rc == -EAGAIN && !load_fw) /* ignore RF error if not going up */
rc = 0;
if (rc)
-   return rc;
+   goto out;
 
wil_set_oob_mode(wil, oob_mode);
if (load_fw) {
@@ -1088,10 +1101,10 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
/* Loading f/w from the file */
rc = wil_request_firmware(wil, wil->wil_fw_name, true);
if (rc)
-   return rc;
+   goto out;
rc = wil_request_firmware(wil, WIL_BOARD_FILE_NAME, true);
if (rc)
-   return rc;
+   goto out;
 
wil_pre_fw_config(wil);
wil_release_cpu(wil);
@@ -1103,6 +1116,8 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
reinit_completion(>wmi_call);
reinit_completion(>halp.comp);
 
+   clear_bit(wil_status_resetting, wil->status);
+
if (load_fw) {
wil_configure_interrupt_moderation(wil);
wil_unmask_irq(wil);
@@ -1136,6 +1151,10 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)
}
 
return rc;
+
+out:
+   clear_bit(wil_status_resetting, wil->status);
+   return rc;
 }
 
 void wil_fw_error_recovery(struct wil6210_priv *wil)
@@ -1241,9 +1260,7 @@ int __wil_down(struct wil6210_priv *wil)
wil_abort_scan(wil, false);
mutex_unlock(>p2p_wdev_mutex);
 
-   wil_reset(wil, false);
-
-   return 0;
+   return wil_reset(wil, false);
 }
 
 int wil_down(struct wil6210_priv *wil)
diff --git a/drivers/net/wireless/ath/wil6210/pm.c 
b/drivers/net/wireless/ath/wil6210/pm.c
index 056b180..0a96518 100644
--- a/drivers/net/wireless/ath/wil6210/pm.c
+++ b/drivers/net/wireless/ath/wil6210/pm.c
@@ -145,6 +145,13 @@ static int wil_suspend_keep_radio_on(struct wil6210_priv 
*wil)
 
/* Prevent handling of new tx and wmi commands */
set_bit(wil_status_suspending, wil->status);
+   if (test_bit(wil_status_collecting_dumps, wil->status)) {
+   /* Device collects crash dump, cancel the suspend */
+   wil_dbg_pm(wil, "reject suspend while collecting crash dump\n");
+   clear_bit(wil_status_suspending, wil->status);
+   

[PATCH 7/9] wil6210: configurable broadcast TX MCS

2017-12-12 Thread Maya Erez
From: Lior David 

Add 2 module parameters that control broadcast/multicast
TX packets:
1. bcast_mcs0_limit - specify the maximum packet size
that will be sent with MCS 0.
2. bcast_mcs - specify the MCS index to use when sending
packets larger than above limit.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/txrx.c | 59 +++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index 89967ce..4fc05f7 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -67,6 +67,60 @@ static int headroom_size_set(const char *val, const struct 
kernel_param *kp)
 MODULE_PARM_DESC(headroom_size,
 " headroom size for rx skb allocation, default - 0");
 
+static uint bcast_mcs0_limit = WIL_BCAST_MCS0_LIMIT;
+static int bcast_mcs0_limit_set(const char *val, const struct kernel_param *kp)
+{
+   int ret;
+   uint saved = bcast_mcs0_limit;
+
+   ret = param_set_uint(val, kp);
+   if (ret)
+   return ret;
+
+   if (bcast_mcs0_limit > WIL_BCAST_MCS0_LIMIT) {
+   bcast_mcs0_limit = saved;
+   ret = -EINVAL;
+   }
+
+   return ret;
+}
+
+static const struct kernel_param_ops bcast_mcs0_limit_ops = {
+   .set = bcast_mcs0_limit_set,
+   .get = param_get_uint,
+};
+
+module_param_cb(bcast_mcs0_limit_set, _mcs0_limit_ops,
+   _mcs0_limit, 0644);
+MODULE_PARM_DESC(bcast_mcs0_limit,
+" max broadcast packet size with MCS0, default - 1024 bytes");
+
+static uint bcast_mcs = 1;
+static int bcast_mcs_set(const char *val, const struct kernel_param *kp)
+{
+   int ret;
+   uint saved = bcast_mcs;
+
+   ret = param_set_uint(val, kp);
+   if (ret)
+   return ret;
+
+   if (bcast_mcs > WIL_MCS_MAX || bcast_mcs == 0) {
+   bcast_mcs = saved;
+   ret = -EINVAL;
+   }
+
+   return ret;
+}
+
+static const struct kernel_param_ops bcast_mcs_ops = {
+   .set = bcast_mcs_set,
+   .get = param_get_uint,
+};
+
+module_param_cb(bcast_mcs, _mcs_ops, _mcs, 0644);
+MODULE_PARM_DESC(bcast_mcs, " MCS index for large bcast TX, default - 1");
+
 static inline uint wil_rx_snaplen(void)
 {
return rx_align_2 ? 6 : 0;
@@ -1783,8 +1837,9 @@ static int __wil_tx_vring(struct wil6210_priv *wil, 
struct vring *vring,
wil_tx_desc_map(d, pa, len, vring_index);
if (unlikely(mcast)) {
d->mac.d[0] |= BIT(MAC_CFG_DESC_TX_0_MCS_EN_POS); /* MCS 0 */
-   if (unlikely(len > WIL_BCAST_MCS0_LIMIT)) /* set MCS 1 */
-   d->mac.d[0] |= (1 << MAC_CFG_DESC_TX_0_MCS_INDEX_POS);
+   if (unlikely(len > bcast_mcs0_limit)) /* use bcast_mcs */
+   d->mac.d[0] |= (bcast_mcs <<
+   MAC_CFG_DESC_TX_0_MCS_INDEX_POS);
}
/* Process TCP/UDP checksum offloading */
if (unlikely(wil_tx_desc_offload_setup(d, skb))) {
-- 
1.9.1



[PATCH 9/9] wil6210: remove reference to preset_chandef

2017-12-12 Thread Maya Erez
From: Lior David 

The field preset_chandef of wireless_dev must not be accessed
by the driver because it is private to cfg80211. Store the
monitor channel locally in wil6210_priv instead.

Signed-off-by: Lior David 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c | 3 +--
 drivers/net/wireless/ath/wil6210/debugfs.c  | 1 -
 drivers/net/wireless/ath/wil6210/netdev.c   | 2 +-
 drivers/net/wireless/ath/wil6210/txrx.c | 3 +--
 drivers/net/wireless/ath/wil6210/wil6210.h  | 1 +
 drivers/net/wireless/ath/wil6210/wmi.c  | 2 +-
 6 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 39509d0..768f63f38 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -956,9 +956,8 @@ static int wil_cfg80211_set_channel(struct wiphy *wiphy,
struct cfg80211_chan_def *chandef)
 {
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
-   struct wireless_dev *wdev = wil_to_wdev(wil);
 
-   wdev->preset_chandef = *chandef;
+   wil->monitor_chandef = *chandef;
 
return 0;
 }
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c 
b/drivers/net/wireless/ath/wil6210/debugfs.c
index 4475937..4a48882 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -869,7 +869,6 @@ static ssize_t wil_write_file_txmgmt(struct file *file, 
const char __user *buf,
 
params.buf = frame;
params.len = len;
-   params.chan = wdev->preset_chandef.chan;
 
rc = wil_cfg80211_mgmt_tx(wiphy, wdev, , NULL);
 
diff --git a/drivers/net/wireless/ath/wil6210/netdev.c 
b/drivers/net/wireless/ath/wil6210/netdev.c
index b641ac1..7ba4e0a 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -150,7 +150,7 @@ void *wil_if_alloc(struct device *dev)
wdev->iftype = NL80211_IFTYPE_STATION; /* TODO */
/* default monitor channel */
ch = wdev->wiphy->bands[NL80211_BAND_60GHZ]->channels;
-   cfg80211_chandef_create(>preset_chandef, ch, NL80211_CHAN_NO_HT);
+   cfg80211_chandef_create(>monitor_chandef, ch, NL80211_CHAN_NO_HT);
 
ndev = alloc_netdev(0, "wlan%d", NET_NAME_UNKNOWN, wil_dev_setup);
if (!ndev) {
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index 4fc05f7..9f8c6087f 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -428,7 +428,6 @@ static int wil_vring_alloc_skb(struct wil6210_priv *wil, 
struct vring *vring,
 static void wil_rx_add_radiotap_header(struct wil6210_priv *wil,
   struct sk_buff *skb)
 {
-   struct wireless_dev *wdev = wil->wdev;
struct wil6210_rtap {
struct ieee80211_radiotap_header rthdr;
/* fields should be in the order of bits in rthdr.it_present */
@@ -455,7 +454,7 @@ static void wil_rx_add_radiotap_header(struct wil6210_priv 
*wil,
int rtap_len = sizeof(struct wil6210_rtap);
int phy_length = 0; /* phy info header size, bytes */
static char phy_data[128];
-   struct ieee80211_channel *ch = wdev->preset_chandef.chan;
+   struct ieee80211_channel *ch = wil->monitor_chandef.chan;
 
if (rtap_include_phy_info) {
rtap_len = sizeof(*rtap_vendor) + sizeof(*d);
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h 
b/drivers/net/wireless/ath/wil6210/wil6210.h
index 703e09e..1131893 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -655,6 +655,7 @@ struct wil6210_priv {
unsigned long last_fw_recovery; /* jiffies of last fw recovery */
wait_queue_head_t wq; /* for all wait_event() use */
/* profile */
+   struct cfg80211_chan_def monitor_chandef;
u32 monitor_flags;
u32 privacy; /* secure connection? */
u8 hidden_ssid; /* relevant in AP mode */
diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index 4d7fb47..bee018d 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1780,7 +1780,7 @@ int wmi_rx_chain_add(struct wil6210_priv *wil, struct 
vring *vring)
int rc;
 
if (wdev->iftype == NL80211_IFTYPE_MONITOR) {
-   struct ieee80211_channel *ch = wdev->preset_chandef.chan;
+   struct ieee80211_channel *ch = wil->monitor_chandef.chan;
 
cmd.sniffer_cfg.mode = cpu_to_le32(WMI_SNIFFER_ON);
if (ch)
-- 
1.9.1



[PATCH 4/9] wil6210: set platform features based on FW capabilities

2017-12-12 Thread Maya Erez
In some cases the platform should be aware of the FW capabilities
to decide which feature to enable.
For example, FW can control the external REF clock for power saving.
Driver should notify the platform about that, to allow platform
power management optimization.

Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/main.c | 11 +++
 drivers/net/wireless/ath/wil6210/wil_platform.h |  6 ++
 drivers/net/wireless/ath/wil6210/wmi.h  |  1 +
 3 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index bafd8d5..7a8f8c2 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -771,6 +771,7 @@ static void wil_collect_fw_info(struct wil6210_priv *wil)
 void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
 {
struct wiphy *wiphy = wil_to_wiphy(wil);
+   int features;
 
wil->keep_radio_on_during_sleep =
test_bit(WIL_PLATFORM_CAPA_RADIO_ON_IN_SUSPEND,
@@ -792,6 +793,16 @@ void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
wiphy->max_sched_scan_ie_len = WMI_MAX_IE_LEN;
wiphy->max_sched_scan_plans = WMI_MAX_PLANS_NUM;
}
+
+   if (wil->platform_ops.set_features) {
+   features = (test_bit(WMI_FW_CAPABILITY_REF_CLOCK_CONTROL,
+wil->fw_capabilities) &&
+   test_bit(WIL_PLATFORM_CAPA_EXT_CLK,
+wil->platform_capa)) ?
+   BIT(WIL_PLATFORM_FEATURE_FW_EXT_CLK_CONTROL) : 0;
+
+   wil->platform_ops.set_features(wil->platform_handle, features);
+   }
 }
 
 void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r)
diff --git a/drivers/net/wireless/ath/wil6210/wil_platform.h 
b/drivers/net/wireless/ath/wil6210/wil_platform.h
index 5cfb946..177026e 100644
--- a/drivers/net/wireless/ath/wil6210/wil_platform.h
+++ b/drivers/net/wireless/ath/wil6210/wil_platform.h
@@ -27,6 +27,11 @@ enum wil_platform_event {
WIL_PLATFORM_EVT_POST_SUSPEND = 4,
 };
 
+enum wil_platform_features {
+   WIL_PLATFORM_FEATURE_FW_EXT_CLK_CONTROL = 0,
+   WIL_PLATFORM_FEATURE_MAX,
+};
+
 enum wil_platform_capa {
WIL_PLATFORM_CAPA_RADIO_ON_IN_SUSPEND = 0,
WIL_PLATFORM_CAPA_T_PWR_ON_0 = 1,
@@ -45,6 +50,7 @@ struct wil_platform_ops {
void (*uninit)(void *handle);
int (*notify)(void *handle, enum wil_platform_event evt);
int (*get_capa)(void *handle);
+   void (*set_features)(void *handle, int features);
 };
 
 /**
diff --git a/drivers/net/wireless/ath/wil6210/wmi.h 
b/drivers/net/wireless/ath/wil6210/wmi.h
index 7c6ac9c..adb317f 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.h
+++ b/drivers/net/wireless/ath/wil6210/wmi.h
@@ -72,6 +72,7 @@ enum wmi_fw_capability {
WMI_FW_CAPABILITY_SET_SILENT_RSSI_TABLE = 13,
WMI_FW_CAPABILITY_LO_POWER_CALIB_FROM_OTP   = 14,
WMI_FW_CAPABILITY_PNO   = 15,
+   WMI_FW_CAPABILITY_REF_CLOCK_CONTROL = 18,
WMI_FW_CAPABILITY_MAX,
 };
 
-- 
1.9.1



[PATCH 1/9] wil6210: support Scheduled scan

2017-12-12 Thread Maya Erez
From: Dedy Lansky 

Add support for sched_scan_start/stop by sending PNO commands to FW.
Driver reports WIPHY_FLAG_SUPPORTS_SCHED_SCAN and invokes
cfg80211_sched_scan_results upon receiving
WMI_SCHED_SCAN_RESULT_EVENTID from FW.

Signed-off-by: Dedy Lansky 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/cfg80211.c |  65 
 drivers/net/wireless/ath/wil6210/main.c |   8 +
 drivers/net/wireless/ath/wil6210/wil6210.h  |   4 +
 drivers/net/wireless/ath/wil6210/wmi.c  | 239 +++-
 drivers/net/wireless/ath/wil6210/wmi.h  |  99 +---
 5 files changed, 395 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/cfg80211.c 
b/drivers/net/wireless/ath/wil6210/cfg80211.c
index 771a534..39509d0 100644
--- a/drivers/net/wireless/ath/wil6210/cfg80211.c
+++ b/drivers/net/wireless/ath/wil6210/cfg80211.c
@@ -1751,6 +1751,69 @@ static int wil_cfg80211_resume(struct wiphy *wiphy)
return 0;
 }
 
+static int
+wil_cfg80211_sched_scan_start(struct wiphy *wiphy,
+ struct net_device *dev,
+ struct cfg80211_sched_scan_request *request)
+{
+   struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+   int i, rc;
+
+   wil_dbg_misc(wil,
+"sched scan start: n_ssids %d, ie_len %zu, flags 0x%x\n",
+request->n_ssids, request->ie_len, request->flags);
+   for (i = 0; i < request->n_ssids; i++) {
+   wil_dbg_misc(wil, "SSID[%d]:", i);
+   wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET, 16, 1,
+ request->ssids[i].ssid,
+ request->ssids[i].ssid_len, true);
+   }
+   wil_dbg_misc(wil, "channels:");
+   for (i = 0; i < request->n_channels; i++)
+   wil_dbg_misc(wil, " %d%s", request->channels[i]->hw_value,
+i == request->n_channels - 1 ? "\n" : "");
+   wil_dbg_misc(wil, "n_match_sets %d, min_rssi_thold %d, delay %d\n",
+request->n_match_sets, request->min_rssi_thold,
+request->delay);
+   for (i = 0; i < request->n_match_sets; i++) {
+   struct cfg80211_match_set *ms = >match_sets[i];
+
+   wil_dbg_misc(wil, "MATCHSET[%d]: rssi_thold %d\n",
+i, ms->rssi_thold);
+   wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET, 16, 1,
+ ms->ssid.ssid,
+ ms->ssid.ssid_len, true);
+   }
+   wil_dbg_misc(wil, "n_scan_plans %d\n", request->n_scan_plans);
+   for (i = 0; i < request->n_scan_plans; i++) {
+   struct cfg80211_sched_scan_plan *sp = >scan_plans[i];
+
+   wil_dbg_misc(wil, "SCAN PLAN[%d]: interval %d iterations %d\n",
+i, sp->interval, sp->iterations);
+   }
+
+   rc = wmi_set_ie(wil, WMI_FRAME_PROBE_REQ, request->ie_len, request->ie);
+   if (rc)
+   return rc;
+   return wmi_start_sched_scan(wil, request);
+}
+
+static int
+wil_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
+u64 reqid)
+{
+   struct wil6210_priv *wil = wiphy_to_wil(wiphy);
+   int rc;
+
+   rc = wmi_stop_sched_scan(wil);
+   /* device would return error if it thinks PNO is already stopped.
+* ignore the return code so user space and driver gets back in-sync
+*/
+   wil_dbg_misc(wil, "sched scan stopped (%d)\n", rc);
+
+   return 0;
+}
+
 static const struct cfg80211_ops wil_cfg80211_ops = {
.add_virtual_intf = wil_cfg80211_add_iface,
.del_virtual_intf = wil_cfg80211_del_iface,
@@ -1784,6 +1847,8 @@ static int wil_cfg80211_resume(struct wiphy *wiphy)
.set_power_mgmt = wil_cfg80211_set_power_mgmt,
.suspend = wil_cfg80211_suspend,
.resume = wil_cfg80211_resume,
+   .sched_scan_start = wil_cfg80211_sched_scan_start,
+   .sched_scan_stop = wil_cfg80211_sched_scan_stop,
 };
 
 static void wil_wiphy_init(struct wiphy *wiphy)
diff --git a/drivers/net/wireless/ath/wil6210/main.c 
b/drivers/net/wireless/ath/wil6210/main.c
index 1b53cd3..5d69796 100644
--- a/drivers/net/wireless/ath/wil6210/main.c
+++ b/drivers/net/wireless/ath/wil6210/main.c
@@ -785,6 +785,14 @@ void wil_refresh_fw_capabilities(struct wil6210_priv *wil)
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
else
wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
+
+   if (test_bit(WMI_FW_CAPABILITY_PNO, wil->fw_capabilities)) {
+   wiphy->max_sched_scan_reqs = 1;
+   wiphy->max_sched_scan_ssids = WMI_MAX_PNO_SSID_NUM;
+   wiphy->max_match_sets = WMI_MAX_PNO_SSID_NUM;
+   wiphy->max_sched_scan_ie_len = WMI_MAX_IE_LEN;
+ 

[PATCH 2/9] wil6210: support 40bit DMA addresses

2017-12-12 Thread Maya Erez
From: Lazar Alexei 

Add the option to support 40bit addresses since some platforms
may not support 48bits but support 40bits

Signed-off-by: Lazar Alexei 
Signed-off-by: Maya Erez 
---
 drivers/net/wireless/ath/wil6210/pcie_bus.c | 26 +++---
 drivers/net/wireless/ath/wil6210/pmc.c  | 11 ++-
 drivers/net/wireless/ath/wil6210/txrx.c | 11 ++-
 drivers/net/wireless/ath/wil6210/wil6210.h  |  2 +-
 4 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/pcie_bus.c 
b/drivers/net/wireless/ath/wil6210/pcie_bus.c
index 42a5480..d4bb0bd 100644
--- a/drivers/net/wireless/ath/wil6210/pcie_bus.c
+++ b/drivers/net/wireless/ath/wil6210/pcie_bus.c
@@ -206,6 +206,8 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
.fw_recovery = wil_platform_rop_fw_recovery,
};
u32 bar_size = pci_resource_len(pdev, 0);
+   int dma_addr_size[] = {48, 40, 32}; /* keep descending order */
+   int i;
 
/* check HW */
dev_info(>dev, WIL_NAME
@@ -241,21 +243,23 @@ static int wil_pcie_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
}
/* rollback to err_plat */
 
-   /* device supports 48bit addresses */
-   rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
-   if (rc) {
-   dev_err(dev, "dma_set_mask_and_coherent(48) failed: %d\n", rc);
-   rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
+   /* device supports >32bit addresses */
+   for (i = 0; i < ARRAY_SIZE(dma_addr_size); i++) {
+   rc = dma_set_mask_and_coherent(dev,
+  DMA_BIT_MASK(dma_addr_size[i]));
if (rc) {
-   dev_err(dev,
-   "dma_set_mask_and_coherent(32) failed: %d\n",
-   rc);
-   goto err_plat;
+   dev_err(dev, "dma_set_mask_and_coherent(%d) failed: 
%d\n",
+   dma_addr_size[i], rc);
+   continue;
}
-   } else {
-   wil->use_extended_dma_addr = 1;
+   dev_info(dev, "using dma mask %d", dma_addr_size[i]);
+   wil->dma_addr_size = dma_addr_size[i];
+   break;
}
 
+   if (wil->dma_addr_size == 0)
+   goto err_plat;
+
rc = pci_enable_device(pdev);
if (rc && pdev->msi_enabled == 0) {
wil_err(wil,
diff --git a/drivers/net/wireless/ath/wil6210/pmc.c 
b/drivers/net/wireless/ath/wil6210/pmc.c
index 2e301b6..4ea27b0 100644
--- a/drivers/net/wireless/ath/wil6210/pmc.c
+++ b/drivers/net/wireless/ath/wil6210/pmc.c
@@ -111,14 +111,14 @@ void wil_pmc_alloc(struct wil6210_priv *wil,
 *
 * HW has limitation that all vrings addresses must share the same
 * upper 16 msb bits part of 48 bits address. To workaround that,
-* if we are using 48 bit addresses switch to 32 bit allocation
-* before allocating vring memory.
+* if we are using more than 32 bit addresses switch to 32 bit
+* allocation before allocating vring memory.
 *
 * There's no check for the return value of dma_set_mask_and_coherent,
 * since we assume if we were able to set the mask during
 * initialization in this system it will not fail if we set it again
 */
-   if (wil->use_extended_dma_addr)
+   if (wil->dma_addr_size > 32)
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
 
pmc->pring_va = dma_alloc_coherent(dev,
@@ -126,8 +126,9 @@ void wil_pmc_alloc(struct wil6210_priv *wil,
>pring_pa,
GFP_KERNEL);
 
-   if (wil->use_extended_dma_addr)
-   dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+   if (wil->dma_addr_size > 32)
+   dma_set_mask_and_coherent(dev,
+ DMA_BIT_MASK(wil->dma_addr_size));
 
wil_dbg_misc(wil,
 "pmc_alloc: allocated pring %p => %pad. %zd x %d = total 
%zd bytes\n",
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c 
b/drivers/net/wireless/ath/wil6210/txrx.c
index 389c718..62c04f0 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -178,14 +178,14 @@ static int wil_vring_alloc(struct wil6210_priv *wil, 
struct vring *vring)
 *
 * HW has limitation that all vrings addresses must share the same
 * upper 16 msb bits part of 48 bits address. To workaround that,
-* if we are using 48 bit addresses switch to 32 bit allocation
-* before allocating vring memory.
+* if we are using more than 32 bit addresses switch to 32 bit
+* allocation before 

[PATCH 0/9] wil6210 patches

2017-12-12 Thread Maya Erez
The following patches include several wil6210 fixes.

Dedy Lansky (2):
  wil6210: support Scheduled scan
  wil6210: remove leftover "FIXME"s

Lazar Alexei (2):
  wil6210: support 40bit DMA addresses
  wil6210: add support for headroom configuration

Lior David (2):
  wil6210: configurable broadcast TX MCS
  wil6210: remove reference to preset_chandef

Maya Erez (3):
  wil6210: add platform capabilities bitmap
  wil6210: set platform features based on FW capabilities
  wil6210: prevent parallel suspend and dump collection

 drivers/net/wireless/ath/wil6210/cfg80211.c   |  68 +-
 drivers/net/wireless/ath/wil6210/debugfs.c|   1 -
 drivers/net/wireless/ath/wil6210/interrupt.c  |   2 +-
 drivers/net/wireless/ath/wil6210/main.c   |  67 +-
 drivers/net/wireless/ath/wil6210/netdev.c |   2 +-
 drivers/net/wireless/ath/wil6210/pcie_bus.c   |  36 +++-
 drivers/net/wireless/ath/wil6210/pm.c |  17 ++
 drivers/net/wireless/ath/wil6210/pmc.c|  11 +-
 drivers/net/wireless/ath/wil6210/txrx.c   | 101 -
 drivers/net/wireless/ath/wil6210/wil6210.h|  15 +-
 drivers/net/wireless/ath/wil6210/wil_crash_dump.c |  11 +
 drivers/net/wireless/ath/wil6210/wil_platform.h   |  15 +-
 drivers/net/wireless/ath/wil6210/wmi.c| 243 +-
 drivers/net/wireless/ath/wil6210/wmi.h| 100 +++--
 14 files changed, 621 insertions(+), 68 deletions(-)

-- 
1.9.1



Re: linux-next: build failure after merge of the mac80211-next tree

2017-12-12 Thread Toke Høiland-Jørgensen
Kalle Valo  writes:

> Toke Høiland-Jørgensen  writes:
>
>>> Sorry for the inconvenience, I hadn't realized mt76 went in now.
>>
>> Yeah, hadn't expected these streams to cross either.
>
> I did ask[1] if everyone are ok that I apply mt76 and I didn't get any
> comments,

Huh, did actually see that. But was not aware that Johannes had already
merged my patches; have been caught up in other stuff since netdev, so
have not been paying that close attention... Sorry about that, should
have pointed out the potential conflict :)

> I guess I need to make more noise next time when I'm applying a new
> driver.

Yeah, I would like to request a marching band to my apartment next time,
please. I'll send you my address off list... ;)

-Toke


Re: [PATCH v2] wcn36xx: Fix dynamic power saving

2017-12-12 Thread Kalle Valo
Kalle Valo  writes:

> Loic Poulain  writes:
>
>> Since driver does not report hardware dynamic power saving cap,
>> this is up to the mac80211 to manage power saving timeout and
>> state machine, using the ieee80211 config callback to report
>> PS changes. This patch enables/disables PS mode according to
>> the new configuration.
>>
>> Remove old behaviour enabling PS mode in a static way, this make
>> the device unusable when power save is enabled since device is
>> forced to PS regardless RX/TX traffic.
>>
>> Acked-by: Bjorn Andersson 
>> Signed-off-by: Loic Poulain 
>
> A fixes line would be nice for backporters. I can add that but need the
> commit id.

Or maybe this actually isn't a regression? Then of course a fixes line
is not needed.

Should I push this to v4.15 or v4.16, any preference?

-- 
Kalle Valo

Re: [PATCH v2] wcn36xx: Fix dynamic power saving

2017-12-12 Thread Kalle Valo
Loic Poulain  writes:

> Since driver does not report hardware dynamic power saving cap,
> this is up to the mac80211 to manage power saving timeout and
> state machine, using the ieee80211 config callback to report
> PS changes. This patch enables/disables PS mode according to
> the new configuration.
>
> Remove old behaviour enabling PS mode in a static way, this make
> the device unusable when power save is enabled since device is
> forced to PS regardless RX/TX traffic.
>
> Acked-by: Bjorn Andersson 
> Signed-off-by: Loic Poulain 

A fixes line would be nice for backporters. I can add that but need the
commit id.

-- 
Kalle Valo

Re: linux-next: build failure after merge of the mac80211-next tree

2017-12-12 Thread Kalle Valo
Toke Høiland-Jørgensen  writes:

>> Sorry for the inconvenience, I hadn't realized mt76 went in now.
>
> Yeah, hadn't expected these streams to cross either.

I did ask[1] if everyone are ok that I apply mt76 and I didn't get any
comments, I guess I need to make more noise next time when I'm applying
a new driver.

[1] https://lkml.kernel.org/r/87wp22jzzb@purkki.adurom.net

-- 
Kalle Valo


Re: [v2] ath9k: add MSI support

2017-12-12 Thread Daniel Drake
On Wed, Nov 15, 2017 at 7:38 AM, Daniel Drake  wrote:
> On Tue, Nov 14, 2017 at 8:15 PM, Kalle Valo  wrote:
>>> Can't be fixed in firmware, but it would be good to have confirmation
>>> of the hardware behavivour, and maybe some other solution is possible?
>>> Are you following this up within Qualcomm?
>>
>> No time to do that right now, sorry.
>
> I got several autoresponders from people on this thread from Qualcomm
> Taiwan. Would it be useful for us to drop off a sample of the affected
> product at your Taipei or Hsinchu office so that you can investigate
> further?

Ping - how can we collaborate on this?

Also, we have been testing the MSI support patch and while it seems to
be working fine on AR9565, multiple users hit failures on AR9462. The
most common report is that the system simply cannot maintain the
connection with the AP for more than a few seconds. It hits a check in
mac80211 where it sends a nullfunc to the AP and expects an ack in
less than 500ms, but it disconnects since it doesn't see the ack.

https://marc.info/?l=linux-wireless=151027741010422=2

We also reproduced a problem in our office with AR9462. With the MSI
support patch in use, we ping a server every second for 1000 seconds
while monitoring "iw dev wlp2s0 link" output. With the MSI support
patch in place, this test fails every time; the connection is dropped
in less than 1000s.
With the patch reverted everything is fine.

We ran the same test with AR9565 in MSI mode and it worked fine.

Daniel


Re: nl80211: Remove obsolete kerneldoc line

2017-12-12 Thread Arend Van Spriel
On Mon, Dec 11, 2017 at 11:37 PM, Jonathan Corbet  wrote:
> Commit ca986ad9bcd3 (nl80211: allow multiple active scheduled scan
> requests) removed WIPHY_FLAG_SUPPORTS_SCHED_SCAN but left the kerneldoc
> description in place, leading to this docs-build warning:
>
>./include/net/cfg80211.h:3278: warning: Excess enum value
>'WIPHY_FLAG_SUPPORTS_SCHED_SCAN' description in 'wiphy_flags'
>
> Remove the line and gain a bit of peace.

My bad. Thanks for cleaning up.

Acked-by: Arend van Spriel 
> Signed-off-by: Jonathan Corbet 
> ---
>  include/net/cfg80211.h | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> index 8b8118a7fadb..cb4d92b79cd9 100644
> --- a/include/net/cfg80211.h
> +++ b/include/net/cfg80211.h
> @@ -3226,7 +3226,6 @@ struct cfg80211_ops {
>   * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
>   * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
>   * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
> - * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans.
>   * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
>   * firmware.
>   * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
> --
> 2.14.3
>


[PATCH] brcmfmac: fix CLM load error for legacy chips when user helper is enabled

2017-12-12 Thread Wright Feng
For legacy chips w/o CLM blob files, kernel with user helper function
enables returns -EAGAIN when we request_firmware() for blob file:
"request_firmware() -> _request_firmware() -> fw_load_from_user_helper()
-> _request_firmware_load() -> retval=-EAGAIN"
We should do one more retry and continue brcmf_c_process_clm_blob if
getting -EAGAIN from request_firmware function.

Signed-off-by: Wright Feng 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 6a59d06..56e2654 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -45,6 +45,8 @@
 
 #define BRCMF_DEFAULT_TXGLOM_SIZE  32  /* max tx frames in glom chain */
 
+#define CLM_LOAD_RETRIES 1 /* # of retries to load clm_blob file */
+
 static int brcmf_sdiod_txglomsz = BRCMF_DEFAULT_TXGLOM_SIZE;
 module_param_named(txglomsz, brcmf_sdiod_txglomsz, int, 0);
 MODULE_PARM_DESC(txglomsz, "Maximum tx packet chain size [SDIO]");
@@ -170,6 +172,7 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
u16 dl_flag = DL_BEGIN;
u32 status;
s32 err;
+   uint retries = 0;
 
brcmf_dbg(TRACE, "Enter\n");
 
@@ -180,11 +183,18 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
return err;
}
 
-   err = request_firmware(, clm_name, dev);
+   do {
+   err = request_firmware(, clm_name, dev);
+   } while (err == -EAGAIN && retries++ < CLM_LOAD_RETRIES);
if (err) {
if (err == -ENOENT) {
brcmf_dbg(INFO, "continue with CLM data currently 
present in firmware\n");
return 0;
+   } else if (err == -EAGAIN) {
+   brcmf_dbg(INFO, "reached maximum retries(%d)\n",
+ CLM_LOAD_RETRIES);
+   brcmf_dbg(INFO, "continue with CLM data in firmware\n");
+   return 0;
}
brcmf_err("request CLM blob file failed (%d)\n", err);
return err;
-- 
1.9.1



[PATCH] mac80211_hwsim: Fix a possible sleep-in-atomic bug in hwsim_get_radio_nl

2017-12-12 Thread Jia-Ju Bai
The driver may sleep under a spinlock.
The function call path is:
hwsim_get_radio_nl (acquire the spinlock)
  nlmsg_new(GFP_KERNEL) --> may sleep

To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.

This bug is found by my static analysis tool(DSAC) and checked by my code 
review.

Signed-off-by: Jia-Ju Bai 
---
 drivers/net/wireless/mac80211_hwsim.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 10b075a..f2ebf4a 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3215,7 +3215,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct 
genl_info *info)
if (!net_eq(wiphy_net(data->hw->wiphy), genl_info_net(info)))
continue;
 
-   skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+   skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!skb) {
res = -ENOMEM;
goto out_err;
-- 
1.7.9.5




[BUG] wl3501: a possible sleep-in-atomic bug in wl3501_reset

2017-12-12 Thread Jia-Ju Bai
According to drivers/net/wireless/wl3501_cs.c, the driver may sleep 
under a spinlock.

The function call path is:
wl3501_reset (acquire the spinlock)
  free_irq --> may sleep

I do not find a good way to fix it, so I only report.
This possible bug is found by my static analysis tool (DSAC) and checked 
by my code review.



Thanks,
Jia-Ju Bai


Re: linux-next: build failure after merge of the mac80211-next tree

2017-12-12 Thread Toke Høiland-Jørgensen
Johannes Berg  writes:

> Hi Stephen,
>
> Thanks!
>
> Felix made me aware of this yesterday evening and said he's going to
> work out the required changes to mt76.
>
> Kalle and I will make sure to submit the trees to Dave one by one so he
> doesn't have to deal with it :)
>
> Unfortunately, this might take a few days to resolve.
>
>> -void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
>> +void mt76_wake_tx_queue(struct ieee80211_hw *hw)
>>  {
>> +struct ieee80211_txq *txq;
>>  struct mt76_dev *dev = hw->priv;
>> -struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv;
>> -struct mt76_queue *hwq = mtxq->hwq;
>> +struct mt76_txq *mtxq;
>> +struct mt76_queue *hwq;
>>  
>> +txq = ieee80211_next_txq(hw);
>> +mtxq = (struct mt76_txq *) txq->drv_priv;
>> +hwq = mtxq->hwq;
>
> Looks pretty much right to me - perhaps for safety there should be a
> NULL check on txq, but OTOH when you get here it should be non-NULL.

Note that while this will fix compilation it probably won't work right.
next_txq() is not guaranteed to return the same txq as was previously
passed in the wake_tx_queue() argument, so if this is the only place the
driver calls next_txq(), things are likely going to break.

Rather, the driver should call next_txq() whenever it schedules queues
instead of doing its own internal scheduling.

> Sorry for the inconvenience, I hadn't realized mt76 went in now.

Yeah, hadn't expected these streams to cross either. If Felix is looking
into this that is great; let me know if you need me to do anything else
on the mac80211 side. :)

-Toke


Re: linux-next: build failure after merge of the mac80211-next tree

2017-12-12 Thread Johannes Berg
Hi Stephen,

Thanks!

Felix made me aware of this yesterday evening and said he's going to
work out the required changes to mt76.

Kalle and I will make sure to submit the trees to Dave one by one so he
doesn't have to deal with it :)

Unfortunately, this might take a few days to resolve.

> -void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
> +void mt76_wake_tx_queue(struct ieee80211_hw *hw)
>  {
> + struct ieee80211_txq *txq;
>   struct mt76_dev *dev = hw->priv;
> - struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv;
> - struct mt76_queue *hwq = mtxq->hwq;
> + struct mt76_txq *mtxq;
> + struct mt76_queue *hwq;
>  
> + txq = ieee80211_next_txq(hw);
> + mtxq = (struct mt76_txq *) txq->drv_priv;
> + hwq = mtxq->hwq;


Looks pretty much right to me - perhaps for safety there should be a
NULL check on txq, but OTOH when you get here it should be non-NULL.

Sorry for the inconvenience, I hadn't realized mt76 went in now.

johannes