[PATCH V2 7/8] brcmfmac: 4373 save-restore support

2018-11-11 Thread Chi-Hsien Lin
Use sr_eng_en bit to check 4373 sr support.

Reviewed-by: Arend van Spriel 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index a8d3b96b727f..08d5173d000c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -1365,6 +1365,11 @@ bool brcmf_chip_sr_capable(struct brcmf_chip *pub)
addr = CORE_CC_REG(base, sr_control1);
reg = chip->ops->read32(chip->ctx, addr);
return reg != 0;
+   case CY_CC_4373_CHIP_ID:
+   /* explicitly check SR engine enable bit */
+   addr = CORE_CC_REG(base, sr_control0);
+   reg = chip->ops->read32(chip->ctx, addr);
+   return (reg & BIT(0)) != 0;
case CY_CC_43012_CHIP_ID:
addr = CORE_CC_REG(pmu->base, retention_ctl);
reg = chip->ops->read32(chip->ctx, addr);
-- 
2.1.0



[PATCH V2 8/8] brcmfmac: disable command decode in sdio_aos

2018-11-11 Thread Chi-Hsien Lin
From: Wright Feng 

AOS is a part of the SDIOD core that becomes active when the rest of
SDIOD is sleeping to keep SDIO bus alive responding to reduced set of
commands.

Transaction between AOS and SDIOD is not protected, and if cmd 52 is
received in AOS and in the middle of response state changed from AOS to
SDIOD, response is corrupted and it causes to SDIO Host controller to
hang.

Command decode for below chips are disabled in this commit:
 - 4339
 - 4345
 - 4354
 - 4373

Reviewed-by: Arend van Spriel 
Signed-off-by: Wright Feng 
Signed-off-by: Double Lo 
Signed-off-by: Madhan Mohan R 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index e1708e297d07..e5f487b37c5a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -3354,7 +3354,11 @@ static int brcmf_sdio_download_firmware(struct 
brcmf_sdio *bus,
 
 static bool brcmf_sdio_aos_no_decode(struct brcmf_sdio *bus)
 {
-   if (bus->ci->chip == CY_CC_43012_CHIP_ID)
+   if (bus->ci->chip == CY_CC_43012_CHIP_ID ||
+   bus->ci->chip == CY_CC_4373_CHIP_ID ||
+   bus->ci->chip == BRCM_CC_4339_CHIP_ID ||
+   bus->ci->chip == BRCM_CC_4345_CHIP_ID ||
+   bus->ci->chip == BRCM_CC_4354_CHIP_ID)
return true;
else
return false;
-- 
2.1.0



[PATCH V2 6/8] brcmfmac: update 43012 F2 watermark setting to fix DMA Error during UDP RX Traffic

2018-11-11 Thread Chi-Hsien Lin
From: Naveen Gupta 

The number of words that the read FIFO has to contain except
the end of frame before sends data back to the host.
Max watermark = (512B - 2* (BurstLength))/4 =
(512 - 128)/4 = 384/4 = 0x60
so if burst length (i.e. BurstLength = 64) is increased,
watermark has to be reduced. This is the optimal setting for this chip.

Reviewed-by: Arend van Spriel 
Signed-off-by: Naveen Gupta 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 7707b0169c21..e1708e297d07 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -52,6 +52,7 @@
 /* watermark expressed in number of words */
 #define DEFAULT_F2_WATERMARK0x8
 #define CY_4373_F2_WATERMARK0x40
+#define CY_43012_F2_WATERMARK0x60
 
 #ifdef DEBUG
 
@@ -4173,6 +4174,17 @@ static void brcmf_sdio_firmware_callback(struct device 
*dev, int err,
   CY_4373_F2_WATERMARK |
   SBSDIO_MESBUSYCTRL_ENAB, );
break;
+   case SDIO_DEVICE_ID_CYPRESS_43012:
+   brcmf_dbg(INFO, "set F2 watermark to 0x%x*4 bytes\n",
+ CY_43012_F2_WATERMARK);
+   brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
+  CY_43012_F2_WATERMARK, );
+   devctl = brcmf_sdiod_readb(sdiod, SBSDIO_DEVICE_CTL,
+  );
+   devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
+   brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
+  );
+   break;
default:
brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
   DEFAULT_F2_WATERMARK, );
-- 
2.1.0



[PATCH V2 4/8] brcmfmac: add support for CYW43012 SDIO chipset

2018-11-11 Thread Chi-Hsien Lin
CYW43012 is a 1x1 802.11a/b/g/n Dual-Band HT20, 256-QAM/Turbo QAM. It
is an Ultra Low Power WLAN+BT combo chip.

Reviewed-by: Arend van Spriel 
Signed-off-by: Chi-Hsien Lin 
Signed-off-by: Praveen Babu C 
---
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  |  1 +
 .../wireless/broadcom/brcm80211/brcmfmac/chip.c| 14 +++-
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 74 ++
 .../broadcom/brcm80211/include/brcm_hw_ids.h   |  1 +
 include/linux/mmc/sdio_ids.h   |  1 +
 5 files changed, 78 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 3e37c8cf82c6..c1d4f93f7347 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -972,6 +972,7 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4354),
BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_BROADCOM_4356),
BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_CYPRESS_4373),
+   BRCMF_SDIO_DEVICE(SDIO_DEVICE_ID_CYPRESS_43012),
{ /* end: all zeroes */ }
 };
 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index 927d62b3d41b..a3c857721446 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -165,6 +165,7 @@ struct sbconfig {
 #define SRCI_LSS_MASK  0x00f0
 #define SRCI_LSS_SHIFT 20
 #defineSRCI_SRNB_MASK  0xf0
+#defineSRCI_SRNB_MASK_EXT  0x100
 #defineSRCI_SRNB_SHIFT 4
 #defineSRCI_SRBSZ_MASK 0xf
 #defineSRCI_SRBSZ_SHIFT0
@@ -592,7 +593,13 @@ static void brcmf_chip_socram_ramsize(struct 
brcmf_core_priv *sr, u32 *ramsize,
if (lss != 0)
*ramsize += (1 << ((lss - 1) + SR_BSZ_BASE));
} else {
-   nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
+   /* length of SRAM Banks increased for corerev greater than 23 */
+   if (sr->pub.rev >= 23) {
+   nb = (coreinfo & (SRCI_SRNB_MASK | SRCI_SRNB_MASK_EXT))
+   >> SRCI_SRNB_SHIFT;
+   } else {
+   nb = (coreinfo & SRCI_SRNB_MASK) >> SRCI_SRNB_SHIFT;
+   }
for (i = 0; i < nb; i++) {
retent = brcmf_chip_socram_banksize(sr, i, );
*ramsize += banksize;
@@ -1356,6 +1363,11 @@ bool brcmf_chip_sr_capable(struct brcmf_chip *pub)
addr = CORE_CC_REG(base, sr_control1);
reg = chip->ops->read32(chip->ctx, addr);
return reg != 0;
+   case CY_CC_43012_CHIP_ID:
+   addr = CORE_CC_REG(pmu->base, retention_ctl);
+   reg = chip->ops->read32(chip->ctx, addr);
+   return (reg & (PMU_RCTL_MACPHY_DISABLE_MASK |
+  PMU_RCTL_LOGIC_DISABLE_MASK)) == 0;
default:
addr = CORE_CC_REG(pmu->base, pmucapabilities_ext);
reg = chip->ops->read32(chip->ctx, addr);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index b9ec40cc7d6b..7707b0169c21 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -624,6 +624,7 @@ BRCMF_FW_DEF(43455, "brcmfmac43455-sdio");
 BRCMF_FW_DEF(4354, "brcmfmac4354-sdio");
 BRCMF_FW_DEF(4356, "brcmfmac4356-sdio");
 BRCMF_FW_DEF(4373, "brcmfmac4373-sdio");
+BRCMF_FW_DEF(43012, "brcmfmac43012-sdio");
 
 static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID, 0x, 43143),
@@ -643,7 +644,8 @@ static const struct brcmf_firmware_mapping 
brcmf_sdio_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFC0, 43455),
BRCMF_FW_ENTRY(BRCM_CC_4354_CHIP_ID, 0x, 4354),
BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0x, 4356),
-   BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0x, 4373)
+   BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0x, 4373),
+   BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0x, 43012)
 };
 
 static void pkt_align(struct sk_buff *p, int len, int align)
@@ -677,6 +679,14 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on)
/* 1st KSO write goes to AOS wake up core if device is asleep  */
brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, );
 
+   /* In case of 43012 chip, the chip could go down immediately after
+* KSO bit is cleared. So the further reads of KSO register could
+* fail. Thereby just bailing out immediately after 

[PATCH V2 5/8] brcmfmac: allow GCI core enumuration

2018-11-11 Thread Chi-Hsien Lin
GCI core is needed for ULP operation. Allow GCI core enumuration with
below changes:
 - Allow GCI to be added to core list even when it doesn't have a wrapper.
 - Allow 8K address space size.
 - Don't overwrite the address value when an additional size descriptor
   is in place.

Reviewed-by: Arend van Spriel 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index a3c857721446..a8d3b96b727f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -786,7 +786,7 @@ static int brcmf_chip_dmp_get_regaddr(struct 
brcmf_chip_priv *ci, u32 *eromaddr,
  u32 *regbase, u32 *wrapbase)
 {
u8 desc;
-   u32 val;
+   u32 val, szdesc;
u8 mpnum = 0;
u8 stype, sztype, wraptype;
 
@@ -832,14 +832,15 @@ static int brcmf_chip_dmp_get_regaddr(struct 
brcmf_chip_priv *ci, u32 *eromaddr,
 
/* next size descriptor can be skipped */
if (sztype == DMP_SLAVE_SIZE_DESC) {
-   val = brcmf_chip_dmp_get_desc(ci, eromaddr, NULL);
+   szdesc = brcmf_chip_dmp_get_desc(ci, eromaddr, NULL);
/* skip upper size descriptor if present */
-   if (val & DMP_DESC_ADDRSIZE_GT32)
+   if (szdesc & DMP_DESC_ADDRSIZE_GT32)
brcmf_chip_dmp_get_desc(ci, eromaddr, NULL);
}
 
-   /* only look for 4K register regions */
-   if (sztype != DMP_SLAVE_SIZE_4K)
+   /* look for 4K or 8K register regions */
+   if (sztype != DMP_SLAVE_SIZE_4K &&
+   sztype != DMP_SLAVE_SIZE_8K)
continue;
 
stype = (val & DMP_SLAVE_TYPE) >> DMP_SLAVE_TYPE_S;
@@ -896,7 +897,8 @@ int brcmf_chip_dmp_erom_scan(struct brcmf_chip_priv *ci)
 
/* need core with ports */
if (nmw + nsw == 0 &&
-   id != BCMA_CORE_PMU)
+   id != BCMA_CORE_PMU &&
+   id != BCMA_CORE_GCI)
continue;
 
/* try to obtain register address info */
-- 
2.1.0



[PATCH V2 3/8] brcmfmac: set SDIO F1 MesBusyCtrl for CYW4373

2018-11-11 Thread Chi-Hsien Lin
From: Madhan Mohan R 

Along with F2 watermark (existing) configuration, F1 MesBusyCtrl
should be enabled & configured to avoid overflow errors.

Reviewed-by: Arend van Spriel 
Signed-off-by: Madhan Mohan R 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 3 +++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 05b8cfea5f9f..b9ec40cc7d6b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4119,6 +4119,9 @@ static void brcmf_sdio_firmware_callback(struct device 
*dev, int err,
devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
   );
+   brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_MESBUSYCTRL,
+  CY_4373_F2_WATERMARK |
+  SBSDIO_MESBUSYCTRL_ENAB, );
break;
default:
brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
index 7faed831f07d..8aaabca1eb0e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
@@ -104,6 +104,9 @@
 #define SBSDIO_FUNC1_RFRAMEBCHI0x1001C
 /* MesBusyCtl (rev 11) */
 #define SBSDIO_FUNC1_MESBUSYCTRL   0x1001D
+/* Enable busy capability for MES access */
+#define SBSDIO_MESBUSYCTRL_ENAB 0x80
+
 /* Sdio Core Rev 12 */
 #define SBSDIO_FUNC1_WAKEUPCTRL0x1001E
 #define SBSDIO_FUNC1_WCTRL_ALPWAIT_MASK0x1
-- 
2.1.0



[PATCH V2 1/8] brcmfmac: add 4354 raw pcie device id

2018-11-11 Thread Chi-Hsien Lin
From: Winnie Chang 

Add the raw 4354 PCIe device ID for unprogrammed Cypress boards.

Reviewed-by: Arend Van Spriel 
Signed-off-by: Winnie Chang 
Signed-off-by: Chi-Hsien Lin 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c   | 1 +
 drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 5dea569d63ed..8887bbc0084f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -2018,6 +2018,7 @@ static const struct dev_pm_ops brcmf_pciedrvr_pm = {
 static const struct pci_device_id brcmf_pcie_devid_table[] = {
BRCMF_PCIE_DEVICE(BRCM_PCIE_4350_DEVICE_ID),
BRCMF_PCIE_DEVICE_SUB(0x4355, BRCM_PCIE_VENDOR_ID_BROADCOM, 0x4355),
+   BRCMF_PCIE_DEVICE(BRCM_PCIE_4354_RAW_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_4356_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_43567_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_43570_DEVICE_ID),
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 686f7a85a045..acb87238922f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -74,6 +74,7 @@
 /* PCIE Device IDs */
 #define BRCM_PCIE_4350_DEVICE_ID   0x43a3
 #define BRCM_PCIE_4354_DEVICE_ID   0x43df
+#define BRCM_PCIE_4354_RAW_DEVICE_ID   0x4354
 #define BRCM_PCIE_4356_DEVICE_ID   0x43ec
 #define BRCM_PCIE_43567_DEVICE_ID  0x43d3
 #define BRCM_PCIE_43570_DEVICE_ID  0x43d9
-- 
2.1.0



[PATCH V2 2/8] brcmfmac: set F2 watermark to 256 for 4373

2018-11-11 Thread Chi-Hsien Lin
From: Wright Feng 

We got SDIO_CRC_ERROR with 4373 on SDR104 when doing bi-directional
throughput test. Enable watermark to 256 to guarantee the operation
stability.

Reviewed-by: Arend van Spriel 
Signed-off-by: Wright Feng 
Signed-off-by: Chi-Hsien Lin 
---
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index b2e1ab5adb64..05b8cfea5f9f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -49,6 +49,10 @@
 #define DCMD_RESP_TIMEOUT  msecs_to_jiffies(2500)
 #define CTL_DONE_TIMEOUT   msecs_to_jiffies(2500)
 
+/* watermark expressed in number of words */
+#define DEFAULT_F2_WATERMARK0x8
+#define CY_4373_F2_WATERMARK0x40
+
 #ifdef DEBUG
 
 #define BRCMF_TRAP_INFO_SIZE   80
@@ -138,6 +142,8 @@ struct rte_console {
 /* 1: isolate internal sdio signals, put external pads in tri-state; requires
  * sdio bus power cycle to clear (rev 9) */
 #define SBSDIO_DEVCTL_PADS_ISO 0x08
+/* 1: enable F2 Watermark */
+#define SBSDIO_DEVCTL_F2WM_ENAB0x10
 /* Force SD->SB reset mapping (rev 11) */
 #define SBSDIO_DEVCTL_SB_RST_CTL   0x30
 /*   Determined by CoreControl bit */
@@ -4046,6 +4052,7 @@ static void brcmf_sdio_firmware_callback(struct device 
*dev, int err,
void *nvram;
u32 nvram_len;
u8 saveclk;
+   u8 devctl;
 
brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
 
@@ -4101,8 +4108,23 @@ static void brcmf_sdio_firmware_callback(struct device 
*dev, int err,
brcmf_sdiod_writel(sdiod, core->base + SD_REG(hostintmask),
   bus->hostintmask, NULL);
 
-
-   brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK, 8, );
+   switch (sdiod->func1->device) {
+   case SDIO_DEVICE_ID_CYPRESS_4373:
+   brcmf_dbg(INFO, "set F2 watermark to 0x%x*4 bytes\n",
+ CY_4373_F2_WATERMARK);
+   brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
+  CY_4373_F2_WATERMARK, );
+   devctl = brcmf_sdiod_readb(sdiod, SBSDIO_DEVICE_CTL,
+  );
+   devctl |= SBSDIO_DEVCTL_F2WM_ENAB;
+   brcmf_sdiod_writeb(sdiod, SBSDIO_DEVICE_CTL, devctl,
+  );
+   break;
+   default:
+   brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK,
+  DEFAULT_F2_WATERMARK, );
+   break;
+   }
} else {
/* Disable F2 again */
sdio_disable_func(sdiod->func2);
-- 
2.1.0



[PATCH V2 0/8] brcmfmac: chip related changes

2018-11-11 Thread Chi-Hsien Lin
This patch series includes various chip-related changes:
* 43012 support
* 4373 saverestore support
* SDIO bus settings
* 4354 raw chipid

Changelog:
V2:
 - Update commit message for patch 1.
 - Update comments for patch 2.
 - Remove CY_4373_F1_MESBUSYCTRL from patch 3.
 - Collapse patch 6 (43102 sr support) in 4 (43012 support). Add helper 
functions.
 - Remove sr_eng_en variable from patch 8.
 - Collapse patch 10 and 11 in 9 (sdio_aos disable).

Chi-Hsien Lin (3):
  brcmfmac: add support for CYW43012 SDIO chipset
  brcmfmac: allow GCI core enumuration
  brcmfmac: 4373 save-restore support

Madhan Mohan R (1):
  brcmfmac: set SDIO F1 MesBusyCtrl for CYW4373

Naveen Gupta (1):
  brcmfmac: update 43012 F2 watermark setting to fix DMA Error during
UDP RX Traffic

Winnie Chang (1):
  brcmfmac: add 4354 raw pcie device id

Wright Feng (2):
  brcmfmac: set F2 watermark to 256 for 4373
  brcmfmac: disable command decode in sdio_aos

 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  |   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/chip.c|  33 --
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c|   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c| 119 ++---
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.h|   3 +
 .../broadcom/brcm80211/include/brcm_hw_ids.h   |   2 +
 include/linux/mmc/sdio_ids.h   |   1 +
 7 files changed, 139 insertions(+), 21 deletions(-)

-- 
2.1.0



[PATCH 05/12] staging: wilc1000: use enum contants for mac status & added 'WILC_' prefix

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Clubbed mac status constants inside the enum constant and also added
'WILC_' prefix to have better namespace.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 15 ---
 drivers/staging/wilc1000/linux_wlan.c |  4 ++--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   |  8 +---
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c200d90..46b1a00 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -797,7 +797,8 @@ static void handle_connect(struct work_struct *work)
}
 
conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP,
- _info, MAC_STATUS_DISCONNECTED,
+ _info,
+ WILC_MAC_STATUS_DISCONNECTED,
  NULL, conn_attr->arg);
hif_drv->hif_state = HOST_IF_IDLE;
kfree(conn_info.req_ies);
@@ -857,7 +858,7 @@ static void handle_connect_timeout(struct work_struct *work)
 
hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
  ,
- MAC_STATUS_DISCONNECTED,
+ WILC_MAC_STATUS_DISCONNECTED,
  NULL,
  hif_drv->usr_conn_req.arg);
 
@@ -1286,7 +1287,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
 
memset(_info, 0, sizeof(struct connect_info));
 
-   if (mac_status == MAC_STATUS_CONNECTED) {
+   if (mac_status == WILC_MAC_STATUS_CONNECTED) {
u32 assoc_resp_info_len;
 
memset(hif_drv->assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
@@ -1311,7 +1312,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
if (hif_drv->usr_conn_req.bssid) {
memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6);
 
-   if (mac_status == MAC_STATUS_CONNECTED &&
+   if (mac_status == WILC_MAC_STATUS_CONNECTED &&
conn_info.status == WLAN_STATUS_SUCCESS) {
memcpy(hif_drv->assoc_bssid,
   hif_drv->usr_conn_req.bssid, ETH_ALEN);
@@ -1331,7 +1332,7 @@ static inline void host_int_parse_assoc_resp_info(struct 
wilc_vif *vif,
  _info, mac_status, NULL,
  hif_drv->usr_conn_req.arg);
 
-   if (mac_status == MAC_STATUS_CONNECTED &&
+   if (mac_status == WILC_MAC_STATUS_CONNECTED &&
conn_info.status == WLAN_STATUS_SUCCESS) {
wilc_set_power_mgmt(vif, 0, 0);
 
@@ -1423,10 +1424,10 @@ static void handle_rcvd_gnrl_async_info(struct 
work_struct *work)
mac_status  = rcvd_info->buffer[7];
if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
host_int_parse_assoc_resp_info(vif, mac_status);
-   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
+   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
   (hif_drv->hif_state == HOST_IF_CONNECTED)) {
host_int_handle_disconnect(vif);
-   } else if ((mac_status == MAC_STATUS_DISCONNECTED) &&
+   } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) &&
   (hif_drv->usr_scan_req.scan_result)) {
del_timer(_drv->scan_timer);
if (hif_drv->usr_scan_req.scan_result)
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 76c9012..274c4f6 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -162,7 +162,7 @@ void wilc_mac_indicate(struct wilc *wilc)
s8 status;
 
wilc_wlan_cfg_get_val(wilc, WID_STATUS, , 1);
-   if (wilc->mac_status == MAC_STATUS_INIT) {
+   if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
wilc->mac_status = status;
complete(>sync_event);
} else {
@@ -624,7 +624,7 @@ static int wilc_wlan_initialize(struct net_device *dev, 
struct wilc_vif *vif)
struct wilc *wl = vif->wilc;
 
if (!wl->initialized) {
-   wl->mac_status = MAC_STATUS_INIT;
+   wl->mac_status = WILC_MAC_STATUS_INIT;
wl->close = 0;
 
wlan_init_locks(dev);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 

[PATCH 08/12] staging: wilc1000: move current_tx_rate enum to wilc_wlan_if.h file

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Move 'current_tx_rate' enum to wilc_wlan_if.h, to have it along with the
other FW related to constants. Also added prefix to have a better
namespace.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 16 
 drivers/staging/wilc1000/linux_wlan.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   | 16 
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index fefbce6..91e60e3 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -127,22 +127,6 @@ struct host_if_pmkid_attr {
struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
 };
 
-enum current_tx_rate {
-   AUTORATE= 0,
-   MBPS_1  = 1,
-   MBPS_2  = 2,
-   MBPS_5_5= 5,
-   MBPS_11 = 11,
-   MBPS_6  = 6,
-   MBPS_9  = 9,
-   MBPS_12 = 12,
-   MBPS_18 = 18,
-   MBPS_24 = 24,
-   MBPS_36 = 36,
-   MBPS_48 = 48,
-   MBPS_54 = 54
-};
-
 struct cfg_param_attr {
u32 flag;
u16 short_retry_limit;
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index c4787bb..faf97df 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -342,7 +342,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = AUTORATE;
+   c_val[0] = WILC_FW_TX_RATE_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto fail;
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index c7e745d..36d6905 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -193,6 +193,22 @@ enum {
WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */
 };
 
+enum {
+   WILC_FW_TX_RATE_AUTO = 0,
+   WILC_FW_TX_RATE_MBPS_1 = 1,
+   WILC_FW_TX_RATE_MBPS_2 = 2,
+   WILC_FW_TX_RATE_MBPS_5_5 = 5,
+   WILC_FW_TX_RATE_MBPS_11 = 11,
+   WILC_FW_TX_RATE_MBPS_6 = 6,
+   WILC_FW_TX_RATE_MBPS_9 = 9,
+   WILC_FW_TX_RATE_MBPS_12 = 12,
+   WILC_FW_TX_RATE_MBPS_18 = 18,
+   WILC_FW_TX_RATE_MBPS_24 = 24,
+   WILC_FW_TX_RATE_MBPS_36 = 36,
+   WILC_FW_TX_RATE_MBPS_48 = 48,
+   WILC_FW_TX_RATE_MBPS_54 = 54
+};
+
 enum wid_type {
WID_CHAR= 0,
WID_SHORT   = 1,
-- 
2.7.4



[PATCH 11/12] staging: wilc1000: use ENOBUFS error code instead of WILC_TX_ERR_NO_BUF macro

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of 'ENOBUFS' instead of WILC_TX_ERR_NO_BUF macro. The value of
WILC_TX_ERR_NO_BUF is -2, which is confusing with ENOENT error code.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c   | 2 +-
 drivers/staging/wilc1000/wilc_wlan.c| 2 +-
 drivers/staging/wilc1000/wilc_wlan_if.h | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 96d8834..66fb988 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -242,7 +242,7 @@ static int linux_wlan_txq_task(void *vp)
if (netif_queue_stopped(wl->vif[1]->ndev))
netif_wake_queue(wl->vif[1]->ndev);
}
-   } while (ret == WILC_TX_ERR_NO_BUF && !wl->close);
+   } while (ret == -ENOBUFS && !wl->close);
}
return 0;
 }
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 563ce62..f0b10e2 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -611,7 +611,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
goto out_release_bus;
 
if (entries == 0) {
-   ret = WILC_TX_ERR_NO_BUF;
+   ret = -ENOBUFS;
goto out_release_bus;
}
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index f4f6ac6..e2310d8 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -41,8 +41,6 @@ struct tx_complete_data {
 
 typedef void (*wilc_tx_complete_func_t)(void *, int);
 
-#define WILC_TX_ERR_NO_BUF (-2)
-
 /
  *
  *  Wlan Configuration ID
-- 
2.7.4



[PATCH 06/12] staging: wilc1000: restructure macros used to handle security type

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Restructure the code to have a proper namespace for macro defined to
handle the security types. Move them as part of wilc_wlan_if.h header as
along with other macro defined for firmware.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/linux_wlan.c |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 43 +--
 drivers/staging/wilc1000/wilc_wlan_if.h   | 29 ++-
 3 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 274c4f6..6f0a2cd 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -391,7 +391,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
+   c_val[0] = WILC_FW_SEC_NO;
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
goto fail;
 
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 9038f8c..4b04775 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -6,15 +6,6 @@
 
 #include "wilc_wfi_cfgoperations.h"
 
-#define NO_ENCRYPT 0
-#define ENCRYPT_ENABLEDBIT(0)
-#define WEPBIT(1)
-#define WEP_EXTENDED   BIT(2)
-#define WPABIT(3)
-#define WPA2   BIT(4)
-#define AESBIT(5)
-#define TKIP   BIT(6)
-
 #define FRAME_TYPE_ID  0
 #define ACTION_CAT_ID  24
 #define ACTION_SUBTYPE_ID  25
@@ -655,7 +646,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
int ret;
u32 i;
u32 sel_bssi_idx = UINT_MAX;
-   u8 security = NO_ENCRYPT;
+   u8 security = WILC_FW_SEC_NO;
enum authtype auth_type = ANY;
u32 cipher_group;
 
@@ -703,9 +694,9 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
 
cipher_group = sme->crypto.cipher_group;
-   if (cipher_group != NO_ENCRYPT) {
+   if (cipher_group != 0) {
if (cipher_group == WLAN_CIPHER_SUITE_WEP40) {
-   security = ENCRYPT_ENABLED | WEP;
+   security = WILC_FW_SEC_WEP;
 
priv->wep_key_len[sme->key_idx] = sme->key_len;
memcpy(priv->wep_key[sme->key_idx], sme->key,
@@ -715,7 +706,7 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len,
 sme->key_idx);
} else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) {
-   security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+   security = WILC_FW_SEC_WEP_EXTENDED;
 
priv->wep_key_len[sme->key_idx] = sme->key_len;
memcpy(priv->wep_key[sme->key_idx], sme->key,
@@ -726,14 +717,14 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
 sme->key_idx);
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
-   security = ENCRYPT_ENABLED | WPA2 | TKIP;
+   security = WILC_FW_SEC_WPA2_TKIP;
else
-   security = ENCRYPT_ENABLED | WPA2 | AES;
+   security = WILC_FW_SEC_WPA2_AES;
} else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
if (cipher_group == WLAN_CIPHER_SUITE_TKIP)
-   security = ENCRYPT_ENABLED | WPA | TKIP;
+   security = WILC_FW_SEC_WPA_TKIP;
else
-   security = ENCRYPT_ENABLED | WPA | AES;
+   security = WILC_FW_SEC_WPA_AES;
} else {
ret = -ENOTSUPP;
netdev_err(dev, "%s: Unsupported cipher\n",
@@ -748,9 +739,9 @@ static int connect(struct wiphy *wiphy, struct net_device 
*dev,
u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i];
 
if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP)
-   security = security | TKIP;
+   security |= WILC_FW_TKIP;
else
-   security = security | AES;
+   security |= 

[PATCH 04/12] staging: wilc1000: move sdio_cmd52 & sdio_cmd53 struct to source file

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Moved sdio_cmd52 & sdio_cmd53 struct from wilc_wlan_if.h, as its used in
wilc_sdio.cfile.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/wilc_sdio.c| 19 +++
 drivers/staging/wilc1000/wilc_wlan_if.h | 19 ---
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_sdio.c 
b/drivers/staging/wilc1000/wilc_sdio.c
index ca351c9..779614e 100644
--- a/drivers/staging/wilc1000/wilc_sdio.c
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -30,6 +30,25 @@ struct wilc_sdio {
int has_thrpt_enh3;
 };
 
+struct sdio_cmd52 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 raw:1;
+   u32 address:17;
+   u32 data:   8;
+};
+
+struct sdio_cmd53 {
+   u32 read_write: 1;
+   u32 function:   3;
+   u32 block_mode: 1;
+   u32 increment:  1;
+   u32 address:17;
+   u32 count:  9;
+   u8 *buffer;
+   u32 block_size;
+};
+
 static const struct wilc_hif_func wilc_hif_sdio;
 
 static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data);
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index 4f258bf..dc40743 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -24,25 +24,6 @@
  *
  /
 
-struct sdio_cmd52 {
-   u32 read_write: 1;
-   u32 function:   3;
-   u32 raw:1;
-   u32 address:17;
-   u32 data:   8;
-};
-
-struct sdio_cmd53 {
-   u32 read_write: 1;
-   u32 function:   3;
-   u32 block_mode: 1;
-   u32 increment:  1;
-   u32 address:17;
-   u32 count:  9;
-   u8 *buffer;
-   u32 block_size;
-};
-
 #define MAC_STATUS_INIT-1
 #define MAC_STATUS_CONNECTED   1
 #define MAC_STATUS_DISCONNECTED0
-- 
2.7.4



[PATCH 07/12] staging: wilc1000: use proper namespace for macros in wilc_wlan_if.h header

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename the macros defined in wilc_wlan_if.h header to have clear
namespace. As convention used 'WILC_FW_' prefix for constants defined for
firmware and 'WILC_' prefix for driver constants.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c |   6 +-
 drivers/staging/wilc1000/linux_wlan.c |  32 +++---
 drivers/staging/wilc1000/wilc_sdio.c  |   3 +-
 drivers/staging/wilc1000/wilc_spi.c   |   2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  14 +--
 drivers/staging/wilc1000/wilc_wlan.c  |  88 +++
 drivers/staging/wilc1000/wilc_wlan_if.h   | 128 +++---
 7 files changed, 138 insertions(+), 135 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 46b1a00..4dfdc7c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -684,7 +684,7 @@ static void handle_connect(struct work_struct *work)
cur_byte[conn_attr->ssid_len] = '\0';
}
cur_byte += MAX_SSID_LEN;
-   *(cur_byte++) = INFRASTRUCTURE;
+   *(cur_byte++) = WILC_FW_BSS_TYPE_INFRA;
 
if (conn_attr->ch >= 1 && conn_attr->ch <= 14) {
*(cur_byte++) = conn_attr->ch;
@@ -2321,9 +2321,9 @@ static void handle_power_management(struct work_struct 
*work)
wid.id = WID_POWER_MANAGEMENT;
 
if (pm_param->enabled)
-   power_mode = MIN_FAST_PS;
+   power_mode = WILC_FW_MIN_FAST_PS;
else
-   power_mode = NO_POWERSAVE;
+   power_mode = WILC_FW_NO_POWERSAVE;
 
wid.val = _mode;
wid.size = sizeof(char);
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 6f0a2cd..c4787bb 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -338,7 +338,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = INFRASTRUCTURE;
+   c_val[0] = WILC_FW_BSS_TYPE_INFRA;
if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto fail;
 
@@ -346,7 +346,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = G_MIXED_11B_2_MODE;
+   c_val[0] = WILC_FW_OPER_MODE_G_MIXED_11B_2;
if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
   0))
goto fail;
@@ -355,19 +355,19 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = G_SHORT_PREAMBLE;
+   c_val[0] = WILC_FW_PREAMBLE_SHORT;
if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = AUTO_PROT;
+   c_val[0] = WILC_FW_11N_PROT_AUTO;
if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = ACTIVE_SCAN;
+   c_val[0] = WILC_FW_ACTIVE_SCAN;
if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = SITE_SURVEY_OFF;
+   c_val[0] = WILC_FW_SITE_SURVEY_OFF;
if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
goto fail;
 
@@ -387,7 +387,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NO_POWERSAVE;
+   c_val[0] = WILC_FW_NO_POWERSAVE;
if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto fail;
 
@@ -395,7 +395,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = OPEN_SYSTEM;
+   c_val[0] = WILC_FW_AUTH_OPEN_SYSTEM;
if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
goto fail;
 
@@ -429,7 +429,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
goto fail;
 
-   c_val[0] = NORMAL_ACK;
+   c_val[0] = WILC_FW_ACK_POLICY_NORMAL;
if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0))
goto fail;
 
@@ -452,7 +452,7 @@ static int linux_wlan_init_test_config(struct net_device 
*dev,
if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
goto fail;
 
-   c_val[0] = REKEY_DISABLE;
+   c_val[0] = 

[PATCH 12/12] staging: wilc1000: rename tsf_hi element of network_info struct

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename 'tsf_hi' element in network_info struct as it's not used to store
only the higher 32-bit value but the complete 64-bit tsf value.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 8 
 drivers/staging/wilc1000/host_interface.h | 2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 5ab426c..3f3b013 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1098,14 +1098,14 @@ static s32 wilc_parse_network_info(u8 *msg_buffer,
if (ieee80211_is_probe_resp(mgt->frame_control)) {
info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info);
info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
+   info->tsf = le64_to_cpu(mgt->u.probe_resp.timestamp);
+   info->tsf_lo = (u32)info->tsf;
offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
} else if (ieee80211_is_beacon(mgt->frame_control)) {
info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info);
info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int);
-   info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp);
-   info->tsf_lo = (u32)info->tsf_hi;
+   info->tsf = le64_to_cpu(mgt->u.beacon.timestamp);
+   info->tsf_lo = (u32)info->tsf;
offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
} else {
/* only process probe response and beacon frame */
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 606e80a..8279345 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -76,7 +76,7 @@ struct network_info {
u16 ies_len;
void *join_params;
struct rssi_history_buffer rssi_history;
-   u64 tsf_hi;
+   u64 tsf;
 };
 
 struct connect_info {
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 9906a9f7..1dec6bb 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -193,7 +193,7 @@ static void refresh_scan(struct wilc_priv *priv, bool 
direct_scan)
  channel,
  CFG80211_BSS_FTYPE_UNKNOWN,
  network_info->bssid,
- network_info->tsf_hi,
+ network_info->tsf,
  network_info->cap_info,
  network_info->beacon_period,
  (const u8 *)network_info->ies,
@@ -308,7 +308,7 @@ static void add_network_to_shadow(struct network_info 
*nw_info,
shadow_nw_info->beacon_period = nw_info->beacon_period;
shadow_nw_info->dtim_period = nw_info->dtim_period;
shadow_nw_info->ch = nw_info->ch;
-   shadow_nw_info->tsf_hi = nw_info->tsf_hi;
+   shadow_nw_info->tsf = nw_info->tsf;
if (ap_found != -1)
kfree(shadow_nw_info->ies);
shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len,
@@ -372,7 +372,7 @@ static void cfg_scan_result(enum scan_event scan_event,
  channel,
  CFG80211_BSS_FTYPE_UNKNOWN,
  network_info->bssid,
- network_info->tsf_hi,
+ network_info->tsf,
  network_info->cap_info,
  network_info->beacon_period,
  (const u8 *)network_info->ies,
-- 
2.7.4



[PATCH 09/12] staging: wilc1000: rename firmware related constants to follow better namespace

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Rename the firmware related macro by prefix with 'WILC_FW_' prefix for
a better namespace. Also, move them to wilc_wlan_if.h file along with other
FW related macros.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c |  4 ++--
 drivers/staging/wilc1000/host_interface.h |  6 --
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  8 
 drivers/staging/wilc1000/wilc_wlan_if.h   | 12 
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 4dfdc7c..c238d39 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3485,11 +3485,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg)
 
switch (frame_type) {
case IEEE80211_STYPE_ACTION:
-   msg->body.reg_frame.reg_id = ACTION_FRM_IDX;
+   msg->body.reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX;
break;
 
case IEEE80211_STYPE_PROBE_REQ:
-   msg->body.reg_frame.reg_id = PROBE_REQ_IDX;
+   msg->body.reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX;
break;
 
default:
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 91e60e3..610ca2b 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -15,13 +15,7 @@
 #define GO_MODE0x03
 #define CLIENT_MODE0x04
 
-#define ACTION_FRM_IDX 0
-#define PROBE_REQ_IDX  1
 #define MAX_NUM_STA9
-#define DEFAULT_SCAN   0
-#define USER_SCAN  BIT(0)
-#define OBSS_PERIODIC_SCAN BIT(1)
-#define OBSS_ONETIME_SCAN  BIT(2)
 #define ADDKEY 0x1
 #define REMOVEKEY  0x2
 #define DEFAULTKEY 0x4
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index b882fe9..4cfa3ff4 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -612,15 +612,15 @@ static int scan(struct wiphy *wiphy, struct 
cfg80211_scan_request *request)
 _ntwk))
return -ENOMEM;
 
-   ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN,
-   scan_ch_list,
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
request->n_channels,
(const u8 *)request->ie,
request->ie_len, cfg_scan_result,
(void *)priv, _ntwk);
} else {
-   ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN,
-   scan_ch_list,
+   ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+   WILC_FW_ACTIVE_SCAN, scan_ch_list,
request->n_channels,
(const u8 *)request->ie,
request->ie_len, cfg_scan_result,
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h 
b/drivers/staging/wilc1000/wilc_wlan_if.h
index 36d6905..f4f6ac6 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -209,6 +209,18 @@ enum {
WILC_FW_TX_RATE_MBPS_54 = 54
 };
 
+enum {
+   WILC_FW_DEFAULT_SCAN = 0,
+   WILC_FW_USER_SCAN = BIT(0),
+   WILC_FW_OBSS_PERIODIC_SCAN = BIT(1),
+   WILC_FW_OBSS_ONETIME_SCAN = BIT(2)
+};
+
+enum {
+   WILC_FW_ACTION_FRM_IDX = 0,
+   WILC_FW_PROBE_REQ_IDX = 1
+};
+
 enum wid_type {
WID_CHAR= 0,
WID_SHORT   = 1,
-- 
2.7.4



[PATCH 10/12] staging: wilc1000: added 'WILC_' prefix for constants to have clear namespace

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

For better namespace added 'WILC_' prefix for driver specific constants.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 162 +++---
 drivers/staging/wilc1000/host_interface.h |  59 
 drivers/staging/wilc1000/linux_wlan.c |  20 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c |  56 
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   8 +-
 drivers/staging/wilc1000/wilc_wlan.c  |   4 +-
 6 files changed, 159 insertions(+), 150 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c238d39..5ab426c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -94,7 +94,7 @@ struct set_multicast {
 };
 
 struct del_all_sta {
-   u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
+   u8 del_all_sta[WILC_MAX_NUM_STA][ETH_ALEN];
u8 assoc_sta;
 };
 
@@ -242,7 +242,7 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc 
*wilc, int idx)
 {
int index = idx - 1;
 
-   if (index < 0 || index >= NUM_CONCURRENT_IFC)
+   if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC)
return NULL;
 
return wilc->vif[index];
@@ -261,7 +261,7 @@ static void handle_set_channel(struct work_struct *work)
wid.val = (char *)_set_ch->set_ch;
wid.size = sizeof(char);
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, , 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -284,7 +284,7 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
 
hif_drv = vif->hif_drv;
 
-   buffer = kzalloc(DRV_HANDLER_SIZE, GFP_KERNEL);
+   buffer = kzalloc(WILC_DRV_HANDLER_SIZE, GFP_KERNEL);
if (!buffer)
goto free_msg;
 
@@ -302,9 +302,9 @@ static void handle_set_wfi_drv_handler(struct work_struct 
*work)
wid.id = WID_SET_DRV_HANDLER;
wid.type = WID_STR;
wid.val = (s8 *)buffer;
-   wid.size = DRV_HANDLER_SIZE;
+   wid.size = WILC_DRV_HANDLER_SIZE;
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, , 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1,
   hif_drv->driver_handler_id);
if (ret)
netdev_err(vif->ndev, "Failed to set driver handler\n");
@@ -331,7 +331,7 @@ static void handle_set_operation_mode(struct work_struct 
*work)
wid.val = (s8 *)_op_mode->mode;
wid.size = sizeof(u32);
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, , 1,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -353,7 +353,7 @@ static void handle_get_mac_address(struct work_struct *work)
wid.val = get_mac_addr->mac_addr;
wid.size = ETH_ALEN;
 
-   ret = wilc_send_config_pkt(vif, GET_CFG, , 1,
+   ret = wilc_send_config_pkt(vif, WILC_GET_CFG, , 1,
   wilc_get_vif_idx(vif));
 
if (ret)
@@ -371,28 +371,28 @@ static void handle_cfg_param(struct work_struct *work)
struct wid wid_list[32];
int i = 0;
 
-   if (param->flag & RETRY_SHORT) {
+   if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) {
wid_list[i].id = WID_SHORT_RETRY_LIMIT;
wid_list[i].val = (s8 *)>short_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & RETRY_LONG) {
+   if (param->flag & WILC_CFG_PARAM_RETRY_LONG) {
wid_list[i].id = WID_LONG_RETRY_LIMIT;
wid_list[i].val = (s8 *)>long_retry_limit;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & FRAG_THRESHOLD) {
+   if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) {
wid_list[i].id = WID_FRAG_THRESHOLD;
wid_list[i].val = (s8 *)>frag_threshold;
wid_list[i].type = WID_SHORT;
wid_list[i].size = sizeof(u16);
i++;
}
-   if (param->flag & RTS_THRESHOLD) {
+   if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) {
wid_list[i].id = WID_RTS_THRESHOLD;
wid_list[i].val = (s8 *)>rts_threshold;
wid_list[i].type = WID_SHORT;
@@ -400,7 +400,7 @@ static void handle_cfg_param(struct work_struct *work)
i++;
}
 
-   ret = wilc_send_config_pkt(vif, SET_CFG, wid_list,
+   ret = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
   i, wilc_get_vif_idx(vif));
 
if (ret)
@@ -424,7 +424,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum 
scan_event evt)
wid.val = (s8 

[PATCH 01/12] staging: wilc1000: use macro from ieee80211.h in register frame api's

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of ieee80211.h provided macros and removed the extra macro
defined for the same purpose.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 3 ---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 2bf91df..eb13b41 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3483,11 +3483,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 
frame_type, bool reg)
return;
 
switch (frame_type) {
-   case ACTION:
+   case IEEE80211_STYPE_ACTION:
msg->body.reg_frame.reg_id = ACTION_FRM_IDX;
break;
 
-   case PROBE_REQ:
+   case IEEE80211_STYPE_PROBE_REQ:
msg->body.reg_frame.reg_id = PROBE_REQ_IDX;
break;
 
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 523b46b..0185fc6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -14,9 +14,6 @@
 #define STATION_MODE   0x02
 #define GO_MODE0x03
 #define CLIENT_MODE0x04
-#define ACTION 0xD0
-#define PROBE_REQ  0x40
-#define PROBE_RESP 0x50
 
 #define ACTION_FRM_IDX 0
 #define PROBE_REQ_IDX  1
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index a6f4fad..f92ecf6c 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1700,12 +1700,12 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, 
struct wireless_dev *wdev,
return;
 
switch (frame_type) {
-   case PROBE_REQ:
+   case IEEE80211_STYPE_PROBE_REQ:
vif->frame_reg[0].type = frame_type;
vif->frame_reg[0].reg = reg;
break;
 
-   case ACTION:
+   case IEEE80211_STYPE_ACTION:
vif->frame_reg[1].type = frame_type;
vif->frame_reg[1].reg = reg;
break;
-- 
2.7.4



[PATCH 00/12] staging: wilc1000: better namespace for constants and cleanup

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

This patch series contains changes to address the review feedback
comments [1]. It mainly contains the changes to have clear names for
the constants. Most of the constants names are taken care, few are left
unchanged in hope with another cleanup those macros might be deleted. After
further cleanup will revisit if anything else is required to address this.

[1]. - https://www.spinics.net/lists/linux-wireless/msg178706.html
 - https://www.spinics.net/lists/linux-wireless/msg178704.html

Ajay Singh (12):
  staging: wilc1000: use macro from ieee80211.h in register frame api's
  staging: wilc1000: use WLAN_PMKID_LEN macro from ieee80211.h header
  staging: wilc1000: remove unused macros and struct members in
host_interface.h
  staging: wilc1000: move sdio_cmd52 & sdio_cmd53 struct to source file
  staging: wilc1000: use enum contants for mac status & added 'WILC_'
prefix
  staging: wilc1000: restructure macros used to handle security type
  staging: wilc1000: use proper namespace for macros in wilc_wlan_if.h
header
  staging: wilc1000: move current_tx_rate enum to wilc_wlan_if.h file
  staging: wilc1000: rename firmware related constants to follow better
namespace
  staging: wilc1000: added 'WILC_' prefix for constants to have clear
namespace
  staging: wilc1000: use ENOBUFS error code instead of
WILC_TX_ERR_NO_BUF macro
  staging: wilc1000: rename tsf_hi element of network_info struct

 drivers/staging/wilc1000/host_interface.c | 203 ++---
 drivers/staging/wilc1000/host_interface.h | 100 --
 drivers/staging/wilc1000/linux_wlan.c |  62 ---
 drivers/staging/wilc1000/wilc_sdio.c  |  22 ++-
 drivers/staging/wilc1000/wilc_spi.c   |   2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 133 +++---
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |   9 +-
 drivers/staging/wilc1000/wilc_wlan.c  |  94 +-
 drivers/staging/wilc1000/wilc_wlan_if.h   | 212 --
 9 files changed, 421 insertions(+), 416 deletions(-)

-- 
2.7.4



[PATCH 02/12] staging: wilc1000: use WLAN_PMKID_LEN macro from ieee80211.h header

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Make use of WLAN_PMKID_LEN macro provided by ieee80211.h header instead
of PMKID_LEN.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 drivers/staging/wilc1000/host_interface.h | 3 +--
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++--
 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 -
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index eb13b41..c200d90 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1460,7 +1460,7 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, 
struct key_attr *hif_key)
memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1),
   hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1),
-  hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
+  hif_key->attr.pmkid.pmkidlist[i].pmkid, WLAN_PMKID_LEN);
}
 
wid.id = WID_PMKID_INFO;
@@ -2793,7 +2793,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif,
memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid,
   >pmkidlist[i].bssid, ETH_ALEN);
memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].pmkid,
-  >pmkidlist[i].pmkid, PMKID_LEN);
+  >pmkidlist[i].pmkid, WLAN_PMKID_LEN);
}
 
result = wilc_enqueue_work(msg);
diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 0185fc6..3d31153 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -46,7 +46,6 @@
 
 #define PMKSA_KEY_LEN  22
 #define ETH_ALEN   6
-#define PMKID_LEN  16
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
 #define NUM_CONCURRENT_IFC 2
@@ -128,7 +127,7 @@ enum host_if_state {
 
 struct host_if_pmkid {
u8 bssid[ETH_ALEN];
-   u8 pmkid[PMKID_LEN];
+   u8 pmkid[WLAN_PMKID_LEN];
 };
 
 struct host_if_pmkid_attr {
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index f92ecf6c..7b753c1 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1217,7 +1217,7 @@ static int set_pmksa(struct wiphy *wiphy, struct 
net_device *netdev,
memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
   ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
-  PMKID_LEN);
+  WLAN_PMKID_LEN);
if (!(flag == PMKID_FOUND))
priv->pmkid_list.numpmkid++;
} else {
@@ -1254,7 +1254,7 @@ static int del_pmksa(struct wiphy *wiphy, struct 
net_device *netdev,
   ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
   priv->pmkid_list.pmkidlist[i + 1].pmkid,
-  PMKID_LEN);
+  WLAN_PMKID_LEN);
}
priv->pmkid_list.numpmkid--;
} else {
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index 4f05a16..6283d9e 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -22,7 +22,6 @@
 #define FLOW_CONTROL_UPPER_THRESHOLD   256
 
 #define WILC_MAX_NUM_PMKIDS16
-#define PMKID_LEN  16
 #define PMKID_FOUND1
 #define NUM_STA_ASSOCIATED 8
 
-- 
2.7.4



[PATCH 03/12] staging: wilc1000: remove unused macros and struct members in host_interface.h

2018-11-11 Thread Ajay.Kathat
From: Ajay Singh 

Cleanup patch to remove the unused macros and struct members in
host_interface.h header file.

Signed-off-by: Ajay Singh 
---
 drivers/staging/wilc1000/host_interface.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 3d31153..fefbce6 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -18,15 +18,10 @@
 #define ACTION_FRM_IDX 0
 #define PROBE_REQ_IDX  1
 #define MAX_NUM_STA9
-#define ACTIVE_SCAN_TIME   10
-#define PASSIVE_SCAN_TIME  1200
-#define MIN_SCAN_TIME  10
-#define MAX_SCAN_TIME  1200
 #define DEFAULT_SCAN   0
 #define USER_SCAN  BIT(0)
 #define OBSS_PERIODIC_SCAN BIT(1)
 #define OBSS_ONETIME_SCAN  BIT(2)
-#define GTK_RX_KEY_BUFF_LEN24
 #define ADDKEY 0x1
 #define REMOVEKEY  0x2
 #define DEFAULTKEY 0x4
@@ -34,18 +29,15 @@
 #define MAX_NUM_SCANNED_NETWORKS   100
 #define MAX_NUM_SCANNED_NETWORKS_SHADOW130
 #define MAX_NUM_PROBED_SSID10
-#define CHANNEL_SCAN_TIME  250
 
 #define TX_MIC_KEY_LEN 8
 #define RX_MIC_KEY_LEN 8
 #define PTK_KEY_LEN16
 
-#define TX_MIC_KEY_MSG_LEN 26
 #define RX_MIC_KEY_MSG_LEN 48
 #define PTK_KEY_MSG_LEN39
 
 #define PMKSA_KEY_LEN  22
-#define ETH_ALEN   6
 #define WILC_MAX_NUM_PMKIDS16
 #define WILC_ADD_STA_LENGTH40
 #define NUM_CONCURRENT_IFC 2
@@ -153,12 +145,10 @@ enum current_tx_rate {
 
 struct cfg_param_attr {
u32 flag;
-   u8 ht_enable;
u16 short_retry_limit;
u16 long_retry_limit;
u16 frag_threshold;
u16 rts_threshold;
-   u8 scan_source;
 };
 
 enum cfg_param {
@@ -166,7 +156,6 @@ enum cfg_param {
RETRY_LONG  = BIT(1),
FRAG_THRESHOLD  = BIT(2),
RTS_THRESHOLD   = BIT(3),
-   HT_ENABLE   = BIT(18),
 };
 
 struct found_net_info {
-- 
2.7.4



Re: [PATCH 1/5] brcmfmac: set apsta to 1 when AP start on primary interface.

2018-11-11 Thread Wright Feng


On 2018/11/9 下午 08:48, Arend van Spriel wrote:
> On 11/8/2018 4:48 AM, Chi-Hsien Lin wrote:
>> From: Wright Feng 
>>
>> APSTA can work on two band concurrently with using VSDB(Virtual
>> Simultaneous Dual-Band) or RSDB(Real Simultaneous Dual-Band) features.
>> In this case, we have to keep apsta is 1 in firmware side. However, if
>> we start wpa_supplicant on wlan0 and then start hostapd on wlan 1, the
>> apsta will be set to 0, and we will see data stall on wlan0(station)
>> So that, we only set apsta to 1 when AP start on primary interface.
> 
> The description makes my head spin. From reading the commit message I 
> think the code should add a !VSDB check instead of dropping the !RSDB 
> check. Would you agree?
> 
> Regards,
> Arend
I will revise the commit message as below and add two checks (!MCHAN and 
!RSDB)in v2. Let me know if you have concern about that.

When starting station mode on wlan0 and AP mode on wlan1, the
apsta will be disabled and cause data stall on wlan0(station)
The apsta feature with MCHAN(Multi-Channel Concurrent) or RSDB(Real
Simultaneous Dual-Band) can make STA+AP work on two bands concurrently.
Because of that, we keep apsta enabled if firmware supports MCHAN or
RSDB features.

- Wright
> 
>> Signed-off-by: Wright Feng 
>> Signed-off-by: Chi-Hsien Lin 
>> ---
>>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
> 


Re: [PATCH 2/5] brcmfmac: remove "arp_hostip_clear" from "brcmf_netdev_stop"

2018-11-11 Thread Wright Feng


On 2018/11/9 上午 03:19, Franky Lin wrote:
> On Wed, Nov 7, 2018 at 7:48 PM Chi-Hsien Lin  
> wrote:
>>
>> From: Wright Feng 
>>
>> The firmware does not respond ARP request and causes ping failure with
>> following steps:
>>
>> 1. Bring up interface
>> ifconfig wlan0 up or start wpa_supplicant
>> 2. Set the IP address
>> ifconfig wlan0 192.168.100.10
>> 3. Bring down interface or
>> ifconfig wlan0 down or kill wpa_supplicant
>> 4. Bring up interface again and set the same IP address
>> 5. Connect to AP(192.168.100.1) and ping to AP will be failed.
>>
>> FMAC clears arp_hostip when bringing down the interface, but not set it
>> back if setting the same IP address. We are able to see the IP address
>> in interface info(inconfig wlan0) but the ping still cannot work because
>> the firmware ARP offload does not respond the ARP request.
>> Because of that, we remove "arp_hostip_clear" from function
>> "brcmf_netdev_stop"
> 
> Shouldn't brcmf_inetaddr_changed get called when the interface up again?
> 
> Thanks,
> - Franky
> 
The brcmf_inetaddr_changed only be called in inet_del_ifa and
inet_insert_ifa. If the IP address is not changed when the interface up
again, the brcmf_inetaddr_changed will not be called.

-Wright
>>
>> Signed-off-by: Wright Feng 
>> Signed-off-by: Chi-Hsien Lin 
>> ---
>>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
>> index b1f702faff4f..e1666cf3801c 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
>> @@ -533,8 +533,6 @@ static int brcmf_netdev_stop(struct net_device *ndev)
>>
>>  brcmf_cfg80211_down(ndev);
>>
>> -   brcmf_fil_iovar_data_set(ifp, "arp_hostip_clear", NULL, 0);
>> -
>>  brcmf_net_setcarrier(ifp, false);
>>
>>  return 0;
>> --
>> 2.1.0
>>
> 
> 
> --
> 
> You're receiving this message because you're a member of the 
> brcm80211-dev-list group.
> 


[PATCH 01/16] iwlwifi: dbg: don't limit dump decisions to all or monitor

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

Currently opmode is limited to asking transport to either
dump all the dumps configured at startup, or monitor only.
Instead, pass to transport a bitmask, to allow flexibility.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   |  7 +++--
 .../net/wireless/intel/iwlwifi/iwl-trans.h|  7 ++---
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  1 -
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 31 +--
 4 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 58a980070445..67e6a35f14c4 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -908,6 +908,7 @@ void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt)
struct iwl_fw_error_dump_file *dump_file;
struct scatterlist *sg_dump_data;
u32 file_len;
+   u32 dump_mask = fwrt->fw->dbg.dump_mask;
 
IWL_DEBUG_INFO(fwrt, "WRT dump start\n");
 
@@ -927,8 +928,10 @@ void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt)
goto out;
}
 
-   fw_error_dump->trans_ptr = iwl_trans_dump_data(fwrt->trans,
-  fwrt->dump.monitor_only);
+   if (fwrt->dump.monitor_only)
+   dump_mask &= IWL_FW_ERROR_DUMP_FW_MONITOR;
+
+   fw_error_dump->trans_ptr = iwl_trans_dump_data(fwrt->trans, dump_mask);
file_len = le32_to_cpu(dump_file->file_len);
fw_error_dump->fwrt_len = file_len;
if (fw_error_dump->trans_ptr) {
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index f384a98a021c..b0300e824815 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -602,7 +602,7 @@ struct iwl_trans_ops {
void (*resume)(struct iwl_trans *trans);
 
struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans,
-bool monitor_only);
+u32 dump_mask);
 };
 
 /**
@@ -776,7 +776,6 @@ struct iwl_trans {
const struct iwl_fw_dbg_dest_tlv_v1 *dbg_dest_tlv;
const struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX];
struct iwl_fw_dbg_trigger_tlv * const *dbg_trigger_tlv;
-   u32 dbg_dump_mask;
u8 dbg_n_dest_reg;
int num_blocks;
struct iwl_dram_data fw_mon[IWL_MAX_DEBUG_ALLOCATIONS];
@@ -896,11 +895,11 @@ static inline void iwl_trans_resume(struct iwl_trans 
*trans)
 }
 
 static inline struct iwl_trans_dump_data *
-iwl_trans_dump_data(struct iwl_trans *trans, bool monitor_only)
+iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask)
 {
if (!trans->ops->dump_data)
return NULL;
-   return trans->ops->dump_data(trans, monitor_only);
+   return trans->ops->dump_data(trans, dump_mask);
 }
 
 static inline struct iwl_device_cmd *
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 2291661dd72d..0a5b35312b59 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -769,7 +769,6 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct 
iwl_cfg *cfg,
memcpy(trans->dbg_conf_tlv, mvm->fw->dbg.conf_tlv,
   sizeof(trans->dbg_conf_tlv));
trans->dbg_trigger_tlv = mvm->fw->dbg.trigger_tlv;
-   trans->dbg_dump_mask = mvm->fw->dbg.dump_mask;
 
trans->iml = mvm->fw->iml;
trans->iml_len = mvm->fw->iml_len;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 551ce439647b..16eed9b0f301 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2990,7 +2990,7 @@ static int iwl_trans_get_fw_monitor_len(struct iwl_trans 
*trans, int *len)
 
 static struct iwl_trans_dump_data
 *iwl_trans_pcie_dump_data(struct iwl_trans *trans,
- bool monitor_only)
+ u32 dump_mask)
 {
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
struct iwl_fw_error_dump_data *data;
@@ -3002,7 +3002,10 @@ static struct iwl_trans_dump_data
int i, ptr;
bool dump_rbs = test_bit(STATUS_FW_ERROR, >status) &&
!trans->cfg->mq_rx_supported &&
-   trans->dbg_dump_mask & BIT(IWL_FW_ERROR_DUMP_RB);
+   dump_mask & BIT(IWL_FW_ERROR_DUMP_RB);
+
+   if (!dump_mask)
+   return NULL;
 
/* transport dump header */
len = sizeof(*dump_data);
@@ -3014,11 +3017,7 @@ static struct iwl_trans_dump_data
/* FW monitor */
monitor_len = iwl_trans_get_fw_monitor_len(trans, );
 
-  

[PATCH 00/16] iwlwifi: updates intended for v4.21 2018-11-11

2018-11-11 Thread Luca Coelho
From: Luca Coelho 

Hi,

Here's the second set of patches intended for v4.21.  It's the usual
development, with some small new features, cleanups and bugfixes.

The changes are:

* New FW debugging infrastructure;
* Some more work on 802.11ax;
* Improve support for multiple RF modules with 22000 devices;
* Remove an unused FW parameter;
* Other debugging improvements;

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.


Emmanuel Grumbach (2):
  iwlwifi: mvm: remove assignment of the reciprocal
  iwlwifi: mvm: add support for TWT capabilities

Lior Cohen (2):
  iwlwifi: add fw dump upon RT ucode start failure
  iwlwifi: add debugfs file to read fw debug data recording

Luca Coelho (1):
  iwlwifi: fix cfg structs for 22000 with different RF modules

Sara Sharon (8):
  iwlwifi: dbg: don't limit dump decisions to all or monitor
  iwlwifi: dbg: split fifos dump
  iwlwifi: fw: add FW API of new TLV infrastructure
  iwlwifi: trans: parse and store debug ini TLVs
  iwlwifi: trans: support loading ini TLVs from external file
  iwlwifi: dbg: disable triggers for ini
  iwlwifi: dbg: add apply point logic
  iwlwifi: fw: support API change to debug TLVs

Shaul Triebitz (3):
  iwlwifi: mvm: set MAC_FILTER_IN_11AX in AP mode
  iwlwifi: mvm: send the STA_HE_CTXT command in AP mode
  iwlwifi: mvm: set HW capability VHT_EXT_NSS_BW

 drivers/net/wireless/intel/iwlwifi/Makefile   |   1 +
 .../net/wireless/intel/iwlwifi/cfg/22000.c|   1 -
 .../wireless/intel/iwlwifi/fw/api/dbg-tlv.h   | 401 ++
 .../net/wireless/intel/iwlwifi/fw/api/mac.h   |  39 +-
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   | 277 +++-
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h   |  22 +
 drivers/net/wireless/intel/iwlwifi/fw/file.h  |   7 +
 drivers/net/wireless/intel/iwlwifi/fw/img.h   |  26 ++
 .../net/wireless/intel/iwlwifi/fw/runtime.h   |   3 +
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.c  | 230 ++
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.h  |  87 
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |  24 +-
 .../wireless/intel/iwlwifi/iwl-modparams.h|   2 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|  23 +-
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   |   5 +
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  39 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |   4 +
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |   1 -
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |   2 +-
 .../wireless/intel/iwlwifi/pcie/internal.h|  44 ++
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 213 +-
 21 files changed, 1374 insertions(+), 77 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
 create mode 100644 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
 create mode 100644 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.h

-- 
2.19.1



[PATCH 02/16] iwlwifi: dbg: split fifos dump

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

Split the dump of RXF and TXF. This is in order to
enable code reuse for INI, which may decide to dump
only RXF and not TXF, and vice versa.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 52 +++--
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 67e6a35f14c4..6243b503d0b0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -225,17 +225,13 @@ static void iwl_fwrt_dump_txf(struct iwl_fw_runtime *fwrt,
*dump_data = iwl_fw_error_next_data(*dump_data);
 }
 
-static void iwl_fw_dump_fifos(struct iwl_fw_runtime *fwrt,
- struct iwl_fw_error_dump_data **dump_data)
+static void iwl_fw_dump_rxf(struct iwl_fw_runtime *fwrt,
+   struct iwl_fw_error_dump_data **dump_data)
 {
-   struct iwl_fw_error_dump_fifo *fifo_hdr;
struct iwl_fwrt_shared_mem_cfg *cfg = >smem_cfg;
-   u32 *fifo_data;
-   u32 fifo_len;
unsigned long flags;
-   int i, j;
 
-   IWL_DEBUG_INFO(fwrt, "WRT FIFO dump\n");
+   IWL_DEBUG_INFO(fwrt, "WRT RX FIFO dump\n");
 
if (!iwl_trans_grab_nic_access(fwrt->trans, ))
return;
@@ -254,6 +250,24 @@ static void iwl_fw_dump_fifos(struct iwl_fw_runtime *fwrt,
  LMAC2_PRPH_OFFSET, 2);
}
 
+   iwl_trans_release_nic_access(fwrt->trans, );
+}
+
+static void iwl_fw_dump_txf(struct iwl_fw_runtime *fwrt,
+   struct iwl_fw_error_dump_data **dump_data)
+{
+   struct iwl_fw_error_dump_fifo *fifo_hdr;
+   struct iwl_fwrt_shared_mem_cfg *cfg = >smem_cfg;
+   u32 *fifo_data;
+   u32 fifo_len;
+   unsigned long flags;
+   int i, j;
+
+   IWL_DEBUG_INFO(fwrt, "WRT TX FIFO dump\n");
+
+   if (!iwl_trans_grab_nic_access(fwrt->trans, ))
+   return;
+
if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_TXF)) {
/* Pull TXF data from LMAC1 */
for (i = 0; i < fwrt->smem_cfg.num_txfifo_entries; i++) {
@@ -595,8 +609,8 @@ static void iwl_fw_dump_mem(struct iwl_fw_runtime *fwrt,
do {size_t item = item_len; len += (!!item) * const_len + item; } \
while (0)
 
-static int iwl_fw_fifo_len(struct iwl_fw_runtime *fwrt,
-  struct iwl_fwrt_shared_mem_cfg *mem_cfg)
+static int iwl_fw_rxf_len(struct iwl_fw_runtime *fwrt,
+ struct iwl_fwrt_shared_mem_cfg *mem_cfg)
 {
size_t hdr_len = sizeof(struct iwl_fw_error_dump_data) +
 sizeof(struct iwl_fw_error_dump_fifo);
@@ -604,7 +618,7 @@ static int iwl_fw_fifo_len(struct iwl_fw_runtime *fwrt,
int i;
 
if (!iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RXF))
-   goto dump_txf;
+   return 0;
 
/* Count RXF2 size */
ADD_LEN(fifo_len, mem_cfg->rxfifo2_size, hdr_len);
@@ -613,7 +627,17 @@ static int iwl_fw_fifo_len(struct iwl_fw_runtime *fwrt,
for (i = 0; i < mem_cfg->num_lmacs; i++)
ADD_LEN(fifo_len, mem_cfg->lmac[i].rxfifo1_size, hdr_len);
 
-dump_txf:
+   return fifo_len;
+}
+
+static int iwl_fw_txf_len(struct iwl_fw_runtime *fwrt,
+ struct iwl_fwrt_shared_mem_cfg *mem_cfg)
+{
+   size_t hdr_len = sizeof(struct iwl_fw_error_dump_data) +
+sizeof(struct iwl_fw_error_dump_fifo);
+   u32 fifo_len = 0;
+   int i;
+
if (!iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_TXF))
goto dump_internal_txf;
 
@@ -697,7 +721,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
 
/* reading RXF/TXF sizes */
if (test_bit(STATUS_FW_ERROR, >trans->status)) {
-   fifo_len = iwl_fw_fifo_len(fwrt, mem_cfg);
+   fifo_len = iwl_fw_rxf_len(fwrt, mem_cfg);
+   fifo_len += iwl_fw_txf_len(fwrt, mem_cfg);
 
/* Make room for PRPH registers */
if (!fwrt->trans->cfg->gen2 &&
@@ -817,7 +842,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
 
/* We only dump the FIFOs if the FW is in error state */
if (fifo_len) {
-   iwl_fw_dump_fifos(fwrt, _data);
+   iwl_fw_dump_rxf(fwrt, _data);
+   iwl_fw_dump_txf(fwrt, _data);
if (radio_len)
iwl_read_radio_regs(fwrt, _data);
}
-- 
2.19.1



[PATCH 06/16] iwlwifi: mvm: add support for TWT capabilities

2018-11-11 Thread Luca Coelho
From: Emmanuel Grumbach 

We need to check the TWT support of the peer and to
propagte the capability to the firmware.
The current implementation will enable TWT only if the TWT
support is advertised in the HE CAP IE and in the Extended
Capability IE.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/fw/api/mac.h   | 16 +
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 24 ++-
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
index d0b79fb461bf..2c9e40eedef5 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
@@ -185,6 +185,14 @@ struct iwl_mac_data_ibss {
__le32 beacon_template;
 } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
 
+/**
+ * enum iwl_mac_data_policy - policy of the data path for this MAC
+ * @TWT_SUPPORTED: twt is supported
+ */
+enum iwl_mac_data_policy {
+   TWT_SUPPORTED   = BIT(0),
+};
+
 /**
  * struct iwl_mac_data_sta - configuration data for station MAC context
  * @is_assoc: 1 for associated state, 0 otherwise
@@ -193,7 +201,7 @@ struct iwl_mac_data_ibss {
  * @bi: beacon interval in TU, applicable only when associated
  * @reserved1: reserved
  * @dtim_interval: DTIM interval in TU, applicable only when associated
- * @reserved2: reserved
+ * @data_policy: see  iwl_mac_data_policy
  * @listen_interval: in beacon intervals, applicable only when associated
  * @assoc_id: unique ID assigned by the AP during association
  * @assoc_beacon_arrive_time: TSF of first beacon after association
@@ -205,11 +213,11 @@ struct iwl_mac_data_sta {
__le32 bi;
__le32 reserved1;
__le32 dtim_interval;
-   __le32 reserved2;
+   __le32 data_policy;
__le32 listen_interval;
__le32 assoc_id;
__le32 assoc_beacon_arrive_time;
-} __packed; /* STA_MAC_DATA_API_S_VER_1 */
+} __packed; /* STA_MAC_DATA_API_S_VER_2 */
 
 /**
  * struct iwl_mac_data_go - configuration data for P2P GO MAC context
@@ -233,7 +241,7 @@ struct iwl_mac_data_go {
 struct iwl_mac_data_p2p_sta {
struct iwl_mac_data_sta sta;
__le32 ctwin;
-} __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
+} __packed; /* P2P_STA_MAC_DATA_API_S_VER_2 */
 
 /**
  * struct iwl_mac_data_pibss - Pseudo IBSS config data
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 3b93293d4559..990ebf89f342 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -777,8 +777,30 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
 
if (vif->bss_conf.assoc && vif->bss_conf.he_support &&
-   !iwlwifi_mod_params.disable_11ax)
+   !iwlwifi_mod_params.disable_11ax) {
+   struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+   u8 sta_id = mvmvif->ap_sta_id;
+
cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX);
+   if (sta_id != IWL_MVM_INVALID_STA) {
+   struct ieee80211_sta *sta;
+
+   sta = 
rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
+   lockdep_is_held(>mutex));
+
+   /*
+* TODO: we should check the ext cap IE but it is
+* unclear why the spec requires two bits (one in HE
+* cap IE, and one in the ext cap IE). In the meantime
+* rely on the HE cap IE only.
+*/
+   if (sta && (sta->he_cap.he_cap_elem.mac_cap_info[0] &
+   IEEE80211_HE_MAC_CAP0_TWT_RES))
+   ctxt_sta->data_policy |=
+   cpu_to_le32(TWT_SUPPORTED);
+   }
+   }
+
 
return iwl_mvm_mac_ctxt_send_cmd(mvm, );
 }
-- 
2.19.1



[PATCH 08/16] iwlwifi: trans: parse and store debug ini TLVs

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

The new debug ini TLVs can be either packed into firmware
binary or written in external file. Support loading them
from both. Store the data per apply point. Apply point is
a point during driver runtime, where the TLV becomes active.
For example, a trigger of hardware error may be configured
to collect a subset of data pre-alive, as a opposed to HW
error that occurs after alive.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/Makefile   |   1 +
 drivers/net/wireless/intel/iwlwifi/fw/file.h  |   7 +
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.c  | 154 ++
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.h  |  84 ++
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |  17 ++
 .../wireless/intel/iwlwifi/iwl-modparams.h|   2 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|   4 +
 7 files changed, 269 insertions(+)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
 create mode 100644 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.h

diff --git a/drivers/net/wireless/intel/iwlwifi/Makefile 
b/drivers/net/wireless/intel/iwlwifi/Makefile
index 04e376cc898c..ff41987a7e35 100644
--- a/drivers/net/wireless/intel/iwlwifi/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/Makefile
@@ -11,6 +11,7 @@ iwlwifi-objs  += pcie/ctxt-info.o 
pcie/ctxt-info-gen3.o
 iwlwifi-objs   += pcie/trans-gen2.o pcie/tx-gen2.o
 iwlwifi-$(CONFIG_IWLDVM) += cfg/1000.o cfg/2000.o cfg/5000.o cfg/6000.o
 iwlwifi-$(CONFIG_IWLMVM) += cfg/7000.o cfg/8000.o cfg/9000.o cfg/22000.o
+iwlwifi-objs   += iwl-dbg-tlv.o
 iwlwifi-objs   += iwl-trans.o
 iwlwifi-objs   += fw/notif-wait.o
 iwlwifi-$(CONFIG_IWLMVM) += fw/paging.o fw/smem.o fw/init.o fw/dbg.o
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h 
b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 6005a41c53d1..81f557c0b58d 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -91,6 +91,8 @@ struct iwl_ucode_header {
} u;
 };
 
+#define IWL_UCODE_INI_TLV_GROUPBIT(24)
+
 /*
  * new TLV uCode file layout
  *
@@ -141,6 +143,11 @@ enum iwl_ucode_tlv_type {
IWL_UCODE_TLV_FW_GSCAN_CAPA = 50,
IWL_UCODE_TLV_FW_MEM_SEG= 51,
IWL_UCODE_TLV_IML   = 52,
+   IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION= IWL_UCODE_INI_TLV_GROUP | 0x1,
+   IWL_UCODE_TLV_TYPE_HCMD = IWL_UCODE_INI_TLV_GROUP | 0x2,
+   IWL_UCODE_TLV_TYPE_REGIONS  = IWL_UCODE_INI_TLV_GROUP | 0x3,
+   IWL_UCODE_TLV_TYPE_TRIGGERS = IWL_UCODE_INI_TLV_GROUP | 0x4,
+   IWL_UCODE_TLV_TYPE_DEBUG_FLOW   = IWL_UCODE_INI_TLV_GROUP | 0x5,
 
/* TLVs 0x1000-0x2000 are for internal driver usage */
IWL_UCODE_TLV_FW_DBG_DUMP_LST   = 0x1000,
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
new file mode 100644
index ..acefd7d5d099
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
@@ -0,0 +1,154 @@
+/**
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright (C) 2018 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless 
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright (C) 2018 Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *contributors may be used to endorse or promote products derived
+ *from 

[PATCH 07/16] iwlwifi: fw: add FW API of new TLV infrastructure

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

Add the FW API of the new debug infrastructure. Next patches
will introduce the utilization of this infra.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../wireless/intel/iwlwifi/fw/api/dbg-tlv.h   | 399 ++
 1 file changed, 399 insertions(+)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
new file mode 100644
index ..82f3c9bbd9b1
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
@@ -0,0 +1,399 @@
+/**
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright (C) 2018 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ *  Intel Linux Wireless 
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright (C) 2018 Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ifndef __iwl_fw_dbg_tlv_h__
+#define __iwl_fw_dbg_tlv_h__
+
+#include 
+
+/*
+ * struct iwl_fw_ini_header: Common Header for all debug group TLV's structures
+ * @tlv_version: version info
+ * @apply_point:  iwl_fw_ini_apply_point
+ * @data: TLV data followed
+ **/
+struct iwl_fw_ini_header {
+   __le32 tlv_version;
+   __le32 apply_point;
+   u8 data[];
+} __packed; /* FW_INI_HEADER_TLV_S */
+
+/**
+ * struct iwl_fw_ini_allocation_tlv - (IWL_FW_INI_TLV_TYPE_BUFFER_ALLOCATION)
+ * buffer allocation TLV - for debug
+ *
+ * @iwl_fw_ini_header: header
+ * @allocation_id:  iwl_fw_ini_allocation_id - to bind allocation and hcmd
+ * if needed (DBGC1/DBGC2/SDFX/...)
+ * @buffer_location: type of iwl_fw_ini_buffer_location
+ * @size: size in bytes
+ * @max_fragments: the maximum allowed fragmentation in the desired memory
+ * allocation above
+ * @min_frag_size: the minimum allowed fragmentation size in bytes
+*/
+struct iwl_fw_ini_allocation_tlv {
+   struct iwl_fw_ini_header header;
+   __le32 allocation_id;
+   __le32 buffer_location;
+   __le32 size;
+   __le32 max_fragments;
+   __le32 min_frag_size;
+} __packed; /* FW_INI_BUFFER_ALLOCATION_TLV_S_VER_1 */
+
+/**
+ * struct iwl_fw_ini_hcmd (IWL_FW_INI_TLV_TYPE_HCMD)
+ * Generic Host command pass through TLV
+ *
+ * @id: the debug configuration command type for instance: 0xf6 / 0xf5 / DHC
+ * @group: the desired cmd group
+ * @padding: all zeros for dword alignment
+ * @data: all of the relevant command (0xf6/0xf5) to be sent
+*/
+struct iwl_fw_ini_hcmd {
+   u8 id;
+   u8 group;
+   __le16 padding;
+   u8 data[0];
+} __packed; 

[PATCH 09/16] iwlwifi: trans: support loading ini TLVs from external file

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

Support loading and storing ini TLVs from external
file. Those TLVs are appended to the default TLVs,
so store them separately.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.c  | 81 +--
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.h  |  7 +-
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |  9 ++-
 .../net/wireless/intel/iwlwifi/iwl-trans.h|  3 +
 4 files changed, 89 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
index acefd7d5d099..7b2951521c77 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
@@ -63,7 +63,8 @@
 #include "iwl-trans.h"
 #include "iwl-dbg-tlv.h"
 
-void iwl_fw_dbg_copy_tlv(struct iwl_trans *trans, struct iwl_ucode_tlv *tlv)
+void iwl_fw_dbg_copy_tlv(struct iwl_trans *trans, struct iwl_ucode_tlv *tlv,
+bool ext)
 {
struct iwl_apply_point_data *data;
struct iwl_fw_ini_header *header = (void *)>data[0];
@@ -75,7 +76,10 @@ void iwl_fw_dbg_copy_tlv(struct iwl_trans *trans, struct 
iwl_ucode_tlv *tlv)
  "Invalid apply point id %d\n", apply_point))
return;
 
-   data = >apply_points[apply_point];
+   if (ext)
+   data = >apply_points_ext[apply_point];
+   else
+   data = >apply_points[apply_point];
 
/*
 * Make sure we still have room to copy this TLV. Offset points to the
@@ -90,7 +94,8 @@ void iwl_fw_dbg_copy_tlv(struct iwl_trans *trans, struct 
iwl_ucode_tlv *tlv)
data->offset += copy_size;
 }
 
-void iwl_alloc_dbg_tlv(struct iwl_trans *trans, size_t len, const u8 *data)
+void iwl_alloc_dbg_tlv(struct iwl_trans *trans, size_t len, const u8 *data,
+  bool ext)
 {
struct iwl_ucode_tlv *tlv;
u32 size[IWL_FW_INI_APPLY_NUM] = {0};
@@ -137,8 +142,13 @@ void iwl_alloc_dbg_tlv(struct iwl_trans *trans, size_t 
len, const u8 *data)
return;
}
 
-   trans->apply_points[i].data = mem;
-   trans->apply_points[i].size = size[i];
+   if (ext) {
+   trans->apply_points_ext[i].data = mem;
+   trans->apply_points_ext[i].size = size[i];
+   } else {
+   trans->apply_points[i].data = mem;
+   trans->apply_points[i].size = size[i];
+   }
}
 }
 
@@ -150,5 +160,66 @@ void iwl_fw_dbg_free(struct iwl_trans *trans)
kfree(trans->apply_points[i].data);
trans->apply_points[i].size = 0;
trans->apply_points[i].offset = 0;
+
+   kfree(trans->apply_points_ext[i].data);
+   trans->apply_points_ext[i].size = 0;
+   trans->apply_points_ext[i].offset = 0;
+   }
+}
+
+static int iwl_parse_fw_dbg_tlv(struct iwl_trans *trans, const u8 *data,
+   size_t len)
+{
+   struct iwl_ucode_tlv *tlv;
+   enum iwl_ucode_tlv_type tlv_type;
+   u32 tlv_len;
+
+   while (len >= sizeof(*tlv)) {
+   len -= sizeof(*tlv);
+   tlv = (void *)data;
+
+   tlv_len = le32_to_cpu(tlv->length);
+   tlv_type = le32_to_cpu(tlv->type);
+
+   if (len < tlv_len) {
+   IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
+   len, tlv_len);
+   return -EINVAL;
+   }
+   len -= ALIGN(tlv_len, 4);
+   data += sizeof(*tlv) + ALIGN(tlv_len, 4);
+
+   switch (tlv_type) {
+   case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION:
+   case IWL_UCODE_TLV_TYPE_HCMD:
+   case IWL_UCODE_TLV_TYPE_REGIONS:
+   case IWL_UCODE_TLV_TYPE_TRIGGERS:
+   case IWL_UCODE_TLV_TYPE_DEBUG_FLOW:
+   iwl_fw_dbg_copy_tlv(trans, tlv, true);
+   default:
+   WARN_ONCE(1, "Invalid TLV %x\n", tlv_type);
+   break;
+   }
}
+
+   return 0;
+}
+
+void iwl_load_fw_dbg_tlv(struct device *dev, struct iwl_trans *trans)
+{
+   const struct firmware *fw;
+   int res;
+
+   if (trans->external_ini_loaded || !iwlwifi_mod_params.enable_ini)
+   return;
+
+   res = request_firmware(, "iwl-dbg-tlv.ini", dev);
+   if (res)
+   return;
+
+   iwl_alloc_dbg_tlv(trans, fw->size, fw->data, true);
+   iwl_parse_fw_dbg_tlv(trans, fw->data, fw->size);
+
+   trans->external_ini_loaded = true;
+   release_firmware(fw);
 }
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.h
index a368017af089..222cd789e07a 100644
--- 

[PATCH 12/16] iwlwifi: add debugfs file to read fw debug data recording

2018-11-11 Thread Luca Coelho
From: Lior Cohen 

FW debug data will oneshot read all data available in DRAM
and fill the supplied user buffer. In case the read request
is greater than the new data in DRAM, the driver will write
all data it has and return the buffer immediately.

Signed-off-by: Shahar S Matityahu 
Signed-off-by: Lior Cohen 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h   |  14 ++
 drivers/net/wireless/intel/iwlwifi/iwl-drv.c  |   2 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|   5 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   |   3 +
 .../wireless/intel/iwlwifi/pcie/internal.h|  44 +
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 160 ++
 6 files changed, 228 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
index 6b3c5677c53a..ab81ea8b636f 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
@@ -266,6 +266,9 @@ _iwl_fw_dbg_stop_recording(struct iwl_trans *trans,
iwl_write_prph(trans, DBGC_IN_SAMPLE, 0);
udelay(100);
iwl_write_prph(trans, DBGC_OUT_CTRL, 0);
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+   trans->dbg_rec_on = false;
+#endif
 }
 
 static inline void
@@ -296,6 +299,14 @@ _iwl_fw_dbg_restart_recording(struct iwl_trans *trans,
}
 }
 
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+static inline void iwl_fw_set_dbg_rec_on(struct iwl_fw_runtime *fwrt)
+{
+   if (fwrt->fw->dbg.dest_tlv && fwrt->cur_fw_img == IWL_UCODE_REGULAR)
+   fwrt->trans->dbg_rec_on = true;
+}
+#endif
+
 static inline void
 iwl_fw_dbg_restart_recording(struct iwl_fw_runtime *fwrt,
 struct iwl_fw_dbg_params *params)
@@ -304,6 +315,9 @@ iwl_fw_dbg_restart_recording(struct iwl_fw_runtime *fwrt,
_iwl_fw_dbg_restart_recording(fwrt->trans, params);
else
iwl_fw_dbg_start_stop_hcmd(fwrt, true);
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+   iwl_fw_set_dbg_rec_on(fwrt);
+#endif
 }
 
 static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 7b98125e4eb9..a65ba955783d 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -1628,6 +1628,8 @@ void iwl_drv_stop(struct iwl_drv *drv)
mutex_unlock(_opmode_table_mtx);
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
+   drv->trans->ops->debugfs_cleanup(drv->trans);
+
debugfs_remove_recursive(drv->dbgfs_drv);
 #endif
 
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index c2531eae5e16..a7009cd4232d 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -536,6 +536,8 @@ struct iwl_trans_rxq_dma_data {
  * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing 
last
  * TX'ed commands and similar. The buffer will be vfree'd by the caller.
  * Note that the transport must fill in the proper file headers.
+ * @debugfs_cleanup: used in the driver unload flow to make a proper cleanup
+ * of the trans debugfs
  */
 struct iwl_trans_ops {
 
@@ -605,6 +607,7 @@ struct iwl_trans_ops {
 
struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans,
 u32 dump_mask);
+   void (*debugfs_cleanup)(struct iwl_trans *trans);
 };
 
 /**
@@ -734,6 +737,7 @@ struct iwl_dram_data {
  * @runtime_pm_mode: the runtime power management mode in use.  This
  * mode is set during the initialization phase and is not
  * supposed to change during runtime.
+ * @dbg_rec_on: true iff there is a fw debug recording currently active
  */
 struct iwl_trans {
const struct iwl_trans_ops *ops;
@@ -790,6 +794,7 @@ struct iwl_trans {
enum iwl_plat_pm_mode system_pm_mode;
enum iwl_plat_pm_mode runtime_pm_mode;
bool suspending;
+   bool dbg_rec_on;
 
/* pointer to trans specific struct */
/*Ensure that this pointer will always be aligned to sizeof pointer */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 2cd07247e0a7..263b03b3ea66 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -377,6 +377,9 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm 
*mvm,
atomic_set(>mac80211_queue_stop_count[i], 0);
 
set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, >status);
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+   iwl_fw_set_dbg_rec_on(>fwrt);
+#endif
clear_bit(IWL_FWRT_STATUS_WAIT_ALIVE, >fwrt.status);
 
return 0;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h 
b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index f9c4c64dee66..0f816761ca45 100644
--- 

[PATCH 11/16] iwlwifi: dbg: add apply point logic

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

Add a function to be called when apply point occurs.
For each of the TLVs, the function will perform the
apply point logic:
- For HCMD - send the stored host command
- For buffer allocation - allocate the memory and send the
  buffer allocation command
- For trigger and region - update the stored configuration

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   | 207 ++
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h   |   4 +
 drivers/net/wireless/intel/iwlwifi/fw/img.h   |  26 +++
 .../net/wireless/intel/iwlwifi/fw/runtime.h   |   3 +
 .../net/wireless/intel/iwlwifi/iwl-dbg-tlv.c  |   3 +
 .../net/wireless/intel/iwlwifi/iwl-trans.h|   3 +-
 6 files changed, 244 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 6460b937d331..76050cc3532a 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -1263,3 +1263,210 @@ void iwl_fw_dbg_read_d3_debug_data(struct 
iwl_fw_runtime *fwrt)
 cfg->d3_debug_data_length);
 }
 IWL_EXPORT_SYMBOL(iwl_fw_dbg_read_d3_debug_data);
+
+static void
+iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt,
+struct iwl_fw_ini_allocation_tlv *alloc)
+{
+   struct iwl_trans *trans = fwrt->trans;
+   struct iwl_continuous_record_cmd cont_rec = {};
+   struct iwl_buffer_allocation_cmd *cmd = (void *)_rec.pad[0];
+   struct iwl_host_cmd hcmd = {
+   .id = LDBG_CONFIG_CMD,
+   .flags = CMD_ASYNC,
+   .data[0] = _rec,
+   .len[0] = sizeof(cont_rec),
+   };
+   void *virtual_addr = NULL;
+   u32 size = le32_to_cpu(alloc->size);
+   dma_addr_t phys_addr;
+
+   cont_rec.record_mode.enable_recording = cpu_to_le16(BUFFER_ALLOCATION);
+
+   if (!trans->num_blocks &&
+   le32_to_cpu(alloc->buffer_location) !=
+   IWL_FW_INI_LOCATION_DRAM_PATH)
+   return;
+
+   virtual_addr = dma_alloc_coherent(fwrt->trans->dev, size,
+ _addr, GFP_KERNEL);
+
+   /* TODO: alloc fragments if needed */
+   if (!virtual_addr)
+   IWL_ERR(fwrt, "Failed to allocate debug memory\n");
+
+   if (WARN_ON_ONCE(trans->num_blocks == ARRAY_SIZE(trans->fw_mon)))
+   return;
+
+   trans->fw_mon[trans->num_blocks].block = virtual_addr;
+   trans->fw_mon[trans->num_blocks].physical = phys_addr;
+   trans->fw_mon[trans->num_blocks].size = size;
+   trans->num_blocks++;
+
+   IWL_DEBUG_FW(trans, "Allocated debug block of size %d\n", size);
+
+   /* First block is assigned via registers / context info */
+   if (trans->num_blocks == 1)
+   return;
+
+   cmd->num_frags = cpu_to_le32(1);
+   cmd->fragments[0].address = cpu_to_le64(phys_addr);
+   cmd->fragments[0].size = alloc->size;
+   cmd->allocation_id = alloc->allocation_id;
+   cmd->buffer_location = alloc->buffer_location;
+
+   iwl_trans_send_cmd(trans, );
+}
+
+static void iwl_fw_dbg_send_hcmd(struct iwl_fw_runtime *fwrt,
+struct iwl_ucode_tlv *tlv)
+{
+   struct iwl_fw_ini_hcmd_tlv *hcmd_tlv = (void *)>data[0];
+   struct iwl_fw_ini_hcmd *data = _tlv->hcmd;
+   u16 len = le32_to_cpu(tlv->length) - sizeof(*hcmd_tlv);
+
+   struct iwl_host_cmd hcmd = {
+   .id = WIDE_ID(data->group, data->id),
+   .len = { len, },
+   .data = { data->data, },
+   };
+
+   iwl_trans_send_cmd(fwrt->trans, );
+}
+
+static void iwl_fw_dbg_update_regions(struct iwl_fw_runtime *fwrt,
+ struct iwl_fw_ini_region_tlv *tlv,
+ bool ext, enum iwl_fw_ini_apply_point pnt)
+{
+   void *iter = (void *)tlv->region_config;
+   int i, size = le32_to_cpu(tlv->num_regions);
+
+   for (i = 0; i < size; i++) {
+   struct iwl_fw_ini_region_cfg *reg = iter;
+   int id = le32_to_cpu(reg->region_id);
+   struct iwl_fw_ini_active_regs *active;
+
+   if (WARN_ON(id >= ARRAY_SIZE(fwrt->dump.active_regs)))
+   break;
+
+   active = >dump.active_regs[id];
+
+   if (ext && active->apply_point == pnt)
+   IWL_WARN(fwrt->trans,
+"External region TLV overrides FW default 
%x\n",
+id);
+
+   IWL_DEBUG_FW(fwrt,
+"%s: apply point %d, activating region ID %d\n",
+__func__, pnt, id);
+
+   active->reg = reg;
+   active->apply_point = pnt;
+
+   if (le32_to_cpu(reg->region_type) !=
+   IWL_FW_INI_REGION_DRAM_BUFFER)
+   

[PATCH 14/16] iwlwifi: mvm: set MAC_FILTER_IN_11AX in AP mode

2018-11-11 Thread Luca Coelho
From: Shaul Triebitz 

In AP mode, if AP supports 11ax, add the MAC_FILTER_IN_11AX
flag in MAC_CTXT command (needed for various 11ax stuff).

Signed-off-by: Shaul Triebitz 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 990ebf89f342..e049d34a3553 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -1194,6 +1194,9 @@ static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm 
*mvm,
IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
}
 
+   if (vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax)
+   cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX);
+
ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
ctxt_ap->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
 vif->bss_conf.dtim_period);
-- 
2.19.1



[PATCH 10/16] iwlwifi: dbg: disable triggers for ini

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

When ini is loaded, disable all legacy trigger
configuration.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c  | 3 +++
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h  | 3 +++
 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 2 ++
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h   | 1 +
 4 files changed, 9 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index efd4ac5bba73..6460b937d331 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -1117,6 +1117,9 @@ int iwl_fw_dbg_collect_trig(struct iwl_fw_runtime *fwrt,
int ret, len = 0;
char buf[64];
 
+   if (fwrt->trans->ini_valid)
+   return 0;
+
if (fmt) {
va_list ap;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
index 544b42f9fb19..07403aa29793 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
@@ -192,6 +192,9 @@ _iwl_fw_dbg_trigger_on(struct iwl_fw_runtime *fwrt,
 {
struct iwl_fw_dbg_trigger_tlv *trig;
 
+   if (fwrt->trans->ini_valid)
+   return NULL;
+
if (!iwl_fw_dbg_trigger_enabled(fwrt->fw, id))
return NULL;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
index 7b2951521c77..0160662a1749 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
@@ -149,6 +149,8 @@ void iwl_alloc_dbg_tlv(struct iwl_trans *trans, size_t len, 
const u8 *data,
trans->apply_points[i].data = mem;
trans->apply_points[i].size = size[i];
}
+
+   trans->ini_valid = true;
}
 }
 
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 0c0cd7dccde8..3d455cf5822b 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -779,6 +779,7 @@ struct iwl_trans {
struct iwl_apply_point_data apply_points_ext[IWL_FW_INI_APPLY_NUM];
 
bool external_ini_loaded;
+   bool ini_valid;
 
const struct iwl_fw_dbg_dest_tlv_v1 *dbg_dest_tlv;
const struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX];
-- 
2.19.1



[PATCH 15/16] iwlwifi: mvm: send the STA_HE_CTXT command in AP mode

2018-11-11 Thread Luca Coelho
From: Shaul Triebitz 

In AP mode, if AP supports HE (and the STA), send the
STA_HE_CTXT command.

This is needed mainly for PPE (packet extension) params.

Signed-off-by: Shaul Triebitz 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 55b965629e33..64be5fa7eda3 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -2968,6 +2968,9 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
if (vif->type == NL80211_IFTYPE_AP) {
mvmvif->ap_assoc_sta_count++;
iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
+   if (vif->bss_conf.he_support &&
+   !iwlwifi_mod_params.disable_11ax)
+   iwl_mvm_cfg_he_sta(mvm, vif, mvm_sta->sta_id);
}
 
iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band,
-- 
2.19.1



[PATCH 16/16] iwlwifi: mvm: set HW capability VHT_EXT_NSS_BW

2018-11-11 Thread Luca Coelho
From: Shaul Triebitz 

Enable the VHT extended NSS BW feature in iwlwifi/mvm.

Signed-off-by: Shaul Triebitz 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 64be5fa7eda3..6fe48cc31071 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -419,6 +419,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
ieee80211_hw_set(hw, DEAUTH_NEED_MGD_TX_PREP);
+   ieee80211_hw_set(hw, SUPPORTS_VHT_EXT_NSS_BW);
 
if (iwl_mvm_has_tlc_offload(mvm)) {
ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW);
-- 
2.19.1



[PATCH 05/16] iwlwifi: add fw dump upon RT ucode start failure

2018-11-11 Thread Luca Coelho
From: Lior Cohen 

FW dump was missing in case the RT FW ucode
section failed to load. This failure happens when
the RT section of the FW file is corrupted.

Signed-off-by: Lior Cohen 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 8 
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h | 1 +
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 6243b503d0b0..efd4ac5bba73 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -998,6 +998,14 @@ const struct iwl_fw_dump_desc iwl_dump_desc_assert = {
 };
 IWL_EXPORT_SYMBOL(iwl_dump_desc_assert);
 
+void iwl_fw_assert_error_dump(struct iwl_fw_runtime *fwrt)
+{
+   IWL_INFO(fwrt, "error dump due to fw assert\n");
+   fwrt->dump.desc = _dump_desc_assert;
+   iwl_fw_error_dump(fwrt);
+}
+IWL_EXPORT_SYMBOL(iwl_fw_assert_error_dump);
+
 void iwl_fw_alive_error_dump(struct iwl_fw_runtime *fwrt)
 {
struct iwl_fw_dump_desc *iwl_dump_desc_no_alive =
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h 
b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
index 4a5fa05c7ac2..544b42f9fb19 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h
@@ -378,6 +378,7 @@ static inline void iwl_fw_resume_timestamp(struct 
iwl_fw_runtime *fwrt) {}
 
 #endif /* CONFIG_IWLWIFI_DEBUGFS */
 
+void iwl_fw_assert_error_dump(struct iwl_fw_runtime *fwrt);
 void iwl_fw_alive_error_dump(struct iwl_fw_runtime *fwrt);
 void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt);
 #endif  /* __iwl_fw_dbg_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index dade206d5511..2cd07247e0a7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -407,6 +407,7 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, 
bool read_nvm)
ret = iwl_mvm_load_ucode_wait_alive(mvm, IWL_UCODE_REGULAR);
if (ret) {
IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
+   iwl_fw_assert_error_dump(>fwrt);
goto error;
}
 
@@ -1024,6 +1025,7 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
ret = iwl_mvm_load_rt_fw(mvm);
if (ret) {
IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret);
+   iwl_fw_assert_error_dump(>fwrt);
goto error;
}
 
-- 
2.19.1



[PATCH 13/16] iwlwifi: fw: support API change to debug TLVs

2018-11-11 Thread Luca Coelho
From: Sara Sharon 

A new field was added. Since the code isn't operational (yet) no
need to worry about backward compatibility.

Signed-off-by: Sara Sharon 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
index 82f3c9bbd9b1..ab82b7a67967 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
@@ -180,6 +180,7 @@ struct iwl_fw_ini_region_tlv {
  * @occurrences: max amount of times to be fired
  * @ignore_consec: ignore consecutive triggers, in usec
  * @force_restart: force FW restart
+ * @multi_dut: initiate debug dump data on several DUTs
  * @trigger_data: generic data to be utilized per trigger
  * @num_regions: number of dump regions defined for this trigger
  * @data: region IDs
@@ -191,6 +192,7 @@ struct iwl_fw_ini_trigger {
__le32 occurrences;
__le32 ignore_consec;
__le32 force_restart;
+   __le32 multi_dut;
__le32 trigger_data;
__le32 num_regions;
__le32 data[];
-- 
2.19.1



[PATCH 04/16] iwlwifi: fix cfg structs for 22000 with different RF modules

2018-11-11 Thread Luca Coelho
From: Luca Coelho 

We have to choose different configuration and different firmwares
depending on the external RF module that is installed.  Since the
external module is not represented in the PCI IDs, we need to change
the configuration at runtime, after checking the RF ID of the module
installed.  We have a bit of a mess in the code that does this,
because it applies cfg's according to the RF ID only, ignoring the
integrated module that is in use.

Fix that for some devices by adding correct configurations for them
and not ignoring the integrated module's type when making the
decision.

Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/cfg/22000.c|  1 -
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c |  2 +-
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 22 +--
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c 
b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
index da5d5f9b2573..8b2339165bca 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
@@ -323,7 +323,6 @@ 
MODULE_FIRMWARE(IWL_22000_HR_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_22000_JF_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 
MODULE_FIRMWARE(IWL_22000_HR_A_F0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 
MODULE_FIRMWARE(IWL_22000_HR_B_F0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
-MODULE_FIRMWARE(IWL_22000_QU_B_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_22000_HR_B_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_22000_JF_B0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_22000_HR_A0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index 8d4711590dfc..353581ccc01e 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -882,7 +882,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0x34F0, 0x0040, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x34F0, 0x0070, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x34F0, 0x0078, iwl22000_2ax_cfg_hr)},
-   {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22000_2ac_cfg_jf)},
+   {IWL_PCI_DEVICE(0x34F0, 0x0310, iwl22000_2ax_cfg_hr)},
{IWL_PCI_DEVICE(0x40C0, 0x, iwl22560_2ax_cfg_su_cdb)},
{IWL_PCI_DEVICE(0x40C0, 0x0010, iwl22560_2ax_cfg_su_cdb)},
{IWL_PCI_DEVICE(0x40c0, 0x0090, iwl22560_2ax_cfg_su_cdb)},
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c 
b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 16eed9b0f301..231ec8131ee8 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -3401,8 +3401,26 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev 
*pdev,
 #if IS_ENABLED(CONFIG_IWLMVM)
trans->hw_rf_id = iwl_read32(trans, CSR_HW_RF_ID);
 
-   if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
-   CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) {
+   if (cfg == _2ax_cfg_hr) {
+   if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
+   CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) {
+   trans->cfg = _2ax_cfg_hr;
+   } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
+  CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_JF)) {
+   trans->cfg = _2ax_cfg_jf;
+   } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
+  CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HRCDB)) {
+   IWL_ERR(trans, "RF ID HRCDB is not supported\n");
+   ret = -EINVAL;
+   goto out_no_pci;
+   } else {
+   IWL_ERR(trans, "Unrecognized RF ID 0x%08x\n",
+   CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id));
+   ret = -EINVAL;
+   goto out_no_pci;
+   }
+   } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) ==
+  CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) {
u32 hw_status;
 
hw_status = iwl_read_prph(trans, UMAG_GEN_HW_STATUS);
-- 
2.19.1



[PATCH 03/16] iwlwifi: mvm: remove assignment of the reciprocal

2018-11-11 Thread Luca Coelho
From: Emmanuel Grumbach 

The firmware stopped looking at this field long ago.

Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 .../net/wireless/intel/iwlwifi/fw/api/mac.h   | 27 +++
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 12 -
 2 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h 
b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
index 1dd23f846fb9..d0b79fb461bf 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h
@@ -151,9 +151,9 @@ enum iwl_tsf_id {
  * @beacon_time: beacon transmit time in system time
  * @beacon_tsf: beacon transmit time in TSF
  * @bi: beacon interval in TU
- * @bi_reciprocal: 2^32 / bi
+ * @reserved1: reserved
  * @dtim_interval: dtim transmit time in TU
- * @dtim_reciprocal: 2^32 / dtim_interval
+ * @reserved2: reserved
  * @mcast_qid: queue ID for multicast traffic.
  * NOTE: obsolete from VER2 and on
  * @beacon_template: beacon template ID
@@ -162,9 +162,9 @@ struct iwl_mac_data_ap {
__le32 beacon_time;
__le64 beacon_tsf;
__le32 bi;
-   __le32 bi_reciprocal;
+   __le32 reserved1;
__le32 dtim_interval;
-   __le32 dtim_reciprocal;
+   __le32 reserved2;
__le32 mcast_qid;
__le32 beacon_template;
 } __packed; /* AP_MAC_DATA_API_S_VER_2 */
@@ -174,14 +174,14 @@ struct iwl_mac_data_ap {
  * @beacon_time: beacon transmit time in system time
  * @beacon_tsf: beacon transmit time in TSF
  * @bi: beacon interval in TU
- * @bi_reciprocal: 2^32 / bi
+ * @reserved: reserved
  * @beacon_template: beacon template ID
  */
 struct iwl_mac_data_ibss {
__le32 beacon_time;
__le64 beacon_tsf;
__le32 bi;
-   __le32 bi_reciprocal;
+   __le32 reserved;
__le32 beacon_template;
 } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
 
@@ -191,9 +191,9 @@ struct iwl_mac_data_ibss {
  * @dtim_time: DTIM arrival time in system time
  * @dtim_tsf: DTIM arrival time in TSF
  * @bi: beacon interval in TU, applicable only when associated
- * @bi_reciprocal: 2^32 / bi , applicable only when associated
+ * @reserved1: reserved
  * @dtim_interval: DTIM interval in TU, applicable only when associated
- * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
+ * @reserved2: reserved
  * @listen_interval: in beacon intervals, applicable only when associated
  * @assoc_id: unique ID assigned by the AP during association
  * @assoc_beacon_arrive_time: TSF of first beacon after association
@@ -203,9 +203,9 @@ struct iwl_mac_data_sta {
__le32 dtim_time;
__le64 dtim_tsf;
__le32 bi;
-   __le32 bi_reciprocal;
+   __le32 reserved1;
__le32 dtim_interval;
-   __le32 dtim_reciprocal;
+   __le32 reserved2;
__le32 listen_interval;
__le32 assoc_id;
__le32 assoc_beacon_arrive_time;
@@ -378,13 +378,6 @@ struct iwl_mac_ctx_cmd {
};
 } __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */
 
-static inline u32 iwl_mvm_reciprocal(u32 v)
-{
-   if (!v)
-   return 0;
-   return 0x / v;
-}
-
 #define IWL_NONQOS_SEQ_GET 0x1
 #define IWL_NONQOS_SEQ_SET 0x2
 struct iwl_nonqos_seq_query_cmd {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index b9c45a40e251..3b93293d4559 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -767,13 +767,8 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
}
 
ctxt_sta->bi = cpu_to_le32(vif->bss_conf.beacon_int);
-   ctxt_sta->bi_reciprocal =
-   cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
ctxt_sta->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
  vif->bss_conf.dtim_period);
-   ctxt_sta->dtim_reciprocal =
-   cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int *
-  vif->bss_conf.dtim_period));
 
ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval);
ctxt_sta->assoc_id = cpu_to_le32(vif->bss_conf.aid);
@@ -832,8 +827,6 @@ static int iwl_mvm_mac_ctxt_cmd_ibss(struct iwl_mvm *mvm,
 
/* cmd.ibss.beacon_time/cmd.ibss.beacon_tsf are curently ignored */
cmd.ibss.bi = cpu_to_le32(vif->bss_conf.beacon_int);
-   cmd.ibss.bi_reciprocal =
-   cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
 
/* TODO: Assumes that the beacon id == mac context id */
cmd.ibss.beacon_template = cpu_to_le32(mvmvif->id);
@@ -1180,13 +1173,8 @@ static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm 
*mvm,
}
 
ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
-   ctxt_ap->bi_reciprocal =
-   

Price Inquiry

2018-11-11 Thread Daniel Murray
Hi,friend,
 
This is Daniel Murray and i am from Sinara Group Co.Ltd Group Co.,LTD in Russia.
We are glad to know about your company from the web and we are interested in 
your products.
Could you kindly send us your Latest catalog and price list for our trial order.
 
Best Regards,
 
Daniel Murray
Purchasing Manager




Re: [PATCH 3/3] mac80211: Implement functionality to monitor station's signal stregnth

2018-11-11 Thread Tamizh chelvam

On 2018-11-09 17:25, Johannes Berg wrote:

Oh, umm, that patch is still here ...

I guess we can combine 2 and 3 too.



Sure.


+   if (sta->rssi_low && bss_conf->enable_beacon) {
+   int last_event =
+   sta->last_rssi_event_value;
+   int sig = -ewma_signal_read(>rx_stats_avg.signal);
+   int low = sta->rssi_low;
+   int high = sta->rssi_high;


This doesn't really support a list, like in patch 2 where you store
sta_info::rssi_tholds?

rssi_low and rssi_high will have a configured value or zero know ? 
Configured value has been stored in the previous patch.



+   if (sig < low &&
+   (last_event == 0 || last_event >= low)) {
+   sta->last_rssi_event_value = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
+   sig, GFP_ATOMIC);
+   rssi_cross = true;
+   } else if (sig > high &&
+  (last_event == 0 || last_event <= high)) {
+   sta->last_rssi_event_value = sig;
+   cfg80211_sta_mon_rssi_notify(
+   rx->sdata->dev, sta->addr,
+   NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
+   sig, GFP_ATOMIC);
+   rssi_cross = true;
+   }
+   }
+
+   if (rssi_cross) {
+   ieee80211_update_rssi_config(sta);
+   rssi_cross = false;
+   }
+}


Ah, but it does, just hard to understand.

However, this does mean what I suspected on the other patch is true -
you're calling ieee80211_update_rssi_config() here, and that uses the
sta->rssi_tholds array without any protection, while a concurrent 
change

of configuration can free the data.


yes, I'll add a protection mechanism.


You need to sort that out. I would suggest to stick all the sta->rssi_*
fields you add into a new struct (you even had an empty one), and
protect that struct using RCU. That also saves the memory in case it's
not assigned at all. Something like

struct sta_mon_rssi_config {
struct rcu_head rcu_head;
int n_thresholds;
s32 low, high;
u32 hyst;
s32 last_value;
s32 thresholds[];
};

then you can kfree_rcu() it, and just do a single allocation using
struct_size() for however many entries you need.


Yes correct. I'll change it.

+ * @count_rx_signal: Number of data frames used in averaging station 
signal.
+ *	This can be used to avoid generating less reliable station rssi 
cross

+ * events that would be based only on couple of received frames.
  */
 struct sta_info {
/* General information, mostly static */
@@ -600,6 +603,7 @@ struct sta_info {
s32 rssi_high;
u32 rssi_hyst;
s32 last_rssi_event_value;
+   unsigned int count_rx_signal;


I guess that would also move into the new struct.


Okay.

Thanks,
Tamizh.


Re: [PATCH 2/3] mac80211: Implement API to configure station specific rssi threshold

2018-11-11 Thread Tamizh chelvam

On 2018-11-09 17:19, Johannes Berg wrote:

On Mon, 2018-10-15 at 23:27 +0530, Tamizh chelvam wrote:


+   sta_mon_rssi_config_free(sta);
+   sta->rssi_hyst = rssi_hyst;
+   if (fixed_thold) {
+   if (n_rssi_tholds > 2) {
+   ret = -EINVAL;
+   goto out;
+   }


This might be slightly wrong, you free and then can still return an
error.


Sure. I'll move the free part after the validation check.


+   if (n_rssi_tholds == 1) {
+   sta->rssi_low = rssi_tholds[0];
+   sta->rssi_high = rssi_tholds[0];
+   } else {
+   sta->rssi_low = rssi_tholds[0];
+   sta->rssi_high = rssi_tholds[1];
+   }
+   } else {
+   const s32 *rssi_tholds;
+
+   rssi_tholds = kmemdup(rssi_tholds,
+ n_rssi_tholds * sizeof(s32),
+ GFP_KERNEL);
+   if (!rssi_tholds) {
+   ret = -ENOMEM;
+   goto out;
+   }


Similarly here, I guess you should do the allocation (and other error
checking) before freeing.


ditto, Sure. I'll move the free part after the validation check.


+   sta->rssi_tholds = rssi_tholds;
+   sta->n_rssi_tholds = n_rssi_tholds;
+   ieee80211_update_rssi_config(sta);





+struct sta_mon_rssi_config {
+};


Huh?

oops:( I have kept all configuring parameters in sta_info itself, 
mistakenly didn't remove this struct:(


The commit log also makes it sounds like mac80211 actually *supports*
this, but clearly that's not the case. However you don't give any data
to the driver either, did you lose a patch along the way? Previously 
you

had patch 5 ("mac80211: Implement functionality to monitor station's
rssi cross event") and if I remember correctly I said you should squash
some, but now that's not here?



Thanks,
Tamizh.


Re: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode

2018-11-11 Thread Tamizh chelvam




+   int (*set_sta_mon_rssi_config)(struct wiphy *wiphy,
+ struct net_device *dev,
+ const u8 *addr,
+ const s32 *rssi_tholds,
+ u32 rssi_hyst, int rssi_n_tholds,
+ bool fixed_thold);
 };


I think it might be better to pass all the last 4 arguments (rssi
related ones) as a struct? That's a pattern we typically have elsewhere
too, and it makes things easier to extend and also easier to pass
around.


Sure.

+ * @NL80211_CMD_SET_STA_MON: This command is used to configure 
station's

+ * connection monitoring notification trigger levels.
+ * @NL80211_CMD_NOTIFY_STA_MON: This is used as an event to notify
+ * the user space that a trigger level was reached for a station.


Please describe the attributes to use with this.


I'll add that in the next version of patchset



+ * @NL80211_ATTR_STA_MON_FIXED_THOLD: Flag attribute is used with
+ * %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring
+ * configuration is fixed limit or a moving range threshold.


This isn't really clear to me, what does it mean?

Sorry for not clear. This flag introduced to mention the driver that if 
this flag set then don't change the rssi_low and rssi_high limit upon
the station's rssi crossing the configured limit. Keep the rssi_low and 
rssi_high as a fixed limit.



+   if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC]))


Don't really need the parentheses in !(info->...)


Yes, I'll remove it.


+   err = nla_parse_nested(attrs, NL80211_ATTR_CQM_MAX, sta_mon,
+  nl80211_attr_cqm_policy, info->extack);


I *think* I made that a proper nested policy, check and then you can
remove passing it here.


Sure. I'll modify it in the next patchset version.


+void
+cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer,
+enum nl80211_cqm_rssi_threshold_event rssi_event,
+s32 rssi_level, gfp_t gfp)
+{
+   struct sk_buff *msg;
+
+   if (WARN_ON(!peer))
+   return;


Tracing for this might be nice too?


Sure.

Thanks,
Tamizh.


[RFC PATCH v2 1/2] nl80211/cfg80211: Add support for Extended Key ID

2018-11-11 Thread Alexander Wetzel
Extend cfg80211 and nl80211 to allow pairwise keys to be installed for
RX only, allowing to switching over TX independently, as required by
IEEE-802.11-2016 to support "Extended Key ID for Individually Addressed
Frames"

PTK and STK keys are now also allowed to use Key ID 1.

Signed-off-by: Alexander Wetzel 
---
 include/net/cfg80211.h   |  2 ++
 include/uapi/linux/nl80211.h | 41 ++---
 net/wireless/nl80211.c   | 51 
 net/wireless/rdev-ops.h  |  3 ++-
 net/wireless/trace.h | 31 ++
 net/wireless/util.c  |  9 ---
 6 files changed, 119 insertions(+), 18 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1fa41b7a1be3..0d59340563e0 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -485,6 +485,7 @@ struct vif_params {
  * with the get_key() callback, must be in little endian,
  * length given by @seq_len.
  * @seq_len: length of @seq.
+ * @flag: One flag from  key_params_flag
  */
 struct key_params {
const u8 *key;
@@ -492,6 +493,7 @@ struct key_params {
int key_len;
int seq_len;
u32 cipher;
+   enum key_params_flag flag;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 6d610bae30a9..d6c7fa72f433 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2254,6 +2254,14 @@ enum nl80211_commands {
  * @NL80211_ATTR_FTM_RESPONDER_STATS: Nested attribute with FTM responder
  * statistics, see  nl80211_ftm_responder_stats.
  *
+ * @NL80211_ATTR_KEY_RXONLY: Flag attribute to request RX key install only for
+ *  a pairwise key. Only supported for keyid's 0 and 1 when driver is
+ *  supporting Extended Key ID.
+ *
+ * @NL80211_ATTR_KEY_SETTX: Flag attribute to switch TX to a specified keyid.
+ *  Only supported for keyid's 0 and 1 when driver is supporting Extended
+ *  Key ID.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2699,6 +2707,9 @@ enum nl80211_attrs {
 
NL80211_ATTR_FTM_RESPONDER_STATS,
 
+   NL80211_ATTR_KEY_RXONLY,
+   NL80211_ATTR_KEY_SETTX,
+
/* add attributes here, update the policy in nl80211.c */
 
__NL80211_ATTR_AFTER_LAST,
@@ -4056,6 +4067,22 @@ enum nl80211_channel_type {
NL80211_CHAN_HT40PLUS
 };
 
+/**
+ * enum key_params_flag - additional key flag for drivers
+ *
+ * Actions other than @NL80211_KEY_DEFAULT_RX_TX are only required from drivers
+ * supporting Extended Key ID for pairwise keys using keyid 0 or 1.
+ *
+ * @NL80211_KEY_DEFAULT_RX_TX: key can be immediately used for Rx and Tx
+ * @NL80211_KEY_RX_ONLY: key must be installed for Rx only
+ * @NL80211_KEY_SET_TX: switch Tx for sta to specified keyid
+ */
+enum key_params_flag {
+   NL80211_KEY_DEFAULT_RX_TX,
+   NL80211_KEY_RX_ONLY,
+   NL80211_KEY_SET_TX
+};
+
 /**
  * enum nl80211_chan_width - channel width definitions
  *
@@ -4299,6 +4326,10 @@ enum nl80211_key_default_types {
  * @NL80211_KEY_DEFAULT_TYPES: A nested attribute containing flags
  * attributes, specifying what a key should be set as default as.
  * See  nl80211_key_default_types.
+ * @NL80211_KEY_RXONLY: Flag attribute to request RX key install only for
+ *  a pairwise key.
+ * @NL80211_KEY_SETTX: Flag attribute to switch TX to a selected key.
+ *
  * @__NL80211_KEY_AFTER_LAST: internal
  * @NL80211_KEY_MAX: highest key attribute
  */
@@ -4312,6 +4343,8 @@ enum nl80211_key_attributes {
NL80211_KEY_DEFAULT_MGMT,
NL80211_KEY_TYPE,
NL80211_KEY_DEFAULT_TYPES,
+   NL80211_KEY_RXONLY,
+   NL80211_KEY_SETTX,
 
/* keep last */
__NL80211_KEY_AFTER_LAST,
@@ -5250,13 +5283,14 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT: Driver/device can omit all data
  * except for supported rates from the probe request content if requested
  * by the %NL80211_SCAN_FLAG_MIN_PREQ_CONTENT flag.
- * @NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER: Driver supports enabling fine
- * timing measurement responder role.
- *
  * @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0: Driver/device confirm that they are
  *  able to rekey an in-use key correctly. Userspace must not rekey PTK 
keys
  *  if this flag is not set. Ignoring this can leak clear text packets 
and/or
  *  freeze the connection.
+ * @NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER: Driver supports enabling fine
+ * timing measurement responder role.
+ * @NL80211_EXT_FEATURE_EXT_KEY_ID: Driver supports "Extended Key ID for
+ *  Individually Addressed Frames" from IEEE802.11-2016.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -5297,6 +5331,7 @@ enum nl80211_ext_feature_index {

[RFC PATCH v2 2/2] mac80211: Add support for Extended Key ID

2018-11-11 Thread Alexander Wetzel
Allow drivers using mac80211 to support Extended Key IDs.

Signed-off-by: Alexander Wetzel 
---
 include/net/mac80211.h |  6 +
 net/mac80211/cfg.c | 30 -
 net/mac80211/debugfs_sta.c |  1 +
 net/mac80211/key.c | 46 ++
 net/mac80211/key.h |  1 +
 net/mac80211/main.c|  2 ++
 net/mac80211/sta_info.c|  1 +
 net/mac80211/sta_info.h|  1 +
 8 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 71985e95d2d9..fb53e7c84c01 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1643,6 +1643,10 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct 
ieee80211_vif *vif);
  * @IEEE80211_KEY_FLAG_PUT_MIC_SPACE: This flag should be set by the driver for
  * a TKIP key if it only requires MIC space. Do not set together with
  * @IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
+ * @IEEE80211_KEY_FLAG_RX_ONLY: Set by mac80211 to indicate that the key
+ *  must not be used for TX (yet).
+ * @IEEE80211_KEY_FLAG_SET_TX: Set by mac80211 to indicate that a previously
+ *  installed key with IEEE80211_KEY_FLAG_RX_ONLY should take over TX also.
  */
 enum ieee80211_key_flags {
IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
@@ -1654,6 +1658,8 @@ enum ieee80211_key_flags {
IEEE80211_KEY_FLAG_RX_MGMT  = BIT(6),
IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(7),
IEEE80211_KEY_FLAG_PUT_MIC_SPACE= BIT(8),
+   IEEE80211_KEY_FLAG_RX_ONLY  = BIT(9),
+   IEEE80211_KEY_FLAG_SET_TX   = BIT(10),
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 51622333d460..c0af820bc557 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -365,6 +365,25 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct 
net_device *dev,
if (!ieee80211_sdata_running(sdata))
return -ENETDOWN;
 
+   if (pairwise && params->flag == NL80211_KEY_SET_TX) {
+   mutex_lock(>sta_mtx);
+   sta = sta_info_get_bss(sdata, mac_addr);
+
+   if (!sta ||
+  !(key = rcu_dereference(sta->ptk[key_idx])) ||
+  !(key->conf.flags | IEEE80211_KEY_FLAG_RX_ONLY)) {
+   err = -ENOENT;
+   } else {
+   key->conf.flags &= ~IEEE80211_KEY_FLAG_RX_ONLY;
+   key->conf.flags |= IEEE80211_KEY_FLAG_SET_TX;
+   err = ieee80211_key_hw_activate_tx(key);
+   if (!err)
+   sta->ptk_idx = key_idx;
+   }
+   mutex_unlock(>sta_mtx);
+   return err;
+   }
+
/* reject WEP and TKIP keys if WEP failed to initialize */
switch (params->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
@@ -451,9 +470,18 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct 
net_device *dev,
break;
}
 
-   if (sta)
+   if (sta) {
sta->cipher_scheme = cs;
 
+   /* Flag STA correctly when using Extended Key ID */
+   if (pairwise && params->flag == NL80211_KEY_RX_ONLY &&
+   !test_sta_flag(sta, WLAN_STA_EXT_KEY_ID))
+   set_sta_flag(sta, WLAN_STA_EXT_KEY_ID);
+   }
+
+   if (params->flag == NL80211_KEY_RX_ONLY)
+   key->conf.flags |= IEEE80211_KEY_FLAG_RX_ONLY;
+
err = ieee80211_key_link(key, sdata, sta);
 
  out_unlock:
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index af5185a836e5..d63dca26d504 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -81,6 +81,7 @@ static const char * const sta_flag_names[] = {
FLAG(MPSP_OWNER),
FLAG(MPSP_RECIPIENT),
FLAG(PS_DELIVER),
+   FLAG(EXT_KEY_ID),
 #undef FLAG
 };
 
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 4700718e010f..007f90a1f948 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -124,6 +124,36 @@ static void decrease_tailroom_need_count(struct 
ieee80211_sub_if_data *sdata,
sdata->crypto_tx_tailroom_needed_cnt -= delta;
 }
 
+int ieee80211_key_hw_activate_tx(struct ieee80211_key *key)
+{
+   struct ieee80211_sub_if_data *sdata = key->sdata;
+   struct sta_info *sta = key->sta;
+   int ret;
+
+   assert_key_lock(key->local);
+
+   if (!sta)
+   return -EOPNOTSUPP;
+
+   if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
+   /* No need to inform driver, report success */
+   return 0;
+
+   /* Inform driver that key is no longer RX only */
+   ret = drv_set_key(key->local, SET_KEY, sdata,
+ >sta, >conf);
+   if (ret) {
+   if (ret == 1)
+   /* Software crypto, report success */
+   return 0;
+   

[RFC PATCH v2 0/2] Extended Key ID support for linux

2018-11-11 Thread Alexander Wetzel
IEEE 802.11-2012 added support for Extended Key ID, allowing pairwise
keys to also use keyID 1 and moving group keys to IDs 2 and 3.

Support for Extended Key ID is basically completed and confirmed working
with both hwsim and "on the air" with ath9k/iwldvm using software
encryption and those patches here.

(The corresponding patch for wpa_supplicanat/hostapd need some more
work, but that's mostly cleanup and support for STKSAs.)

Prior to propose this patch for merging I would like to get Extended
Key ID working with HW encryption for at least some devices, but after
experimenting with ath9k and to a lesser extend with ath10k it's now
clear that this will be an per-driver effort and it may well turn out to
be impossible without firmware updates.

So I've decided to continue working on the HW support for now but also
ask you for feedback for what I got so far. 
Any feedback is welcome and I especially like to learn what you think of
the API extensions and what has to be changed to get it merged.

RFC patch history:
v2:
Correct tested version without null pointer bug

Alexander Wetzel (2):
  nl80211/cfg80211: Add support for Extended Key ID
  mac80211: Add support for Extended Key ID

 include/net/cfg80211.h   |  2 ++
 include/net/mac80211.h   |  6 +
 include/uapi/linux/nl80211.h | 41 ++---
 net/mac80211/cfg.c   | 30 -
 net/mac80211/debugfs_sta.c   |  1 +
 net/mac80211/key.c   | 46 +---
 net/mac80211/key.h   |  1 +
 net/mac80211/main.c  |  2 ++
 net/mac80211/sta_info.c  |  1 +
 net/mac80211/sta_info.h  |  1 +
 net/wireless/nl80211.c   | 51 
 net/wireless/rdev-ops.h  |  3 ++-
 net/wireless/trace.h | 31 ++
 net/wireless/util.c  |  9 ---
 14 files changed, 197 insertions(+), 28 deletions(-)

-- 
2.19.1



Price queries

2018-11-11 Thread sinara-group
Hi,friend,
 
This is Daniel Murray and i am from Sinara Group Co.Ltd Group Co.,LTD in Russia.
We are glad to know about your company from the web and we are interested in 
your products.
Could you kindly send us your Latest catalog and price list for our trial order.
 
Best Regards,
 
Daniel Murray
Purchasing Manager




[PATCH 1/5] iwlwifi: fix wrong WGDS_WIFI_DATA_SIZE

2018-11-11 Thread Luca Coelho
From: Matt Chen 

>From coreboot/BIOS:
Name ("WGDS", Package() {
 Revision,
 Package() {
 DomainType, // 0x7:WiFi ==> We miss this one.
 WgdsWiFiSarDeltaGroup1PowerMax1,// Group 1 FCC 2400 Max
 WgdsWiFiSarDeltaGroup1PowerChainA1, // Group 1 FCC 2400 A Offset
 WgdsWiFiSarDeltaGroup1PowerChainB1, // Group 1 FCC 2400 B Offset
 WgdsWiFiSarDeltaGroup1PowerMax2,// Group 1 FCC 5200 Max
 WgdsWiFiSarDeltaGroup1PowerChainA2, // Group 1 FCC 5200 A Offset
 WgdsWiFiSarDeltaGroup1PowerChainB2, // Group 1 FCC 5200 B Offset
 WgdsWiFiSarDeltaGroup2PowerMax1,// Group 2 EC Jap 2400 Max
 WgdsWiFiSarDeltaGroup2PowerChainA1, // Group 2 EC Jap 2400 A Offset
 WgdsWiFiSarDeltaGroup2PowerChainB1, // Group 2 EC Jap 2400 B Offset
 WgdsWiFiSarDeltaGroup2PowerMax2,// Group 2 EC Jap 5200 Max
 WgdsWiFiSarDeltaGroup2PowerChainA2, // Group 2 EC Jap 5200 A Offset
 WgdsWiFiSarDeltaGroup2PowerChainB2, // Group 2 EC Jap 5200 B Offset
 WgdsWiFiSarDeltaGroup3PowerMax1,// Group 3 ROW 2400 Max
 WgdsWiFiSarDeltaGroup3PowerChainA1, // Group 3 ROW 2400 A Offset
 WgdsWiFiSarDeltaGroup3PowerChainB1, // Group 3 ROW 2400 B Offset
 WgdsWiFiSarDeltaGroup3PowerMax2,// Group 3 ROW 5200 Max
 WgdsWiFiSarDeltaGroup3PowerChainA2, // Group 3 ROW 5200 A Offset
 WgdsWiFiSarDeltaGroup3PowerChainB2, // Group 3 ROW 5200 B Offset
 }
})

When read the ACPI data to find out the WGDS, the DATA_SIZE is never
matched.
>From the above format, it gives 19 numbers, but our driver is hardcode
as 18.
Fix it to pass then can parse the data into our wgds table.
Then we will see:
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init Sending GEO_TX_POWER_LIMIT
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[0]
Band[0]: chain A = 68 chain B = 69 max_tx_power = 54
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[0]
Band[1]: chain A = 48 chain B = 49 max_tx_power = 70
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[1]
Band[0]: chain A = 51 chain B = 67 max_tx_power = 50
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[1]
Band[1]: chain A = 69 chain B = 70 max_tx_power = 68
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[2]
Band[0]: chain A = 49 chain B = 50 max_tx_power = 48
iwlwifi :01:00.0: U iwl_mvm_sar_geo_init SAR geographic profile[2]
Band[1]: chain A = 52 chain B = 53 max_tx_power = 51

Cc: sta...@vger.kernel.org # 4.12+
Fixes: a6bff3cb19b7 ("iwlwifi: mvm: add GEO_TX_POWER_LIMIT cmd for geographic 
tx power table")
Signed-off-by: Matt Chen 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.h | 4 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h 
b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
index 2439e98431ee..7492dfb6729b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
@@ -6,6 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2017Intel Deutschland GmbH
+ * Copyright(c) 2018Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -26,6 +27,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2017Intel Deutschland GmbH
+ * Copyright(c) 2018Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -81,7 +83,7 @@
 #define ACPI_WRDS_WIFI_DATA_SIZE   (ACPI_SAR_TABLE_SIZE + 2)
 #define ACPI_EWRD_WIFI_DATA_SIZE   ((ACPI_SAR_PROFILE_NUM - 1) * \
 ACPI_SAR_TABLE_SIZE + 3)
-#define ACPI_WGDS_WIFI_DATA_SIZE   18
+#define ACPI_WGDS_WIFI_DATA_SIZE   19
 #define ACPI_WRDD_WIFI_DATA_SIZE   2
 #define ACPI_SPLC_WIFI_DATA_SIZE   2
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index dade206d5511..899f4a6432fb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -893,7 +893,7 @@ static int iwl_mvm_sar_geo_init(struct iwl_mvm *mvm)
IWL_DEBUG_RADIO(mvm, "Sending GEO_TX_POWER_LIMIT\n");
 
BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES * ACPI_WGDS_NUM_BANDS *
-ACPI_WGDS_TABLE_SIZE !=  ACPI_WGDS_WIFI_DATA_SIZE);
+ACPI_WGDS_TABLE_SIZE + 1 !=  ACPI_WGDS_WIFI_DATA_SIZE);
 
BUILD_BUG_ON(ACPI_NUM_GEO_PROFILES > IWL_NUM_GEO_PROFILES);
 
-- 
2.19.1



[PATCH 3/5] iwlwifi: mvm: fix regulatory domain update when the firmware starts

2018-11-11 Thread Luca Coelho
From: Emmanuel Grumbach 

When the firmware starts, it doesn't have any regulatory
information, hence it uses the world wide limitations. The
driver can feed the firmware with previous knowledge that
was kept in the driver, but the firmware may still not
update its internal tables.

This happens when we start a BSS interface, and then the
firmware can change the regulatory tables based on our
location and it'll use more lenient, location specific
rules. Then, if the firmware is shut down (when the
interface is brought down), and then an AP interface is
created, the firmware will forget the country specific
rules.

The host will think that we are in a certain country that
may allow channels and will try to teach the firmware about
our location, but the firmware may still not allow to drop
the world wide limitations and apply country specific rules
because it was just re-started.

In this case, the firmware will reply with MCC_RESP_ILLEGAL
to the MCC_UPDATE_CMD. In that case, iwlwifi needs to let
the upper layers (cfg80211 / hostapd) know that the channel
list they know about has been updated.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=201105

Cc: sta...@vger.kernel.org
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 8 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c  | 5 ++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 7c09ce20e8b1..00f831d88366 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -301,8 +301,12 @@ struct ieee80211_regdomain *iwl_mvm_get_regdomain(struct 
wiphy *wiphy,
goto out;
}
 
-   if (changed)
-   *changed = (resp->status == MCC_RESP_NEW_CHAN_PROFILE);
+   if (changed) {
+   u32 status = le32_to_cpu(resp->status);
+
+   *changed = (status == MCC_RESP_NEW_CHAN_PROFILE ||
+   status == MCC_RESP_ILLEGAL);
+   }
 
regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg,
  __le32_to_cpu(resp->n_channels),
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 3633f27d048a..6fc5cc1f2b5b 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -539,9 +539,8 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
}
 
IWL_DEBUG_LAR(mvm,
- "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') 
change: %d n_chans: %d\n",
- status, mcc, mcc >> 8, mcc & 0xff,
- !!(status == MCC_RESP_NEW_CHAN_PROFILE), n_channels);
+ "MCC response status: 0x%x. new MCC: 0x%x ('%c%c') 
n_chans: %d\n",
+ status, mcc, mcc >> 8, mcc & 0xff, n_channels);
 
 exit:
iwl_free_resp();
-- 
2.19.1



[PATCH 2/5] iwlwifi: mvm: support sta_statistics() even on older firmware

2018-11-11 Thread Luca Coelho
From: Emmanuel Grumbach 

The oldest firmware supported by iwlmvm do support getting
the average beacon RSSI. Enable the sta_statistics() call
from mac80211 even on older firmware versions.

Fixes: 33cef9256342 ("iwlwifi: mvm: support beacon statistics for BSS client")
Cc: sta...@vger.kernel.org # 4.2+
Signed-off-by: Emmanuel Grumbach 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 505b0385d800..7c09ce20e8b1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -,10 +,6 @@ static void iwl_mvm_mac_sta_statistics(struct 
ieee80211_hw *hw,
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
}
 
-   if (!fw_has_capa(>fw->ucode_capa,
-IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS))
-   return;
-
/* if beacon filtering isn't on mac80211 does it anyway */
if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER))
return;
-- 
2.19.1



[PATCH 0/5] iwlwifi: fixes intended for 4.20 2018-11-11

2018-11-11 Thread Luca Coelho
From: Luca Coelho 

Hi,

This is my first batch of fixes inteded for 4.20.

These are the fixes:

* fix statistics collection with older FWs (was causing issues on userspace);
* fix a problem with regulatory after FW restart (bugzilla fix)
* fix a problem related to SAR with buggy BIOSes;
* fix geographic SAR parsing of ACPI entries;
* fix a memory leak in debug code;

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.


Emmanuel Grumbach (2):
  iwlwifi: mvm: support sta_statistics() even on older firmware
  iwlwifi: mvm: fix regulatory domain update when the firmware starts

Luca Coelho (1):
  iwlwifi: mvm: don't use SAR Geo if basic SAR is not used

Matt Chen (1):
  iwlwifi: fix wrong WGDS_WIFI_DATA_SIZE

Shahar S Matityahu (1):
  iwlwifi: fix D3 debug data buffer memory leak

 drivers/net/wireless/intel/iwlwifi/fw/acpi.h  |  4 ++-
 .../net/wireless/intel/iwlwifi/fw/runtime.h   |  6 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c   | 33 ++-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 12 +++
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c  |  5 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  2 ++
 6 files changed, 42 insertions(+), 20 deletions(-)

-- 
2.19.1



[PATCH 4/5] iwlwifi: fix D3 debug data buffer memory leak

2018-11-11 Thread Luca Coelho
From: Shahar S Matityahu 

If the driver is unloaded when D3 debug data pulling is enabled
but not triggered, it doesn't release the data buffer.

Fix this by adding iwl_fw_runtime_free and calling it from the
relevant places.

Fixes: 2d8c261511ab ("iwlwifi: add d3 debug data support")
Signed-off-by: Shahar S Matityahu 
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/fw/runtime.h | 6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c| 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h 
b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
index 6b95d0e75889..2b8b50a77990 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h
@@ -154,7 +154,11 @@ void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, 
struct iwl_trans *trans,
const struct iwl_fw_runtime_ops *ops, void *ops_ctx,
struct dentry *dbgfs_dir);
 
-void iwl_fw_runtime_exit(struct iwl_fw_runtime *fwrt);
+static inline void iwl_fw_runtime_free(struct iwl_fw_runtime *fwrt)
+{
+   kfree(fwrt->dump.d3_debug_data);
+   fwrt->dump.d3_debug_data = NULL;
+}
 
 void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt);
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 0e2092526fae..af3fba10abc1 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -858,6 +858,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct 
iwl_cfg *cfg,
iwl_mvm_thermal_exit(mvm);
  out_free:
iwl_fw_flush_dump(>fwrt);
+   iwl_fw_runtime_free(>fwrt);
 
if (iwlmvm_mod_params.init_dbg)
return op_mode;
@@ -910,6 +911,7 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode 
*op_mode)
 
iwl_mvm_tof_clean(mvm);
 
+   iwl_fw_runtime_free(>fwrt);
mutex_destroy(>mutex);
mutex_destroy(>d0i3_suspend_mutex);
 
-- 
2.19.1



[PATCH 5/5] iwlwifi: mvm: don't use SAR Geo if basic SAR is not used

2018-11-11 Thread Luca Coelho
From: Luca Coelho 

We can't use SAR Geo if basic SAR is not enabled, since the SAR Geo
tables define offsets in relation to the basic SAR table in use.

To fix this, make iwl_mvm_sar_init() return one in case WRDS is not
available, so we can skip reading WGDS entirely.

Fixes: a6bff3cb19b7 ("iwlwifi: mvm: add GEO_TX_POWER_LIMIT cmd for geographic 
tx power table")
Cc: sta...@vger.kernel.org # 4.12+
Signed-off-by: Luca Coelho 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 31 +++--
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 899f4a6432fb..da9afa6824cb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -954,8 +954,11 @@ static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
IWL_DEBUG_RADIO(mvm,
"WRDS SAR BIOS table invalid or unavailable. 
(%d)\n",
ret);
-   /* if not available, don't fail and don't bother with EWRD */
-   return 0;
+   /*
+* If not available, don't fail and don't bother with EWRD.
+* Return 1 to tell that we can't use WGDS either.
+*/
+   return 1;
}
 
ret = iwl_mvm_sar_get_ewrd_table(mvm);
@@ -968,9 +971,13 @@ static int iwl_mvm_sar_init(struct iwl_mvm *mvm)
/* choose profile 1 (WRDS) as default for both chains */
ret = iwl_mvm_sar_select_profile(mvm, 1, 1);
 
-   /* if we don't have profile 0 from BIOS, just skip it */
+   /*
+* If we don't have profile 0 from BIOS, just skip it.  This
+* means that SAR Geo will not be enabled either, even if we
+* have other valid profiles.
+*/
if (ret == -ENOENT)
-   return 0;
+   return 1;
 
return ret;
 }
@@ -1168,11 +1175,19 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
 
ret = iwl_mvm_sar_init(mvm);
-   if (ret)
-   goto error;
+   if (ret == 0) {
+   ret = iwl_mvm_sar_geo_init(mvm);
+   } else if (ret > 0 && !iwl_mvm_sar_get_wgds_table(mvm)) {
+   /*
+* If basic SAR is not available, we check for WGDS,
+* which should *not* be available either.  If it is
+* available, issue an error, because we can't use SAR
+* Geo without basic SAR.
+*/
+   IWL_ERR(mvm, "BIOS contains WGDS but no WRDS\n");
+   }
 
-   ret = iwl_mvm_sar_geo_init(mvm);
-   if (ret)
+   if (ret < 0)
goto error;
 
iwl_mvm_leds_sync(mvm);
-- 
2.19.1



Price queries

2018-11-11 Thread sinara-group
Hi,friend,
 
This is Daniel Murray and i am from Sinara Group Co.Ltd Group Co.,LTD in Russia.
We are glad to know about your company from the web and we are interested in 
your products.
Could you kindly send us your Latest catalog and price list for our trial order.
 
Best Regards,
 
Daniel Murray
Purchasing Manager




pull-request: iwlwifi-next 2018-11-11

2018-11-11 Thread Luca Coelho
Hi Kalle,

This is the first batch of patches intended for v4.21.  This includes
only the last patchset I sent.  Usual development work, new PCI IDs and
small fixes and cleanups.  More details about the contents in the tag
description.

I have sent this out before and kbuildbot reported success.

Please let me know if there are any issues.

Cheers,
Luca.


The following changes since commit bb38177cb6c6dc973ad8b88f219742b29f3002f1:

  Merge ath-next from 
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git (2018-11-09 
17:15:25 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git 
tags/iwlwifi-next-for-kalle-2018-11-11

for you to fetch changes up to 56b657f7f9c07421a4f910b7e2b382184f1ddbc8:

  iwlwifi: fw: use helper to determine whether to dump paging (2018-11-11 
11:06:23 +0200)


First set of iwlwifi patches for 4.21

* PCI IDs for some new 9000-series cards;
* Improve antenna usage on connection problems;
* Some improvements in the debugging code;
* Other clean-ups and small fixes;


Andrei Otcheretianski (1):
  iwlwifi: mvm: Send non offchannel traffic via AP sta

Avraham Stern (2):
  iwlwifi: mvm: switch management tx antenna only on tx failure
  iwlwifi: mvm: toggle tx antenna if tx fails during connection 
establishment

Emmanuel Grumbach (1):
  iwlwifi: mvm: remove unused conversion table

Ihab Zhaika (1):
  iwlwifi: add new cards for 9560, 9462, 9461 and killer series

Johannes Berg (2):
  iwlwifi: mvm: synchronize TID queue removal
  iwlwifi: mvm: remove queue_info_lock

Naftali Goldstein (2):
  iwlwifi: fw: do not set sgi bits for HE connection
  iwlwifi: mvm: add description to a few generic assert numbers

Sara Sharon (4):
  iwlwifi: pcie: don't reset TXQ write pointer
  iwlwifi: dbg: avoid passing trigger around
  iwlwifi: dbg: use helper to check if debug type is set
  iwlwifi: fw: use helper to determine whether to dump paging

Shahar S Matityahu (1):
  iwlwifi: trans: Clear persistence bit when starting the FW

Tova Mussai (1):
  iwlwifi: mvm: enable low latency for soft ap

YueHaibing (1):
  iwlwifi: mvm: remove set but not used variable 'he_phy_data'

 drivers/net/wireless/intel/iwlwifi/fw/dbg.c  | 109 
++--
 drivers/net/wireless/intel/iwlwifi/fw/dbg.h  |  18 +---
 drivers/net/wireless/intel/iwlwifi/fw/runtime.h  |   2 +-
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h|   7 ++
 drivers/net/wireless/intel/iwlwifi/iwl-trans.h   |   8 +++
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c  |   2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c |  14 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c|   7 ++
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c|  27 
+++
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h |  10 -
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c |  17 +--
 drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c   |   4 
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c|   6 --
 drivers/net/wireless/intel/iwlwifi/mvm/scan.c|   4 +---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 114 
-
 drivers/net/wireless/intel/iwlwifi/mvm/sta.h |   4 
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c  |  83 
+-
 drivers/net/wireless/intel/iwlwifi/mvm/utils.c   |  54 
+-
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c|  50 
+++
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c  |  16 --
 drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c|   3 +--
 21 files changed, 313 insertions(+), 246 deletions(-)


signature.asc
Description: This is a digitally signed message part