Re: [RFC] mac80211: advertise supported interface types for sw encryption

2018-03-22 Thread mpubbise

On 2018-03-22 13:36, Johannes Berg wrote:

On Thu, 2018-03-22 at 11:51 +0530, mpubb...@codeaurora.org wrote:


> So IMHO - just get rid of the bitmap and hard-code AP_VLAN.
>

I agree with you only partially.

Today, I do not see any driver advertising SW_CRYPTO_CONTROL other 
than

ath10k. There could be some driver which would want to advertise
SW_CRYPTO_CONTROL and do not support the software encryption for VLAN
devices. In that case, hard-coding doesn't seem to solve the problem
completely right? No?


Well, my point is that such a hypothetical driver is completely
irrelevant because it doesn't make any sense to have this behaviour -
it would mean it cannot support AP_VLAN with encryption, so it might as
well not support AP_VLAN at all.


Or you meant to say that driver should advertise the support for
AP_VLANs only if it can support encryption on AP_VLAN devices?


Right.


If this
the case, then I could see some code in ieee80211_register_hw which 
says

this,

 /* if low-level driver supports AP, we also support VLAN */
 if (local->hw.wiphy->interface_modes & 
BIT(NL80211_IFTYPE_AP)) {

 hw->wiphy->interface_modes |=
BIT(NL80211_IFTYPE_AP_VLAN);
 hw->wiphy->software_iftypes |=
BIT(NL80211_IFTYPE_AP_VLAN);
 }


Yes, but if such a driver comes along we can change this.



It makes sense, I will send out the change by hard-coding only for 
AP-VLAN interface.


--
mkp


[PATCH v2 08/13] ath10k: Add hif rx methods for wcn3990

2018-03-22 Thread Govind Singh
Add hif rx methods in rx path for wcn3990
target.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 171 +
 1 file changed, 153 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 899f0a3..6d9ccce 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -26,6 +26,7 @@
 #include 
 #define  WCN3990_CE_ATTR_FLAGS 0
 #define ATH10K_SNOC_RX_POST_RETRY_MS 50
+#define CE_POLL_PIPE 4
 
 static char *const ce_name[] = {
"WLAN_CE_0",
@@ -44,6 +45,9 @@
 
 static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state);
 static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state);
+static void ath10k_snoc_htc_rx_cb(struct ath10k_ce_pipe *ce_state);
+static void ath10k_snoc_htt_rx_cb(struct ath10k_ce_pipe *ce_state);
+static void ath10k_snoc_htt_htc_rx_cb(struct ath10k_ce_pipe *ce_state);
 
 static const struct ath10k_snoc_drv_priv drv_priv = {
.hw_rev = ATH10K_HW_WCN3990,
@@ -53,7 +57,7 @@
 static struct ce_attr host_ce_config_wlan[] = {
/* CE0: host->target HTC control streams */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 16,
.src_sz_max = 2048,
.dest_nentries = 0,
@@ -62,25 +66,25 @@
 
/* CE1: target->host HTT + HTC control */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 512,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htt_htc_rx_cb,
},
 
/* CE2: target->host WMI */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 64,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htc_rx_cb,
},
 
/* CE3: host->target WMI */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 32,
.src_sz_max = 2048,
.dest_nentries = 0,
@@ -89,7 +93,7 @@
 
/* CE4: host->target HTT */
{
-   .flags = WCN3990_CE_ATTR_FLAGS | CE_ATTR_DIS_INTR,
+   .flags = CE_ATTR_FLAGS | CE_ATTR_DIS_INTR,
.src_nentries = 256,
.src_sz_max = 256,
.dest_nentries = 0,
@@ -98,16 +102,16 @@
 
/* CE5: target->host HTT (ipa_uc->target ) */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 512,
.dest_nentries = 512,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htt_rx_cb,
},
 
/* CE6: target autonomous hif_memcpy */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 0,
.dest_nentries = 0,
@@ -115,7 +119,7 @@
 
/* CE7: ce_diag, the Diagnostic Window */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 2,
.src_sz_max = 2048,
.dest_nentries = 2,
@@ -123,7 +127,7 @@
 
/* CE8: Target to uMC */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 128,
@@ -131,29 +135,29 @@
 
/* CE9 target->host HTT */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 512,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htt_htc_rx_cb,
},
 
/* CE10: target->host HTT */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 512,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htt_htc_rx_cb,
},
 
/* CE11: target -> host PKTLOG */
{
-   .flags = WCN3990_CE_ATTR_FLAGS,
+   .flags = CE_ATTR_FLAGS,
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 512,
-   .recv_cb = NULL,
+   .recv_cb = ath10k_snoc_htt_htc_rx_cb,
},
 };
 
@@ -362,6 +366,82 @@ static void ath10k_snoc_rx_post(struct ath10k *ar)
ath10k_snoc_rx_po

[PATCH v2 02/13] ath10k: add resource init and deinit for WCN3990

2018-03-22 Thread Govind Singh
Add methods for resource(memory, irq, HOST CE config)
initialization and de-initialization for WCN3990 target.

WCN3990 target uses 12 copy engine and following CE config.

[CE0] :host->target control and raw streams
[CE1] :target->host HTT
[CE2] :target->host WMI
[CE3] :host->target WMI
[CE4] :host->target HTT
[CE5] :reserved
[CE6] :Target autonomous HIF_memcpy
[CE7] :reserved
[CE8] :reserved
[CE9] :target->host HTT
[CE10] :target->host HTT
[CE11] :target -> host PKTLOG

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 271 +
 1 file changed, 271 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 30354a6..575355c 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -24,12 +24,135 @@
 #include 
 #include 
 #include 
+#define  WCN3990_CE_ATTR_FLAGS 0
+
+static char *const ce_name[] = {
+   "WLAN_CE_0",
+   "WLAN_CE_1",
+   "WLAN_CE_2",
+   "WLAN_CE_3",
+   "WLAN_CE_4",
+   "WLAN_CE_5",
+   "WLAN_CE_6",
+   "WLAN_CE_7",
+   "WLAN_CE_8",
+   "WLAN_CE_9",
+   "WLAN_CE_10",
+   "WLAN_CE_11",
+};
 
 static const struct ath10k_snoc_drv_priv drv_priv = {
.hw_rev = ATH10K_HW_WCN3990,
.dma_mask = DMA_BIT_MASK(37),
 };
 
+static struct ce_attr host_ce_config_wlan[] = {
+   /* CE0: host->target HTC control streams */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 16,
+   .src_sz_max = 2048,
+   .dest_nentries = 0,
+   .send_cb = NULL,
+   },
+
+   /* CE1: target->host HTT + HTC control */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 512,
+   .recv_cb = NULL,
+   },
+
+   /* CE2: target->host WMI */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 64,
+   .recv_cb = NULL,
+   },
+
+   /* CE3: host->target WMI */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 32,
+   .src_sz_max = 2048,
+   .dest_nentries = 0,
+   .send_cb = NULL,
+   },
+
+   /* CE4: host->target HTT */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS | CE_ATTR_DIS_INTR,
+   .src_nentries = 256,
+   .src_sz_max = 256,
+   .dest_nentries = 0,
+   .send_cb = NULL,
+   },
+
+   /* CE5: target->host HTT (ipa_uc->target ) */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 512,
+   .dest_nentries = 512,
+   .recv_cb = NULL,
+   },
+
+   /* CE6: target autonomous hif_memcpy */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 0,
+   .dest_nentries = 0,
+   },
+
+   /* CE7: ce_diag, the Diagnostic Window */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 2,
+   .src_sz_max = 2048,
+   .dest_nentries = 2,
+   },
+
+   /* CE8: Target to uMC */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 128,
+   },
+
+   /* CE9 target->host HTT */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 512,
+   .recv_cb = NULL,
+   },
+
+   /* CE10: target->host HTT */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 512,
+   .recv_cb = NULL,
+   },
+
+   /* CE11: target -> host PKTLOG */
+   {
+   .flags = WCN3990_CE_ATTR_FLAGS,
+   .src_nentries = 0,
+   .src_sz_max = 2048,
+   .dest_nentries = 512,
+   .recv_cb = NULL,
+   },
+};
+
 void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value)
 {
struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
@@ -57,6 +180,119 @@ u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset)
.write32= ath10k_snoc_write32,
 };
 
+static irqreturn_t ath10k_snoc_per_engine_handler(int irq, void *arg)
+{
+   return IRQ_HANDLED;
+}
+
+static int ath10k_snoc_request_irq(struct ath10k *ar)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   int irqflags = IRQF_TRIGGER_RISING;
+   int ret, id;
+
+   for (id = 0; id < CE_COUNT_MAX; id++) {
+ 

[PATCH v2 03/13] ath10k: Add hif start/stop methods for wcn3990 snoc layer

2018-03-22 Thread Govind Singh
Add hif start/stop callback for allocating/freeing buffers
on tx/rx pipe and enabling/disabling the tx/rx pipe
interrupts.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 189 -
 1 file changed, 187 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 575355c..dcd8bb7 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #define  WCN3990_CE_ATTR_FLAGS 0
+#define ATH10K_SNOC_RX_POST_RETRY_MS 50
 
 static char *const ce_name[] = {
"WLAN_CE_0",
@@ -170,9 +171,193 @@ u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset)
return val;
 }
 
+static int __ath10k_snoc_rx_post_buf(struct ath10k_snoc_pipe *pipe)
+{
+   struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl;
+   struct ath10k *ar = pipe->hif_ce_state;
+   struct ath10k_ce *ce = ath10k_ce_priv(ar);
+   struct sk_buff *skb;
+   dma_addr_t paddr;
+   int ret;
+
+   skb = dev_alloc_skb(pipe->buf_sz);
+   if (!skb)
+   return -ENOMEM;
+
+   WARN_ONCE((unsigned long)skb->data & 3, "unaligned skb");
+
+   paddr = dma_map_single(ar->dev, skb->data,
+  skb->len + skb_tailroom(skb),
+  DMA_FROM_DEVICE);
+   if (unlikely(dma_mapping_error(ar->dev, paddr))) {
+   ath10k_warn(ar, "failed to dma map snoc rx buf\n");
+   dev_kfree_skb_any(skb);
+   return -EIO;
+   }
+
+   ATH10K_SKB_RXCB(skb)->paddr = paddr;
+
+   spin_lock_bh(&ce->ce_lock);
+   ret = ce_pipe->ops->ce_rx_post_buf(ce_pipe, skb, paddr);
+   spin_unlock_bh(&ce->ce_lock);
+   if (ret) {
+   dma_unmap_single(ar->dev, paddr, skb->len + skb_tailroom(skb),
+DMA_FROM_DEVICE);
+   dev_kfree_skb_any(skb);
+   return ret;
+   }
+
+   return 0;
+}
+
+static void ath10k_snoc_rx_post_pipe(struct ath10k_snoc_pipe *pipe)
+{
+   struct ath10k *ar = pipe->hif_ce_state;
+   struct ath10k_ce *ce = ath10k_ce_priv(ar);
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   struct ath10k_ce_pipe *ce_pipe = pipe->ce_hdl;
+   int ret, num;
+
+   if (pipe->buf_sz == 0)
+   return;
+
+   if (!ce_pipe->dest_ring)
+   return;
+
+   spin_lock_bh(&ce->ce_lock);
+   num = __ath10k_ce_rx_num_free_bufs(ce_pipe);
+   spin_unlock_bh(&ce->ce_lock);
+   while (num--) {
+   ret = __ath10k_snoc_rx_post_buf(pipe);
+   if (ret) {
+   if (ret == -ENOSPC)
+   break;
+   ath10k_warn(ar, "failed to post rx buf: %d\n", ret);
+   mod_timer(&ar_snoc->rx_post_retry, jiffies +
+ ATH10K_SNOC_RX_POST_RETRY_MS);
+   break;
+   }
+   }
+}
+
+static void ath10k_snoc_rx_post(struct ath10k *ar)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   int i;
+
+   for (i = 0; i < CE_COUNT; i++)
+   ath10k_snoc_rx_post_pipe(&ar_snoc->pipe_info[i]);
+}
+
+static inline void ath10k_snoc_irq_disable(struct ath10k *ar)
+{
+   ath10k_ce_disable_interrupts(ar);
+}
+
+static inline void ath10k_snoc_irq_enable(struct ath10k *ar)
+{
+   ath10k_ce_enable_interrupts(ar);
+}
+
+static void ath10k_snoc_rx_pipe_cleanup(struct ath10k_snoc_pipe *snoc_pipe)
+{
+   struct ath10k_ce_pipe *ce_pipe;
+   struct ath10k_ce_ring *ce_ring;
+   struct sk_buff *skb;
+   struct ath10k *ar;
+   int i;
+
+   ar = snoc_pipe->hif_ce_state;
+   ce_pipe = snoc_pipe->ce_hdl;
+   ce_ring = ce_pipe->dest_ring;
+
+   if (!ce_ring)
+   return;
+
+   if (!snoc_pipe->buf_sz)
+   return;
+
+   for (i = 0; i < ce_ring->nentries; i++) {
+   skb = ce_ring->per_transfer_context[i];
+   if (!skb)
+   continue;
+
+   ce_ring->per_transfer_context[i] = NULL;
+
+   dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr,
+skb->len + skb_tailroom(skb),
+DMA_FROM_DEVICE);
+   dev_kfree_skb_any(skb);
+   }
+}
+
+static void ath10k_snoc_tx_pipe_cleanup(struct ath10k_snoc_pipe *snoc_pipe)
+{
+   struct ath10k_ce_pipe *ce_pipe;
+   struct ath10k_ce_ring *ce_ring;
+   struct ath10k_snoc *ar_snoc;
+   struct sk_buff *skb;
+   struct ath10k *ar;
+   int i;
+
+   ar = snoc_pipe->hif_ce_state;
+   ar_snoc = ath10k_snoc_priv(ar);
+   ce_pipe = snoc_pipe->ce_hdl;
+   ce_ring = ce_pipe->src_ring;
+
+   if (!ce_ring)
+   return;
+
+   if (!snoc_pipe->buf_sz)
+   return;
+
+   for (i = 0;

[PATCH v2 01/13] ath10k: platform driver for WCN3990 SNOC WLAN module

2018-03-22 Thread Govind Singh
WCN3990 is integrated 802.11ac chipset with SNOC
bus interface. Add snoc layer driver registration
and associated ops.

WCN3990 support is not yet complete as cold-boot
handshake is done using qmi(Qualcomm-MSM-Interface)
and qmi client support will be added once qmi framework
is available.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/Kconfig  |   8 ++
 drivers/net/wireless/ath/ath10k/Makefile |   3 +
 drivers/net/wireless/ath/ath10k/snoc.c   | 153 +++
 drivers/net/wireless/ath/ath10k/snoc.h   |  76 +++
 4 files changed, 240 insertions(+)
 create mode 100644 drivers/net/wireless/ath/ath10k/snoc.c
 create mode 100644 drivers/net/wireless/ath/ath10k/snoc.h

diff --git a/drivers/net/wireless/ath/ath10k/Kconfig 
b/drivers/net/wireless/ath/ath10k/Kconfig
index d266f27..84f071a 100644
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -40,6 +40,14 @@ config ATH10K_USB
  This module adds experimental support for USB bus. Currently
  work in progress and will not fully work.
 
+config ATH10K_SNOC
+tristate "Qualcomm ath10k SNOC support (EXPERIMENTAL)"
+depends on ATH10K && ARCH_QCOM
+---help---
+  This module adds support for integrated WCN3990 chip connected
+  to system NOC(SNOC). Currently work in progress and will not
+  fully work.
+
 config ATH10K_DEBUG
bool "Atheros ath10k debugging"
depends on ATH10K
diff --git a/drivers/net/wireless/ath/ath10k/Makefile 
b/drivers/net/wireless/ath/ath10k/Makefile
index 536f3df..44d60a6 100644
--- a/drivers/net/wireless/ath/ath10k/Makefile
+++ b/drivers/net/wireless/ath/ath10k/Makefile
@@ -35,5 +35,8 @@ ath10k_sdio-y += sdio.o
 obj-$(CONFIG_ATH10K_USB) += ath10k_usb.o
 ath10k_usb-y += usb.o
 
+obj-$(CONFIG_ATH10K_SNOC) += ath10k_snoc.o
+ath10k_snoc-y += snoc.o
+
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
new file mode 100644
index 000..30354a6
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -0,0 +1,153 @@
+/*
+ * 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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include "debug.h"
+#include "hif.h"
+#include "htc.h"
+#include "ce.h"
+#include "snoc.h"
+#include 
+#include 
+#include 
+
+static const struct ath10k_snoc_drv_priv drv_priv = {
+   .hw_rev = ATH10K_HW_WCN3990,
+   .dma_mask = DMA_BIT_MASK(37),
+};
+
+void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+
+   iowrite32(value, ar_snoc->mem + offset);
+}
+
+u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   u32 val;
+
+   val = ioread32(ar_snoc->mem + offset);
+
+   return val;
+}
+
+static const struct ath10k_hif_ops ath10k_snoc_hif_ops = {
+   .read32 = ath10k_snoc_read32,
+   .write32= ath10k_snoc_write32,
+};
+
+static const struct ath10k_bus_ops ath10k_snoc_bus_ops = {
+   .read32 = ath10k_snoc_read32,
+   .write32= ath10k_snoc_write32,
+};
+
+static const struct of_device_id ath10k_snoc_dt_match[] = {
+   { .compatible = "qcom,wcn3990-wifi",
+.data = &drv_priv,
+   },
+   { }
+};
+MODULE_DEVICE_TABLE(of, ath10k_snoc_dt_match);
+
+static int ath10k_snoc_probe(struct platform_device *pdev)
+{
+   const struct ath10k_snoc_drv_priv *drv_data;
+   const struct of_device_id *of_id;
+   struct ath10k_snoc *ar_snoc;
+   struct device *dev;
+   struct ath10k *ar;
+   int ret;
+
+   of_id = of_match_device(ath10k_snoc_dt_match, &pdev->dev);
+   if (!of_id) {
+   dev_err(&pdev->dev, "failed to find matching device tree id\n");
+   return -EINVAL;
+   }
+
+   drv_data = of_id->data;
+   dev = &pdev->dev;
+
+   ret = dma_set_mask_and_coherent(dev, drv_data->dma_mask);
+   if (ret) {
+   dev_err(dev, "failed to set dma mask: %d", ret);
+   return ret;
+   }
+
+   ar = ath10k_core

[PATCH v2 00/13] ***Set4: Add support of WCN3990 bus layer support ***

2018-03-22 Thread Govind Singh
This change adds support for integrated wcn3990 chipset on
MSM platforms. WCN3990 is 2x2 802.11ac chipset where wlan
subsystem is interfaced over system interconnect.
Wlan fw runs in Q6 DSP. WCN3990 chipset uses 12 copy engine
for host to target and target to host communication. It has
extra 2 copy engine in rx data path and packet log capability
is exposed via new HTC service over dedicated copy engine.
Each CE has dedicated interrupt of rx path and tx completion.

[CE0] :host->target control and raw streams
[CE1] :target->host HTT
[CE2] :target->host WMI
[CE3] :host->target WMI
[CE4] :host->target HTT
[CE5] :reserved
[CE6] :Target autonomous HIF_memcpy
[CE7] :reserved
[CE8] :reserved
[CE9] :target->host HTT
[CE10] :target->host HTT
[CE11] :target -> host PKTLOG

Changes in V2:
Rebased the set on top of https://patchwork.kernel.org/patch/10298657/.
Removed qcom,-config and minor clean up in dt binding documentation.

Govind Singh (11):
  ath10k: platform driver for WCN3990 SNOC WLAN module
  ath10k: add resource init and deinit for WCN3990
  ath10k: Add hif start/stop methods for wcn3990 snoc layer
  ath10k: Add HTC services for WCN3990
  ath10k: Map HTC services to tx/rx pipes for wcn3990
  ath10k: Add hif power-up/power-down methods
  ath10k: Add hif tx methods for wcn3990
  ath10k: Add hif rx methods for wcn3990
  ath10k: Modify hif tx paddr to dma_addr_t type
  ath10k: Vote for hardware resources for WCN3990
  dt: bindings: add bindings for wcn3990 wifi block

Rakesh Pillai (2):
  ath10k: Add support to get target info from hif ops
  ath10k: Check all CE for data if irq summary is not retained

 .../bindings/net/wireless/qcom,ath10k.txt  |   31 +
 drivers/net/wireless/ath/ath10k/Kconfig|8 +
 drivers/net/wireless/ath/ath10k/Makefile   |3 +
 drivers/net/wireless/ath/ath10k/ce.h   |   10 +-
 drivers/net/wireless/ath/ath10k/core.c |   21 +
 drivers/net/wireless/ath/ath10k/hif.h  |   15 +-
 drivers/net/wireless/ath/ath10k/htc.c  |6 +
 drivers/net/wireless/ath/ath10k/htc.h  |4 +
 drivers/net/wireless/ath/ath10k/hw.h   |3 +
 drivers/net/wireless/ath/ath10k/pci.c  |8 +-
 drivers/net/wireless/ath/ath10k/snoc.c | 1411 
 drivers/net/wireless/ath/ath10k/snoc.h |   95 ++
 12 files changed, 1607 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath10k/snoc.c
 create mode 100644 drivers/net/wireless/ath/ath10k/snoc.h

-- 
1.9.1



[PATCH v2 05/13] ath10k: Map HTC services to tx/rx pipes for wcn3990

2018-03-22 Thread Govind Singh
Add mapping of HTC endpoint services supported
by wcn3990 target to tx/rx pipe.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 168 +
 1 file changed, 168 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index dcd8bb7..a39eee7 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -154,6 +154,116 @@
},
 };
 
+static struct service_to_pipe target_service_to_ce_map_wlan[] = {
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(3),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VO),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(3),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BK),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(3),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_BE),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(3),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_DATA_VI),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(3),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_WMI_CONTROL),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(0),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_RSVD_CTRL),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   { /* not used */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(0),
+   },
+   { /* not used */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(2),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG),
+   __cpu_to_le32(PIPEDIR_OUT), /* out = UL = host -> target */
+   __cpu_to_le32(4),
+   },
+   {
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA_MSG),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(1),
+   },
+   { /* not used */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS),
+   __cpu_to_le32(PIPEDIR_OUT),
+   __cpu_to_le32(5),
+   },
+   { /* in = DL = target -> host */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA2_MSG),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(9),
+   },
+   { /* in = DL = target -> host */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_DATA3_MSG),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(10),
+   },
+   { /* in = DL = target -> host pktlog */
+   __cpu_to_le32(ATH10K_HTC_SVC_ID_HTT_LOG_MSG),
+   __cpu_to_le32(PIPEDIR_IN),  /* in = DL = target -> host */
+   __cpu_to_le32(11),
+   },
+   /* (Additions here) */
+
+   { /* must be last */
+   __cpu_to_le32(0),
+   __cpu_to_le32(0),
+   __cpu_to_le32(0),
+   },
+};
+
 void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value)
 {
struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
@@ -249,6 +359,62 @@ static void ath10k_snoc_rx_post(struct ath10k *ar)

[PATCH v2 09/13] ath10k: Modify hif tx paddr to dma_addr_t type

2018-03-22 Thread Govind Singh
Change type of hif sg tx paddr to dma_addr_t for
supporting target having addressing mode greater than
32 bit.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/hif.h | 2 +-
 drivers/net/wireless/ath/ath10k/pci.c | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/hif.h 
b/drivers/net/wireless/ath/ath10k/hif.h
index 6da4e33..7abb13c 100644
--- a/drivers/net/wireless/ath/ath10k/hif.h
+++ b/drivers/net/wireless/ath/ath10k/hif.h
@@ -26,7 +26,7 @@ struct ath10k_hif_sg_item {
u16 transfer_id;
void *transfer_context; /* NULL = tx completion callback not called */
void *vaddr; /* for debugging mostly */
-   u32 paddr;
+   dma_addr_t paddr;
u16 len;
 };
 
diff --git a/drivers/net/wireless/ath/ath10k/pci.c 
b/drivers/net/wireless/ath/ath10k/pci.c
index 808f3d6..e7c544b 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1379,8 +1379,8 @@ int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
 
for (i = 0; i < n_items - 1; i++) {
ath10k_dbg(ar, ATH10K_DBG_PCI,
-  "pci tx item %d paddr 0x%08x len %d n_items %d\n",
-  i, items[i].paddr, items[i].len, n_items);
+  "pci tx item %d paddr %pad len %d n_items %d\n",
+  i, &items[i].paddr, items[i].len, n_items);
ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ",
items[i].vaddr, items[i].len);
 
@@ -1397,8 +1397,8 @@ int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
/* `i` is equal to `n_items -1` after for() */
 
ath10k_dbg(ar, ATH10K_DBG_PCI,
-  "pci tx item %d paddr 0x%08x len %d n_items %d\n",
-  i, items[i].paddr, items[i].len, n_items);
+  "pci tx item %d paddr %pad len %d n_items %d\n",
+  i, &items[i].paddr, items[i].len, n_items);
ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ",
items[i].vaddr, items[i].len);
 
-- 
1.9.1



[PATCH v2 04/13] ath10k: Add HTC services for WCN3990

2018-03-22 Thread Govind Singh
WCN3990 target uses 3 Copy engine(CE1/CE9/CE10) in RX path
and CE 11 for pktlog.
Add data path HTC ep services and PKTLOG services for WCN3990.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/htc.c | 6 ++
 drivers/net/wireless/ath/ath10k/htc.h | 4 
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/htc.c 
b/drivers/net/wireless/ath/ath10k/htc.c
index 492dc5b..8902720 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -542,8 +542,14 @@ static const char *htc_service_name(enum ath10k_htc_svc_id 
id)
return "NMI Data";
case ATH10K_HTC_SVC_ID_HTT_DATA_MSG:
return "HTT Data";
+   case ATH10K_HTC_SVC_ID_HTT_DATA2_MSG:
+   return "HTT Data";
+   case ATH10K_HTC_SVC_ID_HTT_DATA3_MSG:
+   return "HTT Data";
case ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS:
return "RAW";
+   case ATH10K_HTC_SVC_ID_HTT_LOG_MSG:
+   return "PKTLOG";
}
 
return "Unknown";
diff --git a/drivers/net/wireless/ath/ath10k/htc.h 
b/drivers/net/wireless/ath/ath10k/htc.h
index a2f8814..3487759 100644
--- a/drivers/net/wireless/ath/ath10k/htc.h
+++ b/drivers/net/wireless/ath/ath10k/htc.h
@@ -248,6 +248,7 @@ enum ath10k_htc_svc_gid {
ATH10K_HTC_SVC_GRP_WMI = 1,
ATH10K_HTC_SVC_GRP_NMI = 2,
ATH10K_HTC_SVC_GRP_HTT = 3,
+   ATH10K_LOG_SERVICE_GROUP = 6,
 
ATH10K_HTC_SVC_GRP_TEST = 254,
ATH10K_HTC_SVC_GRP_LAST = 255,
@@ -273,6 +274,9 @@ enum ath10k_htc_svc_id {
 
ATH10K_HTC_SVC_ID_HTT_DATA_MSG  = SVC(ATH10K_HTC_SVC_GRP_HTT, 0),
 
+   ATH10K_HTC_SVC_ID_HTT_DATA2_MSG = SVC(ATH10K_HTC_SVC_GRP_HTT, 1),
+   ATH10K_HTC_SVC_ID_HTT_DATA3_MSG = SVC(ATH10K_HTC_SVC_GRP_HTT, 2),
+   ATH10K_HTC_SVC_ID_HTT_LOG_MSG = SVC(ATH10K_LOG_SERVICE_GROUP, 0),
/* raw stream service (i.e. flash, tcmd, calibration apps) */
ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS = SVC(ATH10K_HTC_SVC_GRP_TEST, 0),
 };
-- 
1.9.1



[PATCH v2 07/13] ath10k: Add hif tx methods for wcn3990

2018-03-22 Thread Govind Singh
Add hif tx/tx-complete methods for wcn3990
target.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 123 -
 1 file changed, 120 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 9d402e4..899f0a3 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -42,6 +42,9 @@
"WLAN_CE_11",
 };
 
+static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state);
+static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state);
+
 static const struct ath10k_snoc_drv_priv drv_priv = {
.hw_rev = ATH10K_HW_WCN3990,
.dma_mask = DMA_BIT_MASK(37),
@@ -54,7 +57,7 @@
.src_nentries = 16,
.src_sz_max = 2048,
.dest_nentries = 0,
-   .send_cb = NULL,
+   .send_cb = ath10k_snoc_htc_tx_cb,
},
 
/* CE1: target->host HTT + HTC control */
@@ -81,7 +84,7 @@
.src_nentries = 32,
.src_sz_max = 2048,
.dest_nentries = 0,
-   .send_cb = NULL,
+   .send_cb = ath10k_snoc_htc_tx_cb,
},
 
/* CE4: host->target HTT */
@@ -90,7 +93,7 @@
.src_nentries = 256,
.src_sz_max = 256,
.dest_nentries = 0,
-   .send_cb = NULL,
+   .send_cb = ath10k_snoc_htt_tx_cb,
},
 
/* CE5: target->host HTT (ipa_uc->target ) */
@@ -359,6 +362,117 @@ static void ath10k_snoc_rx_post(struct ath10k *ar)
ath10k_snoc_rx_post_pipe(&ar_snoc->pipe_info[i]);
 }
 
+static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state)
+{
+   struct ath10k *ar = ce_state->ar;
+   struct sk_buff_head list;
+   struct sk_buff *skb;
+
+   __skb_queue_head_init(&list);
+   while (ath10k_ce_completed_send_next(ce_state, (void **)&skb) == 0) {
+   if (!skb)
+   continue;
+
+   __skb_queue_tail(&list, skb);
+   }
+
+   while ((skb = __skb_dequeue(&list)))
+   ath10k_htc_tx_completion_handler(ar, skb);
+}
+
+static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state)
+{
+   struct ath10k *ar = ce_state->ar;
+   struct sk_buff *skb;
+
+   while (ath10k_ce_completed_send_next(ce_state, (void **)&skb) == 0) {
+   if (!skb)
+   continue;
+
+   dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr,
+skb->len, DMA_TO_DEVICE);
+   ath10k_htt_hif_tx_complete(ar, skb);
+   }
+}
+
+static int ath10k_snoc_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
+struct ath10k_hif_sg_item *items, int n_items)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   struct ath10k_ce *ce = ath10k_ce_priv(ar);
+   struct ath10k_snoc_pipe *snoc_pipe;
+   struct ath10k_ce_pipe *ce_pipe;
+   int err, i = 0;
+
+   snoc_pipe = &ar_snoc->pipe_info[pipe_id];
+   ce_pipe = snoc_pipe->ce_hdl;
+   spin_lock_bh(&ce->ce_lock);
+
+   for (i = 0; i < n_items - 1; i++) {
+   ath10k_dbg(ar, ATH10K_DBG_SNOC,
+  "snoc tx item %d paddr %pad len %d n_items %d\n",
+  i, &items[i].paddr, items[i].len, n_items);
+
+   err = ath10k_ce_send_nolock(ce_pipe,
+   items[i].transfer_context,
+   items[i].paddr,
+   items[i].len,
+   items[i].transfer_id,
+   CE_SEND_FLAG_GATHER);
+   if (err)
+   goto err;
+   }
+
+   ath10k_dbg(ar, ATH10K_DBG_SNOC,
+  "snoc tx item %d paddr %pad len %d n_items %d\n",
+  i, &items[i].paddr, items[i].len, n_items);
+
+   err = ath10k_ce_send_nolock(ce_pipe,
+   items[i].transfer_context,
+   items[i].paddr,
+   items[i].len,
+   items[i].transfer_id,
+   0);
+   if (err)
+   goto err;
+
+   spin_unlock_bh(&ce->ce_lock);
+
+   return 0;
+
+err:
+   for (; i > 0; i--)
+   __ath10k_ce_send_revert(ce_pipe);
+
+   spin_unlock_bh(&ce->ce_lock);
+   return err;
+}
+
+static u16 ath10k_snoc_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+
+   ath10k_dbg(ar, ATH10K_DBG_SNOC, "hif get free queue number\n");
+
+   return ath10k_ce_num_free_src_entries(ar_snoc->pipe_info[pipe].ce_hdl);
+}
+
+static void ath10k_snoc_hif_send_complete_check(struct ath10k *ar, u8 pipe,
+   

[PATCH v2 13/13] dt: bindings: add bindings for wcn3990 wifi block

2018-03-22 Thread Govind Singh
Add device tree binding documentation details for wcn3990
wifi block present in Qualcomm SDM845/APQ8098 SoC into
"qcom,ath10k.txt".

Signed-off-by: Govind Singh 
---
 .../bindings/net/wireless/qcom,ath10k.txt  | 31 ++
 1 file changed, 31 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt 
b/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt
index 3d2a031..34e4f98 100644
--- a/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt
+++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt
@@ -4,6 +4,7 @@ Required properties:
 - compatible: Should be one of the following:
* "qcom,ath10k"
* "qcom,ipq4019-wifi"
+   * "qcom,wcn3990-wifi"
 
 PCI based devices uses compatible string "qcom,ath10k" and takes calibration
 data along with board specific data via "qcom,ath10k-calibration-data".
@@ -18,8 +19,12 @@ In general, entry "qcom,ath10k-pre-calibration-data" and
 "qcom,ath10k-calibration-data" conflict with each other and only one
 can be provided per device.
 
+SNOC based devices (i.e. wcn3990) uses compatible string "qcom,wcn3990-wifi".
+
 Optional properties:
 - reg: Address and length of the register set for the device.
+- reg-names: Must include the list of following reg names,
+"membase"
 - resets: Must contain an entry for each entry in reset-names.
   See ../reset/reseti.txt for details.
 - reset-names: Must include the list of following reset names,
@@ -49,6 +54,8 @@ Optional properties:
 hw versions.
 - qcom,ath10k-pre-calibration-data : pre calibration data as an array,
 the length can vary between hw versions.
+- -supply: handle to the regulator device tree node
+  optional "supply-name" is "vdd-0.8-cx-mx".
 
 Example (to supply the calibration data alone):
 
@@ -119,3 +126,27 @@ wifi0: wifi@a00 {
qcom,msi_base = <0x40>;
qcom,ath10k-pre-calibration-data = [ 01 02 03 ... ];
 };
+
+Example (to supply wcn3990 SoC wifi block details):
+
+qcom,wifi@1800 {
+   compatible = "qcom,wcn3990-wifi";
+   reg = <0x1880 0x80>;
+   reg-names = "membase";
+   clocks = <&clock_gcc clk_aggre2_noc_clk>;
+   clock-names = "smmu_aggre2_noc_clk"
+   interrupts =
+  <0 130 0 /* CE0 */ >,
+  <0 131 0 /* CE1 */ >,
+  <0 132 0 /* CE2 */ >,
+  <0 133 0 /* CE3 */ >,
+  <0 134 0 /* CE4 */ >,
+  <0 135 0 /* CE5 */ >,
+  <0 136 0 /* CE6 */ >,
+  <0 137 0 /* CE7 */ >,
+  <0 138 0 /* CE8 */ >,
+  <0 139 0 /* CE9 */ >,
+  <0 140 0 /* CE10 */ >,
+  <0 141 0 /* CE11 */ >;
+   vdd-0.8-cx-mx-supply = <&pm8998_l5>;
+};
-- 
1.9.1



[PATCH v2 06/13] ath10k: Add hif power-up/power-down methods

2018-03-22 Thread Govind Singh
Add hif power-up/power-down methods for wcn3990
target.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 61 ++
 1 file changed, 61 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index a39eee7..9d402e4 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -519,6 +519,65 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
return 0;
 }
 
+static int ath10k_snoc_init_pipes(struct ath10k *ar)
+{
+   int i, ret;
+
+   for (i = 0; i < CE_COUNT; i++) {
+   ret = ath10k_ce_init_pipe(ar, i, &host_ce_config_wlan[i]);
+   if (ret) {
+   ath10k_err(ar, "failed to initialize copy engine pipe 
%d: %d\n",
+  i, ret);
+   return ret;
+   }
+   }
+
+   return 0;
+}
+
+static int ath10k_snoc_wlan_enable(struct ath10k *ar)
+{
+   return 0;
+}
+
+static void ath10k_snoc_wlan_disable(struct ath10k *ar)
+{
+}
+
+static void ath10k_snoc_hif_power_down(struct ath10k *ar)
+{
+   ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n");
+
+   ath10k_snoc_wlan_disable(ar);
+}
+
+static int ath10k_snoc_hif_power_up(struct ath10k *ar)
+{
+   int ret;
+
+   ath10k_dbg(ar, ATH10K_DBG_SNOC, "%s:WCN3990 driver state = %d\n",
+  __func__, ar->state);
+
+   ret = ath10k_snoc_wlan_enable(ar);
+   if (ret) {
+   ath10k_err(ar, "failed to enable wcn3990: %d\n", ret);
+   return ret;
+   }
+
+   ret = ath10k_snoc_init_pipes(ar);
+   if (ret) {
+   ath10k_err(ar, "failed to initialize CE: %d\n", ret);
+   goto err_wlan_enable;
+   }
+
+   return 0;
+
+err_wlan_enable:
+   ath10k_snoc_wlan_disable(ar);
+
+   return ret;
+}
+
 static const struct ath10k_hif_ops ath10k_snoc_hif_ops = {
.read32 = ath10k_snoc_read32,
.write32= ath10k_snoc_write32,
@@ -526,6 +585,8 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
.stop   = ath10k_snoc_hif_stop,
.map_service_to_pipe= ath10k_snoc_hif_map_service_to_pipe,
.get_default_pipe   = ath10k_snoc_hif_get_default_pipe,
+   .power_up   = ath10k_snoc_hif_power_up,
+   .power_down = ath10k_snoc_hif_power_down,
 };
 
 static const struct ath10k_bus_ops ath10k_snoc_bus_ops = {
-- 
1.9.1



[PATCH v2 10/13] ath10k: Add support to get target info from hif ops

2018-03-22 Thread Govind Singh
From: Rakesh Pillai 

wcn3990 does not use bmi.
Add support to get target info from hif ops.

Signed-off-by: Rakesh Pillai 
Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/core.c |  8 
 drivers/net/wireless/ath/ath10k/hif.h  | 13 +
 drivers/net/wireless/ath/ath10k/snoc.c | 10 ++
 3 files changed, 31 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 830b7fe..61443f5 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2468,6 +2468,14 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
ar->hw->wiphy->hw_version = target_info.version;
break;
case ATH10K_BUS_SNOC:
+   memset(&target_info, 0, sizeof(target_info));
+   ret = ath10k_hif_get_target_info(ar, &target_info);
+   if (ret) {
+   ath10k_err(ar, "could not get target info (%d)\n", ret);
+   goto err_power_down;
+   }
+   ar->target_version = target_info.version;
+   ar->hw->wiphy->hw_version = target_info.version;
break;
default:
ath10k_err(ar, "incorrect hif bus type: %d\n", ar->hif.bus);
diff --git a/drivers/net/wireless/ath/ath10k/hif.h 
b/drivers/net/wireless/ath/ath10k/hif.h
index 7abb13c..1a59ea0 100644
--- a/drivers/net/wireless/ath/ath10k/hif.h
+++ b/drivers/net/wireless/ath/ath10k/hif.h
@@ -20,6 +20,7 @@
 
 #include 
 #include "core.h"
+#include "bmi.h"
 #include "debug.h"
 
 struct ath10k_hif_sg_item {
@@ -93,6 +94,9 @@ struct ath10k_hif_ops {
/* fetch calibration data from target eeprom */
int (*fetch_cal_eeprom)(struct ath10k *ar, void **data,
size_t *data_len);
+
+   int (*get_target_info)(struct ath10k *ar,
+  struct bmi_target_info *target_info);
 };
 
 static inline int ath10k_hif_tx_sg(struct ath10k *ar, u8 pipe_id,
@@ -218,4 +222,13 @@ static inline int ath10k_hif_fetch_cal_eeprom(struct 
ath10k *ar,
return ar->hif.ops->fetch_cal_eeprom(ar, data, data_len);
 }
 
+static inline int ath10k_hif_get_target_info(struct ath10k *ar,
+struct bmi_target_info *tgt_info)
+{
+   if (!ar->hif.ops->get_target_info)
+   return -EOPNOTSUPP;
+
+   return ar->hif.ops->get_target_info(ar, tgt_info);
+}
+
 #endif /* _HIF_H_ */
diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 6d9ccce..1ef0d3b 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -528,6 +528,15 @@ static int ath10k_snoc_hif_tx_sg(struct ath10k *ar, u8 
pipe_id,
return err;
 }
 
+static int ath10k_snoc_hif_get_target_info(struct ath10k *ar,
+  struct bmi_target_info *target_info)
+{
+   target_info->version = ATH10K_HW_WCN3990;
+   target_info->type = ATH10K_HW_WCN3990;
+
+   return 0;
+}
+
 static u16 ath10k_snoc_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
 {
struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
@@ -787,6 +796,7 @@ static int ath10k_snoc_hif_power_up(struct ath10k *ar)
.tx_sg  = ath10k_snoc_hif_tx_sg,
.send_complete_check= ath10k_snoc_hif_send_complete_check,
.get_free_queue_number  = ath10k_snoc_hif_get_free_queue_number,
+   .get_target_info= ath10k_snoc_hif_get_target_info,
 };
 
 static const struct ath10k_bus_ops ath10k_snoc_bus_ops = {
-- 
1.9.1



[PATCH v2 11/13] ath10k: Check all CE for data if irq summary is not retained

2018-03-22 Thread Govind Singh
From: Rakesh Pillai 

WCN3990 has interrupts per CE and the interrupt summary
is not retained after the interrupt handler has finished
execution. We need to check if we received any
ce in rx and tx completion path.

Generate a interrupt summary with all CE interrupts if
the target does not retain interrupt summary after the
execution of interrupt handler.

Signed-off-by: Rakesh Pillai 
Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/ce.h   | 10 +++---
 drivers/net/wireless/ath/ath10k/core.c | 13 +
 drivers/net/wireless/ath/ath10k/hw.h   |  3 +++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ce.h 
b/drivers/net/wireless/ath/ath10k/ce.h
index 2c3c8f5..d8f9da3 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -355,14 +355,18 @@ static inline u32 ath10k_ce_base_address(struct ath10k 
*ar, unsigned int ce_id)
(((x) & CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK) >> \
CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB)
 #define CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS   0x
+#define CE_INTERRUPT_SUMMARY   (GENMASK(CE_COUNT_MAX - 1, 0))
 
 static inline u32 ath10k_ce_interrupt_summary(struct ath10k *ar)
 {
struct ath10k_ce *ce = ath10k_ce_priv(ar);
 
-   return CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(
-   ce->bus_ops->read32((ar), CE_WRAPPER_BASE_ADDRESS +
-   CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS));
+   if (!ar->hw_params.per_ce_irq)
+   return CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(
+   ce->bus_ops->read32((ar), CE_WRAPPER_BASE_ADDRESS +
+   CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS));
+   else
+   return CE_INTERRUPT_SUMMARY;
 }
 
 #endif /* _CE_H_ */
diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index 61443f5..64479ac 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -119,6 +119,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA9887_HW_1_0_VERSION,
@@ -148,6 +149,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA6174_HW_2_1_VERSION,
@@ -176,6 +178,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA6174_HW_2_1_VERSION,
@@ -204,6 +207,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA6174_HW_3_0_VERSION,
@@ -232,6 +236,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA6174_HW_3_2_VERSION,
@@ -263,6 +268,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -297,6 +303,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA9984_HW_1_0_DEV_VERSION,
@@ -336,6 +343,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA9888_HW_2_0_DEV_VERSION,
@@ -374,6 +382,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA9377_HW_1_0_DEV_VERSION,
@@ -402,6 +411,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA9377_HW_1_1_DEV_VERSION,
@@ -432,6 +442,7 @@
.num_wds_entries = 0x20,
.target_64bit = false,
.rx_ring_fill_level = HTT_RX_RING_FILL_LEVEL,
+   .per_ce_irq = false,
},
{
.id = QCA4019_HW_1_0_

[PATCH v2 12/13] ath10k: Vote for hardware resources for WCN3990

2018-03-22 Thread Govind Singh
Add clock and regulator votes for WCN3990 WLAN
chipset.

Signed-off-by: Govind Singh 
---
 drivers/net/wireless/ath/ath10k/snoc.c | 313 -
 drivers/net/wireless/ath/ath10k/snoc.h |  19 ++
 2 files changed, 331 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c 
b/drivers/net/wireless/ath/ath10k/snoc.c
index 1ef0d3b..2e490ff 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -24,6 +24,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #define  WCN3990_CE_ATTR_FLAGS 0
 #define ATH10K_SNOC_RX_POST_RETRY_MS 50
 #define CE_POLL_PIPE 4
@@ -43,6 +45,17 @@
"WLAN_CE_11",
 };
 
+static struct ath10k_wcn3990_vreg_info vreg_cfg[] = {
+   {NULL, "vdd-0.8-cx-mx", 80, 80, 0, 0, false},
+   {NULL, "vdd-1.8-xo", 180, 180, 0, 0, false},
+   {NULL, "vdd-1.3-rfa", 1304000, 1304000, 0, 0, false},
+   {NULL, "vdd-3.3-ch0", 3312000, 3312000, 0, 0, false},
+};
+
+static struct ath10k_wcn3990_clk_info clk_cfg[] = {
+   {NULL, "cxo_ref_clk_pin", 0, false},
+};
+
 static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state);
 static void ath10k_snoc_htt_tx_cb(struct ath10k_ce_pipe *ce_state);
 static void ath10k_snoc_htc_rx_cb(struct ath10k_ce_pipe *ce_state);
@@ -969,6 +982,277 @@ static void ath10k_snoc_release_resource(struct ath10k 
*ar)
ath10k_ce_free_pipe(ar, i);
 }
 
+static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev,
+   struct ath10k_wcn3990_vreg_info *vreg_info)
+{
+   struct regulator *reg;
+   int ret = 0;
+
+   reg = devm_regulator_get_optional(dev, vreg_info->name);
+
+   if (IS_ERR(reg)) {
+   ret = PTR_ERR(reg);
+
+   if (ret  == -EPROBE_DEFER) {
+   ath10k_err(ar, "EPROBE_DEFER for regulator: %s\n",
+  vreg_info->name);
+   return ret;
+   }
+   if (vreg_info->required) {
+   ath10k_err(ar, "Regulator %s doesn't exist: %d\n",
+  vreg_info->name, ret);
+   return ret;
+   }
+   ath10k_dbg(ar, ATH10K_DBG_SNOC,
+  "Optional regulator %s doesn't exist: %d\n",
+  vreg_info->name, ret);
+   goto done;
+   }
+
+   vreg_info->reg = reg;
+
+done:
+   ath10k_dbg(ar, ATH10K_DBG_SNOC,
+  "snog vreg %s min_v %u max_v %u load_ua %u settle_delay 
%lu\n",
+  vreg_info->name, vreg_info->min_v, vreg_info->max_v,
+  vreg_info->load_ua, vreg_info->settle_delay);
+
+   return 0;
+}
+
+static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev,
+  struct ath10k_wcn3990_clk_info *clk_info)
+{
+   struct clk *handle;
+   int ret = 0;
+
+   handle = devm_clk_get(dev, clk_info->name);
+   if (IS_ERR(handle)) {
+   ret = PTR_ERR(handle);
+   if (clk_info->required) {
+   ath10k_err(ar, "snoc clock %s isn't available: %d\n",
+  clk_info->name, ret);
+   return ret;
+   }
+   ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc ignoring clock %s: %d\n",
+  clk_info->name,
+  ret);
+   return 0;
+   }
+
+   ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s freq %u\n",
+  clk_info->name, clk_info->freq);
+
+   clk_info->handle = handle;
+
+   return ret;
+}
+
+static int ath10k_wcn3990_vreg_on(struct ath10k *ar)
+{
+   struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
+   struct ath10k_wcn3990_vreg_info *vreg_info;
+   int ret = 0;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(vreg_cfg); i++) {
+   vreg_info = &ar_snoc->vreg[i];
+
+   if (!vreg_info->reg)
+   continue;
+
+   ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being 
enabled\n",
+  vreg_info->name);
+
+   ret = regulator_set_voltage(vreg_info->reg, vreg_info->min_v,
+   vreg_info->max_v);
+   if (ret) {
+   ath10k_err(ar,
+  "failed to set regulator %s voltage-min: %d 
voltage-max: %d\n",
+  vreg_info->name, vreg_info->min_v, 
vreg_info->max_v);
+   goto err_reg_config;
+   }
+
+   if (vreg_info->load_ua) {
+   ret = regulator_set_load(vreg_info->reg,
+vreg_info->load_ua);
+   if (ret < 0) {
+   ath10k_err(ar,
+  "faile

Re: iwlwifi intermittent beacon capture in monitor mode?

2018-03-22 Thread James Cameron
G'day Tyler,

I've seen that kind of behaviour when there are multiple APs with the
same beacon timing, and one or more APs are not backing off.  In my
case the beacons were colliding.  The times without beacons followed a
regular pattern; based on the variance in CPU oscillator clocks of the
APs.  Cooling or heating an AP changed the pattern.  Behaviour also
varied across cards; RF sensitivity of a batch of cards follows a
statistical normal distribution, with a bit of warping caused by
manufacturing test rejects.

Have you access to a spectrum analyser?  You might check what
transmissions are happening at the same time, on or near 2.457 MHz.

Can you exclude all other APs, e.g. by placing the devices inside a
disconnected microwave oven?

Can you monitor the current of the card with a digital storage
oscilloscope?

Can you watch the beacons with an RF probe and an oscilloscope?

Simplest probe is a diode (axial, bandoleer) with leads cut for a
multiple of 2.457 MHz held in oscilloscope probes within an inch or so
of the card antenna.

With both these last two tests, you may see dips corresponding to
beacon transmissions.  If they stop, you know you have a firmware or
software problem.

-- 
James Cameron
http://quozl.netrek.org/


iwlwifi intermittent beacon capture in monitor mode?

2018-03-22 Thread Tyler Gray
Hi,

I'm using an Intel 7265D card, stock ubuntu 16.04.4 (4.13.0-36),
iwlwifi firmware version 29.610311.0, and if I collect packets in
monitor mode I'm seeing beacons from a nearby AP drop in and out for
periods up to several minutes time.  I've got a laptop running hostapd
on a fairly quiet 2.4 GHz channel.  About 8 feet away in a normal
office I've got a second laptop with the intel 7265 card and specs
above on the same channel in monitor mode.  I'm running tcpdump,
usually with a bpf filter to just collect traffic to/from the hostapd
AP.

Nothing is connected to the AP, so when I collect I just see beacons
every tenth of a second plus a few probe responses.  After some period
of time, I'll stop seeing beacons.  Sometimes I'll get a short 1+
second gap and they'll resume, other times if I let it sit I'll see
nothing for minutes.  Example output from tcpdump is below:

11:41:47.166184 385217040us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.268591 385319440us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.370991 385421840us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.473371 385524240us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.575800 385626640us tsft 1.0 Mb/s 2457 MHz 11b -46dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.678186 385729041us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.780586 385831444us tsft 1.0 Mb/s 2457 MHz 11b -46dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.882996 385933845us tsft 1.0 Mb/s 2457 MHz 11b -46dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:47.985394 386036242us tsft 1.0 Mb/s 2457 MHz 11b -46dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:48.087995 386138843us tsft 1.0 Mb/s 2457 MHz 11b -45dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:48.190189 386241064us tsft 1.0 Mb/s 2457 MHz 11b -47dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:48.292594 386343445us tsft 1.0 Mb/s 2457 MHz 11b -46dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:41:48.394995 386445844us tsft 1.0 Mb/s 2457 MHz 11b -49dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10

<20+ seconds no beacons, ran command "iw wlan0 set channel 1;iw wlan0
set channel 10" in separate terminal window without stopping tcpdump>

11:42:12.459120 410509902us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:12.561527 410612302us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:12.663941 410714703us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:12.868745 410919503us tsft 1.0 Mb/s 2457 MHz 11b -47dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:12.971151 411021903us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.073538 411124304us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.175942 411226704us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.278313 411329104us tsft 1.0 Mb/s 2457 MHz 11b -47dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.380722 411431504us tsft 1.0 Mb/s 2457 MHz 11b -47dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.483122 411533905us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.585522 411636305us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.687941 411738705us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.790333 411841105us tsft 1.0 Mb/s 2457 MHz 11b -47dBm signal
[bit 22] Beacon (test2) [1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 Mbit]
ESS CH: 10
11:42:13.892751 411943506us tsft 1.0 Mb/s 2457 MHz 11b -48dBm signal
[bit

Re: [PATCH 01/12] brcmfmac: do not convert linux error to firmware error string

2018-03-22 Thread Arend van Spriel

On 3/16/2018 11:11 AM, Arend van Spriel wrote:
> ...

Hi Kalle,

Just sent a V2 so please drop this series.

Regards,
Arend



[PATCH V2 08/12] brcmfmac: introduce brcmf_fw_alloc_request() function

2018-03-22 Thread Arend van Spriel
The function brcmf_fw_alloc_request() takes a list of required files
and allocated the struct brcmf_fw_request instance accordingly. The
request can be modified by the caller before being passed to the
brcmf_fw_request_firmwares() function.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../broadcom/brcm80211/brcmfmac/firmware.c | 58 ++
 .../broadcom/brcm80211/brcmfmac/firmware.h | 11 
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c| 58 --
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 38 --
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 42 +---
 5 files changed, 147 insertions(+), 60 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 95004db..f495d22 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -688,3 +688,61 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
return 0;
 }
 
+struct brcmf_fw_request *
+brcmf_fw_alloc_request(u32 chip, u32 chiprev,
+  struct brcmf_firmware_mapping mapping_table[],
+  u32 table_size, struct brcmf_fw_name *fwnames,
+  u32 n_fwnames)
+{
+   struct brcmf_fw_request *fwreq;
+   char chipname[12];
+   const char *mp_path;
+   u32 i, j;
+   char end;
+   size_t reqsz;
+
+   for (i = 0; i < table_size; i++) {
+   if (mapping_table[i].chipid == chip &&
+   mapping_table[i].revmask & BIT(chiprev))
+   break;
+   }
+
+   if (i == table_size) {
+   brcmf_err("Unknown chipid %d [%d]\n", chip, chiprev);
+   return NULL;
+   }
+
+   reqsz = sizeof(*fwreq) + n_fwnames * sizeof(struct brcmf_fw_item);
+   fwreq = kzalloc(reqsz, GFP_KERNEL);
+   if (!fwreq)
+   return NULL;
+
+   brcmf_chip_name(chip, chiprev, chipname, sizeof(chipname));
+
+   brcmf_info("using %s for chip %s\n",
+  mapping_table[i].fw_base, chipname);
+
+   mp_path = brcmf_mp_global.firmware_path;
+   end = mp_path[strlen(mp_path) - 1];
+   fwreq->n_items = n_fwnames;
+
+   for (j = 0; j < n_fwnames; j++) {
+   fwreq->items[j].path = fwnames[j].path;
+   /* check if firmware path is provided by module parameter */
+   if (brcmf_mp_global.firmware_path[0] != '\0') {
+   strlcpy(fwnames[j].path, mp_path,
+   BRCMF_FW_NAME_LEN);
+
+   if (end != '/') {
+   strlcat(fwnames[j].path, "/",
+   BRCMF_FW_NAME_LEN);
+   }
+   }
+   brcmf_fw_get_full_name(fwnames[j].path,
+  mapping_table[i].fw_base,
+  fwnames[j].extension);
+   fwreq->items[j].path = fwnames[j].path;
+   }
+
+   return fwreq;
+}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index 1ca630e..1416fbb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -77,6 +77,17 @@ struct brcmf_fw_request {
struct brcmf_fw_item items[0];
 };
 
+struct brcmf_fw_name {
+   const char *extension;
+   char *path;
+};
+
+struct brcmf_fw_request *
+brcmf_fw_alloc_request(u32 chip, u32 chiprev,
+  struct brcmf_firmware_mapping mapping_table[],
+  u32 table_size, struct brcmf_fw_name *fwnames,
+  u32 n_fwnames);
+
 /*
  * Request firmware(s) asynchronously. When the asynchronous request
  * fails it will not use the callback, but call device_release_driver()
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index a3fe29e..179177a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1735,6 +1735,31 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
device_release_driver(dev);
 }
 
+static struct brcmf_fw_request *
+brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
+{
+   struct brcmf_fw_request *fwreq;
+   struct brcmf_fw_name fwnames[] = {
+   { ".bin", devinfo->fw_name },
+   { ".txt", devinfo->nvram_name },
+   };
+
+   fwreq = brcmf_fw_alloc_request(devinfo->ci->chip, devinfo->ci->chiprev,
+  brcmf_pcie_fwnames,
+  A

[PATCH V2 12/12] brcmfmac: add kerneldoc for struct brcmf_bus::msgbuf

2018-03-22 Thread Arend van Spriel
This field did not have kerneldoc description so adding it now.

Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index 31858a2..27e693e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -140,6 +140,7 @@ struct brcmf_bus_stats {
  * @always_use_fws_queue: bus wants use queue also when fwsignal is inactive.
  * @wowl_supported: is wowl supported by bus driver.
  * @chiprev: revision of the dongle chip.
+ * @msgbuf: msgbuf protocol parameters provided by bus layer.
  */
 struct brcmf_bus {
union {
-- 
1.9.1



[PATCH V2 11/12] brcmfmac: get rid of brcmf_fw_get_full_name()

2018-03-22 Thread Arend van Spriel
The function was pretty minimal and now it is called only from one
place so just get rid of it.

Signed-off-by: Arend van Spriel 
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/firmware.c| 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index c14a02a..9277f4c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -628,13 +628,6 @@ int brcmf_fw_get_firmwares(struct device *dev, struct 
brcmf_fw_request *req,
return 0;
 }
 
-static void brcmf_fw_get_full_name(char fw_name[BRCMF_FW_NAME_LEN],
-  const char *fw_base, const char *extension)
-{
-   strlcat(fw_name, fw_base, BRCMF_FW_NAME_LEN);
-   strlcat(fw_name, extension, BRCMF_FW_NAME_LEN);
-}
-
 struct brcmf_fw_request *
 brcmf_fw_alloc_request(u32 chip, u32 chiprev,
   struct brcmf_firmware_mapping mapping_table[],
@@ -685,9 +678,10 @@ struct brcmf_fw_request *
BRCMF_FW_NAME_LEN);
}
}
-   brcmf_fw_get_full_name(fwnames[j].path,
-  mapping_table[i].fw_base,
-  fwnames[j].extension);
+   strlcat(fwnames[j].path, mapping_table[i].fw_base,
+   BRCMF_FW_NAME_LEN);
+   strlcat(fwnames[j].path, fwnames[j].extension,
+   BRCMF_FW_NAME_LEN);
fwreq->items[j].path = fwnames[j].path;
}
 
-- 
1.9.1



[PATCH V2 07/12] brcmfmac: pass struct in brcmf_fw_get_firmwares()

2018-03-22 Thread Arend van Spriel
Make the function brcmf_fw_get_firmwares() a bit more easy to extend
using a structure to pass the request parameters.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
changelog
  V2:
   - brcmf_fw_request_is_valid() can be static (kbuild robot).
---
 .../broadcom/brcm80211/brcmfmac/firmware.c | 175 ++---
 .../broadcom/brcm80211/brcmfmac/firmware.h |  43 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c|  38 -
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c|  32 +++-
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c |  43 -
 5 files changed, 245 insertions(+), 86 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 6945f58..95004db 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -438,18 +438,31 @@ void brcmf_fw_nvram_free(void *nvram)
 
 struct brcmf_fw {
struct device *dev;
-   u16 flags;
-   const struct firmware *code;
-   const char *nvram_name;
-   u16 domain_nr;
-   u16 bus_nr;
-   void (*done)(struct device *dev, int err, const struct firmware *fw,
-void *nvram_image, u32 nvram_len);
+   struct brcmf_fw_request *req;
+   u32 curpos;
+   void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
 };
 
+static void brcmf_fw_request_done(const struct firmware *fw, void *ctx);
+
+static void brcmf_fw_free_request(struct brcmf_fw_request *req)
+{
+   struct brcmf_fw_item *item;
+   int i;
+
+   for (i = 0, item = &req->items[0]; i < req->n_items; i++, item++) {
+   if (item->type == BRCMF_FW_TYPE_BINARY)
+   release_firmware(item->binary);
+   else if (item->type == BRCMF_FW_TYPE_NVRAM)
+   brcmf_fw_nvram_free(item->nv_data.data);
+   }
+   kfree(req);
+}
+
 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 {
struct brcmf_fw *fwctx = ctx;
+   struct brcmf_fw_item *cur;
u32 nvram_length = 0;
void *nvram = NULL;
u8 *data = NULL;
@@ -457,83 +470,150 @@ static void brcmf_fw_request_nvram_done(const struct 
firmware *fw, void *ctx)
bool raw_nvram;
 
brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(fwctx->dev));
+
+   cur = &fwctx->req->items[fwctx->curpos];
+
if (fw && fw->data) {
data = (u8 *)fw->data;
data_len = fw->size;
raw_nvram = false;
} else {
data = bcm47xx_nvram_get_contents(&data_len);
-   if (!data && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
+   if (!data && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
goto fail;
raw_nvram = true;
}
 
if (data)
nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
-fwctx->domain_nr, fwctx->bus_nr);
+fwctx->req->domain_nr,
+fwctx->req->bus_nr);
 
if (raw_nvram)
bcm47xx_nvram_release_contents(data);
release_firmware(fw);
-   if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
+   if (!nvram && !(cur->flags & BRCMF_FW_REQF_OPTIONAL))
goto fail;
 
-   fwctx->done(fwctx->dev, 0, fwctx->code, nvram, nvram_length);
-   kfree(fwctx);
+   brcmf_dbg(TRACE, "nvram %p len %d\n", nvram, nvram_length);
+   cur->nv_data.data = nvram;
+   cur->nv_data.len = nvram_length;
return;
 
 fail:
brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-   release_firmware(fwctx->code);
-   fwctx->done(fwctx->dev, -ENOENT, NULL, NULL, 0);
+   fwctx->done(fwctx->dev, -ENOENT, NULL);
+   brcmf_fw_free_request(fwctx->req);
kfree(fwctx);
 }
 
-static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
+static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async)
+{
+   struct brcmf_fw_item *cur;
+   const struct firmware *fw = NULL;
+   int ret;
+
+   cur = &fwctx->req->items[fwctx->curpos];
+
+   brcmf_dbg(TRACE, "%srequest for %s\n", async ? "async " : "",
+ cur->path);
+
+   if (async)
+   ret = request_firmware_nowait(THIS_MODULE, true, cur->path,
+ fwctx->dev, GFP_KERNEL, fwctx,
+ brcmf_fw_request_done);
+   else
+   ret = request_firmware(&fw, cur->path, fwctx->dev);
+
+   if (ret < 0) {
+   brcmf_fw_request_done(NULL, fwctx);
+   } else if (!async && fw) {
+   brcmf_dbg(TRACE, "

[PATCH V2 10/12] brcmfmac: get rid of brcmf_fw_map_chip_to_name()

2018-03-22 Thread Arend van Spriel
The function is no longer used so removing it.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../broadcom/brcm80211/brcmfmac/firmware.c | 53 --
 .../broadcom/brcm80211/brcmfmac/firmware.h |  4 --
 2 files changed, 57 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index f495d22..c14a02a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -635,59 +635,6 @@ static void brcmf_fw_get_full_name(char 
fw_name[BRCMF_FW_NAME_LEN],
strlcat(fw_name, extension, BRCMF_FW_NAME_LEN);
 }
 
-int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
- struct brcmf_firmware_mapping mapping_table[],
- u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
- char nvram_name[BRCMF_FW_NAME_LEN])
-{
-   char chipname[12];
-   u32 i;
-   char end;
-
-   for (i = 0; i < table_size; i++) {
-   if (mapping_table[i].chipid == chip &&
-   mapping_table[i].revmask & BIT(chiprev))
-   break;
-   }
-
-   if (i == table_size) {
-   brcmf_err("Unknown chipid %d [%d]\n", chip, chiprev);
-   return -ENODEV;
-   }
-
-   brcmf_chip_name(chip, chiprev, chipname, sizeof(chipname));
-
-   /* check if firmware path is provided by module parameter */
-   if (brcmf_mp_global.firmware_path[0] != '\0') {
-   if (fw_name)
-   strlcpy(fw_name, brcmf_mp_global.firmware_path,
-   BRCMF_FW_NAME_LEN);
-   if (nvram_name)
-   strlcpy(nvram_name, brcmf_mp_global.firmware_path,
-   BRCMF_FW_NAME_LEN);
-
-   end = brcmf_mp_global.firmware_path[
-   strlen(brcmf_mp_global.firmware_path) - 1];
-   if (end != '/') {
-   if (fw_name)
-   strlcat(fw_name, "/", BRCMF_FW_NAME_LEN);
-   if (nvram_name)
-   strlcat(nvram_name, "/", BRCMF_FW_NAME_LEN);
-   }
-   }
-
-   brcmf_info("using %s for chip %s\n",
-  mapping_table[i].fw_base, chipname);
-   if (fw_name)
-   brcmf_fw_get_full_name(fw_name,
-  mapping_table[i].fw_base, ".bin");
-   if (nvram_name)
-   brcmf_fw_get_full_name(nvram_name,
-  mapping_table[i].fw_base, ".txt");
-
-   return 0;
-}
-
 struct brcmf_fw_request *
 brcmf_fw_alloc_request(u32 chip, u32 chiprev,
   struct brcmf_firmware_mapping mapping_table[],
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index 1416fbb..79a2109 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -46,10 +46,6 @@ struct brcmf_firmware_mapping {
 #define BRCMF_FW_ENTRY(chipid, mask, name) \
{ chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
 
-int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
- struct brcmf_firmware_mapping mapping_table[],
- u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
- char nvram_name[BRCMF_FW_NAME_LEN]);
 void brcmf_fw_nvram_free(void *nvram);
 
 enum brcmf_fw_type {
-- 
1.9.1



[PATCH V2 04/12] brcmfmac: allocate struct brcmf_pub instance using wiphy_new()

2018-03-22 Thread Arend van Spriel
Rework the driver so the wiphy instance holds the main driver information
in its private buffer. Previously it held struct brcmf_cfg80211_info
instance so a bit of reorg was needed. This was done so that the wiphy
name or its parent device can be shown in debug output.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
changelog
  V2:
   - keep brcmf_cfg80211_ops static (kbuild robot).
   - fix wrong use of wiphy_priv() (Franky Lin).
---
 .../wireless/broadcom/brcm80211/brcmfmac/btcoex.c  |  2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 86 ++
 .../broadcom/brcm80211/brcmfmac/cfg80211.h | 17 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  2 +
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 27 +--
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  1 +
 .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c |  2 +-
 7 files changed, 76 insertions(+), 61 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
index 03aae6b..372363a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
@@ -462,7 +462,7 @@ static void brcmf_btcoex_dhcp_end(struct brcmf_btcoex_info 
*btci)
 int brcmf_btcoex_set_mode(struct brcmf_cfg80211_vif *vif,
  enum brcmf_btcoex_mode mode, u16 duration)
 {
-   struct brcmf_cfg80211_info *cfg = wiphy_priv(vif->wdev.wiphy);
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
struct brcmf_btcoex_info *btci = cfg->btcoex;
struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 74a8302..4133d66 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -753,7 +753,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info 
*cfg,
 static int brcmf_cfg80211_del_ap_iface(struct wiphy *wiphy,
   struct wireless_dev *wdev)
 {
-   struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct net_device *ndev = wdev->netdev;
struct brcmf_if *ifp = netdev_priv(ndev);
int ret;
@@ -786,7 +786,7 @@ static int brcmf_cfg80211_del_ap_iface(struct wiphy *wiphy,
 static
 int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
-   struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct net_device *ndev = wdev->netdev;
 
if (ndev && ndev == cfg_to_ndev(cfg))
@@ -831,7 +831,7 @@ int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct 
wireless_dev *wdev)
 enum nl80211_iftype type,
 struct vif_params *params)
 {
-   struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_cfg80211_vif *vif = ifp->vif;
s32 infra = 0;
@@ -2127,17 +2127,15 @@ static void brcmf_set_join_pref(struct brcmf_if *ifp,
 brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
s32 *dbm)
 {
-   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
-   struct net_device *ndev = cfg_to_ndev(cfg);
-   struct brcmf_if *ifp = netdev_priv(ndev);
+   struct brcmf_cfg80211_vif *vif = wdev_to_vif(wdev);
s32 qdbm = 0;
s32 err;
 
brcmf_dbg(TRACE, "Enter\n");
-   if (!check_vif_up(ifp->vif))
+   if (!check_vif_up(vif))
return -EIO;
 
-   err = brcmf_fil_iovar_int_get(ifp, "qtxpower", &qdbm);
+   err = brcmf_fil_iovar_int_get(vif->ifp, "qtxpower", &qdbm);
if (err) {
brcmf_err("error (%d)\n", err);
goto done;
@@ -3358,7 +3356,7 @@ static int brcmf_start_internal_escan(struct brcmf_if 
*ifp, u32 fwmap,
struct cfg80211_sched_scan_request *req)
 {
struct brcmf_if *ifp = netdev_priv(ndev);
-   struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+   struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
 
brcmf_dbg(SCAN, "Enter: n_match_sets=%d n_ssids=%d\n",
  req->n_match_sets, req->n_ssids);
@@ -5190,6 +5188,12 @@ static int brcmf_cfg80211_del_pmk(struct wiphy *wiphy, 
struct net_device *dev,
.del_pmk = brcmf_cfg80211_del_pmk,
 };
 
+struct cfg80211_ops *brcmf_cfg80211_get_ops(void)
+{
+   return kmemdup(&brcmf_cfg80211_ops, sizeof(brcmf_cfg80211_ops),
+  GFP_KERNEL);
+}
+
 struct brcmf_cf

[PATCH V2 05/12] brcmfmac: use wiphy debugfs dir entry

2018-03-22 Thread Arend van Spriel
The driver used to create a brcmfmac dir entry at the top level
debugfs mount point. This moves the debugfs entries into the
wiphy debugfs dir entry.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c|  6 
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  5 ---
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 11 +++---
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c   | 42 ++
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   | 17 -
 .../wireless/broadcom/brcm80211/brcmfmac/feature.c |  3 ++
 .../wireless/broadcom/brcm80211/brcmfmac/feature.h |  7 
 .../broadcom/brcm80211/brcmfmac/fwsignal.c | 11 +++---
 .../broadcom/brcm80211/brcmfmac/fwsignal.h |  1 +
 .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  |  8 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/proto.c   |  3 +-
 .../wireless/broadcom/brcm80211/brcmfmac/proto.h   |  7 
 12 files changed, 47 insertions(+), 74 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
index 2d3a5dd..1068a2a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
@@ -445,6 +445,11 @@ static void brcmf_proto_bcdc_rxreorder(struct brcmf_if 
*ifp,
return 0;
 }
 
+static void brcmf_proto_bcdc_debugfs_create(struct brcmf_pub *drvr)
+{
+   brcmf_fws_debugfs_create(drvr);
+}
+
 int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
 {
struct brcmf_bcdc *bcdc;
@@ -472,6 +477,7 @@ int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
drvr->proto->del_if = brcmf_proto_bcdc_del_if;
drvr->proto->reset_if = brcmf_proto_bcdc_reset_if;
drvr->proto->init_done = brcmf_proto_bcdc_init_done;
+   drvr->proto->debugfs_create = brcmf_proto_bcdc_debugfs_create;
drvr->proto->pd = bcdc;
 
drvr->hdrlen += BCDC_HEADER_LEN + BRCMF_PROT_FW_SIGNAL_MAX_TXBYTES;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 23affb5..6c54cae 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -524,9 +524,6 @@ static int __init brcmfmac_module_init(void)
 {
int err;
 
-   /* Initialize debug system first */
-   brcmf_debugfs_init();
-
/* Get the platform data (if available) for our devices */
err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
if (err == -ENODEV)
@@ -538,7 +535,6 @@ static int __init brcmfmac_module_init(void)
/* Continue the initialization by registering the different busses */
err = brcmf_core_init();
if (err) {
-   brcmf_debugfs_exit();
if (brcmfmac_pdata)
platform_driver_unregister(&brcmf_pd);
}
@@ -551,7 +547,6 @@ static void __exit brcmfmac_module_exit(void)
brcmf_core_exit();
if (brcmfmac_pdata)
platform_driver_unregister(&brcmf_pd);
-   brcmf_debugfs_exit();
 }
 
 module_init(brcmfmac_module_init);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 8039732..eb54785 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -972,8 +972,6 @@ static int brcmf_bus_started(struct brcmf_pub *drvr, struct 
cfg80211_ops *ops)
if (ret < 0)
goto fail;
 
-   brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
-
brcmf_feat_attach(drvr);
 
ret = brcmf_proto_init_done(drvr);
@@ -1016,6 +1014,11 @@ static int brcmf_bus_started(struct brcmf_pub *drvr, 
struct cfg80211_ops *ops)
 #endif
 #endif /* CONFIG_INET */
 
+   /* populate debugfs */
+   brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
+   brcmf_feat_debugfs_create(drvr);
+   brcmf_proto_debugfs_create(drvr);
+
return 0;
 
 fail:
@@ -1068,9 +1071,6 @@ int brcmf_attach(struct device *dev, struct 
brcmf_mp_device *settings)
drvr->bus_if->drvr = drvr;
drvr->settings = settings;
 
-   /* attach debug facilities */
-   brcmf_debug_attach(drvr);
-
/* Attach and link in the protocol */
ret = brcmf_proto_attach(drvr);
if (ret != 0) {
@@ -1160,7 +1160,6 @@ void brcmf_detach(struct device *dev)
 
brcmf_proto_detach(drvr);
 
-   brcmf_debug_detach(drvr);
bus_if->drvr = NULL;
wiphy_free(drvr->wiphy);
 }
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
index 2d3e5e2..5048320 100644
--- a/drivers/net/wireless/broad

[PATCH V2 06/12] brcmfmac: derive firmware filenames from basename mapping

2018-03-22 Thread Arend van Spriel
Instead of defining individual filenames for firmware and nvram
use a basename and derive the names from that.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../broadcom/brcm80211/brcmfmac/firmware.c | 31 ++---
 .../broadcom/brcm80211/brcmfmac/firmware.h | 24 ++-
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c| 56 -
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 73 +++---
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 10 +--
 5 files changed, 96 insertions(+), 98 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index e2199f5..6945f58 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -563,6 +563,13 @@ int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
   0);
 }
 
+static void brcmf_fw_get_full_name(char fw_name[BRCMF_FW_NAME_LEN],
+  const char *fw_base, const char *extension)
+{
+   strlcat(fw_name, fw_base, BRCMF_FW_NAME_LEN);
+   strlcat(fw_name, extension, BRCMF_FW_NAME_LEN);
+}
+
 int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
  struct brcmf_firmware_mapping mapping_table[],
  u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
@@ -587,25 +594,31 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
 
/* check if firmware path is provided by module parameter */
if (brcmf_mp_global.firmware_path[0] != '\0') {
-   strlcpy(fw_name, brcmf_mp_global.firmware_path,
-   BRCMF_FW_NAME_LEN);
-   if ((nvram_name) && (mapping_table[i].nvram))
+   if (fw_name)
+   strlcpy(fw_name, brcmf_mp_global.firmware_path,
+   BRCMF_FW_NAME_LEN);
+   if (nvram_name)
strlcpy(nvram_name, brcmf_mp_global.firmware_path,
BRCMF_FW_NAME_LEN);
 
end = brcmf_mp_global.firmware_path[
strlen(brcmf_mp_global.firmware_path) - 1];
if (end != '/') {
-   strlcat(fw_name, "/", BRCMF_FW_NAME_LEN);
-   if ((nvram_name) && (mapping_table[i].nvram))
+   if (fw_name)
+   strlcat(fw_name, "/", BRCMF_FW_NAME_LEN);
+   if (nvram_name)
strlcat(nvram_name, "/", BRCMF_FW_NAME_LEN);
}
}
-   strlcat(fw_name, mapping_table[i].fw, BRCMF_FW_NAME_LEN);
-   if ((nvram_name) && (mapping_table[i].nvram))
-   strlcat(nvram_name, mapping_table[i].nvram, BRCMF_FW_NAME_LEN);
 
-   brcmf_info("using %s for chip %s\n", fw_name, chipname);
+   brcmf_info("using %s for chip %s\n",
+  mapping_table[i].fw_base, chipname);
+   if (fw_name)
+   brcmf_fw_get_full_name(fw_name,
+  mapping_table[i].fw_base, ".bin");
+   if (nvram_name)
+   brcmf_fw_get_full_name(nvram_name,
+  mapping_table[i].fw_base, ".txt");
 
return 0;
 }
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index 8fa4b7e..50218e9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -38,28 +38,16 @@
 struct brcmf_firmware_mapping {
u32 chipid;
u32 revmask;
-   const char *fw;
-   const char *nvram;
+   const char *fw_base;
 };
 
-#define BRCMF_FW_NVRAM_DEF(fw_nvram_name, fw, nvram) \
-static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
-   BRCMF_FW_DEFAULT_PATH fw; \
-static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
-   BRCMF_FW_DEFAULT_PATH nvram; \
-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw);
-
-#define BRCMF_FW_DEF(fw_name, fw) \
-static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
-   BRCMF_FW_DEFAULT_PATH fw; \
-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw) \
-
-#define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
-   { chipid, mask, \
- BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
+#define BRCMF_FW_DEF(fw_name, fw_base) \
+static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
+   BRCMF_FW_DEFAULT_PATH fw_base; \
+MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin")
 
 #define BRCMF_FW_ENTRY(chipid, mask, name) \
-   { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
+   { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
 
 int brcmf_fw_map_chip_to_name(u32 c

[PATCH V2 01/12] brcmfmac: do not convert linux error to firmware error string

2018-03-22 Thread Arend van Spriel
In case of a linux error brcmf_fil_cmd_data() blurts an error message
in which the error code is translated to an error string. However, it
maps it to a firmware error string which should not happen. Simply
print only the numeric error code and be done with it.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
index f2cfdd3..f527edc 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
@@ -124,8 +124,7 @@ static const char *brcmf_fil_get_errstr(u32 err)
 data, len, &fwerr);
 
if (err) {
-   brcmf_dbg(FIL, "Failed: %s (%d)\n",
- brcmf_fil_get_errstr((u32)(-err)), err);
+   brcmf_dbg(FIL, "Failed: error=%d\n", err);
} else if (fwerr < 0) {
brcmf_dbg(FIL, "Firmware error: %s (%d)\n",
  brcmf_fil_get_errstr((u32)(-fwerr)), fwerr);
-- 
1.9.1



[PATCH V2 02/12] brcmfmac: use brcmf_chip_name() to store name in revinfo

2018-03-22 Thread Arend van Spriel
The chip id can either be four or five digits. For the chip name either
the hexadecimal value needs to be taken (four digits) or the decimal
value (five digits). The function brcmf_chip_name() does this conversion
so use it to store the name in driver revision info.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../wireless/broadcom/brcm80211/brcmfmac/chip.c|  9 +
 .../wireless/broadcom/brcm80211/brcmfmac/chip.h|  3 ++-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  | 23 --
 .../wireless/broadcom/brcm80211/brcmfmac/core.c| 10 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|  3 +--
 5 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index f7b30ce..bf45369 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -464,12 +464,12 @@ static void brcmf_chip_ai_resetcore(struct 
brcmf_core_priv *core, u32 prereset,
ci->ops->read32(ci->ctx, core->wrapbase + BCMA_IOCTL);
 }
 
-static char *brcmf_chip_name(uint chipid, char *buf, uint len)
+char *brcmf_chip_name(u32 id, u32 rev, char *buf, uint len)
 {
const char *fmt;
 
-   fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x";
-   snprintf(buf, len, fmt, chipid);
+   fmt = ((id > 0xa000) || (id < 0x4000)) ? "BCM%d/%u" : "BCM%x/%u";
+   snprintf(buf, len, fmt, id, rev);
return buf;
 }
 
@@ -924,7 +924,8 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv 
*ci)
ci->pub.chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
 
-   brcmf_chip_name(ci->pub.chip, ci->pub.name, sizeof(ci->pub.name));
+   brcmf_chip_name(ci->pub.chip, ci->pub.chiprev,
+   ci->pub.name, sizeof(ci->pub.name));
brcmf_dbg(INFO, "found %s chip: BCM%s, rev=%d\n",
  socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name,
  ci->pub.chiprev);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
index dd0ec3e..0ae3b33 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
@@ -45,7 +45,7 @@ struct brcmf_chip {
u32 rambase;
u32 ramsize;
u32 srsize;
-   char name[8];
+   char name[12];
 };
 
 /**
@@ -93,5 +93,6 @@ void brcmf_chip_resetcore(struct brcmf_core *core, u32 
prereset, u32 reset,
 void brcmf_chip_set_passive(struct brcmf_chip *ci);
 bool brcmf_chip_set_active(struct brcmf_chip *ci, u32 rstvec);
 bool brcmf_chip_sr_capable(struct brcmf_chip *pub);
+char *brcmf_chip_name(u32 chipid, u32 chiprev, char *buf, uint len);
 
 #endif /* BRCMF_AXIDMP_H */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 70ef983..09601f8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -30,6 +30,7 @@
 #include "common.h"
 #include "of.h"
 #include "firmware.h"
+#include "chip.h"
 
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
@@ -127,14 +128,13 @@ static int brcmf_c_download(struct brcmf_if *ifp, u16 
flag,
 static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
 {
struct brcmf_bus *bus = ifp->drvr->bus_if;
-   struct brcmf_rev_info *ri = &ifp->drvr->revinfo;
u8 fw_name[BRCMF_FW_NAME_LEN];
u8 *ptr;
size_t len;
s32 err;
 
memset(fw_name, 0, BRCMF_FW_NAME_LEN);
-   err = brcmf_bus_get_fwname(bus, ri->chipnum, ri->chiprev, fw_name);
+   err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
if (err) {
brcmf_err("get firmware name failed (%d)\n", err);
goto done;
@@ -234,6 +234,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 {
s8 eventmask[BRCMF_EVENTING_MASK_LEN];
u8 buf[BRCMF_DCMD_SMLEN];
+   struct brcmf_bus *bus;
struct brcmf_rev_info_le revinfo;
struct brcmf_rev_info *ri;
char *clmver;
@@ -249,16 +250,18 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
}
memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
 
+   bus = ifp->drvr->bus_if;
+   ri = &ifp->drvr->revinfo;
+
err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_REVINFO,
 &revinfo, sizeof(revinfo));
-   ri = &ifp->drvr->revinfo;
if (err < 0) {
brcmf_err("retrieving revision info failed, %d\n", err);
+   strlcpy(ri->chipname, "UNKNOWN", 

[PATCH V2 00/12] brcmfmac: data structure and firmware loading rework

2018-03-22 Thread Arend van Spriel
This patch series is intended for 4.17 containing the following:

  * use wiphy_priv() for storing main driver instance.
  * add driver debugfs entries under wiphy debugfsdir.
  * rework firmware loading module.
  * rework clm_blob loading.

The patches apply to the master branch of the wireless-drivers-next
repository.

Changelog:
 V2:
  - fixes for patch 4 and patch 7.

Arend van Spriel (12):
  brcmfmac: do not convert linux error to firmware error string
  brcmfmac: use brcmf_chip_name() to store name in revinfo
  brcmfmac: use brcmf_chip_name() for consistency
  brcmfmac: allocate struct brcmf_pub instance using wiphy_new()
  brcmfmac: use wiphy debugfs dir entry
  brcmfmac: derive firmware filenames from basename mapping
  brcmfmac: pass struct in brcmf_fw_get_firmwares()
  brcmfmac: introduce brcmf_fw_alloc_request() function
  brcmfmac: add extension to .get_fwname() callbacks
  brcmfmac: get rid of brcmf_fw_map_chip_to_name()
  brcmfmac: get rid of brcmf_fw_get_full_name()
  brcmfmac: add kerneldoc for struct brcmf_bus::msgbuf

 .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c|   6 +
 .../wireless/broadcom/brcm80211/brcmfmac/btcoex.c  |   2 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/bus.h |   7 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c |  86 
 .../broadcom/brcm80211/brcmfmac/cfg80211.h |  17 +-
 .../wireless/broadcom/brcm80211/brcmfmac/chip.c|  14 +-
 .../wireless/broadcom/brcm80211/brcmfmac/chip.h|   3 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  71 ++
 .../wireless/broadcom/brcm80211/brcmfmac/core.c|  48 ++--
 .../wireless/broadcom/brcm80211/brcmfmac/core.h|   4 +-
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c   |  42 +---
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   |  17 --
 .../wireless/broadcom/brcm80211/brcmfmac/feature.c |   3 +
 .../wireless/broadcom/brcm80211/brcmfmac/feature.h |   7 +
 .../broadcom/brcm80211/brcmfmac/firmware.c | 242 ++---
 .../broadcom/brcm80211/brcmfmac/firmware.h |  82 ---
 .../wireless/broadcom/brcm80211/brcmfmac/fwil.c|   3 +-
 .../broadcom/brcm80211/brcmfmac/fwsignal.c |  11 +-
 .../broadcom/brcm80211/brcmfmac/fwsignal.h |   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  |   8 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c |   2 +-
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c| 157 +++--
 .../wireless/broadcom/brcm80211/brcmfmac/proto.c   |   3 +-
 .../wireless/broadcom/brcm80211/brcmfmac/proto.h   |   7 +
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 151 -
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c |  96 +---
 26 files changed, 619 insertions(+), 471 deletions(-)

-- 
1.9.1



[PATCH V2 03/12] brcmfmac: use brcmf_chip_name() for consistency

2018-03-22 Thread Arend van Spriel
When logging the chip id/revision information make use of
brcmf_chip_name() so it is always the same.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 5 ++---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 7 +--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index bf45369..3b829fe 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -926,9 +926,8 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv 
*ci)
 
brcmf_chip_name(ci->pub.chip, ci->pub.chiprev,
ci->pub.name, sizeof(ci->pub.name));
-   brcmf_dbg(INFO, "found %s chip: BCM%s, rev=%d\n",
- socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name,
- ci->pub.chiprev);
+   brcmf_dbg(INFO, "found %s chip: %s\n",
+ socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name);
 
if (socitype == SOCI_SB) {
if (ci->pub.chip != BRCM_CC_4329_CHIP_ID) {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 091b529..e2199f5 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -25,6 +25,7 @@
 #include "firmware.h"
 #include "core.h"
 #include "common.h"
+#include "chip.h"
 
 #define BRCMF_FW_MAX_NVRAM_SIZE64000
 #define BRCMF_FW_NVRAM_DEVPATH_LEN 19  /* devpath0=pcie/1/4/ */
@@ -567,6 +568,7 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
  u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
  char nvram_name[BRCMF_FW_NAME_LEN])
 {
+   char chipname[12];
u32 i;
char end;
 
@@ -581,6 +583,8 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
return -ENODEV;
}
 
+   brcmf_chip_name(chip, chiprev, chipname, sizeof(chipname));
+
/* check if firmware path is provided by module parameter */
if (brcmf_mp_global.firmware_path[0] != '\0') {
strlcpy(fw_name, brcmf_mp_global.firmware_path,
@@ -601,8 +605,7 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
if ((nvram_name) && (mapping_table[i].nvram))
strlcat(nvram_name, mapping_table[i].nvram, BRCMF_FW_NAME_LEN);
 
-   brcmf_info("using %s for chip %#08x(%d) rev %#08x\n",
-  fw_name, chip, chip, chiprev);
+   brcmf_info("using %s for chip %s\n", fw_name, chipname);
 
return 0;
 }
-- 
1.9.1



[PATCH V2 09/12] brcmfmac: add extension to .get_fwname() callbacks

2018-03-22 Thread Arend van Spriel
This changes the bus layer api by having the caller provide an
extension. With this the callback can use brcmf_fw_alloc_request()
to get the needed firmware name.

Reviewed-by: Hante Meuleman 
Reviewed-by: Pieter-Paul Giesberts 
Reviewed-by: Franky Lin 
Signed-off-by: Arend van Spriel 
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/bus.h |  6 +--
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  | 43 +++---
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c| 27 +++---
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 26 +++--
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 27 --
 5 files changed, 51 insertions(+), 78 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index 0b90a63b..31858a2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -88,7 +88,7 @@ struct brcmf_bus_ops {
void (*wowl_config)(struct device *dev, bool enabled);
size_t (*get_ramsize)(struct device *dev);
int (*get_memdump)(struct device *dev, void *data, size_t len);
-   int (*get_fwname)(struct device *dev, uint chip, uint chiprev,
+   int (*get_fwname)(struct device *dev, const char *ext,
  unsigned char *fw_name);
 };
 
@@ -228,10 +228,10 @@ int brcmf_bus_get_memdump(struct brcmf_bus *bus, void 
*data, size_t len)
 }
 
 static inline
-int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev,
+int brcmf_bus_get_fwname(struct brcmf_bus *bus, const char *ext,
 unsigned char *fw_name)
 {
-   return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name);
+   return bus->ops->get_fwname(bus->dev, ext, fw_name);
 }
 
 /*
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 6c54cae..76788e9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -125,42 +125,9 @@ static int brcmf_c_download(struct brcmf_if *ifp, u16 flag,
return err;
 }
 
-static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
-{
-   struct brcmf_bus *bus = ifp->drvr->bus_if;
-   u8 fw_name[BRCMF_FW_NAME_LEN];
-   u8 *ptr;
-   size_t len;
-   s32 err;
-
-   memset(fw_name, 0, BRCMF_FW_NAME_LEN);
-   err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
-   if (err) {
-   brcmf_err("get firmware name failed (%d)\n", err);
-   goto done;
-   }
-
-   /* generate CLM blob file name */
-   ptr = strrchr(fw_name, '.');
-   if (!ptr) {
-   err = -ENOENT;
-   goto done;
-   }
-
-   len = ptr - fw_name + 1;
-   if (len + strlen(".clm_blob") > BRCMF_FW_NAME_LEN) {
-   err = -E2BIG;
-   } else {
-   strlcpy(clm_name, fw_name, len);
-   strlcat(clm_name, ".clm_blob", BRCMF_FW_NAME_LEN);
-   }
-done:
-   return err;
-}
-
 static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
 {
-   struct device *dev = ifp->drvr->bus_if->dev;
+   struct brcmf_bus *bus = ifp->drvr->bus_if;
struct brcmf_dload_data_le *chunk_buf;
const struct firmware *clm = NULL;
u8 clm_name[BRCMF_FW_NAME_LEN];
@@ -173,16 +140,16 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
 
brcmf_dbg(TRACE, "Enter\n");
 
-   memset(clm_name, 0, BRCMF_FW_NAME_LEN);
-   err = brcmf_c_get_clm_name(ifp, clm_name);
+   memset(clm_name, 0, sizeof(clm_name));
+   err = brcmf_bus_get_fwname(bus, ".clm_blob", clm_name);
if (err) {
brcmf_err("get CLM blob file name failed (%d)\n", err);
return err;
}
 
-   err = request_firmware(&clm, clm_name, dev);
+   err = request_firmware(&clm, clm_name, bus->dev);
if (err) {
-   brcmf_info("no clm_blob available(err=%d), device may have 
limited channels available\n",
+   brcmf_info("no clm_blob available (err=%d), device may have 
limited channels available\n",
   err);
return 0;
}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 179177a..091c191 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1350,23 +1350,24 @@ static int brcmf_pcie_get_memdump(struct device *dev, 
void *data, size_t len)
return 0;
 }
 
-static int brcmf_pcie_get_fwname(struct device *dev, u32 chip, u32 chiprev,
-u8 *fw_name)
+static
+int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
 {
struct brcmf_bus *bus_if 

[PATCH v3] mac80211: notify driver for change in multicast rates

2018-03-22 Thread Pradeep Kumar Chitrapu
It is required to pass the rate information to driver/firmware
when rate control is offloaded to firmware. This helps in changing
multicast traffic rates thereby improving the network performance.

Signed-off-by: Pradeep Kumar Chitrapu 
---
V3:
  - Added Documentation
V2:
  - Set the flag in missing places

 include/net/mac80211.h | 3 +++
 net/mac80211/cfg.c | 2 ++
 net/mac80211/ibss.c| 2 +-
 net/mac80211/mesh.c| 3 ++-
 net/mac80211/util.c| 3 ++-
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4c99c13..f0e4f8a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -309,6 +309,8 @@ struct ieee80211_vif_chanctx_switch {
  * @BSS_CHANGED_MU_GROUPS: VHT MU-MIMO group id or user position changed
  * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected
  * keep alive) changed.
+ * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
+ *
  */
 enum ieee80211_bss_change {
BSS_CHANGED_ASSOC   = 1<<0,
@@ -336,6 +338,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_OCB = 1<<22,
BSS_CHANGED_MU_GROUPS   = 1<<23,
BSS_CHANGED_KEEP_ALIVE  = 1<<24,
+   BSS_CHANGED_MCAST_RATE  = 1<<25,
 
/* when adding here, make sure to change ieee80211_reconfig */
 };
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0763792..22bb82e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,6 +2313,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, 
struct net_device *dev,
memcpy(sdata->vif.bss_conf.mcast_rate, rate,
   sizeof(int) * NUM_NL80211_BANDS);
 
+   ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
+
return 0;
 }
 
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index e9c6aa3..f4b0634 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1840,7 +1840,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data 
*sdata,
  IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
| IEEE80211_HT_PARAM_RIFS_MODE;
 
-   changed |= BSS_CHANGED_HT;
+   changed |= BSS_CHANGED_HT | BSS_CHANGED_MCAST_RATE;
ieee80211_bss_info_change_notify(sdata, changed);
 
sdata->smps_mode = IEEE80211_SMPS_OFF;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 277398d..55c04e1 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -884,7 +884,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data 
*sdata)
  BSS_CHANGED_BEACON_ENABLED |
  BSS_CHANGED_HT |
  BSS_CHANGED_BASIC_RATES |
- BSS_CHANGED_BEACON_INT;
+ BSS_CHANGED_BEACON_INT |
+ BSS_CHANGED_MCAST_RATE;
 
local->fif_other_bss++;
/* mesh ifaces must set allmulti to forward mcast traffic */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 6aef679..6594df0 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1971,7 +1971,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
  BSS_CHANGED_CQM |
  BSS_CHANGED_QOS |
  BSS_CHANGED_IDLE |
- BSS_CHANGED_TXPOWER;
+ BSS_CHANGED_TXPOWER |
+ BSS_CHANGED_MCAST_RATE;
 
if (sdata->vif.mu_mimo_owner)
changed |= BSS_CHANGED_MU_GROUPS;
-- 
1.9.1



[PATCHv2] ath10k: fix kernel panic while reading tpc_stats

2018-03-22 Thread Tamizh chelvam
When attempt to read tpc_stats for the chipsets which support
more than 3 tx chain will trigger kernel panic(kernel stack is corrupted)
due to writing values on rate_code array out of range.
This patch changes the array size depends on the WMI_TPC_TX_N_CHAIN and
added check to avoid write values on the array if the num tx chain
get in tpc config event is greater than WMI_TPC_TX_N_CHAIN.

Tested on QCA9984 with firmware-5.bin_10.4-3.5.3-00057

Kernel panic log :

[  323.510944] Kernel panic - not syncing: stack-protector: Kernel stack is 
corrupted in: bf90c654
[  323.510944]
[  323.524390] CPU: 0 PID: 1908 Comm: cat Not tainted 3.14.77 #31
[  323.530224] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[  323.537941] [] (show_stack) from [] 
(dump_stack+0x80/0xa0)
[  323.545146] [] (dump_stack) from [] (panic+0x84/0x1e4)
[  323.552000] [] (panic) from [] 
(__stack_chk_fail+0x10/0x14)
[  323.559350] [] (__stack_chk_fail) from [] 
(ath10k_wmi_event_pdev_tpc_config+0x424/0x438 [ath10k_core])
[  323.570471] [] (ath10k_wmi_event_pdev_tpc_config [ath10k_core]) 
from [] (ath10k_wmi_10_4_op_rx+0x2f0/0x39c [ath10k_core])
[  323.583047] [] (ath10k_wmi_10_4_op_rx [ath10k_core]) from 
[] (ath10k_htc_rx_completion_handler+0x170/0x1a0 [ath10k_core])
[  323.595702] [] (ath10k_htc_rx_completion_handler [ath10k_core]) 
from [] (ath10k_pci_hif_send_complete_check+0x1f0/0x220 [ath10k_pci])
[  323.609421] [] (ath10k_pci_hif_send_complete_check [ath10k_pci]) 
from [] (ath10k_ce_per_engine_service+0x74/0xc4 [ath10k_pci])
[  323.622490] [] (ath10k_ce_per_engine_service [ath10k_pci]) from 
[] (ath10k_ce_per_engine_service_any+0x74/0x80 [ath10k_pci])
[  323.635423] [] (ath10k_ce_per_engine_service_any [ath10k_pci]) 
from [] (ath10k_pci_napi_poll+0x44/0xe8 [ath10k_pci])
[  323.647665] [] (ath10k_pci_napi_poll [ath10k_pci]) from 
[] (net_rx_action+0xac/0x160)
[  323.657208] [] (net_rx_action) from [] 
(__do_softirq+0x104/0x294)
[  323.665017] [] (__do_softirq) from [] 
(irq_exit+0x9c/0x11c)
[  323.672314] [] (irq_exit) from [] (handle_IRQ+0x6c/0x90)
[  323.679341] [] (handle_IRQ) from [] 
(gic_handle_irq+0x3c/0x60)
[  323.686893] [] (gic_handle_irq) from [] 
(__irq_svc+0x40/0x70)
[  323.694349] Exception stack(0xdd489c58 to 0xdd489ca0)
[  323.699384] 9c40:   
 a013
[  323.707547] 9c60:  dc4bce40 6013 ddc1d800 dd488000 0990 
 c085c800
[  323.715707] 9c80:  dd489d44 092d dd489ca0 c026e664 c026e668 
6013 
[  323.723877] [] (__irq_svc) from [] 
(rcu_note_context_switch+0x170/0x184)
[  323.732298] [] (rcu_note_context_switch) from [] 
(__schedule+0x50/0x4d4)
[  323.740716] [] (__schedule) from [] 
(schedule_timeout+0x148/0x178)
[  323.748611] [] (schedule_timeout) from [] 
(wait_for_common+0x114/0x154)
[  323.756972] [] (wait_for_common) from [] 
(ath10k_tpc_stats_open+0xc8/0x340 [ath10k_core])
[  323.766873] [] (ath10k_tpc_stats_open [ath10k_core]) from 
[] (do_dentry_open+0x1ac/0x274)
[  323.776741] [] (do_dentry_open) from [] 
(do_last+0x8c0/0xb08)
[  323.784201] [] (do_last) from [] 
(path_openat+0x210/0x598)
[  323.791408] [] (path_openat) from [] 
(do_filp_open+0x2c/0x78)
[  323.798873] [] (do_filp_open) from [] 
(do_sys_open+0x114/0x1b4)
[  323.806509] [] (do_sys_open) from [] 
(ret_fast_syscall+0x0/0x44)
[  323.814241] CPU1: stopping
[  323.816927] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.14.77 #31
[  323.823008] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[  323.830731] [] (show_stack) from [] 
(dump_stack+0x80/0xa0)
[  323.837934] [] (dump_stack) from [] 
(handle_IPI+0xb8/0x140)
[  323.845224] [] (handle_IPI) from [] 
(gic_handle_irq+0x58/0x60)
[  323.852774] [] (gic_handle_irq) from [] 
(__irq_svc+0x40/0x70)
[  323.860233] Exception stack(0xdd499fa0 to 0xdd499fe8)
[  323.865273] 9fa0: ffed  1d3c9000  dd498000 dd498030 
10c0387d c08b62c8
[  323.873432] 9fc0: 4220406a 512f04d0   0001 dd499fe8 
c021838c c0218390
[  323.881588] 9fe0: 6013 
[  323.885070] [] (__irq_svc) from [] 
(arch_cpu_idle+0x30/0x50)
[  323.892454] [] (arch_cpu_idle) from [] 
(cpu_startup_entry+0xa4/0x108)
[  323.900690] [] (cpu_startup_entry) from [<422085a4>] (0x422085a4)

Signed-off-by: Tamizh chelvam 
---
v2:
  * Removed unnecessary '\n' in the beginning of the format string 

 drivers/net/wireless/ath/ath10k/debug.c |  8 +++-
 drivers/net/wireless/ath/ath10k/wmi.c   | 10 +-
 drivers/net/wireless/ath/ath10k/wmi.h   |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 554cd78..d816299 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1506,7 +1506,13 @@ static void ath10k_tpc_stats_print(struct 
ath10k_tpc_stats *tpc_stats,
*len += scnprintf(buf + *len, buf_len - *len,
  "**

[PATCH] ath10k: fix kernel panic while reading tpc_stats

2018-03-22 Thread Tamizh chelvam
When attempt to read tpc_stats for the chipsets which support
more than 3 tx chain will trigger kernel panic(kernel stack is corrupted)
due to writing values on rate_code array out of range.
This patch changes the array size depends on the WMI_TPC_TX_N_CHAIN and
added check to avoid write values on the array if the num tx chain
get in tpc config event is greater than WMI_TPC_TX_N_CHAIN.

Tested on QCA9984 with firmware-5.bin_10.4-3.5.3-00057

Kernel panic log :

[  323.510944] Kernel panic - not syncing: stack-protector: Kernel stack is 
corrupted in: bf90c654
[  323.510944]
[  323.524390] CPU: 0 PID: 1908 Comm: cat Not tainted 3.14.77 #31
[  323.530224] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[  323.537941] [] (show_stack) from [] 
(dump_stack+0x80/0xa0)
[  323.545146] [] (dump_stack) from [] (panic+0x84/0x1e4)
[  323.552000] [] (panic) from [] 
(__stack_chk_fail+0x10/0x14)
[  323.559350] [] (__stack_chk_fail) from [] 
(ath10k_wmi_event_pdev_tpc_config+0x424/0x438 [ath10k_core])
[  323.570471] [] (ath10k_wmi_event_pdev_tpc_config [ath10k_core]) 
from [] (ath10k_wmi_10_4_op_rx+0x2f0/0x39c [ath10k_core])
[  323.583047] [] (ath10k_wmi_10_4_op_rx [ath10k_core]) from 
[] (ath10k_htc_rx_completion_handler+0x170/0x1a0 [ath10k_core])
[  323.595702] [] (ath10k_htc_rx_completion_handler [ath10k_core]) 
from [] (ath10k_pci_hif_send_complete_check+0x1f0/0x220 [ath10k_pci])
[  323.609421] [] (ath10k_pci_hif_send_complete_check [ath10k_pci]) 
from [] (ath10k_ce_per_engine_service+0x74/0xc4 [ath10k_pci])
[  323.622490] [] (ath10k_ce_per_engine_service [ath10k_pci]) from 
[] (ath10k_ce_per_engine_service_any+0x74/0x80 [ath10k_pci])
[  323.635423] [] (ath10k_ce_per_engine_service_any [ath10k_pci]) 
from [] (ath10k_pci_napi_poll+0x44/0xe8 [ath10k_pci])
[  323.647665] [] (ath10k_pci_napi_poll [ath10k_pci]) from 
[] (net_rx_action+0xac/0x160)
[  323.657208] [] (net_rx_action) from [] 
(__do_softirq+0x104/0x294)
[  323.665017] [] (__do_softirq) from [] 
(irq_exit+0x9c/0x11c)
[  323.672314] [] (irq_exit) from [] (handle_IRQ+0x6c/0x90)
[  323.679341] [] (handle_IRQ) from [] 
(gic_handle_irq+0x3c/0x60)
[  323.686893] [] (gic_handle_irq) from [] 
(__irq_svc+0x40/0x70)
[  323.694349] Exception stack(0xdd489c58 to 0xdd489ca0)
[  323.699384] 9c40:   
 a013
[  323.707547] 9c60:  dc4bce40 6013 ddc1d800 dd488000 0990 
 c085c800
[  323.715707] 9c80:  dd489d44 092d dd489ca0 c026e664 c026e668 
6013 
[  323.723877] [] (__irq_svc) from [] 
(rcu_note_context_switch+0x170/0x184)
[  323.732298] [] (rcu_note_context_switch) from [] 
(__schedule+0x50/0x4d4)
[  323.740716] [] (__schedule) from [] 
(schedule_timeout+0x148/0x178)
[  323.748611] [] (schedule_timeout) from [] 
(wait_for_common+0x114/0x154)
[  323.756972] [] (wait_for_common) from [] 
(ath10k_tpc_stats_open+0xc8/0x340 [ath10k_core])
[  323.766873] [] (ath10k_tpc_stats_open [ath10k_core]) from 
[] (do_dentry_open+0x1ac/0x274)
[  323.776741] [] (do_dentry_open) from [] 
(do_last+0x8c0/0xb08)
[  323.784201] [] (do_last) from [] 
(path_openat+0x210/0x598)
[  323.791408] [] (path_openat) from [] 
(do_filp_open+0x2c/0x78)
[  323.798873] [] (do_filp_open) from [] 
(do_sys_open+0x114/0x1b4)
[  323.806509] [] (do_sys_open) from [] 
(ret_fast_syscall+0x0/0x44)
[  323.814241] CPU1: stopping
[  323.816927] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.14.77 #31
[  323.823008] [] (unwind_backtrace) from [] 
(show_stack+0x10/0x14)
[  323.830731] [] (show_stack) from [] 
(dump_stack+0x80/0xa0)
[  323.837934] [] (dump_stack) from [] 
(handle_IPI+0xb8/0x140)
[  323.845224] [] (handle_IPI) from [] 
(gic_handle_irq+0x58/0x60)
[  323.852774] [] (gic_handle_irq) from [] 
(__irq_svc+0x40/0x70)
[  323.860233] Exception stack(0xdd499fa0 to 0xdd499fe8)
[  323.865273] 9fa0: ffed  1d3c9000  dd498000 dd498030 
10c0387d c08b62c8
[  323.873432] 9fc0: 4220406a 512f04d0   0001 dd499fe8 
c021838c c0218390
[  323.881588] 9fe0: 6013 
[  323.885070] [] (__irq_svc) from [] 
(arch_cpu_idle+0x30/0x50)
[  323.892454] [] (arch_cpu_idle) from [] 
(cpu_startup_entry+0xa4/0x108)
[  323.900690] [] (cpu_startup_entry) from [<422085a4>] (0x422085a4)

Signed-off-by: Tamizh chelvam 
---
 drivers/net/wireless/ath/ath10k/debug.c | 12 +---
 drivers/net/wireless/ath/ath10k/wmi.c   | 10 +-
 drivers/net/wireless/ath/ath10k/wmi.h   |  2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c 
b/drivers/net/wireless/ath/ath10k/debug.c
index 554cd78..8c41c81 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1506,18 +1506,24 @@ static void ath10k_tpc_stats_print(struct 
ath10k_tpc_stats *tpc_stats,
*len += scnprintf(buf + *len, buf_len - *len,
  "\n");
*len += scnprintf(buf + *len

Re: pull-request: mac80211 2018-03-21

2018-03-22 Thread David Miller
From: Johannes Berg 
Date: Wed, 21 Mar 2018 13:06:54 +0100

> Another few fixes - one for hwsim, so not really all that interesting,
> and two patches to work around an ath9k_htc problem.
> 
> Note that I pulled your net tree today, so you may need to be careful
> to not fast-forward if you don't merge anything else before this.
> 
> Please pull and let me know if there's any problem.

Pulled, thanks a lot Johannes.


[PATCH] brcmfmac: add support for BCM4366E chipset

2018-03-22 Thread Dan Haab
From: Dan Haab 

BCM4366E is a wireless chipset with a BCM43664 ChipCommon. It's
supported by the same firmware as 4366c0.

Signed-off-by: Dan Haab 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c   | 1 +
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c   | 2 ++
 drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index f7b30ce..271dadb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -689,6 +689,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv 
*ci)
case BRCM_CC_43525_CHIP_ID:
case BRCM_CC_4365_CHIP_ID:
case BRCM_CC_4366_CHIP_ID:
+   case BRCM_CC_43664_CHIP_ID:
return 0x20;
case CY_CC_4373_CHIP_ID:
return 0x16;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index a7d827c..b4d3832 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -57,6 +57,7 @@ enum brcmf_pcie_state {
 BRCMF_FW_NVRAM_DEF(4365C, "brcmfmac4365c-pcie.bin", "brcmfmac4365c-pcie.txt");
 BRCMF_FW_NVRAM_DEF(4366B, "brcmfmac4366b-pcie.bin", "brcmfmac4366b-pcie.txt");
 BRCMF_FW_NVRAM_DEF(4366C, "brcmfmac4366c-pcie.bin", "brcmfmac4366c-pcie.txt");
+BRCMF_FW_NVRAM_DEF(4366E, "brcmfmac4366c-pcie.bin", "brcmfmac4366c-pcie.txt");
 BRCMF_FW_NVRAM_DEF(4371, "brcmfmac4371-pcie.bin", "brcmfmac4371-pcie.txt");
 
 static struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
@@ -75,6 +76,7 @@ enum brcmf_pcie_state {
BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4365_CHIP_ID, 0xFFF0, 4365C),
BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4366_CHIP_ID, 0x000F, 4366B),
BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4366_CHIP_ID, 0xFFF0, 4366C),
+   BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFF0, 4366E),
BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4371_CHIP_ID, 0x, 4371),
 };
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h 
b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
index 57544a3..686f7a8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -57,6 +57,7 @@
 #define BRCM_CC_43602_CHIP_ID  43602
 #define BRCM_CC_4365_CHIP_ID   0x4365
 #define BRCM_CC_4366_CHIP_ID   0x4366
+#define BRCM_CC_43664_CHIP_ID  43664
 #define BRCM_CC_4371_CHIP_ID   0x4371
 #define CY_CC_4373_CHIP_ID 0x4373
 
-- 
1.9.1



RE: [PATCH v2 2/2] drivers: remove force dma flag from buses

2018-03-22 Thread Nipun Gupta


> -Original Message-
> From: Christoph Hellwig [mailto:h...@lst.de]
> Sent: Thursday, March 22, 2018 13:49
> To: Nipun Gupta 
> 
> > --- a/drivers/dma/qcom/hidma_mgmt.c
> > +++ b/drivers/dma/qcom/hidma_mgmt.c
> > @@ -398,7 +398,7 @@ static int __init
> hidma_mgmt_of_populate_channels(struct device_node *np)
> > }
> > of_node_get(child);
> > new_pdev->dev.of_node = child;
> > -   of_dma_configure(&new_pdev->dev, child);
> > +   of_dma_configure(&new_pdev->dev, child, true);
> > /*
> >  * It is assumed that calling of_msi_configure is safe on
> >  * platforms with or without MSI support.
> 
> Where did we mark this bus as force_dma before?

I thought these devices to be on the platform bus as the device is of type
'struct platform_device', though I am not sure then why 'of_dma_configure()'
is called here. Is this not on platform bus?

> 
> > diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> > index 9a4f4246..895c83e 100644
> > --- a/drivers/of/of_reserved_mem.c
> > +++ b/drivers/of/of_reserved_mem.c
> > @@ -353,7 +353,7 @@ int of_reserved_mem_device_init_by_idx(struct device
> *dev,
> > /* ensure that dma_ops is set for virtual devices
> >  * using reserved memory
> >  */
> > -   of_dma_configure(dev, np);
> > +   of_dma_configure(dev, np, true);
> 
> Did all the callers of this one really force dma?  I have a hard time
> untangling the call stacks unfortunately.

I see this API being called indirectly from NXP DPAA device driver which
is for platform bus devices. So I marked 'true' out here. There are more places
from where it is being called.

Thanks,
Nipun


RE: [PATCH v2 1/2] dma-mapping: move dma configuration to bus infrastructure

2018-03-22 Thread Nipun Gupta


> -Original Message-
> From: Christoph Hellwig [mailto:h...@lst.de]
> Sent: Thursday, March 22, 2018 13:46
> To: Nipun Gupta 
> 
> > +static int amba_dma_configure(struct device *dev)
> > +{
> > +   return dma_common_configure(dev);
> > +}
> 
> So it turns out we only end with two callers of dma_common_configure
> after this series.  Based ont hat I'm tempted with the suggestion
> from Robin to just have amba call platform_dma_configure, and move
> the code from dma_common_configure to platform_dma_configure.

okay, that would be fine, trivial query - will it be okay to include
'linux/platform_device.h' in the AMBA bus? I am reluctant for this change
because of including platform file.

Thanks,
Nipun


Re: [PATCH v2 2/2] wireless-regdb: make scripts compatible with Python 3

2018-03-22 Thread Matthias Schiffer
On 03/22/2018 03:05 PM, Seth Forshee wrote:
> On Sun, Feb 04, 2018 at 12:36:54AM +0100, Matthias Schiffer wrote:
>> When playing with the generation scripts for OpenWrt development, I noticed
>> that these scripts still required Python 2. Future-proof them by replacing
>> deprecated functions with new Python 3 compatible variants. The result
>> works with both Python 2.7 and Python 3.x; older Python 2.x releases are
>> not supported anymore.
>>
>> regulatory.db and regulatory.bin are unchanged and reproducible across
>> Python versions. Note that there is no stable release of m2crypto for
>> Python 3 yet; I used the current development branch for testing.
> 
> I can't say I'm all that knowledgable about Python 2 to Python 3
> conversion, but as far as I can tell this looks okay. It does seem to
> work for me running with both Python 2 and Python 3.
> 
> One question below though, mostly just to satisfy my curiousity.
> 
>> Signed-off-by: Matthias Schiffer 
>> ---
>>
>> v2: explicitly open input file with UTF-8 encoding; otherwise the scripts
>> will fail without a UTF-8 locale set in the environment
>>
>>
>>  db2bin.py  | 22 -
>>  db2fw.py   | 28 +++---
>>  dbparse.py | 81 
>> +-
>>  3 files changed, 74 insertions(+), 57 deletions(-)
>>
>> diff --git a/db2bin.py b/db2bin.py
>> index ae5f064..28cd7d2 100755
>> --- a/db2bin.py
>> +++ b/db2bin.py
>> @@ -1,6 +1,6 @@
>>  #!/usr/bin/env python
>>  
>> -from cStringIO import StringIO
>> +from io import BytesIO, open
>>  import struct
>>  import hashlib
>>  from dbparse import DBParser
>> @@ -10,21 +10,21 @@ MAGIC = 0x52474442
>>  VERSION = 19
>>  
>>  if len(sys.argv) < 3:
>> -print 'Usage: %s output-file input-file [key-file]' % sys.argv[0]
>> +print('Usage: %s output-file input-file [key-file]' % sys.argv[0])
>>  sys.exit(2)
>>  
>>  def create_rules(countries):
>>  result = {}
>> -for c in countries.itervalues():
>> +for c in countries.values():
>>  for rule in c.permissions:
>>  result[rule] = 1
>> -return result.keys()
>> +return list(result)
> 
> Here and elsewhere, to get a list of the keys from a dictionary, we use
> list(dict). Experimentally I find this works, but I haven't been able to
> find anything which actually tells me that this is the defined behavior,
> and examples seem to prefer list(dict.keys()). I'm curious why this is
> guaranteed to provide a lsit of dictionary keys, and why you've done
> that rather than list(dict.keys()) (I'll grant that the scripts
> elsewhere use list(dict), so maybe you were just being consistent with
> that).

list(dict) is the recommended syntax in
http://python-future.org/compatible_idioms.html#dict-keys-values-items-as-a-list
.

Regards,
Matthias



> 
>>  def create_collections(countries):
>>  result = {}
>> -for c in countries.itervalues():
>> +for c in countries.values():
>>  result[c.permissions] = 1
>> -return result.keys()
>> +return list(result)
>>  
>>  
>>  def be32(output, val):
>> @@ -49,9 +49,9 @@ class PTR(object):
>>  return self._offset
>>  
>>  p = DBParser()
>> -countries = p.parse(file(sys.argv[2]))
>> +countries = p.parse(open(sys.argv[2], 'r', encoding='utf-8'))
>>  
>> -countrynames = countries.keys()
>> +countrynames = list(countries)
>>  countrynames.sort()
>>  
>>  power = []
>> @@ -67,7 +67,7 @@ rules.sort()
>>  collections = create_collections(countries)
>>  collections.sort()
>>  
>> -output = StringIO()
>> +output = BytesIO()
>>  
>>  # struct regdb_file_header
>>  be32(output, MAGIC)
>> @@ -118,7 +118,7 @@ reg_country_ptr.set()
>>  for alpha2 in countrynames:
>>  coll = countries[alpha2]
>>  # struct regdb_file_reg_country
>> -output.write(struct.pack('>ccxBI', str(alpha2[0]), str(alpha2[1]), 
>> coll.dfs_region, reg_rules_collections[coll.permissions]))
>> +output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], 
>> coll.dfs_region, reg_rules_collections[coll.permissions]))
>>  
>>  
>>  if len(sys.argv) > 3:
>> @@ -143,5 +143,5 @@ if len(sys.argv) > 3:
>>  else:
>>  siglen.set(0)
>>  
>> -outfile = open(sys.argv[1], 'w')
>> +outfile = open(sys.argv[1], 'wb')
>>  outfile.write(output.getvalue())
>> diff --git a/db2fw.py b/db2fw.py
>> index 630e4d6..91b88d3 100755
>> --- a/db2fw.py
>> +++ b/db2fw.py
>> @@ -1,6 +1,6 @@
>>  #!/usr/bin/env python
>>  
>> -from cStringIO import StringIO
>> +from io import BytesIO, open
>>  import struct
>>  import hashlib
>>  from dbparse import DBParser
>> @@ -10,21 +10,21 @@ MAGIC = 0x52474442
>>  VERSION = 20
>>  
>>  if len(sys.argv) < 3:
>> -print 'Usage: %s output-file input-file' % sys.argv[0]
>> +print('Usage: %s output-file input-file' % sys.argv[0])
>>  sys.exit(2)
>>  
>>  def create_rules(countries):
>>  result = {}
>> -for c in countries.itervalues():
>> +for c in countries.values():
>>  for rule in c.permissions:

Re: [PATCH v2 2/2] wireless-regdb: make scripts compatible with Python 3

2018-03-22 Thread Seth Forshee
On Sun, Feb 04, 2018 at 12:36:54AM +0100, Matthias Schiffer wrote:
> When playing with the generation scripts for OpenWrt development, I noticed
> that these scripts still required Python 2. Future-proof them by replacing
> deprecated functions with new Python 3 compatible variants. The result
> works with both Python 2.7 and Python 3.x; older Python 2.x releases are
> not supported anymore.
> 
> regulatory.db and regulatory.bin are unchanged and reproducible across
> Python versions. Note that there is no stable release of m2crypto for
> Python 3 yet; I used the current development branch for testing.

I can't say I'm all that knowledgable about Python 2 to Python 3
conversion, but as far as I can tell this looks okay. It does seem to
work for me running with both Python 2 and Python 3.

One question below though, mostly just to satisfy my curiousity.

> Signed-off-by: Matthias Schiffer 
> ---
> 
> v2: explicitly open input file with UTF-8 encoding; otherwise the scripts
> will fail without a UTF-8 locale set in the environment
> 
> 
>  db2bin.py  | 22 -
>  db2fw.py   | 28 +++---
>  dbparse.py | 81 
> +-
>  3 files changed, 74 insertions(+), 57 deletions(-)
> 
> diff --git a/db2bin.py b/db2bin.py
> index ae5f064..28cd7d2 100755
> --- a/db2bin.py
> +++ b/db2bin.py
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env python
>  
> -from cStringIO import StringIO
> +from io import BytesIO, open
>  import struct
>  import hashlib
>  from dbparse import DBParser
> @@ -10,21 +10,21 @@ MAGIC = 0x52474442
>  VERSION = 19
>  
>  if len(sys.argv) < 3:
> -print 'Usage: %s output-file input-file [key-file]' % sys.argv[0]
> +print('Usage: %s output-file input-file [key-file]' % sys.argv[0])
>  sys.exit(2)
>  
>  def create_rules(countries):
>  result = {}
> -for c in countries.itervalues():
> +for c in countries.values():
>  for rule in c.permissions:
>  result[rule] = 1
> -return result.keys()
> +return list(result)

Here and elsewhere, to get a list of the keys from a dictionary, we use
list(dict). Experimentally I find this works, but I haven't been able to
find anything which actually tells me that this is the defined behavior,
and examples seem to prefer list(dict.keys()). I'm curious why this is
guaranteed to provide a lsit of dictionary keys, and why you've done
that rather than list(dict.keys()) (I'll grant that the scripts
elsewhere use list(dict), so maybe you were just being consistent with
that).

>  def create_collections(countries):
>  result = {}
> -for c in countries.itervalues():
> +for c in countries.values():
>  result[c.permissions] = 1
> -return result.keys()
> +return list(result)
>  
>  
>  def be32(output, val):
> @@ -49,9 +49,9 @@ class PTR(object):
>  return self._offset
>  
>  p = DBParser()
> -countries = p.parse(file(sys.argv[2]))
> +countries = p.parse(open(sys.argv[2], 'r', encoding='utf-8'))
>  
> -countrynames = countries.keys()
> +countrynames = list(countries)
>  countrynames.sort()
>  
>  power = []
> @@ -67,7 +67,7 @@ rules.sort()
>  collections = create_collections(countries)
>  collections.sort()
>  
> -output = StringIO()
> +output = BytesIO()
>  
>  # struct regdb_file_header
>  be32(output, MAGIC)
> @@ -118,7 +118,7 @@ reg_country_ptr.set()
>  for alpha2 in countrynames:
>  coll = countries[alpha2]
>  # struct regdb_file_reg_country
> -output.write(struct.pack('>ccxBI', str(alpha2[0]), str(alpha2[1]), 
> coll.dfs_region, reg_rules_collections[coll.permissions]))
> +output.write(struct.pack('>BBxBI', alpha2[0], alpha2[1], 
> coll.dfs_region, reg_rules_collections[coll.permissions]))
>  
>  
>  if len(sys.argv) > 3:
> @@ -143,5 +143,5 @@ if len(sys.argv) > 3:
>  else:
>  siglen.set(0)
>  
> -outfile = open(sys.argv[1], 'w')
> +outfile = open(sys.argv[1], 'wb')
>  outfile.write(output.getvalue())
> diff --git a/db2fw.py b/db2fw.py
> index 630e4d6..91b88d3 100755
> --- a/db2fw.py
> +++ b/db2fw.py
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env python
>  
> -from cStringIO import StringIO
> +from io import BytesIO, open
>  import struct
>  import hashlib
>  from dbparse import DBParser
> @@ -10,21 +10,21 @@ MAGIC = 0x52474442
>  VERSION = 20
>  
>  if len(sys.argv) < 3:
> -print 'Usage: %s output-file input-file' % sys.argv[0]
> +print('Usage: %s output-file input-file' % sys.argv[0])
>  sys.exit(2)
>  
>  def create_rules(countries):
>  result = {}
> -for c in countries.itervalues():
> +for c in countries.values():
>  for rule in c.permissions:
>  result[rule] = 1
> -return result.keys()
> +return list(result)
>  
>  def create_collections(countries):
>  result = {}
> -for c in countries.itervalues():
> +for c in countries.values():
>  result[(c.permissions, c.dfs_region)] = 1
> -return result.keys()
> +return list(result)
>  
>  
>  d

Re: [RFC v5 0/9] EAPoL over NL80211

2018-03-22 Thread Denis Kenzior

Hi Johannes,


However, it doesn't actually matter at all - we shouldn't get there
with VLAN interface. EAPOL frames are always sent out to the
corresponding AP interface, see ieee80211_rx_h_data:

 if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
 unlikely(port_control) && sdata->bss) {
 sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
  u.ap);
 dev = sdata->dev;
 rx->sdata = sdata;
 }



Okay, that makes things easier.  However, it does bring up a question. 
Should we be symmetric and remove AP_VLAN as a valid target of control 
port frames?  E.g. drop NL80211_IFTYPE_AP_VLAN case in patch 2 of the 
series.  In effect we'd require all control port frame traffic to go 
over the master interface.





- JOIN_IBSS & JOIN_MESH don't seem to support control_port_ethertype or
control_port_no_encrypt.  Should struct cfg80211_crypto_settings parsed inside
nl80211_crypto_settings be added to ibss_params or mesh_config/mesh_setup?


I don't think it matters - they just don't support this now and don't
really need to.



Except that the eapol over nl80211 flag is being sent in security
settings.  This covers STA/AP/P2P_GO/P2P_CLIENT.  We need some way of
passing this information for mesh & ibss.


Not sure I understand what you're saying. Can't we just say the flag
isn't permitted in those modes?


I'm the one confused now.  You wanted me to add IFTYPE_IBSS in 
nl80211_tx_control_port in your earlier feedback :)


Let me try to restate what I said earlier in a different way and see if 
it makes things a bit clearer:


So in patch 9, we set sdata->control_port_over_nl80211 based on 
parameters passed into start_ap or mgd_assoc.  The 
control_port_over_nl80211 flag is passed in cfg80211_crypto_settings 
structure that is part of the relevant parameters structure.  If 
sdata->control_port_over_nl80211 is true, then we actually redirect the 
control port frames to nl80211.


So my question is, if we want to support IBSS/MESH, should we:
1. add the whole cfg80211_crypto_settings to the IBSS/MESH parameters,
2. add the control_port_over_nl80211 flag directly to IBSS/MESH parameters
3. Pass the flag some other way?
4. Or drop IBSS/MESH from patch 2 (nl80211_tx_control_port) completely?

Regards,
-Denis


Re: [PATCH] brcmfmac: Add timestamp to scan results report

2018-03-22 Thread Johannes Berg
On Thu, 2018-03-22 at 11:44 +0100, Arend van Spriel wrote:
> I recall a similar attempt for another driver, but I think the timestamp 
> should really be the TSF of the beacon/proberesp received. As you 
> already Cc-ed Johannes explicitly maybe he can clarify what is needed 
> here as I do not recall the details. ;-)

Yes, this should be "tsf", it's actually labelled explicitly as such. I
know Android used to get this wrong and *even test* it wrongly, but
that's no excuse.

However, should switch this to cfg80211_inform_bss_data() and use the
timestamp set up here to fill the cfg80211_inform_bss::boottime_ns
value. That's also sent to userspace in the proper way for this.

johannes


Re: [PATCH] brcmfmac: Add timestamp to scan results report

2018-03-22 Thread Arend van Spriel

On 3/21/2018 11:44 PM, dimitr...@google.com wrote:

 From 01da9ee11ce6e0973972b2ffd37eef660714f71a Mon Sep 17 00:00:00 2001
From: Dmitry Shmidt 
Date: Wed, 21 Mar 2018 15:35:45 -0700
Subject: [PATCH] brcmfmac: Add timestamp to scan results report

Monotonic time from boot is good timestamp indicator
and it can be used by kernel and userspace.


Thanks, Dmitry

I recall a similar attempt for another driver, but I think the timestamp 
should really be the TSF of the beacon/proberesp received. As you 
already Cc-ed Johannes explicitly maybe he can clarify what is needed 
here as I do not recall the details. ;-)


Regards,
Arend


Change-Id: I122374fa79c6dbd7967b2c30553cb04dee032ebc
Signed-off-by: Dmitry Shmidt 
---
  drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)




Re: [PATCH v2] mac80211: notify driver for change in multicast rates

2018-03-22 Thread Johannes Berg
On Wed, 2018-03-21 at 16:54 -0700, Pradeep Kumar Chitrapu wrote:
> 
> index 4c99c13..4360765 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -336,6 +336,7 @@ enum ieee80211_bss_change {
>   BSS_CHANGED_OCB = 1<<22,
>   BSS_CHANGED_MU_GROUPS   = 1<<23,
>   BSS_CHANGED_KEEP_ALIVE  = 1<<24,
> + BSS_CHANGED_MCAST_RATE  = 1<<25,

Not sure why I missed this before, but you need to add documentation
for this.

johannes


Re: [PATCH net-next v2 2/2] dt: bindings: add new dt entries for brcmfmac

2018-03-22 Thread Ulf Hansson
On 20 March 2018 at 10:55, Kalle Valo  wrote:
> Arend van Spriel  writes:
>
 If I get it right, you mean something like this:

 mmc3: mmc@1c12000 {
 ...
  broken-sg-support;
  sd-head-align = 4;
  sd-sgentry-align = 512;

  brcmf: wifi@1 {
  ...
  };
 };

 Where dt: bindings documentation for these entries should reside?
 In generic MMC bindings? Well, this is the very special case and
 mmc-linux maintainer will unlikely to accept these changes.
 Also, extra kernel code modification might be required. It could make
 quite trivial change much more complex.
>>>
>>> If the MMC maintainers are not copied on this patch series, it will
>>> likely be hard for them to identify this patch series and chime in...
>>
>> The main question is whether this is indeed a "very special case" as
>> Alexey claims it to be or that it is likely to be applicable to other
>> device and host combinations as you are suggesting.
>>
>> If these properties are imposed by the host or host controller it
>> would make sense to have these in the mmc bindings.
>
> BTW, last year we were discussing something similar (I mean related to
> alignment requirements) with ath10k SDIO patches and at the time the
> patch submitter was proposing to have a bounce buffer in ath10k to
> workaround that. I don't remember the details anymore, they are on the
> ath10k mailing list archive if anyone is curious to know, but I would
> not be surprised if they are similar as here. So there might be a need
> to solve this in a generic way (but not sure of course as I haven't
> checked the details).

I re-call something about these as well, here are the patches. Perhaps
I should pick some of them up...

https://patchwork.kernel.org/patch/10123137/
https://patchwork.kernel.org/patch/10123139/
https://patchwork.kernel.org/patch/10123141/
https://patchwork.kernel.org/patch/10123143/

Kind regards
Uffe


Re: [RFC v5 0/9] EAPoL over NL80211

2018-03-22 Thread Johannes Berg
On Wed, 2018-03-21 at 10:18 -0500, Denis Kenzior wrote:
> 
> Sorry.  I assumed people read the change log :)

And I should :-)

> > > - It is unclear to me how AP_VLAN and AP interfaces should synchronize on
> > > conn_owner_nlportid.  This is required for tx_control_port to work.
> > 
> > I'm not really sure what you mean? Technically I guess an AP_VLAN could
> > have a different owner from an AP, but if the AP goes down all the
> > AP_VLANs go down with it already anyway.
> 
> So the issue is that when mac80211 calls cfg80211_rx_control_port and 
> subsequently __nl80211_rx_control_port, we grab the nlportid from the 
> wdev.  So if that isn't synchronized, then AP_VLAN devices won't be 
> sending the EAPoL frames to the right place.

Oh, ok, gotcha. I guess mac80211 would have to sync over the data, just
like it does for other things? You also copied over the
control_port_over_nl80211 setting, so could do the same here?

But no, maybe that doesn't make sense, since ...

Hmm. Ok, I think I see what you're getting at.

The key point seems to be that we don't have any sort of "add VLAN to
AP operation" - it's auto-detected based on the MAC address.

However, it doesn't actually matter at all - we shouldn't get there
with VLAN interface. EAPOL frames are always sent out to the
corresponding AP interface, see ieee80211_rx_h_data:

if (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
unlikely(port_control) && sdata->bss) {
sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
 u.ap);
dev = sdata->dev;
rx->sdata = sdata;
}


> > > - JOIN_IBSS & JOIN_MESH don't seem to support control_port_ethertype or
> > > control_port_no_encrypt.  Should struct cfg80211_crypto_settings parsed 
> > > inside
> > > nl80211_crypto_settings be added to ibss_params or mesh_config/mesh_setup?
> > 
> > I don't think it matters - they just don't support this now and don't
> > really need to.
> > 
> 
> Except that the eapol over nl80211 flag is being sent in security 
> settings.  This covers STA/AP/P2P_GO/P2P_CLIENT.  We need some way of 
> passing this information for mesh & ibss.

Not sure I understand what you're saying. Can't we just say the flag
isn't permitted in those modes?

johannes


Re: [PATCH] mt76: enable MAC80211_LEDS by default

2018-03-22 Thread Lorenzo Bianconi
On Mar 22, Arnd Bergmann wrote:
> On Wed, Mar 21, 2018, 23:27 Lorenzo Bianconi
>  wrote:
> >
> > On Mar 21, Arnd Bergmann wrote:
> > > On Wed, Mar 21, 2018 at 6:45 AM, Johannes Berg
> > >  wrote:
> > > > On Fri, 2018-03-16 at 15:45 +0100, Lorenzo Bianconi wrote:
> > > >> --- a/drivers/net/wireless/mediatek/mt76/Kconfig
> > > >> +++ b/drivers/net/wireless/mediatek/mt76/Kconfig
> > > >> @@ -1,5 +1,8 @@
> > > >>  config MT76_CORE
> > > >>   tristate
> > > >> + select MAC80211_LEDS
> > > >
> > > > Should drivers really mess with mac80211's configuration that way? I
> > > > believe this is a user-visible config, no?
> > >
> > > We have a couple of drivers using 'select LEDS_CLASS' and others
> > > doing 'depends on LEDS_CLASS'. I think the latter is what we should
> > > have here for all those drivers.
> > >
> > > MAC80211_LEDS looks like it's designed to be optional, so nothing
> > > should select or depend on that.
> > >
> > >   Arnd
> >
> > Reviewing the current code we do not actually need MAC80211_LEDS, so I agree
> > to remove it from Kconfig and let userspace selects the option. I would use
> > select for LEDS_CLASS. If you agree I can send a v2 otherwise I fine to 
> > apply
> > Arnd's patch.
> > Felix what do you think?
> 
> Looking at mt76 again, my impression is that the core driver should not have
> an dependency on LEDS at all, the dependency should instead be restricted
> to the CONFIG_MT76_LEDS symbol as my patch from January did (with the
> change to 'default y').
> 
>   Arnd

I agree.
Fell free to add Acked-by: Lorenzo Bianconi 

Regards,
Lorenzo


Re: [PATCH v2 2/2] drivers: remove force dma flag from buses

2018-03-22 Thread Christoph Hellwig
> --- a/drivers/dma/qcom/hidma_mgmt.c
> +++ b/drivers/dma/qcom/hidma_mgmt.c
> @@ -398,7 +398,7 @@ static int __init hidma_mgmt_of_populate_channels(struct 
> device_node *np)
>   }
>   of_node_get(child);
>   new_pdev->dev.of_node = child;
> - of_dma_configure(&new_pdev->dev, child);
> + of_dma_configure(&new_pdev->dev, child, true);
>   /*
>* It is assumed that calling of_msi_configure is safe on
>* platforms with or without MSI support.

Where did we mark this bus as force_dma before?

> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 9a4f4246..895c83e 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -353,7 +353,7 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
>   /* ensure that dma_ops is set for virtual devices
>* using reserved memory
>*/
> - of_dma_configure(dev, np);
> + of_dma_configure(dev, np, true);

Did all the callers of this one really force dma?  I have a hard time
untangling the call stacks unfortunately.



Re: [PATCH v2 1/2] dma-mapping: move dma configuration to bus infrastructure

2018-03-22 Thread h...@lst.de
> > +int dma_configure(struct device *dev)
> > +{
> > +   if (dev->bus->dma_configure)
> > +   return dev->bus->dma_configure(dev);
> 
> What if dma_common_configure() is called in case "bus->dma_configure" is not 
> defined?

Then we'd still have a dependency of common code on OF and ACPI.

On the other hand we'd get free OF and ACPI dma ranges parsing for
everyone, which might be handy.  And which would really help mitigating
the risk that we missed some bus that gets dma configuration from OF,
so maybe it actually is a good idea.  I'd just rename it to
dma_default_configure or similar in that case.


Re: [PATCH v2 1/2] dma-mapping: move dma configuration to bus infrastructure

2018-03-22 Thread Christoph Hellwig
> +static int amba_dma_configure(struct device *dev)
> +{
> + return dma_common_configure(dev);
> +}

So it turns out we only end with two callers of dma_common_configure
after this series.  Based ont hat I'm tempted with the suggestion
from Robin to just have amba call platform_dma_configure, and move
the code from dma_common_configure to platform_dma_configure.

> +int dma_configure(struct device *dev)
> +{
> + if (dev->bus->dma_configure)
> + return dev->bus->dma_configure(dev);
> +
> + return 0;
> +}
>  void dma_deconfigure(struct device *dev)

As grep pointed out this wants a blank line after the function, and while
in nitpicking mode I'd suggest to remove the blank line above the return
statement while at it.

> diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
> index 88a3558..fa9896d 100644
> --- a/drivers/gpu/host1x/bus.c
> +++ b/drivers/gpu/host1x/bus.c
> @@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev, 
> struct device_driver *drv)
>   return strcmp(dev_name(dev), drv->name) == 0;
>  }
>  
> +static int host1x_dma_configure(struct device *dev)
> +{
> + if (dev->of_node)
> + return of_dma_configure(dev, dev->of_node);
> +
> + return 0;

Same here.

> + */
> +static int pci_dma_configure(struct device *dev)
> +{
> + struct device *bridge;
> + enum dev_dma_attr attr;
> + int ret = 0;
> +
> + bridge = pci_get_host_bridge_device(to_pci_dev(dev));
> +
> + if (IS_ENABLED(CONFIG_OF) && bridge->parent &&
> + bridge->parent->of_node) {
> + ret = of_dma_configure(dev, bridge->parent->of_node);
> + } else if (has_acpi_companion(bridge)) {
> + attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode));
> + if (attr != DEV_DMA_NOT_SUPPORTED)
> + ret = acpi_dma_configure(dev, attr);
> + }

The attr declaration can be moved into the inner scope here.

> + pci_put_host_bridge_device(bridge);
> +
> + return ret;

Drop the blank line after the return, please.


Re: [RFC] mac80211: advertise supported interface types for sw encryption

2018-03-22 Thread Johannes Berg
On Thu, 2018-03-22 at 11:51 +0530, mpubb...@codeaurora.org wrote:
> 
> > So IMHO - just get rid of the bitmap and hard-code AP_VLAN.
> > 
> 
> I agree with you only partially.
> 
> Today, I do not see any driver advertising SW_CRYPTO_CONTROL other than 
> ath10k. There could be some driver which would want to advertise 
> SW_CRYPTO_CONTROL and do not support the software encryption for VLAN 
> devices. In that case, hard-coding doesn't seem to solve the problem 
> completely right? No?

Well, my point is that such a hypothetical driver is completely
irrelevant because it doesn't make any sense to have this behaviour -
it would mean it cannot support AP_VLAN with encryption, so it might as
well not support AP_VLAN at all.

> Or you meant to say that driver should advertise the support for 
> AP_VLANs only if it can support encryption on AP_VLAN devices? 

Right.

> If this 
> the case, then I could see some code in ieee80211_register_hw which says 
> this,
> 
>  /* if low-level driver supports AP, we also support VLAN */
>  if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) {
>  hw->wiphy->interface_modes |= 
> BIT(NL80211_IFTYPE_AP_VLAN);
>  hw->wiphy->software_iftypes |= 
> BIT(NL80211_IFTYPE_AP_VLAN);
>  }

Yes, but if such a driver comes along we can change this.

johannes