MLK-12077-1 bcmdhd: add Broadcom bcmdhd engineering release for 4.1 kernel
authorDong Aisheng <aisheng.dong@nxp.com>
Tue, 5 Jan 2016 10:08:31 +0000 (18:08 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:50:02 +0000 (14:50 -0500)
Broadcom bcmdhd engineering release for 4.1 kernel

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
140 files changed:
drivers/net/wireless/bcmdhd/Makefile
drivers/net/wireless/bcmdhd/aiutils.c
drivers/net/wireless/bcmdhd/bcmevent.c
drivers/net/wireless/bcmdhd/bcmsdh.c
drivers/net/wireless/bcmdhd/bcmsdh_linux.c
drivers/net/wireless/bcmdhd/bcmsdh_sdmmc.c
drivers/net/wireless/bcmdhd/bcmsdh_sdmmc_linux.c
drivers/net/wireless/bcmdhd/bcmsdspi_linux.c
drivers/net/wireless/bcmdhd/bcmspibrcm.c
drivers/net/wireless/bcmdhd/bcmutils.c
drivers/net/wireless/bcmdhd/bcmwifi_channels.c
drivers/net/wireless/bcmdhd/bcmwifi_channels.h
drivers/net/wireless/bcmdhd/bcmwifi_rates.h
drivers/net/wireless/bcmdhd/circularbuf.c
drivers/net/wireless/bcmdhd/dhd.h
drivers/net/wireless/bcmdhd/dhd_bta.c
drivers/net/wireless/bcmdhd/dhd_bta.h
drivers/net/wireless/bcmdhd/dhd_bus.h
drivers/net/wireless/bcmdhd/dhd_cdc.c
drivers/net/wireless/bcmdhd/dhd_cfg80211.c
drivers/net/wireless/bcmdhd/dhd_cfg80211.h
drivers/net/wireless/bcmdhd/dhd_common.c
drivers/net/wireless/bcmdhd/dhd_custom_gpio.c
drivers/net/wireless/bcmdhd/dhd_dbg.h
drivers/net/wireless/bcmdhd/dhd_ip.c
drivers/net/wireless/bcmdhd/dhd_ip.h
drivers/net/wireless/bcmdhd/dhd_linux.c
drivers/net/wireless/bcmdhd/dhd_linux.h
drivers/net/wireless/bcmdhd/dhd_linux_platdev.c
drivers/net/wireless/bcmdhd/dhd_linux_sched.c
drivers/net/wireless/bcmdhd/dhd_linux_wq.c
drivers/net/wireless/bcmdhd/dhd_linux_wq.h
drivers/net/wireless/bcmdhd/dhd_msgbuf.c
drivers/net/wireless/bcmdhd/dhd_pcie.c
drivers/net/wireless/bcmdhd/dhd_pcie.h
drivers/net/wireless/bcmdhd/dhd_pcie_linux.c
drivers/net/wireless/bcmdhd/dhd_pno.c
drivers/net/wireless/bcmdhd/dhd_pno.h
drivers/net/wireless/bcmdhd/dhd_proto.h
drivers/net/wireless/bcmdhd/dhd_sdio.c
drivers/net/wireless/bcmdhd/dhd_wlfc.c
drivers/net/wireless/bcmdhd/dhd_wlfc.h
drivers/net/wireless/bcmdhd/dngl_stats.h
drivers/net/wireless/bcmdhd/dngl_wlhdr.h
drivers/net/wireless/bcmdhd/hndpmu.c
drivers/net/wireless/bcmdhd/include/aidmp.h
drivers/net/wireless/bcmdhd/include/bcm_cfg.h
drivers/net/wireless/bcmdhd/include/bcm_mpool_pub.h
drivers/net/wireless/bcmdhd/include/bcmcdc.h
drivers/net/wireless/bcmdhd/include/bcmdefs.h
drivers/net/wireless/bcmdhd/include/bcmdevs.h
drivers/net/wireless/bcmdhd/include/bcmendian.h
drivers/net/wireless/bcmdhd/include/bcmmsgbuf.h
drivers/net/wireless/bcmdhd/include/bcmnvram.h
drivers/net/wireless/bcmdhd/include/bcmpcie.h
drivers/net/wireless/bcmdhd/include/bcmpcispi.h
drivers/net/wireless/bcmdhd/include/bcmperf.h
drivers/net/wireless/bcmdhd/include/bcmsdbus.h
drivers/net/wireless/bcmdhd/include/bcmsdh.h
drivers/net/wireless/bcmdhd/include/bcmsdh_sdmmc.h
drivers/net/wireless/bcmdhd/include/bcmsdpcm.h
drivers/net/wireless/bcmdhd/include/bcmsdspi.h
drivers/net/wireless/bcmdhd/include/bcmsdstd.h
drivers/net/wireless/bcmdhd/include/bcmspi.h
drivers/net/wireless/bcmdhd/include/bcmspibrcm.h
drivers/net/wireless/bcmdhd/include/bcmsrom_fmt.h
drivers/net/wireless/bcmdhd/include/bcmsrom_tbl.h
drivers/net/wireless/bcmdhd/include/bcmutils.h
drivers/net/wireless/bcmdhd/include/brcm_nl80211.h
drivers/net/wireless/bcmdhd/include/circularbuf.h
drivers/net/wireless/bcmdhd/include/dbus.h
drivers/net/wireless/bcmdhd/include/devctrl_if/wlioctl_defs.h
drivers/net/wireless/bcmdhd/include/dhdioctl.h
drivers/net/wireless/bcmdhd/include/epivers.h
drivers/net/wireless/bcmdhd/include/hndpmu.h
drivers/net/wireless/bcmdhd/include/hndrte_armtrap.h
drivers/net/wireless/bcmdhd/include/hndrte_cons.h
drivers/net/wireless/bcmdhd/include/hndsoc.h
drivers/net/wireless/bcmdhd/include/linux_osl.h
drivers/net/wireless/bcmdhd/include/linuxver.h
drivers/net/wireless/bcmdhd/include/miniopt.h
drivers/net/wireless/bcmdhd/include/msgtrace.h
drivers/net/wireless/bcmdhd/include/osl.h
drivers/net/wireless/bcmdhd/include/packed_section_end.h
drivers/net/wireless/bcmdhd/include/packed_section_start.h
drivers/net/wireless/bcmdhd/include/pcicfg.h
drivers/net/wireless/bcmdhd/include/pcie_core.h
drivers/net/wireless/bcmdhd/include/proto/802.11.h
drivers/net/wireless/bcmdhd/include/proto/802.11_bta.h
drivers/net/wireless/bcmdhd/include/proto/802.11e.h
drivers/net/wireless/bcmdhd/include/proto/802.1d.h
drivers/net/wireless/bcmdhd/include/proto/802.3.h
drivers/net/wireless/bcmdhd/include/proto/bcmeth.h
drivers/net/wireless/bcmdhd/include/proto/bcmevent.h
drivers/net/wireless/bcmdhd/include/proto/bcmip.h
drivers/net/wireless/bcmdhd/include/proto/bcmipv6.h
drivers/net/wireless/bcmdhd/include/proto/bcmtcp.h
drivers/net/wireless/bcmdhd/include/proto/bt_amp_hci.h
drivers/net/wireless/bcmdhd/include/proto/eapol.h
drivers/net/wireless/bcmdhd/include/proto/ethernet.h
drivers/net/wireless/bcmdhd/include/proto/p2p.h
drivers/net/wireless/bcmdhd/include/proto/sdspi.h
drivers/net/wireless/bcmdhd/include/proto/vlan.h
drivers/net/wireless/bcmdhd/include/proto/wpa.h
drivers/net/wireless/bcmdhd/include/proto/wps.h
drivers/net/wireless/bcmdhd/include/sbchipc.h
drivers/net/wireless/bcmdhd/include/sbconfig.h
drivers/net/wireless/bcmdhd/include/sbhnddma.h
drivers/net/wireless/bcmdhd/include/sbpcmcia.h
drivers/net/wireless/bcmdhd/include/sbsdio.h
drivers/net/wireless/bcmdhd/include/sbsdpcmdev.h
drivers/net/wireless/bcmdhd/include/sbsocram.h
drivers/net/wireless/bcmdhd/include/sdio.h
drivers/net/wireless/bcmdhd/include/sdioh.h
drivers/net/wireless/bcmdhd/include/sdiovar.h
drivers/net/wireless/bcmdhd/include/siutils.h
drivers/net/wireless/bcmdhd/include/spid.h
drivers/net/wireless/bcmdhd/include/trxhdr.h
drivers/net/wireless/bcmdhd/include/typedefs.h
drivers/net/wireless/bcmdhd/include/wlfc_proto.h
drivers/net/wireless/bcmdhd/include/wlioctl.h
drivers/net/wireless/bcmdhd/linux_osl.c
drivers/net/wireless/bcmdhd/sbutils.c
drivers/net/wireless/bcmdhd/siutils.c
drivers/net/wireless/bcmdhd/siutils_priv.h
drivers/net/wireless/bcmdhd/uamp_api.h
drivers/net/wireless/bcmdhd/wl_android.c
drivers/net/wireless/bcmdhd/wl_android.h
drivers/net/wireless/bcmdhd/wl_cfg80211.c
drivers/net/wireless/bcmdhd/wl_cfg80211.h
drivers/net/wireless/bcmdhd/wl_cfg_btcoex.c
drivers/net/wireless/bcmdhd/wl_cfgp2p.c
drivers/net/wireless/bcmdhd/wl_cfgp2p.h
drivers/net/wireless/bcmdhd/wl_cfgvendor.c
drivers/net/wireless/bcmdhd/wl_dbg.h
drivers/net/wireless/bcmdhd/wl_iw.c
drivers/net/wireless/bcmdhd/wl_iw.h
drivers/net/wireless/bcmdhd/wl_linux_mon.c
drivers/net/wireless/bcmdhd/wldev_common.c
drivers/net/wireless/bcmdhd/wldev_common.h

index 88ab641..e15f5cc 100644 (file)
@@ -149,7 +149,7 @@ ifneq ($(CONFIG_BCM4339),)
 endif
 
 ifneq ($(CONFIG_BCMDHD_SDIO),)
- # DHDCFLAGS += -DBDC -DOOB_INTR_ONLY -DDHD_BCMEVENTS -DMMC_SDIO_ABORT
+#  DHDCFLAGS += -DBDC -DOOB_INTR_ONLY -DDHD_BCMEVENTS -DMMC_SDIO_ABORT -DHW_OOB
   DHDCFLAGS += -DBDC -DSDIO_ISR_THREAD -DDHD_BCMEVENTS -DMMC_SDIO_ABORT
   DHDCFLAGS += -DBCMSDIO -DBCMLXSDMMC -DUSE_SDIOFIFO_IOVAR
 endif
index 611f9a7..11474a4 100644 (file)
@@ -2,7 +2,7 @@
  * Misc utility routines for accessing chip-specific features
  * of the SiliconBackplane-based Broadcom chips.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: aiutils.c 432226 2013-10-26 04:34:36Z $
+ * $Id: aiutils.c 530682 2015-01-30 18:48:21Z $
  */
 #include <bcm_cfg.h>
 #include <typedefs.h>
@@ -49,6 +49,7 @@ get_erom_ent(si_t *sih, uint32 **eromptr, uint32 mask, uint32 match)
 {
        uint32 ent;
        uint inv = 0, nom = 0;
+       uint32 size = 0;
 
        while (TRUE) {
                ent = R_REG(si_osh(sih), *eromptr);
@@ -68,6 +69,13 @@ get_erom_ent(si_t *sih, uint32 **eromptr, uint32 mask, uint32 match)
                if ((ent & mask) == match)
                        break;
 
+               /* escape condition related EROM size if it has invalid values */
+               size += sizeof(*eromptr);
+               if (size >= ER_SZ_MAX) {
+                       SI_ERROR(("Failed to find end of EROM marker\n"));
+                       break;
+               }
+
                nom++;
        }
 
index 5e1e994..81f2078 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * bcmevent read-only data shared by kernel or app layers
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -94,10 +94,6 @@ const bcmevent_name_t bcmevent_names[] = {
        BCMEVENT_NAME(WLC_E_ACTION_FRAME_RX),
        BCMEVENT_NAME(WLC_E_ACTION_FRAME_COMPLETE),
 #endif
-#ifdef BCMWAPI_WAI
-       BCMEVENT_NAME(WLC_E_WAI_STA_EVENT),
-       BCMEVENT_NAME(WLC_E_WAI_MSG),
-#endif /* BCMWAPI_WAI */
        BCMEVENT_NAME(WLC_E_ESCAN_RESULT),
        BCMEVENT_NAME(WLC_E_ACTION_FRAME_OFF_CHAN_COMPLETE),
 #ifdef WLP2P
index f77de60..4386f26 100644 (file)
@@ -2,7 +2,7 @@
  *  BCMSDH interface glue
  *  implement bcmsdh API for SDIOH driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 56e775c..bf265d4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SDIO access interface for drivers - linux specific (pci only)
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 22cef80..4add1dd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdh_sdmmc.c 457662 2014-02-24 15:07:28Z $
+ * $Id: bcmsdh_sdmmc.c 557203 2015-05-18 02:05:14Z $
  */
 #include <typedefs.h>
 
@@ -59,7 +59,13 @@ static void IRQHandler(struct sdio_func *func);
 static void IRQHandlerF2(struct sdio_func *func);
 #endif /* !defined(OOB_INTR_ONLY) */
 static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, uint32 regaddr);
-static int sdio_reset_comm(struct mmc_card *card);
+//extern int sdio_reset_comm(struct mmc_card *card);
+
+/* workaround to simply return 0 as suggested by Broadcom */
+static int sdio_reset_comm(struct mmc_card *card)
+{
+        return 0;
+}
 
 #define DEFAULT_SDIO_F2_BLKSIZE                512
 #ifndef CUSTOM_SDIO_F2_BLKSIZE
@@ -92,12 +98,6 @@ DHD_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait);
 
 int sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 *data);
 
-/* workaround to simply return 0 as suggested by Broadcom */
-static int sdio_reset_comm(struct mmc_card *card)
-{
-       return 0;
-}
-
 static int
 sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
 {
@@ -952,6 +952,7 @@ sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func, uint add
        return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
 }
 
+#ifdef BCMSDIOH_TXGLOM
 static SDIOH_API_RC
 sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
                      uint addr, void *pkt)
@@ -1074,6 +1075,7 @@ sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func
        sd_trace(("%s: Exit\n", __FUNCTION__));
        return SDIOH_API_RC_SUCCESS;
 }
+#endif /* BCMSDIOH_TXGLOM */
 
 static SDIOH_API_RC
 sdioh_buffer_tofrom_bus(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
@@ -1142,12 +1144,13 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, u
        DHD_PM_RESUME_RETURN_ERROR(SDIOH_API_RC_FAIL);
 
        if (pkt) {
+#ifdef BCMSDIOH_TXGLOM
                /* packet chain, only used for tx/rx glom, all packets length
                 * are aligned, total length is a block multiple
                 */
                if (PKTNEXT(sd->osh, pkt))
                        return sdioh_request_packet_chain(sd, fix_inc, write, func, addr, pkt);
-
+#endif /* BCMSDIOH_TXGLOM */
                /* non-glom mode, ignore the buffer parameter and use the packet pointer
                 * (this shouldn't happen)
                 */
index ff988f0..98a834e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdh_sdmmc_linux.c 434724 2013-11-07 05:38:43Z $
+ * $Id: bcmsdh_sdmmc_linux.c 523920 2015-01-05 06:07:16Z $
  */
 
 #include <typedefs.h>
@@ -228,14 +228,18 @@ static int bcmsdh_sdmmc_suspend(struct device *pdev)
        if (func->num != 2)
                return 0;
 
+       dhd_mmc_suspend = TRUE;
        sdioh = sdio_get_drvdata(func);
        err = bcmsdh_suspend(sdioh->bcmsdh);
-       if (err)
+       if (err) {
+               dhd_mmc_suspend = FALSE;
                return err;
+       }
 
        sdio_flags = sdio_get_host_pm_caps(func);
        if (!(sdio_flags & MMC_PM_KEEP_POWER)) {
                sd_err(("%s: can't keep power while host is suspended\n", __FUNCTION__));
+               dhd_mmc_suspend = FALSE;
                return  -EINVAL;
        }
 
@@ -243,12 +247,12 @@ static int bcmsdh_sdmmc_suspend(struct device *pdev)
        err = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
        if (err) {
                sd_err(("%s: error while trying to keep power\n", __FUNCTION__));
+               dhd_mmc_suspend = FALSE;
                return err;
        }
 #if defined(OOB_INTR_ONLY)
        bcmsdh_oob_intr_set(sdioh->bcmsdh, FALSE);
 #endif 
-       dhd_mmc_suspend = TRUE;
        smp_mb();
 
        return 0;
index 0f15102..1c0ff48 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom SPI Host Controller Driver - Linux Per-port
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 97a253b..f5894bf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom BCMSDH to gSPI Protocol Conversion Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index b57910d..8c99c82 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Driver O/S-independent utility routines
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -20,7 +20,7 @@
  *      Notwithstanding the above, under no circumstances may you combine this
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
- * $Id: bcmutils.c 490613 2014-07-11 05:23:34Z $
+ * $Id: bcmutils.c 530682 2015-01-30 18:48:21Z $
  */
 
 #include <bcm_cfg.h>
@@ -266,12 +266,12 @@ pktq_penq(struct pktq *pq, int prec, void *p)
        struct pktq_prec *q;
 
        ASSERT(prec >= 0 && prec < pq->num_prec);
-       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));         /* queueing chains not allowed */
+       /* queueing chains not allowed and no segmented SKB (Kernel-3.18.y) */
+       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));
 
        ASSERT(!pktq_full(pq));
        ASSERT(!pktq_pfull(pq, prec));
 
-       PKTSETLINK(p, NULL);
        q = &pq->q[prec];
 
        if (q->head)
@@ -296,11 +296,11 @@ pktq_penq_head(struct pktq *pq, int prec, void *p)
        struct pktq_prec *q;
 
        ASSERT(prec >= 0 && prec < pq->num_prec);
-       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));         /* queueing chains not allowed */
+       /* queueing chains not allowed and no segmented SKB (Kernel-3.18.y) */
+       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));
 
        ASSERT(!pktq_full(pq));
        ASSERT(!pktq_pfull(pq, prec));
-       PKTSETLINK(p, NULL);
 
        q = &pq->q[prec];
 
@@ -1810,7 +1810,9 @@ bcm_parse_tlvs(void *buf, int buflen, uint key)
        bcm_tlv_t *elt;
        int totlen;
 
-       elt = (bcm_tlv_t*)buf;
+       if ((elt = (bcm_tlv_t*)buf) == NULL) {
+               return NULL;
+       }
        totlen = buflen;
 
        /* find tagged parameter */
@@ -1938,8 +1940,6 @@ bcm_format_flags(const bcm_bit_desc_t *bd, uint32 flags, char* buf, int len)
 
        /* indicate the str was too short */
        if (flags != 0) {
-               if (len < 2)
-                       p -= 2 - len;   /* overwrite last char */
                p += snprintf(p, 2, ">");
        }
 
@@ -2120,8 +2120,10 @@ bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
        strncpy(buf, name, buflen);
 
        /* append data onto the end of the name string */
-       memcpy(&buf[len], data, datalen);
-       len += datalen;
+       if (data) {
+               memcpy(&buf[len], data, datalen);
+               len += datalen;
+       }
 
        return len;
 }
index 10a7cb5..b7c1e83 100644 (file)
@@ -3,7 +3,7 @@
  * Contents are wifi-specific, used by any kernel or app-level
  * software that might want wifi things as it grows.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 2c7a4e2..9922633 100644 (file)
@@ -3,7 +3,7 @@
  * This header file housing the define and function prototype use by
  * both the wl driver, tools & Apps.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 38d339b..09870d8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Indices for 802.11 a/b/g/n/ac 1-3 chain symmetric transmit rates
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 6f89f73..a4a4730 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Initialization and support routines for self-booting compressed image.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 59cdfbe..3eb3edc 100644 (file)
@@ -4,7 +4,7 @@
  * Provides type definitions and function prototypes used to link the
  * DHD OS, bus, and protocol modules.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -24,7 +24,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd.h 492809 2014-07-23 11:21:52Z $
+ * $Id: dhd.h 557502 2015-05-19 06:32:03Z $
  */
 
 /****************
@@ -60,10 +60,6 @@ int get_scheduler_policy(struct task_struct *p);
 #include <wlfc_proto.h>
 
 
-#if defined(WL11U)
-#define MFP /* Applying interaction with MFP by spec HS2.0 REL2 */
-#endif /* WL11U */
-
 #if defined(KEEP_ALIVE)
 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
 #define KEEP_ALIVE_PERIOD 55000
@@ -139,12 +135,15 @@ enum dhd_prealloc_index {
        DHD_PREALLOC_RXBUF,
        DHD_PREALLOC_DATABUF,
        DHD_PREALLOC_OSL_BUF,
-#if defined(STATIC_WL_PRIV_STRUCT)
        DHD_PREALLOC_WIPHY_ESCAN0 = 5,
-#endif /* STATIC_WL_PRIV_STRUCT */
-       DHD_PREALLOC_DHD_INFO = 7
+       DHD_PREALLOC_WIPHY_ESCAN1 = 6,
+       DHD_PREALLOC_DHD_INFO = 7,
+       DHD_PREALLOC_DHD_WLFC_INFO = 8,
+       DHD_PREALLOC_SECTION_MAX = DHD_PREALLOC_DHD_WLFC_INFO
 };
 
+#define PREALLOC_MASK_LEN      4
+
 /* Packet alignment for most efficient SDIO (can change based on platform) */
 #ifndef DHD_SDALIGN
 #define DHD_SDALIGN    32
@@ -257,6 +256,7 @@ typedef struct dhd_pub {
 
        wl_country_t dhd_cspec;         /* Current Locale info */
        char eventmask[WL_EVENTING_MASK_LEN];
+       char prealloc_malloc_mask[PREALLOC_MASK_LEN];
        int     op_mode;                                /* STA, HostAPD, WFD, SoftAP */
 
 /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
@@ -597,6 +597,22 @@ typedef struct {
        uint32 tick;            /* O/S tick time (usec) */
 } dhd_timeout_t;
 
+#ifdef SHOW_LOGTRACE
+typedef struct {
+       int  num_fmts;
+       char **fmts;
+       char *raw_fmts;
+       char *raw_sstr;
+       uint32 ramstart;
+       uint32 rodata_start;
+       uint32 rodata_end;
+       char *rom_raw_sstr;
+       uint32 rom_ramstart;
+       uint32 rom_rodata_start;
+       uint32 rom_rodata_end;
+} dhd_event_log_t;
+#endif /* SHOW_LOGTRACE */
+
 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
 
@@ -605,7 +621,7 @@ extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
 extern struct net_device * dhd_idx2net(void *pub, int ifidx);
 extern int net_os_send_hang_message(struct net_device *dev);
 extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
-                         wl_event_msg_t *, void **data_ptr);
+                         wl_event_msg_t *, void **data_ptr, void *raw_event);
 extern void wl_event_to_host_order(wl_event_msg_t * evt);
 
 extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
@@ -881,14 +897,14 @@ extern const uint8 prio2fifo[];
 #endif /* PROP_TXSTATUS */
 
 uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
-void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size);
+void dhd_os_prefree(dhd_pub_t *dhdpub, int section, void *addr, uint size);
 
 #if defined(CONFIG_DHD_USE_STATIC_BUF)
-#define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, FALSE)
-#define DHD_OS_PREFREE(dhdpub, addr, size) dhd_os_prefree(dhdpub, addr, size)
+#define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, TRUE)
+#define DHD_OS_PREFREE(dhdpub, section, addr, size) dhd_os_prefree(dhdpub, section, addr, size)
 #else
 #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
-#define DHD_OS_PREFREE(dhdpub, addr, size) MFREE(dhdpub->osh, addr, size)
+#define DHD_OS_PREFREE(dhdpub, section, addr, size) MFREE(dhdpub->osh, addr, size)
 #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
 
 
index 46ee3d4..6dac01d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BT-AMP support routines
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index db636a8..000b295 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BT-AMP support routines
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f22ac6a..5886bd9 100644 (file)
@@ -4,7 +4,7 @@
  * Provides type definitions and function prototypes used to link the
  * DHD OS, bus, and protocol modules.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index eecc182..32507ce 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DHD Protocol Module for CDC and BDC.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_cdc.c 498632 2014-08-25 14:09:22Z $
+ * $Id: dhd_cdc.c 557252 2015-05-18 08:55:13Z $
  *
  * BDC is like CDC, except it includes a header for data packets to convey
  * packet priority over the bus, and flags (e.g. to indicate checksum status
@@ -475,8 +475,9 @@ dhd_prot_attach(dhd_pub_t *dhd)
        return 0;
 
 fail:
-       if (cdc != NULL)
-               DHD_OS_PREFREE(dhd, cdc, sizeof(dhd_prot_t));
+       if (cdc != NULL) {
+               DHD_OS_PREFREE(dhd, DHD_PREALLOC_PROT, cdc, sizeof(dhd_prot_t));
+       }
        return BCME_NOMEM;
 }
 
@@ -487,7 +488,7 @@ dhd_prot_detach(dhd_pub_t *dhd)
 #ifdef PROP_TXSTATUS
        dhd_wlfc_deinit(dhd);
 #endif
-       DHD_OS_PREFREE(dhd, dhd->prot, sizeof(dhd_prot_t));
+       DHD_OS_PREFREE(dhd, DHD_PREALLOC_PROT, dhd->prot, sizeof(dhd_prot_t));
        dhd->prot = NULL;
 }
 
index 971e70e..6cbeacd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver - Dongle Host Driver (DHD) related
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index da83567..0419dad 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver - Dongle Host Driver (DHD) related
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 31ccb49..807af74 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom Dongle Host Driver (DHD), common DHD core.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_common.c 496755 2014-08-14 04:56:53Z $
+ * $Id: dhd_common.c 557502 2015-05-19 06:32:03Z $
  */
 #include <typedefs.h>
 #include <osl.h>
 
 #include <proto/bcmevent.h>
 
+#ifdef SHOW_LOGTRACE
+#include <event_log.h>
+#endif /* SHOW_LOGTRACE */
+
 #include <dhd_bus.h>
 #include <dhd_proto.h>
 #include <dhd_dbg.h>
@@ -881,8 +885,332 @@ dhd_ioctl(dhd_pub_t * dhd_pub, dhd_ioctl_t *ioc, void * buf, uint buflen)
 }
 
 #ifdef SHOW_EVENTS
+#ifdef SHOW_LOGTRACE
+
+#define MAX_NO_OF_ARG  16
+
+#define FMTSTR_SIZE    100
+#define SIZE_LOC_STR   50
+#define MIN_DLEN       4
+#define TAG_BYTES      12
+#define TAG_WORDS      3
+
+static int
+check_event_log_sequence_number(uint32 seq_no)
+{
+       int32 diff;
+       uint32 ret;
+       static uint32 logtrace_seqnum_prev = 0;
+
+       diff = ntoh32(seq_no)-logtrace_seqnum_prev;
+       switch (diff)
+       {
+               case 0:
+                       ret = -1; /* duplicate packet . drop */
+                       break;
+
+               case 1:
+                       ret =0; /* in order */
+                       break;
+
+               default:
+                       if ((ntoh32(seq_no) == 0) &&
+                               (logtrace_seqnum_prev == 0xFFFFFFFF) ) { /* in-order - Roll over */
+                                       ret = 0;
+                       } else {
+
+                               if (diff > 0) {
+                                       DHD_EVENT(("WLC_E_TRACE:"
+                                               "Event lost (log) seqnum %d nblost %d\n",
+                                               ntoh32(seq_no), (diff-1)));
+                               } else {
+                                       DHD_EVENT(("WLC_E_TRACE:"
+                                               "Event Packets coming out of order!!\n"));
+                               }
+                               ret = 0;
+                       }
+       }
+
+       logtrace_seqnum_prev = ntoh32(seq_no);
+
+       return ret;
+}
+
+static void
+dhd_eventmsg_print(dhd_pub_t *dhd_pub, void *event_data, void *raw_event_ptr,
+       uint datalen, const char *event_name)
+{
+       msgtrace_hdr_t hdr;
+       uint32 nblost;
+       uint8 count;
+       char *s, *p;
+       static uint32 seqnum_prev = 0;
+       uint32 *log_ptr =  NULL;
+       uchar *buf;
+       event_log_hdr_t event_hdr;
+       uint32 i;
+       int32 j;
+
+       dhd_event_log_t *raw_event = (dhd_event_log_t *) raw_event_ptr;
+
+       char fmtstr_loc_buf[FMTSTR_SIZE] = {0};
+       char (*str_buf)[SIZE_LOC_STR] = NULL;
+       char * str_tmpptr = NULL;
+       uint32 addr = 0;
+       uint32 **hdr_ptr = NULL;
+       uint32 h_i = 0;
+       uint32 hdr_ptr_len = 0;
+
+       typedef union {
+               uint32 val;
+               char * addr;
+       } u_arg;
+       u_arg arg[MAX_NO_OF_ARG] = {{0}};
+       char *c_ptr = NULL;
+
+       buf = (uchar *) event_data;
+       memcpy(&hdr, buf, MSGTRACE_HDRLEN);
+
+       if (hdr.version != MSGTRACE_VERSION) {
+               DHD_EVENT(("\nMACEVENT: %s [unsupported version --> "
+                       "dhd version:%d dongle version:%d]\n",
+                       event_name, MSGTRACE_VERSION, hdr.version));
+               /* Reset datalen to avoid display below */
+               datalen = 0;
+               return;
+       }
+
+       if (hdr.trace_type == MSGTRACE_HDR_TYPE_MSG) {
+               /* There are 2 bytes available at the end of data */
+               buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0';
+
+               if (ntoh32(hdr.discarded_bytes) || ntoh32(hdr.discarded_printf)) {
+                       DHD_EVENT(("WLC_E_TRACE: [Discarded traces in dongle -->"
+                               "discarded_bytes %d discarded_printf %d]\n",
+                               ntoh32(hdr.discarded_bytes),
+                               ntoh32(hdr.discarded_printf)));
+               }
+
+               nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1;
+               if (nblost > 0) {
+                       DHD_EVENT(("WLC_E_TRACE:"
+                               "[Event lost (msg) --> seqnum %d nblost %d\n",
+                               ntoh32(hdr.seqnum), nblost));
+               }
+               seqnum_prev = ntoh32(hdr.seqnum);
+
+               /* Display the trace buffer. Advance from
+                * \n to \n to avoid display big
+                * printf (issue with Linux printk )
+                */
+               p = (char *)&buf[MSGTRACE_HDRLEN];
+               while (*p != '\0' && (s = strstr(p, "\n")) != NULL) {
+                       *s = '\0';
+                       DHD_EVENT(("%s\n", p));
+                       p = s+1;
+               }
+               if (*p)
+                       DHD_EVENT(("%s", p));
+
+               /* Reset datalen to avoid display below */
+               datalen = 0;
+
+       } else if (hdr.trace_type == MSGTRACE_HDR_TYPE_LOG) {
+               /* Let the standard event printing work for now */
+               uint32 timestamp, w;
+
+               if (check_event_log_sequence_number(hdr.seqnum)) {
+                       DHD_EVENT(("%s: WLC_E_TRACE:"
+                               "[Event duplicate (log) %d] dropping!!\n",
+                               __FUNCTION__, hdr.seqnum));
+                       return; /* drop duplicate events */
+               }
+
+               p = (char *)&buf[MSGTRACE_HDRLEN];
+               datalen -= MSGTRACE_HDRLEN;
+               w = ntoh32((uint32)*p);
+               p += MIN_DLEN;
+               datalen -= MIN_DLEN;
+               timestamp = ntoh32((uint32)*p);
+               BCM_REFERENCE(timestamp);
+               BCM_REFERENCE(w);
+
+               /*
+               * Allocating max possible number of event TAGs in the received buffer
+               * considering  that  each event requires minimum of TAG_BYTES.
+               */
+               hdr_ptr_len = ((datalen/TAG_BYTES)+1) * sizeof(uint32*);
+
+               if ((raw_event->fmts)) {
+                       if (!(str_buf = MALLOC(dhd_pub->osh, (MAX_NO_OF_ARG * SIZE_LOC_STR)))) {
+                               DHD_ERROR(("%s: malloc failed\n", __FUNCTION__));
+                       }
+
+                       if (!(hdr_ptr = MALLOC(dhd_pub->osh, hdr_ptr_len))) {
+                               DHD_ERROR(("%s: malloc failed\n", __FUNCTION__));
+                       }
+               }
+
+               DHD_EVENT(("timestamp %x%x\n", timestamp, w));
+               if ((!raw_event->fmts) || (!str_buf) || (!hdr_ptr)) {
+                       while (datalen > MIN_DLEN) {
+                               p += MIN_DLEN;
+                               datalen -= MIN_DLEN;
+                               /* Print each word.  DO NOT ntoh it.  */
+                               DHD_EVENT((" %8.8x", *((uint32 *) p)));
+                       }
+                       DHD_EVENT(("\n"));
+                       datalen = 0;
+                       if (str_buf) {
+                               MFREE(dhd_pub->osh, str_buf, (MAX_NO_OF_ARG * SIZE_LOC_STR));
+                       }
+                       if (hdr_ptr) {
+                               MFREE(dhd_pub->osh, hdr_ptr, hdr_ptr_len);
+                       }
+                       return;
+               }
+
+               /* (raw_event->fmts) has value */
+
+               log_ptr = (uint32 *) (p + datalen);
+
+               while (datalen > MIN_DLEN) {
+                       log_ptr--;
+                       datalen -= MIN_DLEN;
+                       event_hdr.t = *log_ptr;
+                       /*
+                        * Check for partially overriten entries
+                        */
+                       if (log_ptr - (uint32 *) p < event_hdr.count) {
+                                       break;
+                       }
+                       /*
+                       * Check for end of the Frame.
+                       */
+                       if (event_hdr.tag ==  EVENT_LOG_TAG_NULL) {
+                               continue;
+                       }
+                       /*
+                       * Check For Special Time Stamp Packet
+                       */
+                       if (event_hdr.tag == EVENT_LOG_TAG_TS) {
+                               datalen -= TAG_BYTES;
+                               log_ptr = log_ptr - TAG_WORDS;
+                               continue;
+                       }
+
+                       log_ptr[0] = event_hdr.t;
+                       if (h_i < (hdr_ptr_len / sizeof(uint32*))) {
+                               hdr_ptr[h_i++] = log_ptr;
+                       }
+                       if (event_hdr.count > MAX_NO_OF_ARG) {
+                               break;
+                       }
+
+                       /* Now place the header at the front
+                       * and copy back.
+                       */
+                       log_ptr -= event_hdr.count;
+
+                       c_ptr = NULL;
+                       datalen = datalen - (event_hdr.count * MIN_DLEN);
+               }
+               datalen = 0;
+
+               for (j = (h_i-1); j >= 0; j--) {
+                       if (!(hdr_ptr[j])) {
+                               break;
+                       }
+
+                       event_hdr.t = *hdr_ptr[j];
+
+                       log_ptr = hdr_ptr[j];
+
+                       /* Now place the header at the front
+                       * and copy back.
+                       */
+                       log_ptr -= event_hdr.count;
+
+                       /* Copy the format string to parse %s and add "CONSOLE: "  ??? */
+                       if ((event_hdr.fmt_num >> 2) < raw_event->num_fmts) {
+                               snprintf(fmtstr_loc_buf, FMTSTR_SIZE,
+                                       "CONSOLE: [0x%x] %s", log_ptr[event_hdr.count-1],
+                                       raw_event->fmts[event_hdr.fmt_num >> 2]);
+                                       c_ptr = fmtstr_loc_buf;
+                       }
+
+                       for (count = 0; count < (event_hdr.count-1); count++) {
+                               if (c_ptr != NULL) {
+                                       if ((c_ptr = strstr(c_ptr, "%")) != NULL) {
+                                               c_ptr++;
+                                       }
+                               }
+
+                               if ((c_ptr != NULL) && (*c_ptr == 's')) {
+                                       if ((raw_event->raw_sstr) &&
+                                               ((log_ptr[count] > raw_event->rodata_start) &&
+                                               (log_ptr[count] < raw_event->rodata_end))) {
+                                               /* ram static string */
+                                               addr = log_ptr[count] - raw_event->rodata_start;
+                                               str_tmpptr = raw_event->raw_sstr + addr;
+                                               memcpy(str_buf[count], str_tmpptr, SIZE_LOC_STR);
+                                               str_buf[count][SIZE_LOC_STR-1] = '\0';
+                                               arg[count].addr = str_buf[count];
+                                       } else if ((raw_event->rom_raw_sstr) &&
+                                               ((log_ptr[count] >
+                                               raw_event->rom_rodata_start) &&
+                                               (log_ptr[count] <
+                                               raw_event->rom_rodata_end))) {
+                                               /* rom static string */
+                                               addr = log_ptr[count] - raw_event->rom_rodata_start;
+                                               str_tmpptr = raw_event->rom_raw_sstr + addr;
+                                               memcpy(str_buf[count], str_tmpptr, SIZE_LOC_STR);
+                                               str_buf[count][SIZE_LOC_STR-1] = '\0';
+                                               arg[count].addr = str_buf[count];
+                                       } else {
+                                               /*
+                                               *  Dynamic string OR
+                                               * No data for static string.
+                                               * So store all string's address as string.
+                                               */
+                                               snprintf(str_buf[count], SIZE_LOC_STR, "(s)0x%x",
+                                                       log_ptr[count]);
+                                                       arg[count].addr = str_buf[count];
+                                       }
+                               } else {
+                                       /* Other than string */
+                                       arg[count].val = log_ptr[count];
+                               }
+                       }
+
+                       DHD_EVENT((fmtstr_loc_buf, arg[0], arg[1], arg[2], arg[3],
+                               arg[4], arg[5], arg[6], arg[7], arg[8], arg[9], arg[10],
+                               arg[11], arg[12], arg[13], arg[14], arg[15]));
+
+                       for (i = 0; i < MAX_NO_OF_ARG; i++) {
+                               arg[i].addr = 0;
+                       }
+                       for (i = 0; i < MAX_NO_OF_ARG; i++) {
+                               memset(str_buf[i], 0, SIZE_LOC_STR);
+                       }
+
+               }
+
+               if (str_buf) {
+                       MFREE(dhd_pub->osh, str_buf, (MAX_NO_OF_ARG * SIZE_LOC_STR));
+               }
+
+               if (hdr_ptr) {
+                       MFREE(dhd_pub->osh, hdr_ptr, hdr_ptr_len);
+               }
+       }
+}
+
+#endif /* SHOW_LOGTRACE */
+
 static void
-wl_show_host_event(wl_event_msg_t *event, void *event_data)
+wl_show_host_event(dhd_pub_t *dhd_pub, wl_event_msg_t *event, void *event_data,
+       void *raw_event_ptr)
 {
        uint i, status, reason;
        bool group = FALSE, flush_txq = FALSE, link = FALSE;
@@ -1055,93 +1383,13 @@ wl_show_host_event(wl_event_msg_t *event, void *event_data)
                break;
 #endif /* WIFI_ACT_FRAME */
 
-       case WLC_E_TRACE: {
-               static uint32 seqnum_prev = 0;
-               static uint32 logtrace_seqnum_prev = 0;
-               msgtrace_hdr_t hdr;
-               uint32 nblost;
-               char *s, *p;
-
-               buf = (uchar *) event_data;
-               memcpy(&hdr, buf, MSGTRACE_HDRLEN);
-
-               if (hdr.version != MSGTRACE_VERSION) {
-                       printf("\nMACEVENT: %s [unsupported version --> "
-                              "dhd version:%d dongle version:%d]\n",
-                              event_name, MSGTRACE_VERSION, hdr.version);
-                       /* Reset datalen to avoid display below */
-                       datalen = 0;
-                       break;
-               }
-
-               if (hdr.trace_type == MSGTRACE_HDR_TYPE_MSG) {
-                       /* There are 2 bytes available at the end of data */
-                       buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0';
-
-                       if (ntoh32(hdr.discarded_bytes) || ntoh32(hdr.discarded_printf)) {
-                               printf("\nWLC_E_TRACE: [Discarded traces in dongle -->"
-                                      "discarded_bytes %d discarded_printf %d]\n",
-                                      ntoh32(hdr.discarded_bytes), ntoh32(hdr.discarded_printf));
-                       }
-
-                       nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1;
-                       if (nblost > 0) {
-                               printf("\nWLC_E_TRACE: [Event lost (msg) --> seqnum %d nblost %d\n",
-                                      ntoh32(hdr.seqnum), nblost);
-                       }
-                       seqnum_prev = ntoh32(hdr.seqnum);
-
-                       /* Display the trace buffer. Advance from \n to \n to avoid display big
-                        * printf (issue with Linux printk )
-                        */
-                       p = (char *)&buf[MSGTRACE_HDRLEN];
-               while (*p != '\0' && (s = strstr(p, "\n")) != NULL) {
-                               *s = '\0';
-                               printf("WLC_E_TRACE: %s\n", p);
-                               p = s+1;
-                       }
-                       if (*p) printf("WLC_E_TRACE: %s", p);
-
-                       /* Reset datalen to avoid display below */
-                       datalen = 0;
-
-               } else if (hdr.trace_type == MSGTRACE_HDR_TYPE_LOG) {
-                       /* Let the standard event printing work for now */
-                       uint32 timestamp, w;
-                       if (ntoh32(hdr.seqnum) == logtrace_seqnum_prev) {
-                               printf("\nWLC_E_TRACE: [Event duplicate (log) %d",
-                                      logtrace_seqnum_prev);
-                       } else {
-                               nblost = ntoh32(hdr.seqnum) - logtrace_seqnum_prev - 1;
-                               if (nblost > 0) {
-                                       printf("\nWLC_E_TRACE: [Event lost (log)"
-                                              " --> seqnum %d nblost %d\n",
-                                              ntoh32(hdr.seqnum), nblost);
-                               }
-                               logtrace_seqnum_prev = ntoh32(hdr.seqnum);
-
-                               p = (char *)&buf[MSGTRACE_HDRLEN];
-                               datalen -= MSGTRACE_HDRLEN;
-                               w = ntoh32((uint32) *p);
-                               p += 4;
-                               datalen -= 4;
-                               timestamp = ntoh32((uint32) *p);
-                               printf("Logtrace %x timestamp %x %x",
-                                      logtrace_seqnum_prev, timestamp, w);
-
-                               while (datalen > 4) {
-                                       p += 4;
-                                       datalen -= 4;
-                                       /* Print each word.  DO NOT ntoh it.  */
-                                       printf(" %8.8x", *((uint32 *) p));
-                               }
-                               printf("\n");
-                       }
-                       datalen = 0;
-               }
-
+#ifdef SHOW_LOGTRACE
+       case WLC_E_TRACE:
+       {
+               dhd_eventmsg_print(dhd_pub, event_data, raw_event_ptr, datalen, event_name);
                break;
        }
+#endif /* SHOW_LOGTRACE */
 
 
        case WLC_E_RSSI:
@@ -1185,7 +1433,7 @@ wl_show_host_event(wl_event_msg_t *event, void *event_data)
 
 int
 wl_host_event(dhd_pub_t *dhd_pub, int *ifidx, void *pktdata,
-              wl_event_msg_t *event, void **data_ptr)
+              wl_event_msg_t *event, void **data_ptr, void *raw_event)
 {
        /* check whether packet is a BRCM event pkt */
        bcm_event_t *pvt_data = (bcm_event_t *)pktdata;
@@ -1245,7 +1493,10 @@ wl_host_event(dhd_pub_t *dhd_pub, int *ifidx, void *pktdata,
 #endif /* DHD_DEBUG */
 #ifdef PROP_TXSTATUS
        case WLC_E_FIFO_CREDIT_MAP:
-               dhd_wlfc_enable(dhd_pub);
+               if (dhd_wlfc_enable(dhd_pub) != BCME_OK) {
+                       DHD_ERROR(("%s: dhd_wlfc_enable failed\n", __FUNCTION__));
+                       return (BCME_ERROR);
+               }
                dhd_wlfc_FIFOcreditmap_event(dhd_pub, event_data);
                WLFC_DBGMESG(("WLC_E_FIFO_CREDIT_MAP:(AC0,AC1,AC2,AC3),(BC_MC),(OTHER): "
                        "(%d,%d,%d,%d),(%d),(%d)\n", event_data[0], event_data[1],
@@ -1256,7 +1507,7 @@ wl_host_event(dhd_pub_t *dhd_pub, int *ifidx, void *pktdata,
        case WLC_E_BCMC_CREDIT_SUPPORT:
                dhd_wlfc_BCMCCredit_support_event(dhd_pub);
                break;
-#endif
+#endif /* PROP_TXSTATUS */
 
        case WLC_E_IF: {
                struct wl_event_data_if *ifevent = (struct wl_event_data_if *)event_data;
@@ -1369,7 +1620,7 @@ wl_host_event(dhd_pub_t *dhd_pub, int *ifidx, void *pktdata,
        }
 
 #ifdef SHOW_EVENTS
-       wl_show_host_event(event, (void *)event_data);
+       wl_show_host_event(dhd_pub, event, (void *)event_data, raw_event);
 #endif /* SHOW_EVENTS */
 
        return (BCME_OK);
index 3737e07..626d8be 100644 (file)
@@ -1,6 +1,6 @@
 /*
 * Customer code to add GPIO control during WLAN start/stop
-* Copyright (C) 1999-2014, Broadcom Corporation
+* Copyright (C) 1999-2015, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
index b9f1c6f..f8d3b2a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Debug/trace/assert driver definitions for Dongle Host Driver.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 9b1b182..2d046c2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * IP Packet Parser Module.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_ip.c 486237 2014-06-19 09:22:00Z $
+ * $Id: dhd_ip.c 529177 2015-01-26 12:49:53Z $
  */
 #include <typedefs.h>
 #include <osl.h>
@@ -128,10 +128,14 @@ typedef struct _tdata_psh_info_t {
 } tdata_psh_info_t;
 
 typedef struct {
-       uint8 src_ip_addr[IPV4_ADDR_LEN];       /* SRC ip addrs of this TCP stream */
-       uint8 dst_ip_addr[IPV4_ADDR_LEN];       /* DST ip addrs of this TCP stream */
-       uint8 src_tcp_port[TCP_PORT_LEN];       /* SRC tcp ports of this TCP stream */
-       uint8 dst_tcp_port[TCP_PORT_LEN];       /* DST tcp ports of this TCP stream */
+       struct {
+               uint8 src[IPV4_ADDR_LEN];       /* SRC ip addrs of this TCP stream */
+               uint8 dst[IPV4_ADDR_LEN];       /* DST ip addrs of this TCP stream */
+       } ip_addr;
+       struct {
+               uint8 src[TCP_PORT_LEN];        /* SRC tcp ports of this TCP stream */
+               uint8 dst[TCP_PORT_LEN];        /* DST tcp ports of this TCP stream */
+       } tcp_port;
        tdata_psh_info_t *tdata_psh_info_head;  /* Head of received TCP PSH DATA chain */
        tdata_psh_info_t *tdata_psh_info_tail;  /* Tail of received TCP PSH DATA chain */
        uint32 last_used_time;  /* The last time this tcpdata_info was used(in ms) */
@@ -463,20 +467,20 @@ static INLINE bool dhd_tcpdata_psh_acked(dhd_pub_t *dhdp, uint8 *ip_hdr,
                tcpdata_info_t *tcpdata_info_tmp = &tcpack_sup_mod->tcpdata_info_tbl[i];
                DHD_TRACE(("%s %d: data info[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR
                        " TCP port %d %d\n", __FUNCTION__, __LINE__, i,
-                       IPV4_ADDR_TO_STR(ntoh32_ua(tcpdata_info_tmp->src_ip_addr)),
-                       IPV4_ADDR_TO_STR(ntoh32_ua(tcpdata_info_tmp->dst_ip_addr)),
-                       ntoh16_ua(tcpdata_info_tmp->src_tcp_port),
-                       ntoh16_ua(tcpdata_info_tmp->dst_tcp_port)));
+                       IPV4_ADDR_TO_STR(ntoh32_ua(tcpdata_info_tmp->ip_addr.src)),
+                       IPV4_ADDR_TO_STR(ntoh32_ua(tcpdata_info_tmp->ip_addr.dst)),
+                       ntoh16_ua(tcpdata_info_tmp->tcp_port.src),
+                       ntoh16_ua(tcpdata_info_tmp->tcp_port.dst)));
 
                /* If either IP address or TCP port number does not match, skip. */
                if (memcmp(&ip_hdr[IPV4_SRC_IP_OFFSET],
-                       tcpdata_info_tmp->dst_ip_addr, IPV4_ADDR_LEN) == 0 &&
+                       tcpdata_info_tmp->ip_addr.dst, IPV4_ADDR_LEN) == 0 &&
                        memcmp(&ip_hdr[IPV4_DEST_IP_OFFSET],
-                       tcpdata_info_tmp->src_ip_addr, IPV4_ADDR_LEN) == 0 &&
+                       tcpdata_info_tmp->ip_addr.src, IPV4_ADDR_LEN) == 0 &&
                        memcmp(&tcp_hdr[TCP_SRC_PORT_OFFSET],
-                       tcpdata_info_tmp->dst_tcp_port, TCP_PORT_LEN) == 0 &&
+                       tcpdata_info_tmp->tcp_port.dst, TCP_PORT_LEN) == 0 &&
                        memcmp(&tcp_hdr[TCP_DEST_PORT_OFFSET],
-                       tcpdata_info_tmp->src_tcp_port, TCP_PORT_LEN) == 0) {
+                       tcpdata_info_tmp->tcp_port.src, TCP_PORT_LEN) == 0) {
                        tcpdata_info = tcpdata_info_tmp;
                        break;
                }
@@ -657,7 +661,10 @@ dhd_tcpack_suppress(dhd_pub_t *dhdp, void *pkt)
                        ntoh16_ua(&old_tcp_hdr[TCP_SRC_PORT_OFFSET]),
                        ntoh16_ua(&old_tcp_hdr[TCP_DEST_PORT_OFFSET])));
 
-               /* If either of IP address or TCP port number does not match, skip. */
+               /* If either of IP address or TCP port number does not match, skip.
+                * Note that src/dst addr fields in ip header are contiguous being 8 bytes in total.
+                * Also, src/dst port fields in TCP header are contiguous being 4 bytes in total.
+                */
                if (memcmp(&new_ip_hdr[IPV4_SRC_IP_OFFSET],
                        &old_ip_hdr[IPV4_SRC_IP_OFFSET], IPV4_ADDR_LEN * 2) ||
                        memcmp(&new_tcp_hdr[TCP_SRC_PORT_OFFSET],
@@ -825,16 +832,19 @@ dhd_tcpdata_info_get(dhd_pub_t *dhdp, void *pkt)
                uint32 now_in_ms = OSL_SYSUPTIME();
                DHD_TRACE(("%s %d: data info[%d], IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR
                        " TCP port %d %d\n", __FUNCTION__, __LINE__, i,
-                       IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->src_ip_addr)),
-                       IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->dst_ip_addr)),
-                       ntoh16_ua(tdata_info_tmp->src_tcp_port),
-                       ntoh16_ua(tdata_info_tmp->dst_tcp_port)));
-
-               /* If both IP address and TCP port number match, we found it so break. */
+                       IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->ip_addr.src)),
+                       IPV4_ADDR_TO_STR(ntoh32_ua(tdata_info_tmp->ip_addr.dst)),
+                       ntoh16_ua(tdata_info_tmp->tcp_port.src),
+                       ntoh16_ua(tdata_info_tmp->tcp_port.dst)));
+
+               /* If both IP address and TCP port number match, we found it so break.
+                * Note that src/dst addr fields in ip header are contiguous being 8 bytes in total.
+                * Also, src/dst port fields in TCP header are contiguous being 4 bytes in total.
+                */
                if (memcmp(&ip_hdr[IPV4_SRC_IP_OFFSET],
-                       (void *)tdata_info_tmp->src_ip_addr, IPV4_ADDR_LEN * 2) == 0 &&
+                       (void *)&tdata_info_tmp->ip_addr, IPV4_ADDR_LEN * 2) == 0 &&
                        memcmp(&tcp_hdr[TCP_SRC_PORT_OFFSET],
-                       (void *)tdata_info_tmp->src_tcp_port, TCP_PORT_LEN * 2) == 0) {
+                       (void *)&tdata_info_tmp->tcp_port, TCP_PORT_LEN * 2) == 0) {
                        tcpdata_info = tdata_info_tmp;
                        tcpdata_info->last_used_time = now_in_ms;
                        break;
@@ -865,7 +875,7 @@ dhd_tcpdata_info_get(dhd_pub_t *dhdp, void *pkt)
                                bcopy(last_tdata_info, tdata_info_tmp, sizeof(tcpdata_info_t));
                        }
                        bzero(last_tdata_info, sizeof(tcpdata_info_t));
-                       DHD_ERROR(("%s %d: tcpdata_info(idx %d) is aged out. ttl cnt is now %d\n",
+                       DHD_INFO(("%s %d: tcpdata_info(idx %d) is aged out. ttl cnt is now %d\n",
                                __FUNCTION__, __LINE__, i, tcpack_sup_mod->tcpdata_info_cnt));
                        /* Don't increase "i" here, so that the prev last tcpdata_info is checked */
                } else
@@ -894,17 +904,19 @@ dhd_tcpdata_info_get(dhd_pub_t *dhdp, void *pkt)
                /* No TCP flow with the same IP addr and TCP port is found
                 * in tcp_data_info_tbl. So add this flow to the table.
                 */
-               DHD_ERROR(("%s %d: Add data info to tbl[%d]: IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR
+               DHD_INFO(("%s %d: Add data info to tbl[%d]: IP addr "IPV4_ADDR_STR" "IPV4_ADDR_STR
                        " TCP port %d %d\n",
                        __FUNCTION__, __LINE__, tcpack_sup_mod->tcpdata_info_cnt,
                        IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_SRC_IP_OFFSET])),
                        IPV4_ADDR_TO_STR(ntoh32_ua(&ip_hdr[IPV4_DEST_IP_OFFSET])),
                        ntoh16_ua(&tcp_hdr[TCP_SRC_PORT_OFFSET]),
                        ntoh16_ua(&tcp_hdr[TCP_DEST_PORT_OFFSET])));
-
-               bcopy(&ip_hdr[IPV4_SRC_IP_OFFSET], (void *)tcpdata_info->src_ip_addr,
+               /* Note that src/dst addr fields in ip header are contiguous being 8 bytes in total.
+                * Also, src/dst port fields in TCP header are contiguous being 4 bytes in total.
+                */
+               bcopy(&ip_hdr[IPV4_SRC_IP_OFFSET], (void *)&tcpdata_info->ip_addr,
                        IPV4_ADDR_LEN * 2);
-               bcopy(&tcp_hdr[TCP_SRC_PORT_OFFSET], (void *)tcpdata_info->src_tcp_port,
+               bcopy(&tcp_hdr[TCP_SRC_PORT_OFFSET], (void *)&tcpdata_info->tcp_port,
                        TCP_PORT_LEN * 2);
 
                tcpdata_info->last_used_time = OSL_SYSUPTIME();
index 328329e..6843b31 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Provides type definitions and function prototypes used to parse ip packet.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 2e23e29..203f895 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom Dongle Host Driver (DHD), Linux-specific network interface
  * Basically selected code segments from usb-cdc.c and usb-rndis.c
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_linux.c 512574 2014-11-04 03:07:46Z $
+ * $Id: dhd_linux.c 589976 2015-10-01 07:01:27Z $
  */
 
 #include <typedefs.h>
 #include <linuxver.h>
 #include <osl.h>
+#ifdef SHOW_LOGTRACE
+#include <linux/syscalls.h>
+#include <event_log.h>
+#endif /* SHOW_LOGTRACE */
 
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -219,6 +223,10 @@ extern wl_iw_extra_params_t  g_wl_iw_params;
 #include <linux/earlysuspend.h>
 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND) */
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+#include <linux/nl80211.h>
+#endif /* OEM_ANDROID && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
+
 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
 
 #ifdef PKT_FILTER_SUPPORT
@@ -375,6 +383,9 @@ typedef struct dhd_info {
        wait_queue_head_t ctrl_wait;
        atomic_t pend_8021x_cnt;
        dhd_attach_states_t dhd_state;
+#ifdef SHOW_LOGTRACE
+       dhd_event_log_t event_data;
+#endif /* SHOW_LOGTRACE */
 
 #if defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND)
        struct early_suspend early_suspend;
@@ -811,7 +822,11 @@ _turn_on_arp_filter(dhd_pub_t *dhd, int op_mode)
                goto exit;
        }
        /* In case of P2P GO or GC, apply pkt filter to pass arp pkt to host */
+#if defined(ARP_OFFLOAD_SUPPORT)
        if ((dhd->arp_version == 1) &&
+#else
+       if (
+#endif
                (op_mode & (DHD_FLAG_P2P_GC_MODE | DHD_FLAG_P2P_GO_MODE))) {
                _apply = TRUE;
                goto exit;
@@ -1360,6 +1375,28 @@ extern struct net_device *ap_net_dev;
 extern tsk_ctl_t ap_eth_ctl; /* ap netdev heper thread ctl */
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+int32 dhd_role_to_nl80211_iftype(int32 role)
+{
+       switch (role) {
+       case WLC_E_IF_ROLE_STA:
+               return NL80211_IFTYPE_STATION;
+       case WLC_E_IF_ROLE_AP:
+               return NL80211_IFTYPE_AP;
+       case WLC_E_IF_ROLE_WDS:
+               return NL80211_IFTYPE_WDS;
+       case WLC_E_IF_ROLE_P2P_GO:
+               return NL80211_IFTYPE_P2P_GO;
+       case WLC_E_IF_ROLE_P2P_CLIENT:
+               return NL80211_IFTYPE_P2P_CLIENT;
+       case WLC_E_IF_ROLE_IBSS:
+               return NL80211_IFTYPE_ADHOC;
+       default:
+               return NL80211_IFTYPE_UNSPECIFIED;
+       }
+}
+#endif /* OEM_ANDROID && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
+
 static void
 dhd_ifadd_event_handler(void *handle, void *event_info, u8 event)
 {
@@ -1368,6 +1405,10 @@ dhd_ifadd_event_handler(void *handle, void *event_info, u8 event)
        struct net_device *ndev;
        int ifidx, bssidx;
        int ret;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+       struct wireless_dev *vwdev, *primary_wdev;
+       struct net_device *primary_ndev;
+#endif /* OEM_ANDROID && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
 
        if (event != DHD_WQ_WORK_IF_ADD) {
                DHD_ERROR(("%s: unexpected event \n", __FUNCTION__));
@@ -1398,6 +1439,22 @@ dhd_ifadd_event_handler(void *handle, void *event_info, u8 event)
                goto done;
        }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+       vwdev = kzalloc(sizeof(*vwdev), GFP_KERNEL);
+       if (unlikely(!vwdev)) {
+               DHD_ERROR(("Could not allocate wireless device\n"));
+               goto done;
+       }
+       primary_ndev = dhd->pub.info->iflist[0]->net;
+       primary_wdev = ndev_to_wdev(primary_ndev);
+       vwdev->wiphy = primary_wdev->wiphy;
+       vwdev->iftype = dhd_role_to_nl80211_iftype(if_event->event.role);
+       vwdev->netdev = ndev;
+       ndev->ieee80211_ptr = vwdev;
+       SET_NETDEV_DEV(ndev, wiphy_dev(vwdev->wiphy));
+       DHD_ERROR(("virtual interface(%s) is created\n", if_event->name));
+#endif /* OEM_ANDROID && (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
+
        ret = dhd_register_if(&dhd->pub, ifidx, TRUE);
        if (ret != BCME_OK) {
                DHD_ERROR(("%s: dhd_register_if failed\n", __FUNCTION__));
@@ -2135,8 +2192,6 @@ dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success)
        dhd_info_t *dhd = (dhd_info_t *)(dhdp->info);
        struct ether_header *eh;
        uint16 type;
-       uint datalen;
-       dhd_if_t *ifp;
 
        dhd_prot_hdrpull(dhdp, NULL, txp, NULL, NULL);
 
@@ -2148,12 +2203,9 @@ dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success)
 
 #ifdef PROP_TXSTATUS
        if (dhdp->wlfc_state && (dhdp->proptxstatus_mode != WLFC_FCMODE_NONE)) {
-               ifp = dhd->iflist[DHD_PKTTAG_IF(PKTTAG(txp))];
-               /* if the interface is released somewhere just return */
-               if (ifp == NULL)
-                       return;
+               dhd_if_t *ifp = dhd->iflist[DHD_PKTTAG_IF(PKTTAG(txp))];
+               uint datalen  = PKTLEN(dhd->pub.osh, txp);
 
-               datalen  = PKTLEN(dhd->pub.osh, txp);
                if (success) {
                        dhd->pub.tx_packets++;
                        ifp->stats.tx_packets++;
@@ -2387,11 +2439,6 @@ dhd_rxf_thread(void *data)
                setScheduler(current, SCHED_FIFO, &param);
        }
 
-       DAEMONIZE("dhd_rxf");
-       /* DHD_OS_WAKE_LOCK is called in dhd_sched_dpc[dhd_linux.c] down below  */
-
-       /*  signal: thread has started */
-       complete(&tsk->completed);
 
 #ifdef CUSTOM_SET_CPUCORE
        dhd->pub.current_rxf = current;
@@ -3065,11 +3112,13 @@ dhd_stop(struct net_device *net)
                                (dhd->dhd_state & DHD_ATTACH_STATE_CFG80211)) {
                                int i;
 
+
                                dhd_net_if_lock_local(dhd);
                                for (i = 1; i < DHD_MAX_IFS; i++)
                                        dhd_remove_if(&dhd->pub, i, FALSE);
                                dhd_net_if_unlock_local(dhd);
                        }
+                       cancel_work_sync(dhd->dhd_deferred_wq);
                }
        }
 #endif /* WL_CFG80211 */
@@ -3369,7 +3418,11 @@ dhd_event_ifadd(dhd_info_t *dhdinfo, wl_event_data_if_t *ifevent, char *name, ui
         */
        if (ifevent->ifidx > 0) {
                dhd_if_event_t *if_event = MALLOC(dhdinfo->pub.osh, sizeof(dhd_if_event_t));
-
+               if (if_event == NULL) {
+                       DHD_ERROR(("dhd_event_ifadd: Failed MALLOC, malloced %d bytes",
+                               MALLOCED(dhdinfo->pub.osh)));
+                       return BCME_NOMEM;
+               }
                memcpy(&if_event->event, ifevent, sizeof(if_event->event));
                memcpy(if_event->mac, mac, ETHER_ADDR_LEN);
                strncpy(if_event->name, name, IFNAMSIZ);
@@ -3395,6 +3448,11 @@ dhd_event_ifdel(dhd_info_t *dhdinfo, wl_event_data_if_t *ifevent, char *name, ui
         * anything else
         */
        if_event = MALLOC(dhdinfo->pub.osh, sizeof(dhd_if_event_t));
+       if (if_event == NULL) {
+               DHD_ERROR(("dhd_event_ifdel: malloc failed for if_event, malloced %d bytes",
+                       MALLOCED(dhdinfo->pub.osh)));
+               return BCME_NOMEM;
+       }
        memcpy(&if_event->event, ifevent, sizeof(if_event->event));
        memcpy(if_event->mac, mac, ETHER_ADDR_LEN);
        strncpy(if_event->name, name, IFNAMSIZ);
@@ -3579,6 +3637,368 @@ extern void debugger_init(void *bus_handle);
 #endif
 
 
+#ifdef SHOW_LOGTRACE
+static char *logstrs_path = "/root/logstrs.bin";
+static char *st_str_file_path = "/root/rtecdc.bin";
+static char *map_file_path = "/root/rtecdc.map";
+static char *rom_st_str_file_path = "/root/roml.bin";
+static char *rom_map_file_path = "/root/roml.map";
+
+#define BYTES_AHEAD_NUM                11      /* address in map file is before these many bytes */
+#define READ_NUM_BYTES         1000 /* read map file each time this No. of bytes */
+#define GO_BACK_FILE_POS_NUM_BYTES     100 /* set file pos back to cur pos */
+static char *ramstart_str = "text_start"; /* string in mapfile has addr ramstart */
+static char *rodata_start_str = "rodata_start"; /* string in mapfile has addr rodata start */
+static char *rodata_end_str = "rodata_end"; /* string in mapfile has addr rodata end */
+static char *ram_file_str = "rtecdc";
+static char *rom_file_str = "roml";
+#define RAMSTART_BIT   0x01
+#define RDSTART_BIT            0x02
+#define RDEND_BIT              0x04
+#define ALL_MAP_VAL            (RAMSTART_BIT | RDSTART_BIT | RDEND_BIT)
+
+module_param(logstrs_path, charp, S_IRUGO);
+module_param(st_str_file_path, charp, S_IRUGO);
+module_param(map_file_path, charp, S_IRUGO);
+module_param(rom_st_str_file_path, charp, S_IRUGO);
+module_param(rom_map_file_path, charp, S_IRUGO);
+
+static void
+dhd_init_logstrs_array(dhd_event_log_t *temp)
+{
+       struct file *filep = NULL;
+       struct kstat stat;
+       mm_segment_t fs;
+       char *raw_fmts =  NULL;
+       int logstrs_size = 0;
+
+       logstr_header_t *hdr = NULL;
+       uint32 *lognums = NULL;
+       char *logstrs = NULL;
+       int ram_index = 0;
+       char **fmts;
+       int num_fmts = 0;
+       uint32 i = 0;
+       int error = 0;
+
+       fs = get_fs();
+       set_fs(KERNEL_DS);
+
+       filep = filp_open(logstrs_path, O_RDONLY, 0);
+
+       if (IS_ERR(filep)) {
+               DHD_ERROR(("%s: Failed to open the file %s \n", __FUNCTION__, logstrs_path));
+               goto fail;
+       }
+       error = vfs_stat(logstrs_path, &stat);
+       if (error) {
+               DHD_ERROR(("%s: Failed to stat file %s \n", __FUNCTION__, logstrs_path));
+               goto fail;
+       }
+       logstrs_size = (int) stat.size;
+
+       raw_fmts = kmalloc(logstrs_size, GFP_KERNEL);
+       if (raw_fmts == NULL) {
+               DHD_ERROR(("%s: Failed to allocate memory \n", __FUNCTION__));
+               goto fail;
+       }
+       if (vfs_read(filep, raw_fmts, logstrs_size, &filep->f_pos) !=   logstrs_size) {
+               DHD_ERROR(("%s: Failed to read file %s", __FUNCTION__, logstrs_path));
+               goto fail;
+       }
+
+       /* Remember header from the logstrs.bin file */
+       hdr = (logstr_header_t *) (raw_fmts + logstrs_size -
+               sizeof(logstr_header_t));
+
+       if (hdr->log_magic == LOGSTRS_MAGIC) {
+               /*
+               * logstrs.bin start with header.
+               */
+               num_fmts =      hdr->rom_logstrs_offset / sizeof(uint32);
+               ram_index = (hdr->ram_lognums_offset -
+                       hdr->rom_lognums_offset) / sizeof(uint32);
+               lognums = (uint32 *) &raw_fmts[hdr->rom_lognums_offset];
+               logstrs = (char *)       &raw_fmts[hdr->rom_logstrs_offset];
+       } else {
+               /*
+                * Legacy logstrs.bin format without header.
+                */
+               num_fmts = *((uint32 *) (raw_fmts)) / sizeof(uint32);
+               if (num_fmts == 0) {
+                       /* Legacy ROM/RAM logstrs.bin format:
+                         *  - ROM 'lognums' section
+                         *   - RAM 'lognums' section
+                         *   - ROM 'logstrs' section.
+                         *   - RAM 'logstrs' section.
+                         *
+                         * 'lognums' is an array of indexes for the strings in the
+                         * 'logstrs' section. The first uint32 is 0 (index of first
+                         * string in ROM 'logstrs' section).
+                         *
+                         * The 4324b5 is the only ROM that uses this legacy format. Use the
+                         * fixed number of ROM fmtnums to find the start of the RAM
+                         * 'lognums' section. Use the fixed first ROM string ("Con\n") to
+                         * find the ROM 'logstrs' section.
+                         */
+                       #define NUM_4324B5_ROM_FMTS     186
+                       #define FIRST_4324B5_ROM_LOGSTR "Con\n"
+                       ram_index = NUM_4324B5_ROM_FMTS;
+                       lognums = (uint32 *) raw_fmts;
+                       num_fmts =      ram_index;
+                       logstrs = (char *) &raw_fmts[num_fmts << 2];
+                       while (strncmp(FIRST_4324B5_ROM_LOGSTR, logstrs, 4)) {
+                               num_fmts++;
+                               logstrs = (char *) &raw_fmts[num_fmts << 2];
+                       }
+               } else {
+                               /* Legacy RAM-only logstrs.bin format:
+                                *        - RAM 'lognums' section
+                                *        - RAM 'logstrs' section.
+                                *
+                                * 'lognums' is an array of indexes for the strings in the
+                                * 'logstrs' section. The first uint32 is an index to the
+                                * start of 'logstrs'. Therefore, if this index is divided
+                                * by 'sizeof(uint32)' it provides the number of logstr
+                                *      entries.
+                                */
+                               ram_index = 0;
+                               lognums = (uint32 *) raw_fmts;
+                               logstrs = (char *)      &raw_fmts[num_fmts << 2];
+                       }
+       }
+       fmts = kmalloc(num_fmts  * sizeof(char *), GFP_KERNEL);
+       if (fmts == NULL) {
+               DHD_ERROR(("Failed to allocate fmts memory"));
+               goto fail;
+       }
+
+       for (i = 0; i < num_fmts; i++) {
+               /* ROM lognums index into logstrs using 'rom_logstrs_offset' as a base
+               * (they are 0-indexed relative to 'rom_logstrs_offset').
+               *
+               * RAM lognums are already indexed to point to the correct RAM logstrs (they
+               * are 0-indexed relative to the start of the logstrs.bin file).
+               */
+               if (i == ram_index) {
+                       logstrs = raw_fmts;
+               }
+               fmts[i] = &logstrs[lognums[i]];
+       }
+       temp->fmts = fmts;
+       temp->raw_fmts = raw_fmts;
+       temp->num_fmts = num_fmts;
+       filp_close(filep, NULL);
+       set_fs(fs);
+       return;
+fail:
+       if (raw_fmts) {
+               kfree(raw_fmts);
+               raw_fmts = NULL;
+       }
+       if (!IS_ERR(filep))
+               filp_close(filep, NULL);
+       set_fs(fs);
+       temp->fmts = NULL;
+       return;
+}
+
+static int
+dhd_read_map(char *fname, uint32 *ramstart, uint32 *rodata_start,
+       uint32 *rodata_end)
+{
+       struct file *filep = NULL;
+       mm_segment_t fs;
+       char *raw_fmts =  NULL;
+       uint32 read_size = READ_NUM_BYTES;
+       int error = 0;
+       char * cptr = NULL;
+       char c;
+       uint8 count = 0;
+
+       *ramstart = 0;
+       *rodata_start = 0;
+       *rodata_end = 0;
+
+       if (fname == NULL) {
+               DHD_ERROR(("%s: ERROR fname is NULL \n", __FUNCTION__));
+               return BCME_ERROR;
+       }
+
+       fs = get_fs();
+       set_fs(KERNEL_DS);
+
+       filep = filp_open(fname, O_RDONLY, 0);
+       if (IS_ERR(filep)) {
+               DHD_ERROR(("%s: Failed to open %s \n",  __FUNCTION__, fname));
+               goto fail;
+       }
+
+       raw_fmts = kmalloc(read_size, GFP_KERNEL);
+       if (raw_fmts == NULL) {
+               DHD_ERROR(("%s: Failed to allocate raw_fmts memory \n", __FUNCTION__));
+               goto fail;
+       }
+
+       /* read ram start, rodata_start and rodata_end values from map  file */
+
+       while (count != ALL_MAP_VAL)
+       {
+               error = vfs_read(filep, raw_fmts, read_size, (&filep->f_pos));
+               if (error < 0) {
+                       DHD_ERROR(("%s: read failed %s err:%d \n", __FUNCTION__,
+                               map_file_path, error));
+                       goto fail;
+               }
+
+               if (error < read_size) {
+                       /*
+                       * since we reset file pos back to earlier pos by
+                       * GO_BACK_FILE_POS_NUM_BYTES bytes we won't reach EOF.
+                       * So if ret value is less than read_size, reached EOF don't read further
+                       */
+                       break;
+               }
+
+               /* Get ramstart address */
+               if ((cptr = strstr(raw_fmts, ramstart_str))) {
+                       cptr = cptr - BYTES_AHEAD_NUM;
+                       sscanf(cptr, "%x %c text_start", ramstart, &c);
+                       count |= RAMSTART_BIT;
+               }
+
+               /* Get ram rodata start address */
+               if ((cptr = strstr(raw_fmts, rodata_start_str))) {
+                       cptr = cptr - BYTES_AHEAD_NUM;
+                       sscanf(cptr, "%x %c rodata_start", rodata_start, &c);
+                       count |= RDSTART_BIT;
+               }
+
+               /* Get ram rodata end address */
+               if ((cptr = strstr(raw_fmts, rodata_end_str))) {
+                       cptr = cptr - BYTES_AHEAD_NUM;
+                       sscanf(cptr, "%x %c rodata_end", rodata_end, &c);
+                       count |= RDEND_BIT;
+               }
+               memset(raw_fmts, 0, read_size);
+               /*
+               * go back to predefined NUM of bytes so that we won't miss
+               * the string and  addr even if it comes as splited in next read.
+               */
+               filep->f_pos = filep->f_pos - GO_BACK_FILE_POS_NUM_BYTES;
+       }
+
+       DHD_ERROR(("---ramstart: 0x%x, rodata_start: 0x%x, rodata_end:0x%x\n",
+               *ramstart, *rodata_start, *rodata_end));
+
+       DHD_ERROR(("readmap over \n"));
+
+fail:
+       if (raw_fmts) {
+               kfree(raw_fmts);
+               raw_fmts = NULL;
+       }
+       if (!IS_ERR(filep))
+               filp_close(filep, NULL);
+
+       set_fs(fs);
+       if (count == ALL_MAP_VAL) {
+               return BCME_OK;
+       }
+       DHD_ERROR(("readmap error 0X%x \n", count));
+       return BCME_ERROR;
+}
+
+static void
+dhd_init_static_strs_array(dhd_event_log_t *temp, char *str_file, char *map_file)
+{
+       struct file *filep = NULL;
+       mm_segment_t fs;
+       char *raw_fmts =  NULL;
+       uint32 logstrs_size = 0;
+
+       int error = 0;
+       uint32 ramstart = 0;
+       uint32 rodata_start = 0;
+       uint32 rodata_end = 0;
+       uint32 logfilebase = 0;
+
+       error = dhd_read_map(map_file, &ramstart, &rodata_start, &rodata_end);
+       if (error == BCME_ERROR) {
+               DHD_ERROR(("readmap Error!! \n"));
+               /* don't do event log parsing in actual case */
+               temp->raw_sstr = NULL;
+               return;
+       }
+       DHD_ERROR(("ramstart: 0x%x, rodata_start: 0x%x, rodata_end:0x%x\n",
+               ramstart, rodata_start, rodata_end));
+
+       fs = get_fs();
+       set_fs(KERNEL_DS);
+
+       filep = filp_open(str_file, O_RDONLY, 0);
+       if (IS_ERR(filep)) {
+               DHD_ERROR(("%s: Failed to open the file %s \n",  __FUNCTION__, str_file));
+               goto fail;
+       }
+
+       /* Full file size is huge. Just read required part */
+       logstrs_size = rodata_end - rodata_start;
+
+       raw_fmts = kmalloc(logstrs_size, GFP_KERNEL);
+       if (raw_fmts == NULL) {
+               DHD_ERROR(("%s: Failed to allocate raw_fmts memory \n", __FUNCTION__));
+               goto fail;
+       }
+
+       logfilebase = rodata_start - ramstart;
+
+       error = generic_file_llseek(filep, logfilebase, SEEK_SET);
+       if (error < 0) {
+               DHD_ERROR(("%s: %s llseek failed %d \n", __FUNCTION__, str_file, error));
+               goto fail;
+       }
+
+       error = vfs_read(filep, raw_fmts, logstrs_size, (&filep->f_pos));
+       if (error != logstrs_size) {
+               DHD_ERROR(("%s: %s read failed %d \n", __FUNCTION__, str_file, error));
+               goto fail;
+       }
+
+       if (strstr(str_file, ram_file_str) != NULL) {
+               temp->raw_sstr = raw_fmts;
+               temp->ramstart = ramstart;
+               temp->rodata_start = rodata_start;
+               temp->rodata_end = rodata_end;
+       } else if (strstr(str_file, rom_file_str) != NULL) {
+               temp->rom_raw_sstr = raw_fmts;
+               temp->rom_ramstart = ramstart;
+               temp->rom_rodata_start = rodata_start;
+               temp->rom_rodata_end = rodata_end;
+       }
+
+       filp_close(filep, NULL);
+       set_fs(fs);
+
+       return;
+fail:
+       if (raw_fmts) {
+               kfree(raw_fmts);
+               raw_fmts = NULL;
+       }
+       if (!IS_ERR(filep))
+               filp_close(filep, NULL);
+       set_fs(fs);
+       if (strstr(str_file, ram_file_str) != NULL) {
+               temp->raw_sstr = NULL;
+       } else if (strstr(str_file, rom_file_str) != NULL) {
+               temp->rom_raw_sstr = NULL;
+       }
+       return;
+}
+
+#endif /* SHOW_LOGTRACE */
+
 dhd_pub_t *
 dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 {
@@ -3744,6 +4164,12 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
        }
 #endif /* defined(WL_WIRELESS_EXT) */
 
+#ifdef SHOW_LOGTRACE
+       dhd_init_logstrs_array(&dhd->event_data);
+       dhd_init_static_strs_array(&dhd->event_data, st_str_file_path, map_file_path);
+       dhd_init_static_strs_array(&dhd->event_data, rom_st_str_file_path, rom_map_file_path);
+#endif /* SHOW_LOGTRACE */
+
 
        /* Set up the watchdog timer */
        init_timer(&dhd->timer);
@@ -4696,6 +5122,7 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        }
 #endif /* WL_CFG80211 */
        setbit(eventmask, WLC_E_TRACE);
+       setbit(eventmask, WLC_E_CSA_COMPLETE_IND);
 
        /* Write updated Event mask */
        bcm_mkiovar("event_msgs", eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf));
@@ -4974,10 +5401,14 @@ static int dhd_inetaddr_notifier_call(struct notifier_block *this,
 
        dhd_pub = &dhd->pub;
 
+#if defined(ARP_OFFLOAD_SUPPORT)
        if (dhd_pub->arp_version == 1) {
                idx = 0;
        }
        else {
+#else
+       {
+#endif
                for (idx = 0; idx < DHD_MAX_IFS; idx++) {
                        if (dhd->iflist[idx] && dhd->iflist[idx]->net == ifa->ifa_dev->dev)
                        break;
@@ -5260,6 +5691,9 @@ dhd_register_if(dhd_pub_t *dhdp, int ifidx, bool need_rtnl_lock)
                up(&dhd_registration_sem);
 #endif
                if (!dhd_download_fw_on_driverload) {
+#ifdef WL_CFG80211
+                       wl_terminate_event_handler();
+#endif /* WL_CFG80211 */
 #ifdef BCMSDIO
                        dhd_net_bus_devreset(net, TRUE);
                        dhd_net_bus_suspend(net);
@@ -5432,6 +5866,14 @@ void dhd_detach(dhd_pub_t *dhdp)
        dhd_deferred_work_deinit(dhd->dhd_deferred_wq);
        dhd->dhd_deferred_wq = NULL;
 
+#ifdef SHOW_LOGTRACE
+       if (dhd->event_data.fmts)
+               kfree(dhd->event_data.fmts);
+       if (dhd->event_data.raw_fmts)
+               kfree(dhd->event_data.raw_fmts);
+       if (dhd->event_data.raw_sstr)
+               kfree(dhd->event_data.raw_sstr);
+#endif /* SHOW_LOGTRACE */
 #ifdef PNO_SUPPORT
        if (dhdp->pno_state)
                dhd_pno_deinit(dhdp);
@@ -5821,15 +6263,45 @@ uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_i
        uint8* buf;
        gfp_t flags = CAN_SLEEP() ? GFP_KERNEL: GFP_ATOMIC;
 
+       if (section > DHD_PREALLOC_SECTION_MAX) {
+               DHD_ERROR(("%s: Invalid Section ID: %d\n", __FUNCTION__, section));
+               return NULL;
+       }
+
        buf = (uint8*)wifi_platform_prealloc(dhdpub->info->adapter, section, size);
-       if (buf == NULL && kmalloc_if_fail)
+       if (buf == NULL && kmalloc_if_fail) {
+               if (isset(dhdpub->prealloc_malloc_mask, section)) {
+                       DHD_ERROR(("%s: Section %d(size: %d) is already allocated\n",
+                               __FUNCTION__, section, size));
+                       return NULL;
+               }
+
                buf = kmalloc(size, flags);
+               if (buf) {
+                       DHD_ERROR(("%s: Preallocated memory section %d(size: %d)"
+                               "allocated by kmalloc\n", __FUNCTION__,
+                               section, size));
+                       setbit(dhdpub->prealloc_malloc_mask, section);
+               }
+       }
 
        return buf;
 }
 
-void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size)
+void dhd_os_prefree(dhd_pub_t *dhdpub, int section, void *addr, uint size)
 {
+       if (section > DHD_PREALLOC_SECTION_MAX) {
+               DHD_ERROR(("%s: Invalid Section ID: %d\n", __FUNCTION__, section));
+               return;
+       }
+
+       if (addr && isset(dhdpub->prealloc_malloc_mask, section)) {
+               DHD_ERROR(("%s: Preallocated memory section %d(size: %d)"
+                       "memory is freed by kfree\n", __FUNCTION__,
+                       section, size));
+               clrbit(dhdpub->prealloc_malloc_mask, section);
+               kfree(addr);
+       }
 }
 
 #if defined(WL_WIRELESS_EXT)
@@ -5859,7 +6331,12 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
        int bcmerror = 0;
        ASSERT(dhd != NULL);
 
-       bcmerror = wl_host_event(&dhd->pub, ifidx, pktdata, event, data);
+#ifdef SHOW_LOGTRACE
+       bcmerror = wl_host_event(&dhd->pub, ifidx, pktdata, event, data, &dhd->event_data);
+#else
+       bcmerror = wl_host_event(&dhd->pub, ifidx, pktdata, event, data, NULL);
+#endif /* SHOW_LOGTRACE */
+
        if (bcmerror != BCME_OK)
                return (bcmerror);
 
index 7a15fc1..8df20cf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DHD Linux header file (dhd_linux exports for cfg80211 and other components)
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index a4bbb83..d5fa132 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux platform device for DHD WLAN adapter
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
 #endif /* CONFIG_DTS */
 
 #if !defined(CONFIG_WIFI_CONTROL_FUNC)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58))
+#define WLAN_PLAT_NODFS_FLAG    0x01
+#endif
 struct wifi_platform_data {
        int (*set_power)(int val);
        int (*set_reset)(int val);
        int (*set_carddetect)(int val);
        void *(*mem_prealloc)(int section, unsigned long size);
        int (*get_mac_addr)(unsigned char *buf);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58))
+       void *(*get_country_code)(char *ccode, u32 flags);
+#else
        void *(*get_country_code)(char *ccode);
+#endif
 };
 #endif /* CONFIG_WIFI_CONTROL_FUNC */
 
@@ -202,36 +209,31 @@ int wifi_platform_set_power(wifi_adapter_info_t *adapter, bool on, unsigned long
 }
 
 #if 1
-/* Murata debug: this function is re-worked because "wifi_plat_data" is NULL.  */
-/* Need to investigate how this pointer/data is being passed into probe function. */
-/* "wifi_plat_data" used to be "wifi_ctrl".  */
-/* All this code is done for only one reason -- calling mmc_detect_change() in /drivers/mmc/core/core.c. */
 extern void wifi_card_detect(void);
 int wifi_platform_bus_enumerate(wifi_adapter_info_t *adapter, bool device_present)
 {
-       int err = 0;
-       struct wifi_platform_data *plat_data;
+        int err = 0;
+        struct wifi_platform_data *plat_data;
 
-       if (!adapter) {
-               pr_err("!!!! %s: failed!  adapter variable is NULL!!!!!\n", __FUNCTION__); 
-               return -EINVAL;
-       }
+        if (!adapter) {
+                pr_err("!!!! %s: failed!  adapter variable is NULL!!!!!\n", __FUNCTION__);
+                return -EINVAL;
+        }
 
-       DHD_ERROR(("%s device present %d\n", __FUNCTION__, device_present));
+        DHD_ERROR(("%s device present %d\n", __FUNCTION__, device_present));
 
-       if (!adapter->wifi_plat_data) {
-               wifi_card_detect(); /* hook for card_detect */
-       } else {
-               plat_data = adapter->wifi_plat_data;
-               if (plat_data->set_carddetect)
-                       err = plat_data->set_carddetect(device_present);
-       }
+        if (!adapter->wifi_plat_data) {
+                wifi_card_detect(); /* hook for card_detect */
+        } else {
+                plat_data = adapter->wifi_plat_data;
+                if (plat_data->set_carddetect)
+                        err = plat_data->set_carddetect(device_present);
+        }
 
-       return 0; /* force success status returned */
+        return 0; /* force success status returned */
 }
 
 #else
-
 int wifi_platform_bus_enumerate(wifi_adapter_info_t *adapter, bool device_present)
 {
        int err = 0;
@@ -276,7 +278,11 @@ void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode)
 
        DHD_TRACE(("%s\n", __FUNCTION__));
        if (plat_data->get_country_code) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58))
+               return plat_data->get_country_code(ccode, WLAN_PLAT_NODFS_FLAG);
+#else
                return plat_data->get_country_code(ccode);
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) */
        }
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) */
 
@@ -288,7 +294,9 @@ static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
        struct resource *resource;
        wifi_adapter_info_t *adapter;
 #ifdef CONFIG_DTS
-//     int irq, gpio;
+#if defined(OOB_INTR_ONLY) && defined (HW_OOB)
+       int irq, gpio;
+#endif /* defined(OOB_INTR_ONLY) && defined (HW_OOB) */
 #endif /* CONFIG_DTS */
 
        /* Android style wifi platform data device ("bcmdhd_wlan" or "bcm4329_wlan")
@@ -313,8 +321,7 @@ static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
                DHD_ERROR(("%s regulator is null\n", __FUNCTION__));
                return -1;
        }
-
-#if 0
+#if defined(OOB_INTR_ONLY) && defined (HW_OOB)
        /* This is to get the irq for the OOB */
        gpio = of_get_gpio(pdev->dev.of_node, 0);
 
@@ -332,7 +339,7 @@ static int wifi_plat_dev_drv_probe(struct platform_device *pdev)
        /* need to change the flags according to our requirement */
        adapter->intr_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL |
                IORESOURCE_IRQ_SHAREABLE;
-#endif
+#endif /* defined(OOB_INTR_ONLY) && defined (HW_OOB) */
 #endif /* CONFIG_DTS */
 
        wifi_plat_dev_probe_ret = dhd_wifi_platform_load();
@@ -495,12 +502,12 @@ static int wifi_ctrlfunc_register_drv(void)
 
 void wifi_ctrlfunc_unregister_drv(void)
 {
+
 #ifdef CONFIG_DTS
        DHD_ERROR(("unregister wifi platform drivers\n"));
        platform_driver_unregister(&wifi_platform_dev_driver);
 #else
        struct device *dev1, *dev2;
-
        dev1 = bus_find_device(&platform_bus_type, NULL, WIFI_PLAT_NAME, wifi_platdev_match);
        dev2 = bus_find_device(&platform_bus_type, NULL, WIFI_PLAT_NAME2, wifi_platdev_match);
        if (!dts_enabled)
index ba78dfd..18b8fae 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Expose some of the kernel scheduler routines
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 0364c9d..0b5ed5b 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom Dongle Host Driver (DHD), Generic work queue framework
  * Generic interface to handle dhd deferred work events
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_linux_wq.c 411851 2013-07-10 20:48:00Z $
+ * $Id: dhd_linux_wq.c 589976 2015-10-01 07:01:27Z $
  */
 
 #include <linux/init.h>
@@ -82,7 +82,7 @@ dhd_kfifo_init(u8 *buf, int size, spinlock_t *lock)
                return NULL;
        }
        kfifo_init(fifo, buf, size);
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)) */
+#endif 
        return fifo;
 }
 
index 3a4ad1c..f74fbd7 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom Dongle Host Driver (DHD), Generic work queue framework
  * Generic interface to handle dhd deferred work events
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 344874f..8ece5d0 100644 (file)
@@ -4,7 +4,7 @@
  * Provides type definitions and function prototypes used to link the
  * DHD OS, bus, and protocol modules.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index ca4364d..391381d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DHD Bus Module for PCIE
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 9b3f718..a60a1fc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux DHD Bus Module for PCIE
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 5a58320..21959e4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux DHD Bus Module for PCIE
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 34894a0..040b452 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom Dongle Host Driver (DHD)
  * Prefered Network Offload and Wi-Fi Location Service(WLS) code.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index e7d594c..41ef088 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Header file of Broadcom Dongle Host Driver (DHD)
  * Prefered Network Offload code and Wi-Fi Location Service(WLS) code.
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 4b794a4..d1dcd5f 100644 (file)
@@ -4,7 +4,7 @@
  * Provides type definitions and function prototypes used to link the
  * DHD OS, bus, and protocol modules.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 83b65f9..553aeb9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DHD Bus Module for SDIO
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_sdio.c 506047 2014-10-02 12:43:31Z $
+ * $Id: dhd_sdio.c 572232 2015-07-17 12:14:31Z $
  */
 
-#include <linux/mmc/host.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/sdio_func.h>
-
 #include <typedefs.h>
 #include <osl.h>
 #include <bcmsdh.h>
@@ -57,7 +53,6 @@
 #include <sbsdpcmdev.h>
 #include <bcmsdpcm.h>
 #include <bcmsdbus.h>
-#include <bcmsdh_sdmmc.h>
 
 #include <proto/ethernet.h>
 #include <proto/802.1d.h>
@@ -148,6 +143,7 @@ extern bool  bcmsdh_fatal_error(void *sdh);
 #if (PMU_MAX_TRANSITION_DLY <= 1000000)
 #undef PMU_MAX_TRANSITION_DLY
 #define PMU_MAX_TRANSITION_DLY 1000000
+#define PMU_TRANSITION_DLY_EXTRA 500000
 #endif
 
 /* hooks for limiting threshold custom tx num in rx processing */
@@ -1132,6 +1128,7 @@ dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
        int err;
        uint8 clkctl, clkreq, devctl;
        bcmsdh_info_t *sdh;
+       uint32 delay = PMU_MAX_TRANSITION_DLY;
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
@@ -1205,12 +1202,18 @@ dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                        }
                }
 
+               /* Give the 43362 chip a little bit extra time for HT Avail */
+               if (bus->sih->chip == BCM43362_CHIP_ID) {
+                       delay += PMU_TRANSITION_DLY_EXTRA;
+               }
+
                /* Otherwise, wait here (polling) for HT Avail */
                if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
                        SPINWAIT_SLEEP(sdioh_spinwait_sleep,
                                ((clkctl = bcmsdh_cfg_read(sdh, SDIO_FUNC_1,
-                                                           SBSDIO_FUNC1_CHIPCLKCSR, &err)),
-                                 !SBSDIO_CLKAV(clkctl, bus->alp_only)), PMU_MAX_TRANSITION_DLY);
+                               SBSDIO_FUNC1_CHIPCLKCSR, &err)),
+                               !SBSDIO_CLKAV(clkctl, bus->alp_only)),
+                               delay);
                }
                if (err) {
                        DHD_ERROR(("%s: HT Avail request error: %d\n", __FUNCTION__, err));
@@ -1742,9 +1745,6 @@ static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txs
        uint32 swhdr_offset;
        bool alloc_new_pkt = FALSE;
        uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN;
-       sdioh_info_t *sd = bus->sdh->sdioh;
-       struct sdio_func *sdio_func = sd->func[0];
-       struct mmc_host *host = sdio_func->card->host;
 
        *new_pkt = NULL;
        osh = bus->dhd->osh;
@@ -1822,7 +1822,7 @@ static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txs
                         * Use the padding packet to avoid memory copy if applicable,
                         * otherwise, just allocate a new pkt.
                         */
-                       if (bus->pad_pkt && (host->max_segs > 1)) {
+                       if (bus->pad_pkt) {
                                *pad_pkt_len = chain_tail_padding;
                                bus->tx_tailpad_chain++;
                        } else {
@@ -1877,10 +1877,9 @@ static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txs
                PKTALIGN(osh, tmp_pkt, PKTLEN(osh, pkt), DHD_SDALIGN);
                bcopy(PKTDATA(osh, pkt), PKTDATA(osh, tmp_pkt), PKTLEN(osh, pkt));
                *new_pkt = tmp_pkt;
-                /*
-                * pull back sdpcm_hdrlen length from old skb as new skb here
-                * is passed to postprocessing
-                 */
+               /* pull back sdpcm_hdrlen length from old skb as new skb here is passed
+                * to postprocessing
+                */
                PKTPULL(osh, pkt, sdpcm_hdrlen);
                pkt = tmp_pkt;
        }
@@ -7186,8 +7185,9 @@ dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh)
                DHD_ERROR(("%s: MALLOC of %d-byte databuf failed\n",
                        __FUNCTION__, MAX_DATA_BUF));
                /* release rxbuf which was already located as above */
-               if (!bus->rxblen)
-                       DHD_OS_PREFREE(bus->dhd, bus->rxbuf, bus->rxblen);
+               if (bus->rxbuf) {
+                       DHD_OS_PREFREE(bus->dhd, DHD_PREALLOC_RXBUF, bus->rxbuf, bus->rxblen);
+               }
                goto fail;
        }
 
index c76f96a..ecdc94a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DHD PROP_TXSTATUS Module.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_wlfc.c 505040 2014-09-26 06:39:18Z $
+ * $Id: dhd_wlfc.c 557502 2015-05-19 06:32:03Z $
  *
  */
 
@@ -92,9 +92,9 @@ _dhd_wlfc_prec_enque(struct pktq *pq, int prec, void* p, bool qHead,
        if (!p)
                return;
 
-
        ASSERT(prec >= 0 && prec < pq->num_prec);
-       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));         /* queueing chains not allowed */
+       /* queueing chains not allowed and no segmented SKB (Kernel-3.18.y) */
+       ASSERT(!((PKTLINK(p) != NULL) && (PKTLINK(p) != p)));
 
        ASSERT(!pktq_full(pq));
        ASSERT(!pktq_pfull(pq, prec));
@@ -2496,7 +2496,9 @@ int dhd_wlfc_enable(dhd_pub_t *dhd)
        }
 
        /* allocate space to track txstatus propagated from firmware */
-       dhd->wlfc_state = MALLOC(dhd->osh, sizeof(athost_wl_status_info_t));
+       dhd->wlfc_state = DHD_OS_PREALLOC(dhd, DHD_PREALLOC_DHD_WLFC_INFO,
+                       sizeof(athost_wl_status_info_t));
+
        if (dhd->wlfc_state == NULL) {
                rc = BCME_NOMEM;
                goto exit;
@@ -2513,7 +2515,8 @@ int dhd_wlfc_enable(dhd_pub_t *dhd)
        if (!WLFC_GET_AFQ(dhd->wlfc_mode)) {
                wlfc->hanger = _dhd_wlfc_hanger_create(dhd->osh, WLFC_HANGER_MAXITEMS);
                if (wlfc->hanger == NULL) {
-                       MFREE(dhd->osh, dhd->wlfc_state, sizeof(athost_wl_status_info_t));
+                       DHD_OS_PREFREE(dhd, DHD_PREALLOC_DHD_WLFC_INFO,
+                               dhd->wlfc_state, sizeof(athost_wl_status_info_t));
                        dhd->wlfc_state = NULL;
                        rc = BCME_NOMEM;
                        goto exit;
@@ -3323,7 +3326,8 @@ dhd_wlfc_deinit(dhd_pub_t *dhd)
 
 
        /* free top structure */
-       MFREE(dhd->osh, dhd->wlfc_state, sizeof(athost_wl_status_info_t));
+       DHD_OS_PREFREE(dhd, DHD_PREALLOC_DHD_WLFC_INFO,
+               dhd->wlfc_state, sizeof(athost_wl_status_info_t));
        dhd->wlfc_state = NULL;
        dhd->proptxstatus_mode = hostreorder ?
                WLFC_ONLY_AMPDU_HOSTREORDER : WLFC_FCMODE_NONE;
index 4417302..9879419 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright (C) 1999-2014, Broadcom Corporation
+* Copyright (C) 1999-2015, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
index ac84522..c9b4e69 100644 (file)
@@ -2,7 +2,7 @@
  * Common stats definitions for clients of dongle
  * ports
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 2c1366a..3c64131 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Dongle WL Header definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 70d383e..cd0ecbb 100644 (file)
@@ -2,7 +2,7 @@
  * Misc utility routines for accessing PMU corerev specific features
  * of the SiliconBackplane-based Broadcom chips.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: hndpmu.c 433378 2013-10-31 17:19:39Z $
+ * $Id: hndpmu.c 530682 2015-01-30 18:48:21Z $
  */
 
 
index 519d8be..257b730 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom AMBA Interconnect definitions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: aidmp.h 404499 2013-05-28 01:06:37Z $
+ * $Id: aidmp.h 530682 2015-01-30 18:48:21Z $
  */
 
 #ifndef        _AIDMP_H
@@ -58,6 +58,7 @@
 #define        ER_ADD                  4
 #define        ER_END                  0xe
 #define        ER_BAD                  0xffffffff
+#define        ER_SZ_MAX               4096 /* 4KB */
 
 /* EROM CompIdentA */
 #define        CIA_MFG_MASK            0xfff00000
index fa2db7c..e3a04bf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCM common config options
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index ee06f3b..d035365 100644 (file)
@@ -35,7 +35,7 @@
  *              and instrumentation on top of the heap, without modifying the heap
  *              allocation implementation.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 1028bb3..dbeb303 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Definitions subject to change without notice.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index adfceb8..fbb1f33 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Misc system wide definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 5a85775..1f7b894 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom device-specific manifest constants.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index ff527f6..e717df4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Byte order utilities
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 3e7e961..bca1c54 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Definitions subject to change without notice.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index d9f2b4a..d569022 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * NVRAM variable manipulation
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 3a5c671..cbe742b 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom PCIE
  * Software-specific definitions shared between device and host side
  * Explains the shared area between host and dongle
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 8ecb7c2..0289274 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom PCI-SPI Host Controller Register Definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index acebfa3..6b0b2ca 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Performance counters software interface.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index a0cd8dc..28bbe4c 100644 (file)
@@ -2,7 +2,7 @@
  * Definitions for API from sdio common code (bcmsdh) to individual
  * host controller drivers.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index df65028..3dbfea1 100644 (file)
@@ -3,7 +3,7 @@
  *     export functions to client drivers
  *     abstract OS and BUS specific details of SDIO
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index e637ae4..436277e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 273a4d7..e2c42b7 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom SDIO/PCMCIA
  * Software-specific definitions shared between device and host side
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index b5a0caf..100a000 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SD-SPI Protocol Conversion - BCMSDH->SPI Translation Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 97c2a5a..2b54af1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  'Standard' SDIO HOST CONTROLLER driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index cf814ce..e48bc47 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom SPI Low-Level Hardware Driver API
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index d055ff1..ba90f35 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SD-SPI Protocol Conversion - BCMSDH->gSPI Translation Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 7d247bf..f73ef0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SROM format definition.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 503fc28..01b8b6b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Table that encodes the srom formats for PCI/PCIe NICs.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index c94b8fa..9eb6c90 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Misc useful os-independent macros and functions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index dbf1d23..64d89fa 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Definitions for nl80211 testmode access to host driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index e73fab8..1f29ac8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Initialization and support routines for self-booting compressed image.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index daef6c5..5e4d073 100644 (file)
@@ -2,7 +2,7 @@
  * Dongle BUS interface Abstraction layer
  *   target serial buses like USB, SDIO, SPI, etc.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 788b02a..f8f0893 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Definitions subject to change without notice.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
 #define AES_ENABLED            0x0004
 #define WSEC_SWFLAG            0x0008
 #define SES_OW_ENABLED         0x0040  /* to go into transition mode without setting wep */
-#ifdef BCMWAPI_WPI
-#define SMS4_ENABLED           0x0100
-#endif /* BCMWAPI_WPI */
 
 /* wsec macros for operating on the above definitions */
 #define WSEC_WEP_ENABLED(wsec) ((wsec) & WEP_ENABLED)
 #define WSEC_TKIP_ENABLED(wsec)        ((wsec) & TKIP_ENABLED)
 #define WSEC_AES_ENABLED(wsec) ((wsec) & AES_ENABLED)
 
-#ifdef BCMWAPI_WPI
-#define WSEC_ENABLED(wsec)     ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
-#else /* BCMWAPI_WPI */
 #define WSEC_ENABLED(wsec)     ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
-#endif /* BCMWAPI_WPI */
 #define WSEC_SES_OW_ENABLED(wsec)      ((wsec) & SES_OW_ENABLED)
-#ifdef BCMWAPI_WAI
-#define WSEC_SMS4_ENABLED(wsec)        ((wsec) & SMS4_ENABLED)
-#endif /* BCMWAPI_WAI */
 
 #define MFP_CAPABLE            0x0200
 #define MFP_REQUIRED   0x0400
 #define WPA2_AUTH_PSK          0x0080  /* Pre-shared key */
 #define BRCM_AUTH_PSK           0x0100  /* BRCM specific PSK */
 #define BRCM_AUTH_DPT          0x0200  /* DPT PSK without group keys */
-#if defined(BCMWAPI_WAI) || defined(BCMWAPI_WPI)
-#define WPA_AUTH_WAPI           0x0400
-#define WAPI_AUTH_NONE         WPA_AUTH_NONE   /* none (IBSS) */
-#define WAPI_AUTH_UNSPECIFIED  0x0400  /* over AS */
-#define WAPI_AUTH_PSK          0x0800  /* Pre-shared key */
-#endif /* BCMWAPI_WAI || BCMWAPI_WPI */
 //#define WPA2_AUTH_MFP           0x1000  /* MFP (11w) in contrast to CCX */
 #define WPA2_AUTH_1X_SHA256    0x1000  /* 1X with SHA256 key derivation */
 #define WPA2_AUTH_TPK          0x2000  /* TDLS Peer Key */
index 187fd07..ef1cb97 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Definitions subject to change without notice.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index aa91d3c..55821d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
 
 #define        EPI_MINOR_VERSION       141
 
-#define        EPI_RC_NUMBER           72
+#define        EPI_RC_NUMBER           0
 
 #define        EPI_INCREMENTAL_NUMBER  0
 
 #define        EPI_BUILD_NUMBER        0
 
-#define        EPI_VERSION             1, 141, 72, 0
+#define        EPI_VERSION             1, 141, 0, 0
 
-#define        EPI_VERSION_NUM         0x018d4800
+#define        EPI_VERSION_NUM         0x018d0000
 
-#define EPI_VERSION_DEV                1.141.72
+#define EPI_VERSION_DEV                1.141.0
 
 /* Driver Version String, ASCII, 32 chars max */
-#define        EPI_VERSION_STR         "1.141.72 (r)"
+#define        EPI_VERSION_STR         "1.141 (TOB) (r)"
 
 #endif /* _epivers_h_ */
index f760e62..f340602 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * HND SiliconBackplane PMU support.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 70cfa91..390586b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * HNDRTE arm trap handling.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 6cc846f..8246e0f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Console support for hndrte.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 7726a8a..3aa332c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom HND chip & on-chip-interconnect-related definitions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 7c614ba..4157e7e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux OS Independent Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index c0d8017..de349cd 100644 (file)
@@ -2,7 +2,7 @@
  * Linux-specific abstractions to gain some independence from linux kernel versions.
  * Pave over some 2.2 versus 2.4 versus 2.6 kernel differences.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 73212a8..59aedd3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Command line options parser.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index c01676f..0f7f83b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Trace messages sent over HBUS
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index cdfb107..f022b7f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * OS Abstraction Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index a7133c2..675701d 100644 (file)
@@ -15,7 +15,7 @@
  * #include <packed_section_end.h>
  *
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index ed5045c..46d310d 100644 (file)
@@ -15,7 +15,7 @@
  * #include <packed_section_end.h>
  *
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 2d28dde..2186d93 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * pcicfg.h: PCI configuration constants and structures.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 678fe9c..30a1187 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCM43XX PCIE core hardware definitions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index e61bcdc..6b6111a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -3479,10 +3479,6 @@ typedef struct vht_features_ie_hdr vht_features_ie_hdr_t;
 #define WCN_OUI                        "\x00\x50\xf2"  /* WCN OUI */
 #define WCN_TYPE               4       /* WCN type */
 
-#ifdef BCMWAPI_WPI
-#define SMS4_KEY_LEN           16
-#define SMS4_WPI_CBC_MAC_LEN   16
-#endif
 
 /* 802.11r protocol definitions */
 
@@ -3545,13 +3541,6 @@ typedef struct mmic_ie mmic_ie_t;
 #define BSSID_INVALID           "\x00\x00\x00\x00\x00\x00"
 #define BSSID_BROADCAST         "\xFF\xFF\xFF\xFF\xFF\xFF"
 
-#ifdef BCMWAPI_WAI
-#define WAPI_IE_MIN_LEN        20      /* WAPI IE min length */
-#define WAPI_VERSION           1       /* WAPI version */
-#define WAPI_VERSION_LEN       2       /* WAPI version length */
-#define WAPI_OUI               "\x00\x14\x72"  /* WAPI OUI */
-#define WAPI_OUI_LEN           DOT11_OUI_LEN   /* WAPI OUI length */
-#endif /* BCMWAPI_WAI */
 
 /* ************* WMM Parameter definitions. ************* */
 #define WMM_OUI                        "\x00\x50\xF2"  /* WNN OUI */
index 19d898b..fff6333 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BT-AMP (BlueTooth Alternate Mac and Phy) 802.11 PAL (Protocol Adaptation Layer)
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f990f21..a8de2f3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 802.11e protocol header file
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 17a5430..1ab86c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 841e6da..ca00a9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 50d9bdc..1a80722 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom Ethernettype  protocol definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index ae03830..b0e55b9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom Event  protocol definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -23,7 +23,7 @@
  *
  * Dependencies: proto/bcmeth.h
  *
- * $Id: bcmevent.h 502360 2014-09-12 19:31:22Z $
+ * $Id: bcmevent.h 589976 2015-10-01 07:01:27Z $
  *
  */
 
@@ -343,6 +343,7 @@ typedef struct wl_event_data_if {
 #define WLC_E_IF_ROLE_WDS              2       /* WDS link */
 #define WLC_E_IF_ROLE_P2P_GO           3       /* P2P Group Owner */
 #define WLC_E_IF_ROLE_P2P_CLIENT       4       /* P2P Client */
+#define WLC_E_IF_ROLE_IBSS              8       /* IBSS */
 
 /* WLC_E_RSSI event data */
 typedef struct wl_event_data_rssi {
index 7549235..6fee8e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index fd2d6fa..b9a9a2a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 6754f36..7185bc5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Fundamental constants relating to TCP Protocol
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index fc05ab1..f4404a2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BT-AMP (BlueTooth Alternate Mac and Phy) HCI (Host/Controller Interface)
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 3f283a6..e0dbaa0 100644 (file)
@@ -5,9 +5,27 @@
  * IEEE Std 802.1X-2001
  * IEEE 802.1X RADIUS Usage Guidelines
  *
- * Copyright Open Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
+ * 
+ *      Unless you and Broadcom execute a separate written software license
+ * agreement governing use of this software, this software is licensed to you
+ * under the terms of the GNU General Public License version 2 (the "GPL"),
+ * available at http://www.broadcom.com/licenses/GPLv2.php, with the
+ * following added to such license:
+ * 
+ *      As a special exception, the copyright holders of this software give you
+ * permission to link this software with independent modules, and to copy and
+ * distribute the resulting executable under terms of your choice, provided that
+ * you also meet, for each linked independent module, the terms and conditions of
+ * the license of that module.  An independent module is a module which is not
+ * derived from this software.  The special exception does not apply to any
+ * modifications of the software.
+ * 
+ *      Notwithstanding the above, under no circumstances may you combine this
+ * software in any way with any other Broadcom software provided under a license
+ * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: eapol.h 452678 2014-01-31 19:16:29Z $
+ * $Id: eapol.h 526865 2015-01-15 07:44:19Z $
  */
 
 #ifndef _eapol_h_
index 0760302..e488061 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 27c4794..00391d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f84d0b8..b80d614 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SD-SPI Protocol Standard
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index a474cfd..8443f13 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 802.1Q VLAN protocol definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 9ef6ecc..e9e1b3c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Fundamental types and constants relating to WPA
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -118,12 +118,6 @@ typedef BWL_PRE_PACKED_STRUCT struct
 #define WPA_CIPHER_BIP         6       /* WEP (104-bit) */
 #define WPA_CIPHER_TPK         7       /* Group addressed traffic not allowed */
 
-#ifdef BCMWAPI_WAI
-#define WAPI_CIPHER_NONE       WPA_CIPHER_NONE
-#define WAPI_CIPHER_SMS4       11
-
-#define WAPI_CSE_WPI_SMS4      1
-#endif /* BCMWAPI_WAI */
 
 #define IS_WPA_CIPHER(cipher)  ((cipher) == WPA_CIPHER_NONE || \
                                 (cipher) == WPA_CIPHER_WEP_40 || \
@@ -133,17 +127,6 @@ typedef BWL_PRE_PACKED_STRUCT struct
                                 (cipher) == WPA_CIPHER_AES_CCM || \
                                 (cipher) == WPA_CIPHER_TPK)
 
-#ifdef BCMWAPI_WAI
-#define IS_WAPI_CIPHER(cipher) ((cipher) == WAPI_CIPHER_NONE || \
-                                (cipher) == WAPI_CSE_WPI_SMS4)
-
-/* convert WAPI_CSE_WPI_XXX to WAPI_CIPHER_XXX */
-#define WAPI_CSE_WPI_2_CIPHER(cse) ((cse) == WAPI_CSE_WPI_SMS4 ? \
-                               WAPI_CIPHER_SMS4 : WAPI_CIPHER_NONE)
-
-#define WAPI_CIPHER_2_CSE_WPI(cipher) ((cipher) == WAPI_CIPHER_SMS4 ? \
-                               WAPI_CSE_WPI_SMS4 : WAPI_CIPHER_NONE)
-#endif /* BCMWAPI_WAI */
 
 /* WPA TKIP countermeasures parameters */
 #define WPA_TKIP_CM_DETECT     60      /* multiple MIC failure window (seconds) */
@@ -185,19 +168,6 @@ typedef BWL_PRE_PACKED_STRUCT struct
 
 #define WPA2_PMKID_COUNT_LEN   2
 
-#ifdef BCMWAPI_WAI
-#define WAPI_CAP_PREAUTH               RSN_CAP_PREAUTH
-
-/* Other WAI definition */
-#define WAPI_WAI_REQUEST               0x00F1
-#define WAPI_UNICAST_REKEY             0x00F2
-#define WAPI_STA_AGING                 0x00F3
-#define WAPI_MUTIL_REKEY               0x00F4
-#define WAPI_STA_STATS                 0x00F5
-
-#define WAPI_USK_REKEY_COUNT           0x4000000 /* 0xA00000 */
-#define WAPI_MSK_REKEY_COUNT           0x4000000 /* 0xA00000 */
-#endif /* BCMWAPI_WAI */
 
 /* This marks the end of a packed structure section. */
 #include <packed_section_end.h>
index 306d554..67a341c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * WPS IE definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 4fe5763..b9f1e9c 100644 (file)
@@ -7,7 +7,7 @@
  *
  * $Id: sbchipc.h 468568 2014-04-08 05:33:12Z $
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 83f7d66..8f2a26c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom SiliconBackplane hardware register definitions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 9db0fa1..7eca2b2 100644 (file)
@@ -2,7 +2,7 @@
  * Generic Broadcom Home Networking Division (HND) DMA engine HW interface
  * This supports the following chips: BCM42xx, 44xx, 47xx .
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: sbhnddma.h 424099 2013-09-16 07:44:34Z $
+ * $Id: sbhnddma.h 530682 2015-01-30 18:48:21Z $
  */
 
 #ifndef        _sbhnddma_h_
index f746ddc..38fccd2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCM43XX Sonics SiliconBackplane PCMCIA core hardware definitions.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 0196257..5130e53 100644 (file)
@@ -4,7 +4,7 @@
  *
  * SDIO core support 1bit, 4 bit SDIO mode as well as SPI mode.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 97051ce..0796c11 100644 (file)
@@ -2,7 +2,7 @@
  * Broadcom SiliconBackplane SDIO/PCMCIA hardware-specific
  * device core support
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f6066e4..c0c26bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * BCM47XX Sonics SiliconBackplane embedded ram core
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 6b8d437..96da732 100644 (file)
@@ -2,7 +2,7 @@
  * SDIO spec header file
  * Protocol and standard (common) device definitions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f2bd9ae..de4689b 100644 (file)
@@ -2,7 +2,7 @@
  * SDIO Host Controller Spec header file
  * Register map and definitions for the Standard Host Controller
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 5335ea1..108ce60 100644 (file)
@@ -2,7 +2,7 @@
  * Structure used by apps whose drivers access SDIO drivers.
  * Pulled out separately so dhdu and wlu can both use it.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 9b1a305..badcb5c 100644 (file)
@@ -2,7 +2,7 @@
  * Misc utility routines for accessing the SOC Interconnects
  * of Broadcom HNBU chips.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: siutils.h 481592 2014-05-29 22:10:51Z $
+ * $Id: siutils.h 530682 2015-01-30 18:48:21Z $
  */
 
 #ifndef        _siutils_h_
index 4dc5191..6838d1b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * SPI device spec header file
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 6e55b15..76c1886 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * TRX image file header format.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 473ed9e..b87289a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 95edeec..1705cc5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright (C) 1999-2014, Broadcom Corporation
+* Copyright (C) 1999-2015, Broadcom Corporation
 * 
 *      Unless you and Broadcom execute a separate written software license
 * agreement governing use of this software, this software is licensed to you
index 218d898..479ee4e 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Definitions subject to change without notice.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -24,7 +24,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wlioctl.h 502360 2014-09-12 19:31:22Z $
+ * $Id: wlioctl.h 575651 2015-07-30 13:49:47Z $
  */
 
 #ifndef _wlioctl_h_
@@ -617,6 +617,18 @@ typedef struct {
        cca_congest_t  secs[1]; /* Data */
 } cca_congest_channel_req_t;
 
+typedef struct {
+       uint32 msrmnt_time;     /**< Time for Measurement (msec) */
+       uint32 msrmnt_done;     /**< flag set when measurement complete */
+       char buf[1];
+} cca_stats_n_flags;
+
+typedef struct {
+       uint32 msrmnt_query;    /* host to driver query for measurement done */
+       uint32 time_req;        /* time required for measurement */
+       uint8 report_opt;       /* option to print different stats in report */
+} cca_msrmnt_query;
+
 /* interference sources */
 enum interference_source {
        ITFR_NONE = 0,          /* interference */
@@ -3352,20 +3364,6 @@ typedef BWL_PRE_PACKED_STRUCT struct {
 #define LOGRRC_FIX_LEN 8
 #define IOBUF_ALLOWED_NUM_OF_LOGREC(type, len) ((len - LOGRRC_FIX_LEN)/sizeof(type))
 
-#ifdef BCMWAPI_WAI
-#define IV_LEN 16
-       struct wapi_sta_msg_t
-       {
-               uint16  msg_type;
-               uint16  datalen;
-               uint8   vap_mac[6];
-               uint8   reserve_data1[2];
-               uint8   sta_mac[6];
-               uint8   reserve_data2[2];
-               uint8   gsn[IV_LEN];
-               uint8   wie[256];
-       };
-#endif /* BCMWAPI_WAI */
 
        /* chanim acs record */
        typedef struct {
index 3d78cb4..5d23301 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux OS Independent Layer
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: linux_osl.c 513768 2014-11-07 09:12:55Z $
+ * $Id: linux_osl.c 542523 2015-03-20 03:21:32Z $
  */
 
 #define LINUX_PORT
@@ -61,7 +61,7 @@
 #define STATIC_BUF_TOTAL_LEN   (STATIC_BUF_MAX_NUM * STATIC_BUF_SIZE)
 
 typedef struct bcm_static_buf {
-       struct semaphore static_sem;
+       spinlock_t static_lock;
        unsigned char *buf_ptr;
        unsigned char buf_use[STATIC_BUF_MAX_NUM];
 } bcm_static_buf_t;
@@ -310,12 +310,11 @@ int osl_static_mem_init(osl_t *osh, void *adapter)
                                ASSERT(osh->magic == OS_HANDLE_MAGIC);
                                kfree(osh);
                                return -ENOMEM;
+                       } else {
+                               printk("alloc static buf at %p!\n", bcm_static_buf);
                        }
-                       else
-                               printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf);
-
 
-                       sema_init(&bcm_static_buf->static_sem, 1);
+                       spin_lock_init(&bcm_static_buf->static_lock);
 
                        bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE;
                }
@@ -849,7 +848,7 @@ osl_pktget_static(osl_t *osh, uint len)
                        bcm_static_skb->pkt_use[i] = 1;
 
                        skb = bcm_static_skb->skb_4k[i];
-                       skb->tail = skb->data + len;
+                       skb_set_tail_pointer(skb, len);
                        skb->len = len;
 
                        up(&bcm_static_skb->osl_pkt_sem);
@@ -867,7 +866,7 @@ osl_pktget_static(osl_t *osh, uint len)
                if (i != STATIC_PKT_MAX_NUM) {
                        bcm_static_skb->pkt_use[i + STATIC_PKT_MAX_NUM] = 1;
                        skb = bcm_static_skb->skb_8k[i];
-                       skb->tail = skb->data + len;
+                       skb_set_tail_pointer(skb, len);
                        skb->len = len;
 
                        up(&bcm_static_skb->osl_pkt_sem);
@@ -880,7 +879,7 @@ osl_pktget_static(osl_t *osh, uint len)
                bcm_static_skb->pkt_use[STATIC_PKT_MAX_NUM * 2] = 1;
 
                skb = bcm_static_skb->skb_16k;
-               skb->tail = skb->data + len;
+               skb_set_tail_pointer(skb, len);
                skb->len = len;
 
                up(&bcm_static_skb->osl_pkt_sem);
@@ -1031,10 +1030,11 @@ osl_malloc(osl_t *osh, uint size)
 #ifdef CONFIG_DHD_USE_STATIC_BUF
        if (bcm_static_buf)
        {
+               unsigned long irq_flags;
                int i = 0;
                if ((size >= PAGE_SIZE)&&(size <= STATIC_BUF_SIZE))
                {
-                       down(&bcm_static_buf->static_sem);
+                       spin_lock_irqsave(&bcm_static_buf->static_lock, irq_flags);
 
                        for (i = 0; i < STATIC_BUF_MAX_NUM; i++)
                        {
@@ -1044,13 +1044,13 @@ osl_malloc(osl_t *osh, uint size)
 
                        if (i == STATIC_BUF_MAX_NUM)
                        {
-                               up(&bcm_static_buf->static_sem);
+                               spin_unlock_irqrestore(&bcm_static_buf->static_lock, irq_flags);
                                printk("all static buff in use!\n");
                                goto original;
                        }
 
                        bcm_static_buf->buf_use[i] = 1;
-                       up(&bcm_static_buf->static_sem);
+                       spin_unlock_irqrestore(&bcm_static_buf->static_lock, irq_flags);
 
                        bzero(bcm_static_buf->buf_ptr+STATIC_BUF_SIZE*i, size);
                        if (osh)
@@ -1092,6 +1092,8 @@ void
 osl_mfree(osl_t *osh, void *addr, uint size)
 {
 #ifdef CONFIG_DHD_USE_STATIC_BUF
+       unsigned long flags;
+
        if (bcm_static_buf)
        {
                if ((addr > (void *)bcm_static_buf) && ((unsigned char *)addr
@@ -1101,9 +1103,9 @@ osl_mfree(osl_t *osh, void *addr, uint size)
 
                        buf_idx = ((unsigned char *)addr - bcm_static_buf->buf_ptr)/STATIC_BUF_SIZE;
 
-                       down(&bcm_static_buf->static_sem);
+                       spin_lock_irqsave(&bcm_static_buf->static_lock, flags);
                        bcm_static_buf->buf_use[buf_idx] = 0;
-                       up(&bcm_static_buf->static_sem);
+                       spin_unlock_irqrestore(&bcm_static_buf->static_lock, flags);
 
                        if (osh && osh->cmn) {
                                ASSERT(osh->magic == OS_HANDLE_MAGIC);
index f95b171..af1b3c0 100644 (file)
@@ -2,7 +2,7 @@
  * Misc utility routines for accessing chip-specific features
  * of the SiliconBackplane-based Broadcom chips.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index f8d2584..63a1e3f 100644 (file)
@@ -2,7 +2,7 @@
  * Misc utility routines for accessing chip-specific features
  * of the SiliconBackplane-based Broadcom chips.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -22,7 +22,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: siutils.c 498632 2014-08-25 14:09:22Z $
+ * $Id: siutils.c 550969 2015-04-22 00:27:43Z $
  */
 
 #include <bcm_cfg.h>
@@ -1150,6 +1150,17 @@ factor6(uint32 x)
        }
 }
 
+/*
+ * Divide the clock by the divisor with protection for
+ * a zero divisor.
+ */
+static uint32
+divide_clock(uint32 clock, uint32 div)
+{
+       return div ? clock / div : 0;
+}
+
+
 /** calculate the speed the SI would run at given a set of clockcontrol values */
 uint32
 si_clock_rate(uint32 pll_type, uint32 n, uint32 m)
@@ -1207,10 +1218,10 @@ si_clock_rate(uint32 pll_type, uint32 n, uint32 m)
 
                switch (mc) {
                case CC_MC_BYPASS:      return (clock);
-               case CC_MC_M1:          return (clock / m1);
-               case CC_MC_M1M2:        return (clock / (m1 * m2));
-               case CC_MC_M1M2M3:      return (clock / (m1 * m2 * m3));
-               case CC_MC_M1M3:        return (clock / (m1 * m3));
+               case CC_MC_M1:          return divide_clock(clock, m1);
+               case CC_MC_M1M2:        return divide_clock(clock, m1 * m2);
+               case CC_MC_M1M2M3:      return divide_clock(clock, m1 * m2 * m3);
+               case CC_MC_M1M3:        return divide_clock(clock, m1 * m3);
                default:                return (0);
                }
        } else {
index a7d8ffc..a35a5c0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Include file private to the SOC Interconnect support files.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index dde4e1c..0612c24 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Description: Universal AMP API
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 4c1344d..4ac27ae 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver - Android related functions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_android.c 513774 2014-11-07 09:30:34Z $
+ * $Id: wl_android.c 555968 2015-05-12 01:56:23Z $
  */
 
 #include <linux/module.h>
@@ -98,6 +98,7 @@
 #define CMD_CHANSPEC      "CHANSPEC"
 #define CMD_DATARATE      "DATARATE"
 #define CMD_ASSOC_CLIENTS "ASSOCLIST"
+#define CMD_SET_CSA       "SETCSA"
 #define CMD_KEEP_ALIVE         "KEEPALIVE"
 
 
@@ -230,6 +231,12 @@ extern bool ap_fw_loaded;
 extern char iface_name[IFNAMSIZ];
 #endif 
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
+#define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
+#else
+#define strnicmp(str1, str2, len) strnicmp((str1), (str2), (len))
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
+
 /**
  * Local (static) functions and variables
  */
@@ -266,18 +273,31 @@ static int wl_android_get_rssi(struct net_device *net, char *command, int total_
        int bytes_written = 0;
        int error = 0;
        scb_val_t scbval;
-
-       if (*(command + 4) == ' ') {
-               DHD_ERROR(("%s: cmd:%s\n", __FUNCTION__, (command+5)));
-               if (!(bcm_ether_atoe((command+5), &scbval.ea)))
+       char *delim = NULL;
+
+       delim = strchr(command, ' ');
+       /* For Ap mode rssi command would be
+        * driver rssi <sta_mac_addr>
+        * for STA/GC mode
+        * driver rssi
+       */
+       if (delim) {
+               /* Ap/GO mode
+               * driver rssi <sta_mac_addr>
+               */
+               DHD_TRACE(("%s: cmd:%s\n", __FUNCTION__, delim));
+               /* skip space from delim after finding char */
+               delim++;
+               if (!(bcm_ether_atoe((delim), &scbval.ea)))
                {
                        DHD_ERROR(("%s:address err\n", __FUNCTION__));
                        return -1;
                }
                scbval.val = htod32(0);
-               DHD_ERROR(("%s: address:"MACDBG, __FUNCTION__, MAC2STRDBG(scbval.ea.octet)));
+               DHD_TRACE(("%s: address:"MACDBG, __FUNCTION__, MAC2STRDBG(scbval.ea.octet)));
        }
        else {
+               /* STA/GC mode */
                memset(&scbval, 0, sizeof(scb_val_t));
        }
 
@@ -295,7 +315,7 @@ static int wl_android_get_rssi(struct net_device *net, char *command, int total_
                bytes_written = ssid.SSID_len;
        }
        bytes_written += snprintf(&command[bytes_written], total_len, " rssi %d", scbval.val);
-       DHD_INFO(("%s: command result is %s (%d)\n", __FUNCTION__, command, bytes_written));
+       DHD_TRACE(("%s: command result is %s (%d)\n", __FUNCTION__, command, bytes_written));
        return bytes_written;
 }
 
@@ -352,7 +372,7 @@ int wl_android_get_80211_mode(struct net_device *dev, char *command, int total_l
                return -1;
 
        DHD_INFO(("%s: mode:%s\n", __FUNCTION__, mode));
-       bytes_written = snprintf(command, total_len, "%s %s %s", CMD_80211_MODE, "mode", mode);
+       bytes_written = snprintf(command, total_len, "%s %s", CMD_80211_MODE, mode);
        DHD_INFO(("%s: command:%s EXIT\n", __FUNCTION__, command));
        return bytes_written;
 
@@ -369,10 +389,11 @@ int wl_android_get_chanspec(struct net_device *dev, char *command, int total_len
        uint16 bw = 0;
        uint16 channel = 0;
        u32 sb = 0;
-       char ba[3];
        chanspec_t chanspec;
 
-       /* Get channel & Freq */
+       /* command is
+        * driver chanspec
+        */
        error = wldev_iovar_getint(dev, "chanspec", &chsp);
        if (error)
                return -1;
@@ -386,11 +407,6 @@ int wl_android_get_chanspec(struct net_device *dev, char *command, int total_len
 
        DHD_INFO(("%s:channel:%d band:%d bandwidth:%d\n", __FUNCTION__, channel, band, bw));
 
-       if (band == WL_CHANSPEC_BAND_2G)
-               strcpy(ba, "2G");
-       else if (band  == WL_CHANSPEC_BAND_5G)
-               strcpy(ba, "5G");
-
        if (bw == WL_CHANSPEC_BW_80)
                bw = WL_CH_BANDWIDTH_80MHZ;
        else if (bw == WL_CHANSPEC_BW_40)
@@ -420,8 +436,8 @@ int wl_android_get_chanspec(struct net_device *dev, char *command, int total_len
                        channel += (CH_10MHZ_APART + CH_20MHZ_APART);
                }
        }
-       bytes_written = snprintf(command, total_len, "%s %s %d %s %s %s %d", CMD_CHANSPEC,
-                       "channel", channel, "band", ba, "bw", bw);
+       bytes_written = snprintf(command, total_len, "%s channel %d band %s bw %d", CMD_CHANSPEC,
+               channel, band == WL_CHANSPEC_BAND_5G ? "5G":"2G", bw);
 
        DHD_INFO(("%s: command:%s EXIT\n", __FUNCTION__, command));
        return bytes_written;
@@ -441,8 +457,7 @@ int wl_android_get_datarate(struct net_device *dev, char *command, int total_len
 
        DHD_INFO(("%s:datarate:%d\n", __FUNCTION__, datarate));
 
-       bytes_written = snprintf(command, total_len, "%s %s %d", CMD_DATARATE,
-                       "datarate", (datarate/2));
+       bytes_written = snprintf(command, total_len, "%s %d", CMD_DATARATE, (datarate/2));
        return bytes_written;
 }
 int wl_android_get_assoclist(struct net_device *dev, char *command, int total_len)
@@ -463,16 +478,92 @@ int wl_android_get_assoclist(struct net_device *dev, char *command, int total_le
                return -1;
 
        assoc_maclist->count = dtoh32(assoc_maclist->count);
-       bytes_written = snprintf(command, total_len, "%s %s %d %s", CMD_ASSOC_CLIENTS,
-                       "listcount", assoc_maclist->count, "assoclist:");
+       bytes_written = snprintf(command, total_len, "%s listcount: %d Stations:",
+               CMD_ASSOC_CLIENTS, assoc_maclist->count);
 
        for (i = 0; i < assoc_maclist->count; i++) {
-               bytes_written = snprintf(command, total_len, "%s"MACDBG"%c",
-               command, MAC2STRDBG(assoc_maclist->ea[i].octet), ' ');
+               bytes_written += snprintf(command + bytes_written, total_len, " " MACDBG,
+                       MAC2STRDBG(assoc_maclist->ea[i].octet));
        }
        return bytes_written;
 
 }
+extern chanspec_t
+wl_chspec_host_to_driver(chanspec_t chanspec);
+static int wl_android_set_csa(struct net_device *dev, char *command, int total_len)
+{
+       int error = 0;
+       char smbuf[WLC_IOCTL_SMLEN];
+       wl_chan_switch_t csa_arg;
+       char buf[32];
+       u32 chnsp = 0;
+       int err = 0;
+
+       DHD_INFO(("%s: command:%s\n", __FUNCTION__, command));
+
+       command = (command + strlen(CMD_SET_CSA));
+       /* Order is mode, count channel */
+       if (!*++command) {
+               DHD_ERROR(("%s:error missing arguments\n", __FUNCTION__));
+               return -1;
+       }
+       csa_arg.mode = bcm_atoi(command);
+       if (csa_arg.mode != 0 && csa_arg.mode != 1) {
+               DHD_ERROR(("Invalid mode\n"));
+               return -1;
+       } if (!*++command) {
+               DHD_ERROR(("%s:error missing count\n", __FUNCTION__));
+               return -1;
+       }
+       command++;
+       csa_arg.count = bcm_atoi(command);
+       if (!*++command) {
+               DHD_ERROR(("%s:error missing channel\n", __FUNCTION__));
+               return -1;
+       }
+       csa_arg.reg = 0;
+       csa_arg.chspec = 0;
+       command += 2;
+       if (sizeof(buf) > strlen(command))
+               bcm_strncpy_s(buf, sizeof(buf), command, strlen(command));
+       else {
+               DHD_ERROR(("%s:command is invalid\n", __FUNCTION__));
+               return -1;
+       }
+       chnsp = wf_chspec_aton(buf);
+       if (chnsp == 0) {
+               DHD_ERROR(("%s:chsp is not correct\n", __FUNCTION__));
+               return -1;
+       }
+       chnsp = wl_chspec_host_to_driver(chnsp);
+       csa_arg.chspec = chnsp;
+
+       if (chnsp & WL_CHANSPEC_BAND_5G) {
+               u32 chanspec = chnsp;
+               err = wldev_iovar_getint(dev, "per_chan_info", &chanspec);
+               if (!err) {
+                       if ((chanspec & WL_CHAN_RADAR) || (chanspec & WL_CHAN_PASSIVE)) {
+                               DHD_ERROR(("Channel is radar sensitive\n"));
+                               return -1;
+                       }
+                       if (chanspec == 0) {
+                               DHD_ERROR(("Invalid hw channel\n"));
+                               return -1;
+                       }
+               } else  {
+                       DHD_ERROR(("does not support per_chan_info\n"));
+                       return -1;
+               }
+               DHD_INFO(("non radar sensitivity\n"));
+       }
+       error = wldev_iovar_setbuf(dev, "csa", &csa_arg, sizeof(csa_arg),
+               smbuf, sizeof(smbuf), NULL);
+       if (error) {
+               DHD_ERROR(("%s:set csa failed:%d\n", __FUNCTION__, error));
+               return -1;
+       }
+       return 0;
+}
 static int wl_android_get_band(struct net_device *dev, char *command, int total_len)
 {
        uint band;
@@ -497,7 +588,7 @@ wls_parse_batching_cmd(struct net_device *dev, char *command, int total_len)
        int err = BCME_OK;
        uint i, tokens;
        char *pos, *pos2, *token, *token2, *delim;
-       char param[PNO_PARAM_SIZE], value[VALUE_SIZE];
+       char param[PNO_PARAM_SIZE+1], value[VALUE_SIZE+1];
        struct dhd_pno_batch_params batch_params;
        DHD_PNO(("%s: command=%s, len=%d\n", __FUNCTION__, command, total_len));
        if (total_len < strlen(CMD_WLS_BATCHING)) {
@@ -793,19 +884,28 @@ wl_android_set_mac_address_filter(struct net_device *dev, const char* str)
        int macmode = MACLIST_MODE_DISABLED;
        struct maclist *list;
        char eabuf[ETHER_ADDR_STR_LEN];
+       char *token;
 
        /* string should look like below (macmode/macnum/maclist) */
        /*   1 2 00:11:22:33:44:55 00:11:22:33:44:ff  */
 
        /* get the MAC filter mode */
-       macmode = bcm_atoi(strsep((char**)&str, " "));
+       token = strsep((char**)&str, " ");
+       if (!token) {
+               return -1;
+       }
+       macmode = bcm_atoi(token);
 
        if (macmode < MACLIST_MODE_DISABLED || macmode > MACLIST_MODE_ALLOW) {
                DHD_ERROR(("%s : invalid macmode %d\n", __FUNCTION__, macmode));
                return -1;
        }
 
-       macnum = bcm_atoi(strsep((char**)&str, " "));
+       token = strsep((char**)&str, " ");
+       if (!token) {
+               return -1;
+       }
+       macnum = bcm_atoi(token);
        if (macnum < 0 || macnum > MAX_NUM_MAC_FILT) {
                DHD_ERROR(("%s : invalid number of MAC address entries %d\n",
                        __FUNCTION__, macnum));
@@ -1448,8 +1548,9 @@ wl_android_set_miracast(struct net_device *dev, char *command, int total_len)
 
        DHD_INFO(("%s: enter miracast mode %d\n", __FUNCTION__, mode));
 
-       if (miracast_cur_mode == mode)
+       if (miracast_cur_mode == mode) {
                return 0;
+       }
 
        wl_android_iolist_resume(dev, &miracast_resume_list);
        miracast_cur_mode = MIRACAST_MODE_OFF;
@@ -1465,27 +1566,29 @@ wl_android_set_miracast(struct net_device *dev, char *command, int total_len)
                        DHD_ERROR(("%s: Connected station's beacon interval: "
                                "%d and set mchan_algo to %d \n",
                                __FUNCTION__, val, config.param));
-               }
-               else {
+               } else {
                        config.param = MIRACAST_MCHAN_ALGO;
                }
                ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
-               if (ret)
+               if (ret) {
                        goto resume;
+               }
 
                /* setting mchan_bw to platform specific value */
                config.iovar = "mchan_bw";
                config.param = MIRACAST_MCHAN_BW;
                ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
-               if (ret)
+               if (ret) {
                        goto resume;
+               }
 
                /* setting apmdu to platform specific value */
                config.iovar = "ampdu_mpdu";
                config.param = MIRACAST_AMPDU_SIZE;
                ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
-               if (ret)
+               if (ret) {
                        goto resume;
+               }
                /* FALLTROUGH */
                /* Source mode shares most configurations with sink mode.
                 * Fall through here to avoid code duplication
@@ -1495,17 +1598,27 @@ wl_android_set_miracast(struct net_device *dev, char *command, int total_len)
                config.iovar = "roam_off";
                config.param = 1;
                ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
-               if (ret)
+               if (ret) {
                        goto resume;
+               }
+
                /* tunr off pm */
-               val = 0;
-               config.iovar = NULL;
-               config.ioctl = WLC_GET_PM;
-               config.arg = &val;
-               config.len = sizeof(int);
-               ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
-               if (ret)
+               ret = wldev_ioctl(dev, WLC_GET_PM, &val, sizeof(val), false);
+               if (ret) {
                        goto resume;
+               }
+
+               if (val != PM_OFF) {
+                       val = PM_OFF;
+                       config.iovar = NULL;
+                       config.ioctl = WLC_GET_PM;
+                       config.arg = &val;
+                       config.len = sizeof(int);
+                       ret = wl_android_iolist_add(dev, &miracast_resume_list, &config);
+                       if (ret) {
+                               goto resume;
+                       }
+               }
 
                break;
        case MIRACAST_MODE_OFF:
@@ -1722,11 +1835,11 @@ int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
 
        DHD_INFO(("%s: Android private cmd \"%s\" on %s\n", __FUNCTION__, command, ifr->ifr_name));
 
-       if (strncasecmp(command, CMD_START, strlen(CMD_START)) == 0) {
+       if (strnicmp(command, CMD_START, strlen(CMD_START)) == 0) {
                DHD_INFO(("%s, Received regular START command\n", __FUNCTION__));
                bytes_written = wl_android_wifi_on(net);
        }
-       else if (strncasecmp(command, CMD_SETFWPATH, strlen(CMD_SETFWPATH)) == 0) {
+       else if (strnicmp(command, CMD_SETFWPATH, strlen(CMD_SETFWPATH)) == 0) {
                bytes_written = wl_android_set_fwpath(net, command, priv_cmd.total_len);
        }
 
@@ -1737,44 +1850,44 @@ int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
                goto exit;
        }
 
-       if (strncasecmp(command, CMD_STOP, strlen(CMD_STOP)) == 0) {
+       if (strnicmp(command, CMD_STOP, strlen(CMD_STOP)) == 0) {
                bytes_written = wl_android_wifi_off(net);
        }
-       else if (strncasecmp(command, CMD_SCAN_ACTIVE, strlen(CMD_SCAN_ACTIVE)) == 0) {
+       else if (strnicmp(command, CMD_SCAN_ACTIVE, strlen(CMD_SCAN_ACTIVE)) == 0) {
                /* TBD: SCAN-ACTIVE */
        }
-       else if (strncasecmp(command, CMD_SCAN_PASSIVE, strlen(CMD_SCAN_PASSIVE)) == 0) {
+       else if (strnicmp(command, CMD_SCAN_PASSIVE, strlen(CMD_SCAN_PASSIVE)) == 0) {
                /* TBD: SCAN-PASSIVE */
        }
-       else if (strncasecmp(command, CMD_RSSI, strlen(CMD_RSSI)) == 0) {
+       else if (strnicmp(command, CMD_RSSI, strlen(CMD_RSSI)) == 0) {
                bytes_written = wl_android_get_rssi(net, command, priv_cmd.total_len);
        }
-       else if (strncasecmp(command, CMD_LINKSPEED, strlen(CMD_LINKSPEED)) == 0) {
+       else if (strnicmp(command, CMD_LINKSPEED, strlen(CMD_LINKSPEED)) == 0) {
                bytes_written = wl_android_get_link_speed(net, command, priv_cmd.total_len);
        }
 #ifdef PKT_FILTER_SUPPORT
-       else if (strncasecmp(command, CMD_RXFILTER_START, strlen(CMD_RXFILTER_START)) == 0) {
+       else if (strnicmp(command, CMD_RXFILTER_START, strlen(CMD_RXFILTER_START)) == 0) {
                bytes_written = net_os_enable_packet_filter(net, 1);
        }
-       else if (strncasecmp(command, CMD_RXFILTER_STOP, strlen(CMD_RXFILTER_STOP)) == 0) {
+       else if (strnicmp(command, CMD_RXFILTER_STOP, strlen(CMD_RXFILTER_STOP)) == 0) {
                bytes_written = net_os_enable_packet_filter(net, 0);
        }
-       else if (strncasecmp(command, CMD_RXFILTER_ADD, strlen(CMD_RXFILTER_ADD)) == 0) {
+       else if (strnicmp(command, CMD_RXFILTER_ADD, strlen(CMD_RXFILTER_ADD)) == 0) {
                int filter_num = *(command + strlen(CMD_RXFILTER_ADD) + 1) - '0';
                bytes_written = net_os_rxfilter_add_remove(net, TRUE, filter_num);
        }
-       else if (strncasecmp(command, CMD_RXFILTER_REMOVE, strlen(CMD_RXFILTER_REMOVE)) == 0) {
+       else if (strnicmp(command, CMD_RXFILTER_REMOVE, strlen(CMD_RXFILTER_REMOVE)) == 0) {
                int filter_num = *(command + strlen(CMD_RXFILTER_REMOVE) + 1) - '0';
                bytes_written = net_os_rxfilter_add_remove(net, FALSE, filter_num);
        }
 #endif /* PKT_FILTER_SUPPORT */
-       else if (strncasecmp(command, CMD_BTCOEXSCAN_START, strlen(CMD_BTCOEXSCAN_START)) == 0) {
+       else if (strnicmp(command, CMD_BTCOEXSCAN_START, strlen(CMD_BTCOEXSCAN_START)) == 0) {
                /* TBD: BTCOEXSCAN-START */
        }
-       else if (strncasecmp(command, CMD_BTCOEXSCAN_STOP, strlen(CMD_BTCOEXSCAN_STOP)) == 0) {
+       else if (strnicmp(command, CMD_BTCOEXSCAN_STOP, strlen(CMD_BTCOEXSCAN_STOP)) == 0) {
                /* TBD: BTCOEXSCAN-STOP */
        }
-       else if (strncasecmp(command, CMD_BTCOEXMODE, strlen(CMD_BTCOEXMODE)) == 0) {
+       else if (strnicmp(command, CMD_BTCOEXMODE, strlen(CMD_BTCOEXMODE)) == 0) {
 #ifdef WL_CFG80211
                void *dhdp = wl_cfg80211_get_dhdp();
                bytes_written = wl_cfg80211_set_btcoex_dhcp(net, dhdp, command);
@@ -1789,122 +1902,124 @@ int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
 #endif /* PKT_FILTER_SUPPORT */
 #endif /* WL_CFG80211 */
        }
-       else if (strncasecmp(command, CMD_SETSUSPENDOPT, strlen(CMD_SETSUSPENDOPT)) == 0) {
+       else if (strnicmp(command, CMD_SETSUSPENDOPT, strlen(CMD_SETSUSPENDOPT)) == 0) {
                bytes_written = wl_android_set_suspendopt(net, command, priv_cmd.total_len);
        }
-       else if (strncasecmp(command, CMD_SETSUSPENDMODE, strlen(CMD_SETSUSPENDMODE)) == 0) {
+       else if (strnicmp(command, CMD_SETSUSPENDMODE, strlen(CMD_SETSUSPENDMODE)) == 0) {
                bytes_written = wl_android_set_suspendmode(net, command, priv_cmd.total_len);
        }
-       else if (strncasecmp(command, CMD_SETBAND, strlen(CMD_SETBAND)) == 0) {
+       else if (strnicmp(command, CMD_SETBAND, strlen(CMD_SETBAND)) == 0) {
                uint band = *(command + strlen(CMD_SETBAND) + 1) - '0';
                bytes_written = wldev_set_band(net, band);
        }
-       else if (strncasecmp(command, CMD_GETBAND, strlen(CMD_GETBAND)) == 0) {
+       else if (strnicmp(command, CMD_GETBAND, strlen(CMD_GETBAND)) == 0) {
                bytes_written = wl_android_get_band(net, command, priv_cmd.total_len);
        }
 #ifdef WL_CFG80211
        /* CUSTOMER_SET_COUNTRY feature is define for only GGSM model */
-       else if (strncasecmp(command, CMD_COUNTRY, strlen(CMD_COUNTRY)) == 0) {
+       else if (strnicmp(command, CMD_COUNTRY, strlen(CMD_COUNTRY)) == 0) {
                char *country_code = command + strlen(CMD_COUNTRY) + 1;
                bytes_written = wldev_set_country(net, country_code, true, true);
        }
 #endif /* WL_CFG80211 */
-       else if (strncasecmp(command, CMD_80211_MODE, strlen(CMD_80211_MODE)) == 0) {
+       else if (strnicmp(command, CMD_SET_CSA, strlen(CMD_SET_CSA)) == 0) {
+               bytes_written = wl_android_set_csa(net, command, priv_cmd.total_len);
+       } else if (strnicmp(command, CMD_80211_MODE, strlen(CMD_80211_MODE)) == 0) {
                bytes_written = wl_android_get_80211_mode(net, command, priv_cmd.total_len);
-       } else if (strncasecmp(command, CMD_CHANSPEC, strlen(CMD_CHANSPEC)) == 0) {
+       } else if (strnicmp(command, CMD_CHANSPEC, strlen(CMD_CHANSPEC)) == 0) {
                bytes_written = wl_android_get_chanspec(net, command, priv_cmd.total_len);
-       } else if (strncasecmp(command, CMD_DATARATE, strlen(CMD_DATARATE)) == 0) {
+       } else if (strnicmp(command, CMD_DATARATE, strlen(CMD_DATARATE)) == 0) {
                bytes_written = wl_android_get_datarate(net, command, priv_cmd.total_len);
-       } else if (strncasecmp(command, CMD_ASSOC_CLIENTS,      strlen(CMD_ASSOC_CLIENTS)) == 0) {
+       } else if (strnicmp(command, CMD_ASSOC_CLIENTS, strlen(CMD_ASSOC_CLIENTS)) == 0) {
                bytes_written = wl_android_get_assoclist(net, command, priv_cmd.total_len);
        }
 
 #ifdef PNO_SUPPORT
-       else if (strncasecmp(command, CMD_PNOSSIDCLR_SET, strlen(CMD_PNOSSIDCLR_SET)) == 0) {
+       else if (strnicmp(command, CMD_PNOSSIDCLR_SET, strlen(CMD_PNOSSIDCLR_SET)) == 0) {
                bytes_written = dhd_dev_pno_stop_for_ssid(net);
        }
 #ifndef WL_SCHED_SCAN
-       else if (strncasecmp(command, CMD_PNOSETUP_SET, strlen(CMD_PNOSETUP_SET)) == 0) {
+       else if (strnicmp(command, CMD_PNOSETUP_SET, strlen(CMD_PNOSETUP_SET)) == 0) {
                bytes_written = wl_android_set_pno_setup(net, command, priv_cmd.total_len);
        }
 #endif /* !WL_SCHED_SCAN */
-       else if (strncasecmp(command, CMD_PNOENABLE_SET, strlen(CMD_PNOENABLE_SET)) == 0) {
+       else if (strnicmp(command, CMD_PNOENABLE_SET, strlen(CMD_PNOENABLE_SET)) == 0) {
                int enable = *(command + strlen(CMD_PNOENABLE_SET) + 1) - '0';
                bytes_written = (enable)? 0 : dhd_dev_pno_stop_for_ssid(net);
        }
-       else if (strncasecmp(command, CMD_WLS_BATCHING, strlen(CMD_WLS_BATCHING)) == 0) {
+       else if (strnicmp(command, CMD_WLS_BATCHING, strlen(CMD_WLS_BATCHING)) == 0) {
                bytes_written = wls_parse_batching_cmd(net, command, priv_cmd.total_len);
        }
 #endif /* PNO_SUPPORT */
-       else if (strncasecmp(command, CMD_P2P_DEV_ADDR, strlen(CMD_P2P_DEV_ADDR)) == 0) {
+       else if (strnicmp(command, CMD_P2P_DEV_ADDR, strlen(CMD_P2P_DEV_ADDR)) == 0) {
                bytes_written = wl_android_get_p2p_dev_addr(net, command, priv_cmd.total_len);
        }
-       else if (strncasecmp(command, CMD_P2P_SET_NOA, strlen(CMD_P2P_SET_NOA)) == 0) {
+       else if (strnicmp(command, CMD_P2P_SET_NOA, strlen(CMD_P2P_SET_NOA)) == 0) {
                int skip = strlen(CMD_P2P_SET_NOA) + 1;
                bytes_written = wl_cfg80211_set_p2p_noa(net, command + skip,
                        priv_cmd.total_len - skip);
        }
 #ifdef WL_NAN
-       else if (strncasecmp(command, CMD_NAN, strlen(CMD_NAN)) == 0) {
+       else if (strnicmp(command, CMD_NAN, strlen(CMD_NAN)) == 0) {
                bytes_written = wl_cfg80211_nan_cmd_handler(net, command,
                        priv_cmd.total_len);
        }
 #endif /* WL_NAN */
 #if !defined WL_ENABLE_P2P_IF
-       else if (strncasecmp(command, CMD_P2P_GET_NOA, strlen(CMD_P2P_GET_NOA)) == 0) {
+       else if (strnicmp(command, CMD_P2P_GET_NOA, strlen(CMD_P2P_GET_NOA)) == 0) {
                bytes_written = wl_cfg80211_get_p2p_noa(net, command, priv_cmd.total_len);
        }
 #endif /* WL_ENABLE_P2P_IF */
-       else if (strncasecmp(command, CMD_P2P_SET_PS, strlen(CMD_P2P_SET_PS)) == 0) {
+       else if (strnicmp(command, CMD_P2P_SET_PS, strlen(CMD_P2P_SET_PS)) == 0) {
                int skip = strlen(CMD_P2P_SET_PS) + 1;
                bytes_written = wl_cfg80211_set_p2p_ps(net, command + skip,
                        priv_cmd.total_len - skip);
        }
 #ifdef WL_CFG80211
-       else if (strncasecmp(command, CMD_SET_AP_WPS_P2P_IE,
+       else if (strnicmp(command, CMD_SET_AP_WPS_P2P_IE,
                strlen(CMD_SET_AP_WPS_P2P_IE)) == 0) {
                int skip = strlen(CMD_SET_AP_WPS_P2P_IE) + 3;
                bytes_written = wl_cfg80211_set_wps_p2p_ie(net, command + skip,
                        priv_cmd.total_len - skip, *(command + skip - 2) - '0');
        }
 #endif /* WL_CFG80211 */
-       else if (strncasecmp(command, CMD_OKC_SET_PMK, strlen(CMD_OKC_SET_PMK)) == 0)
+       else if (strnicmp(command, CMD_OKC_SET_PMK, strlen(CMD_OKC_SET_PMK)) == 0)
                bytes_written = wl_android_set_pmk(net, command, priv_cmd.total_len);
-       else if (strncasecmp(command, CMD_OKC_ENABLE, strlen(CMD_OKC_ENABLE)) == 0)
+       else if (strnicmp(command, CMD_OKC_ENABLE, strlen(CMD_OKC_ENABLE)) == 0)
                bytes_written = wl_android_okc_enable(net, command, priv_cmd.total_len);
 #if defined(WL_SUPPORT_AUTO_CHANNEL)
-       else if (strncasecmp(command, CMD_GET_BEST_CHANNELS,
+       else if (strnicmp(command, CMD_GET_BEST_CHANNELS,
                strlen(CMD_GET_BEST_CHANNELS)) == 0) {
                bytes_written = wl_cfg80211_get_best_channels(net, command,
                        priv_cmd.total_len);
        }
 #endif /* WL_SUPPORT_AUTO_CHANNEL */
-       else if (strncasecmp(command, CMD_HAPD_MAC_FILTER, strlen(CMD_HAPD_MAC_FILTER)) == 0) {
+       else if (strnicmp(command, CMD_HAPD_MAC_FILTER, strlen(CMD_HAPD_MAC_FILTER)) == 0) {
                int skip = strlen(CMD_HAPD_MAC_FILTER) + 1;
                wl_android_set_mac_address_filter(net, (const char*)command+skip);
        }
-       else if (strncasecmp(command, CMD_SETROAMMODE, strlen(CMD_SETROAMMODE)) == 0)
+       else if (strnicmp(command, CMD_SETROAMMODE, strlen(CMD_SETROAMMODE)) == 0)
                bytes_written = wl_android_set_roam_mode(net, command, priv_cmd.total_len);
 #if defined(BCMFW_ROAM_ENABLE)
-       else if (strncasecmp(command, CMD_SET_ROAMPREF, strlen(CMD_SET_ROAMPREF)) == 0) {
+       else if (strnicmp(command, CMD_SET_ROAMPREF, strlen(CMD_SET_ROAMPREF)) == 0) {
                bytes_written = wl_android_set_roampref(net, command, priv_cmd.total_len);
        }
 #endif /* BCMFW_ROAM_ENABLE */
-       else if (strncasecmp(command, CMD_MIRACAST, strlen(CMD_MIRACAST)) == 0)
+       else if (strnicmp(command, CMD_MIRACAST, strlen(CMD_MIRACAST)) == 0)
                bytes_written = wl_android_set_miracast(net, command, priv_cmd.total_len);
-       else if (strncasecmp(command, CMD_SETIBSSBEACONOUIDATA, strlen(CMD_SETIBSSBEACONOUIDATA)) == 0)
+       else if (strnicmp(command, CMD_SETIBSSBEACONOUIDATA, strlen(CMD_SETIBSSBEACONOUIDATA)) == 0)
                bytes_written = wl_android_set_ibss_beacon_ouidata(net,
                command, priv_cmd.total_len);
-       else if (strncasecmp(command, CMD_KEEP_ALIVE, strlen(CMD_KEEP_ALIVE)) == 0) {
+       else if (strnicmp(command, CMD_KEEP_ALIVE, strlen(CMD_KEEP_ALIVE)) == 0) {
                int skip = strlen(CMD_KEEP_ALIVE) + 1;
                bytes_written = wl_keep_alive_set(net, command + skip, priv_cmd.total_len - skip);
        }
-       else if (strncasecmp(command, CMD_ROAM_OFFLOAD, strlen(CMD_ROAM_OFFLOAD)) == 0) {
+       else if (strnicmp(command, CMD_ROAM_OFFLOAD, strlen(CMD_ROAM_OFFLOAD)) == 0) {
                int enable = *(command + strlen(CMD_ROAM_OFFLOAD) + 1) - '0';
                bytes_written = wl_cfg80211_enable_roam_offload(net, enable);
        }
 #ifdef CONNECTION_STATISTICS
-       else if (strncasecmp(command, CMD_GET_CONNECTION_STATS,
+       else if (strnicmp(command, CMD_GET_CONNECTION_STATS,
                strlen(CMD_GET_CONNECTION_STATS)) == 0) {
                bytes_written = wl_android_get_connection_stats(net, command,
                        priv_cmd.total_len);
index 43bf381..17ac5d2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver - Android related functions
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 4468a95..5204649 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_cfg80211.c 513448 2014-11-06 13:44:21Z $
+ * $Id: wl_cfg80211.c 589976 2015-10-01 07:01:27Z $
  */
 /* */
 #include <typedefs.h>
 #endif /* !WL_ENABLE_P2P_IF && !WL_CFG80211_P2P_DEV_IF */
 #endif /* WL11U */
 
-#ifdef BCMWAPI_WPI
-/* these items should evetually go into wireless.h of the linux system headfile dir */
-#ifndef IW_ENCODE_ALG_SM4
-#define IW_ENCODE_ALG_SM4 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_ENABLED
-#define IW_AUTH_WAPI_ENABLED 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_VERSION_1
-#define IW_AUTH_WAPI_VERSION_1  0x00000008
-#endif
-
-#ifndef IW_AUTH_CIPHER_SMS4
-#define IW_AUTH_CIPHER_SMS4     0x00000020
-#endif
 
-#ifndef IW_AUTH_KEY_MGMT_WAPI_PSK
-#define IW_AUTH_KEY_MGMT_WAPI_PSK 4
-#endif
+#define IW_WSEC_ENABLED(wsec)   ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
 
-#ifndef IW_AUTH_KEY_MGMT_WAPI_CERT
-#define IW_AUTH_KEY_MGMT_WAPI_CERT 8
-#endif
-#endif /* BCMWAPI_WPI */
 
-#ifdef BCMWAPI_WPI
-#define IW_WSEC_ENABLED(wsec)   ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
-#else /* BCMWAPI_WPI */
-#define IW_WSEC_ENABLED(wsec)   ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))
-#endif /* BCMWAPI_WPI */
 
 static struct device *cfg80211_parent_dev = NULL;
 /* g_bcm_cfg should be static. Do not change */
@@ -156,10 +128,12 @@ u32 wl_dbg_level = WL_DBG_ERR;
 #define CH_MIN_2G_CHANNEL 1
 
 
+#ifdef WL_RELMCAST
 enum rmc_event_type {
        RMC_EVENT_NONE,
        RMC_EVENT_LEADER_CHECK_FAIL
 };
+#endif /* WL_RELMCAST */
 
 /* This is to override regulatory domains defined in cfg80211 module (reg.c)
  * By default world regulatory domain defined in reg.c puts the flags NL80211_RRF_PASSIVE_SCAN
@@ -280,7 +254,6 @@ common_iface_combinations[] = {
 #define WPS_CONFIG_PHY_DISPLAY 0x4008
 
 
-
 #define WL_AKM_SUITE_SHA256_1X  0x000FAC05
 #define WL_AKM_SUITE_SHA256_PSK 0x000FAC06
 #define WL_MFP_CAPABLE         0x1
@@ -295,6 +268,14 @@ common_iface_combinations[] = {
 #endif
 
 #define CUSTOM_RETRY_MASK 0xff000000 /* Mask for retry counter of custom dwell time */
+#define LONG_LISTEN_TIME 2000
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
+#define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
+#else
+#define STA_INFO_BIT(info) (STATION_ ## info)
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
+
 /*
  * cfg80211_ops api/callback list
  */
@@ -317,9 +298,15 @@ static s32 wl_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
        struct cfg80211_ibss_params *params);
 static s32 wl_cfg80211_leave_ibss(struct wiphy *wiphy,
        struct net_device *dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32 wl_cfg80211_get_station(struct wiphy *wiphy,
        struct net_device *dev, const u8 *mac,
        struct station_info *sinfo);
+#else
+static s32 wl_cfg80211_get_station(struct wiphy *wiphy,
+       struct net_device *dev, u8 *mac,
+       struct station_info *sinfo);
+#endif
 static s32 wl_cfg80211_set_power_mgmt(struct wiphy *wiphy,
        struct net_device *dev, bool enabled,
        s32 timeout);
@@ -361,11 +348,24 @@ static s32 wl_cfg80211_resume(struct wiphy *wiphy);
        2, 0))
 static s32 wl_cfg80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
        bcm_struct_cfgdev *cfgdev, u64 cookie);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0))
+static s32 wl_cfg80211_del_station(
+               struct wiphy *wiphy, struct net_device *ndev,
+               struct station_del_parameters *params);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32 wl_cfg80211_del_station(struct wiphy *wiphy,
-       struct net_device *ndev,
-       struct station_del_parameters *params);
+       struct net_device *ndev, const u8* mac_addr);
+#else
+static s32 wl_cfg80211_del_station(struct wiphy *wiphy,
+       struct net_device *ndev, u8* mac_addr);
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32 wl_cfg80211_change_station(struct wiphy *wiphy,
        struct net_device *dev, const u8 *mac, struct station_parameters *params);
+#else
+static s32 wl_cfg80211_change_station(struct wiphy *wiphy,
+       struct net_device *dev, u8 *mac, struct station_parameters *params);
+#endif
 #endif /* WL_SUPPORT_BACKPORTED_KPATCHES || KERNEL_VER >= KERNEL_VERSION(3, 2, 0)) */
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39))
 static s32 wl_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -386,12 +386,30 @@ static void wl_cfg80211_scan_abort(struct bcm_cfg80211 *cfg);
 static s32 wl_notify_escan_complete(struct bcm_cfg80211 *cfg,
        struct net_device *ndev, bool aborted, bool fw_abort);
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
+static s32
+wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
+        const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
+        u32 peer_capability, bool initiator, const u8 *data, size_t len);
+#else
+#if defined(CONFIG_ARCH_MSM) && defined(TDLS_MGMT_VERSION2)
+static s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
+       u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
+       u32 peer_capability, const u8 *data, size_t len);
+#else
 static s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
-       const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
-       u32 peer_capability, bool initiator, const u8 *data,
+       u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, const u8 *data,
        size_t len);
-static s32 wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
+#endif /* CONFIG_ARCH_MSM && TDLS_MGMT_VERSION2 */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
+static s32
+wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
        const u8 *peer, enum nl80211_tdls_operation oper);
+#else
+static s32 wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
+       u8 *peer, enum nl80211_tdls_operation oper);
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) */
 #endif 
 #ifdef WL_SCHED_SCAN
 static int wl_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev);
@@ -482,10 +500,6 @@ static s32 wl_set_key_mgmt(struct net_device *dev,
        struct cfg80211_connect_params *sme);
 static s32 wl_set_set_sharedkey(struct net_device *dev,
        struct cfg80211_connect_params *sme);
-#ifdef BCMWAPI_WPI
-static s32 wl_set_set_wapi_ie(struct net_device *dev,
-        struct cfg80211_connect_params *sme);
-#endif
 static s32 wl_get_assoc_ies(struct bcm_cfg80211 *cfg, struct net_device *ndev);
 static void wl_ch_to_chanspec(int ch,
        struct wl_join_params *join_params, size_t *join_params_size);
@@ -637,6 +651,17 @@ extern int dhd_wait_pend8021x(struct net_device *dev);
 #ifdef PROP_TXSTATUS_VSDB
 extern int disable_proptx;
 #endif /* PROP_TXSTATUS_VSDB */
+static s32
+wl_csa_complete_ind(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
+const wl_event_msg_t *e, void *data);
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0)) && (LINUX_VERSION_CODE <= (3, 7, \
+       0)))
+struct chan_info {
+       int freq;
+       int chan_type;
+};
+#endif
+
 
 #if (WL_DBG_LEVEL > 0)
 #define WL_DBG_ESTR_MAX        50
@@ -770,11 +795,29 @@ static const u32 __wl_cipher_suites[] = {
        WLAN_CIPHER_SUITE_TKIP,
        WLAN_CIPHER_SUITE_CCMP,
        WLAN_CIPHER_SUITE_AES_CMAC,
-#ifdef BCMWAPI_WPI
-       WLAN_CIPHER_SUITE_SMS4,
-#endif
 };
 
+#ifdef WL_SUPPORT_ACS
+/*
+ * The firmware code required for this feature to work is currently under
+ * BCMINTERNAL flag. In future if this is to enabled we need to bring the
+ * required firmware code out of the BCMINTERNAL flag.
+ */
+struct wl_dump_survey {
+       u32 obss;
+       u32 ibss;
+       u32 no_ctg;
+       u32 no_pckt;
+       u32 tx;
+       u32 idle;
+};
+#endif /* WL_SUPPORT_ACS */
+
+#ifdef WL_SUPPORT_ACS
+uint8 g_hostap_chan_count;
+uint16 g_hostap_chan_cache[50];
+#endif /* WL_SUPPORT_ACS */
+
 
 #if defined(USE_DYNAMIC_MAXPKT_RXGLOM)
 static int maxrxpktglom = 0;
@@ -1312,7 +1355,9 @@ wl_cfg80211_add_virtual_iface(struct wiphy *wiphy,
 #else
        char *name,
 #endif /* WL_CFG80211_P2P_DEV_IF */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
        unsigned char name_assign_type,
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) */
        enum nl80211_iftype type, u32 *flags,
        struct vif_params *params)
 {
@@ -1516,6 +1561,35 @@ wl_cfg80211_add_virtual_iface(struct wiphy *wiphy,
                } else {
                        wl_clr_p2p_status(cfg, IF_ADDING);
                        WL_ERR((" virtual interface(%s) is not created \n", cfg->p2p->vir_ifname));
+
+                       WL_ERR(("left timeout : %d\n", timeout));
+                       WL_ERR(("IF_ADDING status : %d\n", wl_get_p2p_status(cfg, IF_ADDING)));
+                       WL_ERR(("event valid : %d\n", cfg->if_event_info.valid));
+
+                       wl_clr_p2p_status(cfg, GO_NEG_PHASE);
+                       wl_set_p2p_status(cfg, IF_DELETING);
+
+                       err = wl_cfgp2p_ifdel(cfg, &cfg->p2p->int_addr);
+                       if (err == BCME_OK) {
+                               timeout = wait_event_interruptible_timeout(cfg->netif_change_event,
+                                       (wl_get_p2p_status(cfg, IF_DELETING) == false),
+                                       msecs_to_jiffies(MAX_WAIT_TIME));
+                               if (timeout > 0 && !wl_get_p2p_status(cfg, IF_DELETING) &&
+                                       cfg->if_event_info.valid) {
+                                       WL_ERR(("IFDEL operation done\n"));
+                               } else {
+                                       WL_ERR(("IFDEL didn't complete properly\n"));
+                                       err = BCME_ERROR;
+                               }
+                       }
+                       if (err != BCME_OK) {
+                               struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg);
+
+                               WL_ERR(("p2p_ifdel failed, error %d, sent HANG event to %s\n",
+                                       err, ndev->name));
+                               net_os_send_hang_message(ndev);
+                       }
+
                        memset(cfg->p2p->vir_ifname, '\0', IFNAMSIZ);
                        cfg->p2p->vif_created = false;
 #ifdef PROP_TXSTATUS_VSDB
@@ -1907,7 +1981,10 @@ static s32 wl_cfg80211_handle_ifdel(struct bcm_cfg80211 *cfg, wl_if_event_info *
 #endif /* PROP_TXSTATUS_VSDB */
        }
 
+       dhd_net_if_lock(ndev);
        wl_cfg80211_remove_if(cfg, if_event_info->ifidx, ndev);
+       dhd_net_if_unlock(ndev);
+
        return BCME_OK;
 }
 
@@ -2112,7 +2189,7 @@ wl_run_escan(struct bcm_cfg80211 *cfg, struct net_device *ndev,
        u8 chan_buf[sizeof(u32)*(WL_NUMCHANNELS + 1)];
        u32 num_chans = 0;
        s32 channel;
-       s32 n_valid_chan;
+       u32 n_valid_chan;
        s32 search_state = WL_P2P_DISC_ST_SCAN;
        u32 i, j, n_nodfs = 0;
        u16 *default_chan_list = NULL;
@@ -2383,13 +2460,44 @@ __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
        struct net_device *remain_on_channel_ndev = NULL;
 #endif
 
-       dhd_pub_t *dhd;
-
-       dhd = (dhd_pub_t *)(cfg->pub);
-       if (dhd->op_mode & DHD_FLAG_HOSTAP_MODE) {
+#ifdef WL_SUPPORT_ACS
+       /*
+        * Hostapd triggers scan before starting automatic channel selection
+        * to collect channel characteristics. However firmware scan engine
+        * doesn't support any channel characteristics collection along with
+        * scan. Hence return scan success.
+        */
+       if (request && (scan_req_iftype(request) == NL80211_IFTYPE_AP)) {
+               struct cfg80211_scan_info info = {
+                       .aborted = 0,
+               };
+               /*
+                * In case of ACS, store the channel number that hostap
+                * interested in. can be used to filter out when
+                * wl_cfg80211_dump_survey() handler is called.
+                */
+               {       struct ieee80211_channel *chan = request->channels[0];
+                       g_hostap_chan_count = 0;
+                       while (g_hostap_chan_count  < request->n_channels)
+                       {
+                               g_hostap_chan_cache[g_hostap_chan_count] =
+                                       chan[g_hostap_chan_count].center_freq;
+                               g_hostap_chan_count++;
+                       }
+                       WL_DBG(("channel count hostapd interested in %d",
+                               g_hostap_chan_count));
+               }
+               /* Indicate cfg80211 that we are done with scan */
+               cfg80211_scan_done(request, &info);
+               WL_INFO(("Scan Command on SoftAP Interface. Ignoring...\n"));
+               return 0;
+       }
+#elif BCMDONGLEHOST
+       if (((dhd_pub_t *)(cfg->pub))->op_mode & DHD_FLAG_HOSTAP_MODE) {
                WL_ERR(("Invalid Scan Command at SoftAP mode\n"));
                return -EINVAL;
        }
+#endif /* BCMDONGLEHOST */
 
        ndev = ndev_to_wlc_ndev(ndev, cfg);
 
@@ -3022,7 +3130,9 @@ wl_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
        }
        wl_update_prof(cfg, dev, NULL, &join_params.ssid, WL_PROF_SSID);
        wl_update_prof(cfg, dev, NULL, &cfg->channel, WL_PROF_CHAN);
+#ifdef WL_RELMCAST
        cfg->rmc_event_seq = 0; /* initialize rmcfail sequence */
+#endif /* WL_RELMCAST */
        return err;
 }
 
@@ -3081,13 +3191,6 @@ wl_set_wpa_version(struct net_device *dev, struct cfg80211_connect_params *sme)
        if (is_wps_conn(sme))
                val = WPA_AUTH_DISABLED;
 
-#ifdef BCMWAPI_WPI
-       if (sme->crypto.wpa_versions & NL80211_WAPI_VERSION_1) {
-               WL_DBG((" * wl_set_wpa_version, set wpa_auth"
-                       " to WPA_AUTH_WAPI 0x400"));
-               val = WAPI_AUTH_PSK | WAPI_AUTH_UNSPECIFIED;
-       }
-#endif
        WL_DBG(("setting wpa_auth to 0x%0x\n", val));
        err = wldev_iovar_setint_bsscfg(dev, "wpa_auth", val, bssidx);
        if (unlikely(err)) {
@@ -3099,33 +3202,6 @@ wl_set_wpa_version(struct net_device *dev, struct cfg80211_connect_params *sme)
        return err;
 }
 
-#ifdef BCMWAPI_WPI
-static s32
-wl_set_set_wapi_ie(struct net_device *dev, struct cfg80211_connect_params *sme)
-{
-       struct bcm_cfg80211 *cfg = g_bcm_cfg;
-       s32 err = 0;
-       s32 bssidx;
-       if (wl_cfgp2p_find_idx(cfg, dev, &bssidx) != BCME_OK) {
-               WL_ERR(("Find p2p index from dev(%p) failed\n", dev));
-               return BCME_ERROR;
-       }
-
-       WL_DBG((" %s \n", __FUNCTION__));
-
-       if (sme->crypto.wpa_versions & NL80211_WAPI_VERSION_1) {
-               err = wldev_iovar_setbuf_bsscfg(dev, "wapiie", sme->ie, sme->ie_len,
-                       cfg->ioctl_buf, WLC_IOCTL_MAXLEN, bssidx, &cfg->ioctl_buf_sync);
-
-               if (unlikely(err)) {
-                       WL_ERR(("===> set_wapi_ie Error (%d)\n", err));
-                       return err;
-               }
-       } else
-               WL_DBG((" * skip \n"));
-       return err;
-}
-#endif /* BCMWAPI_WPI */
 
 static s32
 wl_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme)
@@ -3179,9 +3255,6 @@ wl_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme)
        s32 err = 0;
        s32 wsec_val = 0;
 
-#ifdef BCMWAPI_WPI
-       s32 val = 0;
-#endif
        s32 bssidx;
        if (wl_cfgp2p_find_idx(cfg, dev, &bssidx) != BCME_OK) {
                WL_ERR(("Find p2p index from dev(%p) failed\n", dev));
@@ -3201,12 +3274,6 @@ wl_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme)
                case WLAN_CIPHER_SUITE_AES_CMAC:
                        pval = AES_ENABLED;
                        break;
-#ifdef BCMWAPI_WPI
-               case WLAN_CIPHER_SUITE_SMS4:
-                       val = SMS4_ENABLED;
-                       pval = SMS4_ENABLED;
-                       break;
-#endif
                default:
                        WL_ERR(("invalid cipher pairwise (%d)\n",
                                sme->crypto.ciphers_pairwise[0]));
@@ -3228,12 +3295,6 @@ wl_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme)
                case WLAN_CIPHER_SUITE_AES_CMAC:
                        gval = AES_ENABLED;
                        break;
-#ifdef BCMWAPI_WPI
-               case WLAN_CIPHER_SUITE_SMS4:
-                       val = SMS4_ENABLED;
-                       gval = SMS4_ENABLED;
-                       break;
-#endif
                default:
                        WL_ERR(("invalid cipher group (%d)\n",
                                sme->crypto.cipher_group));
@@ -3250,21 +3311,12 @@ wl_set_set_cipher(struct net_device *dev, struct cfg80211_connect_params *sme)
                        /* WPS-2.0 allows no security */
                        err = wldev_iovar_setint_bsscfg(dev, "wsec", 0, bssidx);
        } else {
-#ifdef BCMWAPI_WPI
-               if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_SMS4) {
-                       WL_DBG((" NO, is_wps_conn, WAPI set to SMS4_ENABLED"));
-                       err = wldev_iovar_setint_bsscfg(dev, "wsec", val, bssidx);
-               } else {
-#endif
                        WL_DBG((" NO, is_wps_conn, Set pval | gval to WSEC"));
                        wsec_val = pval | gval;
 
                        WL_DBG((" Set WSEC to fW 0x%x \n", wsec_val));
                        err = wldev_iovar_setint_bsscfg(dev, "wsec",
                                wsec_val, bssidx);
-#ifdef BCMWAPI_WPI
-               }
-#endif
        }
        if (unlikely(err)) {
                WL_ERR(("error (%d)\n", err));
@@ -3326,22 +3378,6 @@ wl_set_key_mgmt(struct net_device *dev, struct cfg80211_connect_params *sme)
                                return -EINVAL;
                        }
                }
-#ifdef BCMWAPI_WPI
-               else if (val & (WAPI_AUTH_PSK | WAPI_AUTH_UNSPECIFIED)) {
-                       switch (sme->crypto.akm_suites[0]) {
-                       case WLAN_AKM_SUITE_WAPI_CERT:
-                               val = WAPI_AUTH_UNSPECIFIED;
-                               break;
-                       case WLAN_AKM_SUITE_WAPI_PSK:
-                               val = WAPI_AUTH_PSK;
-                               break;
-                       default:
-                               WL_ERR(("invalid cipher group (%d)\n",
-                                       sme->crypto.cipher_group));
-                               return -EINVAL;
-                       }
-               }
-#endif
                WL_DBG(("setting wpa_auth to %d\n", val));
 
                err = wldev_iovar_setint_bsscfg(dev, "wpa_auth", val, bssidx);
@@ -3376,18 +3412,10 @@ wl_set_set_sharedkey(struct net_device *dev,
                sec = wl_read_prof(cfg, dev, WL_PROF_SEC);
                WL_DBG(("wpa_versions 0x%x cipher_pairwise 0x%x\n",
                        sec->wpa_versions, sec->cipher_pairwise));
-               if (!(sec->wpa_versions & (NL80211_WPA_VERSION_1 |
-#ifdef BCMWAPI_WPI
-                       NL80211_WPA_VERSION_2 | NL80211_WAPI_VERSION_1)) &&
-#else
-                       NL80211_WPA_VERSION_2)) &&
-#endif
-                       (sec->cipher_pairwise & (WLAN_CIPHER_SUITE_WEP40 |
-#ifdef BCMWAPI_WPI
-               WLAN_CIPHER_SUITE_WEP104 | WLAN_CIPHER_SUITE_SMS4)))
-#else
+               if ((!(sec->wpa_versions & (NL80211_WPA_VERSION_1 |
+               NL80211_WPA_VERSION_2))) &&
+               (sec->cipher_pairwise & (WLAN_CIPHER_SUITE_WEP40 |
                WLAN_CIPHER_SUITE_WEP104)))
-#endif
                {
                        memset(&key, 0, sizeof(key));
                        key.len = (u32) sme->key_len;
@@ -3405,11 +3433,6 @@ wl_set_set_sharedkey(struct net_device *dev,
                        case WLAN_CIPHER_SUITE_WEP104:
                                key.algo = CRYPTO_ALGO_WEP128;
                                break;
-#ifdef BCMWAPI_WPI
-                       case WLAN_CIPHER_SUITE_SMS4:
-                               key.algo = CRYPTO_ALGO_SMS4;
-                               break;
-#endif
                        default:
                                WL_ERR(("Invalid algorithm (%d)\n",
                                        sme->crypto.ciphers_pairwise[0]));
@@ -3489,6 +3512,18 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
 
        WL_DBG(("In\n"));
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
+       if (sme->channel_hint) {
+               chan = sme->channel_hint;
+               WL_DBG(("channel_hint (%d), channel_hint center_freq (%d)\n",
+                       ieee80211_frequency_to_channel(sme->channel_hint->center_freq),
+                       sme->channel_hint->center_freq));
+       }
+       if (sme->bssid_hint) {
+               sme->bssid = sme->bssid_hint;
+               WL_DBG(("bssid_hint "MACDBG" \n", MAC2STRDBG(sme->bssid_hint)));
+       }
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) */
        if (unlikely(!sme->ssid)) {
                WL_ERR(("Invalid ssid\n"));
                return -EOPNOTSUPP;
@@ -3500,6 +3535,11 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
                return -EINVAL;
        }
 
+       WL_DBG(("SME IE : len=%zu\n", sme->ie_len));
+       if (sme->ie != NULL && sme->ie_len > 0 && (wl_dbg_level & WL_DBG_DBG)) {
+               prhex(NULL, (void *)sme->ie, sme->ie_len);
+       }
+
        RETURN_EIO_IF_NOT_UP(cfg);
 
        /*
@@ -3632,37 +3672,18 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
                        chan->center_freq, chan_cnt));
        } else
                cfg->channel = 0;
-#ifdef BCMWAPI_WPI
-       WL_DBG(("1. enable wapi auth\n"));
-       if (sme->crypto.wpa_versions & NL80211_WAPI_VERSION_1) {
-               WL_DBG(("2. set wapi ie  \n"));
-               err = wl_set_set_wapi_ie(dev, sme);
-               if (unlikely(err))
-                       return err;
-       } else
-               WL_DBG(("2. Not wapi ie  \n"));
-#endif
-       WL_DBG(("ie (%p), ie_len (%zd)\n", sme->ie, sme->ie_len));
+
        WL_DBG(("3. set wapi version \n"));
        err = wl_set_wpa_version(dev, sme);
        if (unlikely(err)) {
                WL_ERR(("Invalid wpa_version\n"));
                return err;
        }
-#ifdef BCMWAPI_WPI
-       if (sme->crypto.wpa_versions & NL80211_WAPI_VERSION_1)
-               WL_DBG(("4. WAPI Dont Set wl_set_auth_type\n"));
-       else {
-               WL_DBG(("4. wl_set_auth_type\n"));
-#endif
                err = wl_set_auth_type(dev, sme);
                if (unlikely(err)) {
                        WL_ERR(("Invalid auth type\n"));
                        return err;
                }
-#ifdef BCMWAPI_WPI
-       }
-#endif
 
        err = wl_set_set_cipher(dev, sme);
        if (unlikely(err)) {
@@ -3743,7 +3764,7 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
        err = wldev_iovar_setbuf_bsscfg(dev, "join", ext_join_params, join_params_size,
                cfg->ioctl_buf, WLC_IOCTL_MAXLEN, bssidx, &cfg->ioctl_buf_sync);
 
-       WL_ERR(("Connectting with" MACDBG " channel (%d) ssid \"%s\", len (%d)\n\n",
+       WL_ERR(("Connecting with" MACDBG " channel (%d) ssid \"%s\", len (%d)\n\n",
                MAC2STRDBG((u8*)(&ext_join_params->assoc.bssid)), cfg->channel,
                ext_join_params->ssid.SSID, ext_join_params->ssid.SSID_len));
 
@@ -3837,6 +3858,11 @@ wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
        }
 #endif /* CUSTOM_SET_CPUCORE */
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
+       /* cfg80211 expects disconnect event from DHD to release wdev->current_bss */
+       cfg80211_disconnected(dev, reason_code, NULL, 0, false, GFP_KERNEL);
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) */
+
        return err;
 }
 
@@ -4021,12 +4047,6 @@ wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
                        key.algo = CRYPTO_ALGO_AES_CCM;
                        WL_DBG(("WLAN_CIPHER_SUITE_CCMP\n"));
                        break;
-#ifdef BCMWAPI_WPI
-               case WLAN_CIPHER_SUITE_SMS4:
-                       key.algo = CRYPTO_ALGO_SMS4;
-                       WL_DBG(("WLAN_CIPHER_SUITE_SMS4\n"));
-                       break;
-#endif
                default:
                        WL_ERR(("Invalid cipher (0x%x)\n", params->cipher));
                        return -EINVAL;
@@ -4143,13 +4163,6 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
                val = AES_ENABLED;
                WL_DBG(("WLAN_CIPHER_SUITE_CCMP\n"));
                break;
-#ifdef BCMWAPI_WPI
-       case WLAN_CIPHER_SUITE_SMS4:
-               key.algo = CRYPTO_ALGO_SMS4;
-               WL_DBG(("WLAN_CIPHER_SUITE_SMS4\n"));
-               val = SMS4_ENABLED;
-               break;
-#endif /* BCMWAPI_WPI */
        default:
                WL_ERR(("Invalid cipher (0x%x)\n", params->cipher));
                return -EINVAL;
@@ -4277,12 +4290,6 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
                        params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
                        WL_DBG(("WLAN_CIPHER_SUITE_AES_CMAC\n"));
                        break;
-#ifdef BCMWAPI_WPI
-               case WLAN_CIPHER_SUITE_SMS4:
-                       key.algo = CRYPTO_ALGO_SMS4;
-                       WL_DBG(("WLAN_CIPHER_SUITE_SMS4\n"));
-                       break;
-#endif
                default:
                        WL_ERR(("Invalid algo (0x%x)\n", wsec));
                        return -EINVAL;
@@ -4300,9 +4307,17 @@ wl_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
        return -EOPNOTSUPP;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32
-wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
-       const u8 *mac, struct station_info *sinfo)
+wl_cfg80211_get_station(struct wiphy *wiphy,
+       struct net_device *dev, const u8 *mac,
+       struct station_info *sinfo)
+#else
+static s32
+wl_cfg80211_get_station(struct wiphy *wiphy,
+       struct net_device *dev, u8 *mac,
+       struct station_info *sinfo)
+#endif
 {
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
        scb_val_t scb_val;
@@ -4322,7 +4337,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                        WL_ERR(("GET STA INFO failed, %d\n", err));
                        return err;
                }
-               sinfo->filled = BIT(NL80211_STA_INFO_INACTIVE_TIME);
+               sinfo->filled = STA_INFO_BIT(INFO_INACTIVE_TIME);
                sta = (sta_info_t *)cfg->ioctl_buf;
                sta->len = dtoh16(sta->len);
                sta->cap = dtoh16(sta->cap);
@@ -4332,7 +4347,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                sinfo->inactive_time = sta->idle * 1000;
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
                if (sta->flags & WL_STA_ASSOC) {
-                       sinfo->filled |= BIT(NL80211_STA_INFO_CONNECTED_TIME);
+                       sinfo->filled |= STA_INFO_BIT(INFO_CONNECTED_TIME);
                        sinfo->connected_time = sta->in;
                }
                WL_INFO(("STA %s : idle time : %d sec, connected time :%d ms\n",
@@ -4343,14 +4358,15 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                wl_get_mode_by_netdev(cfg, dev) == WL_MODE_IBSS) {
                get_pktcnt_t pktcnt;
                u8 *curmacp;
+               struct ether_addr bssid;
 
                if (cfg->roam_offload) {
-                       struct ether_addr bssid;
                        err = wldev_ioctl(dev, WLC_GET_BSSID, &bssid, ETHER_ADDR_LEN, false);
                        if (err) {
                                WL_ERR(("Failed to get current BSSID\n"));
                        } else {
-                               if (memcmp(mac, &bssid.octet, ETHER_ADDR_LEN) != 0) {
+                               if (!ETHER_ISNULLADDR(&bssid.octet) &&
+                                               memcmp(mac, &bssid.octet, ETHER_ADDR_LEN) != 0) {
                                        /* roaming is detected */
                                        err = wl_cfg80211_delayed_roam(cfg, dev, &bssid);
                                        if (err)
@@ -4383,7 +4399,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                        int rxpktglom;
 #endif
                        rate = dtoh32(rate);
-                       sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
+                       sinfo->filled |= STA_INFO_BIT(INFO_TX_BITRATE);
                        sinfo->txrate.legacy = rate * 5;
                        WL_DBG(("Rate %d Mbps\n", (rate / 2)));
 #if defined(USE_DYNAMIC_MAXPKT_RXGLOM)
@@ -4412,16 +4428,16 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                        goto get_station_err;
                }
                rssi = wl_rssi_offset(dtoh32(scb_val.val));
-               sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
+               sinfo->filled |= STA_INFO_BIT(INFO_SIGNAL);
                sinfo->signal = rssi;
                WL_DBG(("RSSI %d dBm\n", rssi));
                err = wldev_ioctl(dev, WLC_GET_PKTCNTS, &pktcnt,
                        sizeof(pktcnt), false);
                if (!err) {
-                       sinfo->filled |= (BIT(NL80211_STA_INFO_RX_PACKETS) |
-                               BIT(NL80211_STA_INFO_RX_DROP_MISC) |
-                               BIT(NL80211_STA_INFO_TX_PACKETS) |
-                               BIT(NL80211_STA_INFO_TX_FAILED));
+                       sinfo->filled |= (STA_INFO_BIT(INFO_RX_PACKETS) |
+                               STA_INFO_BIT(INFO_RX_DROP_MISC) |
+                               STA_INFO_BIT(INFO_TX_PACKETS) |
+                               STA_INFO_BIT(INFO_TX_FAILED));
                        sinfo->rx_packets = pktcnt.rx_good_pkt;
                        sinfo->rx_dropped_misc = pktcnt.rx_bad_pkt;
                        sinfo->tx_packets = pktcnt.tx_good_pkt;
@@ -4524,22 +4540,25 @@ static s32 wl_cfg80211_resume(struct wiphy *wiphy)
 {
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
        struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg);
-       s32 err = 0;
+       s32 err = BCME_OK;
 
        if (unlikely(!wl_get_drv_status(cfg, READY, ndev))) {
                WL_INFO(("device is not ready\n"));
-               return 0;
+               return err;
        }
 
+
        return err;
 }
 
+
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39))
 static s32 wl_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow)
 #else
 static s32 wl_cfg80211_suspend(struct wiphy *wiphy)
 #endif
 {
+       s32 err = BCME_OK;
 #ifdef DHD_CLEAR_ON_SUSPEND
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
        struct net_info *iter, *next;
@@ -4548,7 +4567,7 @@ static s32 wl_cfg80211_suspend(struct wiphy *wiphy)
        if (unlikely(!wl_get_drv_status(cfg, READY, ndev))) {
                WL_INFO(("device is not ready : status (%d)\n",
                        (int)cfg->status));
-               return 0;
+               return err;
        }
        for_each_ndev(cfg, iter, next)
                wl_set_drv_status(cfg, SCAN_ABORTING, iter->ndev);
@@ -4572,7 +4591,9 @@ static s32 wl_cfg80211_suspend(struct wiphy *wiphy)
                }
        }
 #endif /* DHD_CLEAR_ON_SUSPEND */
-       return 0;
+
+
+       return err;
 }
 
 static s32
@@ -4800,20 +4821,24 @@ wl_cfg80211_remain_on_channel(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev,
                struct timer_list *_timer;
                WL_DBG(("scan is running. go to fake listen state\n"));
 
-               wl_set_drv_status(cfg, FAKE_REMAINING_ON_CHANNEL, ndev);
+               if (duration > LONG_LISTEN_TIME) {
+                       wl_cfg80211_scan_abort(cfg);
+               } else {
+                       wl_set_drv_status(cfg, FAKE_REMAINING_ON_CHANNEL, ndev);
 
-               if (timer_pending(&cfg->p2p->listen_timer)) {
-                       WL_DBG(("cancel current listen timer \n"));
-                       del_timer_sync(&cfg->p2p->listen_timer);
-               }
+                       if (timer_pending(&cfg->p2p->listen_timer)) {
+                               WL_DBG(("cancel current listen timer \n"));
+                               del_timer_sync(&cfg->p2p->listen_timer);
+                       }
 
-               _timer = &cfg->p2p->listen_timer;
-               wl_clr_p2p_status(cfg, LISTEN_EXPIRED);
+                       _timer = &cfg->p2p->listen_timer;
+                       wl_clr_p2p_status(cfg, LISTEN_EXPIRED);
 
-               INIT_TIMER(_timer, wl_cfgp2p_listen_expired, duration, 0);
+                       INIT_TIMER(_timer, wl_cfgp2p_listen_expired, duration, 0);
 
-               err = BCME_OK;
-               goto exit;
+                       err = BCME_OK;
+                       goto exit;
+               }
        }
 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
 
@@ -4888,6 +4913,7 @@ wl_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
        s32 err = 0;
 
+       RETURN_EIO_IF_NOT_UP(cfg);
 #if defined(WL_CFG80211_P2P_DEV_IF)
        if (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE) {
                WL_DBG((" enter ) on P2P dedicated discover interface\n"));
@@ -5275,6 +5301,14 @@ wl_cfg80211_send_action_frame(struct wiphy *wiphy, struct net_device *dev,
                wl_notify_escan_complete(cfg, cfg->escan_info.ndev, true, true);
        }
 
+       /* Abort P2P listen */
+       if (discover_cfgdev(cfgdev, cfg)) {
+               if (cfg->p2p_supported && cfg->p2p) {
+                       wl_cfgp2p_set_p2p_mode(cfg, WL_P2P_DISC_ST_SCAN, 0, 0,
+                               wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE));
+               }
+       }
+
 #ifdef WL11U
        /* handling DFS channel exceptions */
        if (!wl_cfg80211_check_DFS_channel(cfg, af_params, action_frame->data, action_frame->len)) {
@@ -5295,6 +5329,12 @@ wl_cfg80211_send_action_frame(struct wiphy *wiphy, struct net_device *dev,
        /* save af_params for rx process */
        cfg->afx_hdl->pending_tx_act_frm = af_params;
 
+       if (wl_cfgp2p_is_p2p_gas_action(action_frame->data, action_frame->len)) {
+               WL_DBG(("Set GAS action frame config.\n"));
+               config_af_params.search_channel = false;
+               config_af_params.max_tx_retry = 1;
+       }
+
        /* search peer's channel */
        if (config_af_params.search_channel) {
                /* initialize afx_hdl */
@@ -5335,6 +5375,8 @@ wl_cfg80211_send_action_frame(struct wiphy *wiphy, struct net_device *dev,
 
        wl_cfgp2p_print_actframe(true, action_frame->data, action_frame->len, af_params->channel);
 
+       wl_cfgp2p_need_wait_actfrmae(cfg, action_frame->data, action_frame->len, true);
+
        /* Now send a tx action frame */
        ack = wl_cfgp2p_tx_action_frame(cfg, dev, af_params, bssidx) ? false : true;
 
@@ -5486,9 +5528,10 @@ wl_cfg80211_mgmt_tx(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev,
                        if (dev == wl_to_p2p_bss_ndev(cfg, P2PAPI_BSSCFG_CONNECTION))
                                dev = bcmcfg_to_prmry_ndev(cfg);
 #endif
-                       if ((dev == bcmcfg_to_prmry_ndev(cfg)) && cfg->p2p)
+                       if ((dev == bcmcfg_to_prmry_ndev(cfg)) && cfg->p2p) {
                                bssidx = wl_to_p2p_bss_bssidx(cfg, P2PAPI_BSSCFG_DEVICE);
-                               wl_cfgp2p_set_management_ie(cfg, dev, bssidx,
+                       }
+                       wl_cfgp2p_set_management_ie(cfg, dev, bssidx,
                                VNDR_IE_PRBRSP_FLAG, (u8 *)(buf + ie_offset), ie_len);
                        cfg80211_mgmt_tx_status(cfgdev, *cookie, buf, len, true, GFP_KERNEL);
                        goto exit;
@@ -5828,11 +5871,6 @@ wl_validate_wpa2ie(struct net_device *dev, bcm_tlv_t *wpa2ie, s32 bssidx)
                case WPA_CIPHER_AES_CCM:
                        gval = AES_ENABLED;
                        break;
-#ifdef BCMWAPI_WPI
-               case WAPI_CIPHER_SMS4:
-                       gval = SMS4_ENABLED;
-                       break;
-#endif
                default:
                        WL_ERR(("No Security Info\n"));
                        break;
@@ -5857,11 +5895,6 @@ wl_validate_wpa2ie(struct net_device *dev, bcm_tlv_t *wpa2ie, s32 bssidx)
                case WPA_CIPHER_AES_CCM:
                        pval = AES_ENABLED;
                        break;
-#ifdef BCMWAPI_WPI
-               case WAPI_CIPHER_SMS4:
-                       pval = SMS4_ENABLED;
-                       break;
-#endif
                default:
                        WL_ERR(("No Security Info\n"));
        }
@@ -6491,11 +6524,19 @@ static s32 wl_cfg80211_hostapd_sec(
 
 #if defined(WL_SUPPORT_BACKPORTED_KPATCHES) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3, \
        2, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0))
+static s32 wl_cfg80211_del_station(
+               struct wiphy *wiphy, struct net_device *ndev,
+               struct station_del_parameters *params)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32
-wl_cfg80211_del_station(
-       struct wiphy *wiphy,
-       struct net_device *ndev,
-       struct station_del_parameters *params)
+wl_cfg80211_del_station(struct wiphy *wiphy,
+       struct net_device *ndev, const u8* mac_addr)
+#else
+static s32
+wl_cfg80211_del_station(struct wiphy *wiphy,
+       struct net_device *ndev, u8* mac_addr)
+#endif
 {
        struct net_device *dev;
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
@@ -6507,8 +6548,12 @@ wl_cfg80211_del_station(
        struct maclist *assoc_maclist = (struct maclist *)mac_buf;
        int num_associated = 0;
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0))
+       const u8 *mac_addr = params->mac;
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) */
+
        WL_DBG(("Entry\n"));
-       if (params->mac == NULL) {
+       if (mac_addr == NULL) {
                WL_DBG(("mac_addr is NULL ignore it\n"));
                return 0;
        }
@@ -6533,28 +6578,31 @@ wl_cfg80211_del_station(
        else
                num_associated = assoc_maclist->count;
 
-       memcpy(scb_val.ea.octet, params->mac, ETHER_ADDR_LEN);
+       memcpy(scb_val.ea.octet, mac_addr, ETHER_ADDR_LEN);
        scb_val.val = DOT11_RC_DEAUTH_LEAVING;
        err = wldev_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scb_val,
                sizeof(scb_val_t), true);
        if (err < 0)
                WL_ERR(("WLC_SCB_DEAUTHENTICATE_FOR_REASON err %d\n", err));
        WL_ERR(("Disconnect STA : %s scb_val.val %d\n",
-               bcm_ether_ntoa((const struct ether_addr *)(params->mac), eabuf),
+               bcm_ether_ntoa((const struct ether_addr *)mac_addr, eabuf),
                scb_val.val));
 
-       if (num_associated > 0 && ETHER_ISBCAST(params->mac))
+       if (num_associated > 0 && ETHER_ISBCAST(mac_addr))
                wl_delay(400);
 
        return 0;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32
-wl_cfg80211_change_station(
-       struct wiphy *wiphy,
-       struct net_device *dev,
-       const u8 *mac,
-       struct station_parameters *params)
+wl_cfg80211_change_station(struct wiphy *wiphy,
+       struct net_device *dev, const u8 *mac, struct station_parameters *params)
+#else
+static s32
+wl_cfg80211_change_station(struct wiphy *wiphy,
+       struct net_device *dev, u8 *mac, struct station_parameters *params)
+#endif
 {
        int err;
        struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
@@ -6565,13 +6613,21 @@ wl_cfg80211_change_station(
                return -ENOTSUPP;
 
        if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))) {
-               err = wldev_ioctl(primary_ndev, WLC_SCB_DEAUTHORIZE, (void *)mac, ETH_ALEN, true);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
+       err = wldev_ioctl(primary_ndev, WLC_SCB_AUTHORIZE, (u8 *)mac, ETH_ALEN, true);
+#else
+       err = wldev_ioctl(primary_ndev, WLC_SCB_AUTHORIZE, mac, ETH_ALEN, true);
+#endif
                if (err)
                        WL_ERR(("WLC_SCB_DEAUTHORIZE error (%d)\n", err));
                return err;
        }
 
-       err = wldev_ioctl(primary_ndev, WLC_SCB_AUTHORIZE, (void *)mac, ETH_ALEN, true);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
+       err = wldev_ioctl(primary_ndev, WLC_SCB_AUTHORIZE, (u8 *)mac, ETH_ALEN, true);
+#else
+       err = wldev_ioctl(primary_ndev, WLC_SCB_AUTHORIZE, mac, ETH_ALEN, true);
+#endif
        if (err)
                WL_ERR(("WLC_SCB_AUTHORIZE error (%d)\n", err));
        return err;
@@ -6990,6 +7046,11 @@ wl_cfg80211_sched_scan_start(struct wiphy *wiphy,
        int i;
        int ret = 0;
 
+       if (!request) {
+               WL_ERR(("Sched scan request was NULL\n"));
+               return -EINVAL;
+       }
+
        WL_DBG(("Enter \n"));
        WL_PNO((">>> SCHED SCAN START\n"));
        WL_PNO(("Enter n_match_sets:%d   n_ssids:%d \n",
@@ -6998,7 +7059,7 @@ wl_cfg80211_sched_scan_start(struct wiphy *wiphy,
                request->n_ssids, pno_time, pno_repeat, pno_freq_expo_max));
 
 
-       if (!request || !request->n_ssids || !request->n_match_sets) {
+       if (!request->n_ssids || !request->n_match_sets) {
                WL_ERR(("Invalid sched scan req!! n_ssids:%d \n", request->n_ssids));
                return -EINVAL;
        }
@@ -7063,47 +7124,283 @@ wl_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
 }
 #endif /* WL_SCHED_SCAN */
 
-static struct cfg80211_ops wl_cfg80211_ops = {
-       .add_virtual_intf = wl_cfg80211_add_virtual_iface,
-       .del_virtual_intf = wl_cfg80211_del_virtual_iface,
-       .change_virtual_intf = wl_cfg80211_change_virtual_iface,
-#if defined(WL_CFG80211_P2P_DEV_IF)
-       .start_p2p_device = wl_cfgp2p_start_p2p_device,
-       .stop_p2p_device = wl_cfgp2p_stop_p2p_device,
-#endif /* WL_CFG80211_P2P_DEV_IF */
-       .scan = wl_cfg80211_scan,
-       .set_wiphy_params = wl_cfg80211_set_wiphy_params,
-       .join_ibss = wl_cfg80211_join_ibss,
-       .leave_ibss = wl_cfg80211_leave_ibss,
-       .get_station = wl_cfg80211_get_station,
-       .set_tx_power = wl_cfg80211_set_tx_power,
-       .get_tx_power = wl_cfg80211_get_tx_power,
-       .add_key = wl_cfg80211_add_key,
-       .del_key = wl_cfg80211_del_key,
-       .get_key = wl_cfg80211_get_key,
-       .set_default_key = wl_cfg80211_config_default_key,
-       .set_default_mgmt_key = wl_cfg80211_config_default_mgmt_key,
-       .set_power_mgmt = wl_cfg80211_set_power_mgmt,
-       .connect = wl_cfg80211_connect,
-       .disconnect = wl_cfg80211_disconnect,
-       .suspend = wl_cfg80211_suspend,
-       .resume = wl_cfg80211_resume,
-       .set_pmksa = wl_cfg80211_set_pmksa,
-       .del_pmksa = wl_cfg80211_del_pmksa,
-       .flush_pmksa = wl_cfg80211_flush_pmksa,
-       .remain_on_channel = wl_cfg80211_remain_on_channel,
-       .cancel_remain_on_channel = wl_cfg80211_cancel_remain_on_channel,
-       .mgmt_tx = wl_cfg80211_mgmt_tx,
-       .mgmt_frame_register = wl_cfg80211_mgmt_frame_register,
-       .change_bss = wl_cfg80211_change_bss,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
-       .set_channel = wl_cfg80211_set_channel,
-#endif 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0))
-       .set_beacon = wl_cfg80211_add_set_beacon,
-       .add_beacon = wl_cfg80211_add_set_beacon,
-#else
-       .change_beacon = wl_cfg80211_change_beacon,
+#ifdef WL_SUPPORT_ACS
+/*
+ * Currently the dump_obss IOVAR is returning string as output so we need to
+ * parse the output buffer in an unoptimized way. Going forward if we get the
+ * IOVAR output in binary format this method can be optimized
+ */
+static int wl_parse_dump_obss(char *buf, struct wl_dump_survey *survey)
+{
+       int i;
+       char *token;
+       char delim[] = " \n";
+
+       token = strsep(&buf, delim);
+       while (token != NULL) {
+               if (!strcmp(token, "OBSS")) {
+                       for (i = 0; i < OBSS_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->obss = simple_strtoul(token, NULL, 10);
+               }
+
+               if (!strcmp(token, "IBSS")) {
+                       for (i = 0; i < IBSS_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->ibss = simple_strtoul(token, NULL, 10);
+               }
+
+               if (!strcmp(token, "TXDur")) {
+                       for (i = 0; i < TX_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->tx = simple_strtoul(token, NULL, 10);
+               }
+
+               if (!strcmp(token, "Category")) {
+                       for (i = 0; i < CTG_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->no_ctg = simple_strtoul(token, NULL, 10);
+               }
+
+               if (!strcmp(token, "Packet")) {
+                       for (i = 0; i < PKT_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->no_pckt = simple_strtoul(token, NULL, 10);
+               }
+
+               if (!strcmp(token, "Opp(time):")) {
+                       for (i = 0; i < IDLE_TOKEN_IDX; i++)
+                               token = strsep(&buf, delim);
+                       survey->idle = simple_strtoul(token, NULL, 10);
+               }
+
+               token = strsep(&buf, delim);
+       }
+
+       return 0;
+}
+
+static int wl_dump_obss(struct net_device *ndev, cca_msrmnt_query req,
+       struct wl_dump_survey *survey)
+{
+       cca_stats_n_flags *results;
+       char *buf;
+       int retry, err;
+
+       buf = kzalloc(sizeof(char) * WLC_IOCTL_MAXLEN, GFP_KERNEL);
+       if (unlikely(!buf)) {
+               WL_ERR(("%s: buf alloc failed\n", __func__));
+               return -ENOMEM;
+       }
+
+       retry = IOCTL_RETRY_COUNT;
+       while (retry--) {
+               err = wldev_iovar_getbuf(ndev, "dump_obss", &req, sizeof(req),
+                       buf, WLC_IOCTL_MAXLEN, NULL);
+               if (err >=  0) {
+                       break;
+               }
+               WL_DBG(("attempt = %d, err = %d, \n",
+                       (IOCTL_RETRY_COUNT - retry), err));
+       }
+
+       if (retry <= 0) {
+               WL_ERR(("failure, dump_obss IOVAR failed\n"));
+               err = -EINVAL;
+               goto exit;
+       }
+
+       results = (cca_stats_n_flags *)(buf);
+       wl_parse_dump_obss(results->buf, survey);
+       kfree(buf);
+
+       return 0;
+exit:
+       kfree(buf);
+       return err;
+}
+
+static int wl_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
+       int idx, struct survey_info *info)
+{
+       struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
+       struct wl_dump_survey *survey;
+       struct ieee80211_supported_band *band;
+       struct ieee80211_channel*chan;
+       cca_msrmnt_query req;
+       int val, err, noise, retry;
+       uint8 cache_idx;
+
+       dhd_pub_t *dhd = (dhd_pub_t *)(cfg->pub);
+       if (!(dhd->op_mode & DHD_FLAG_HOSTAP_MODE)) {
+               return -ENOENT;
+       }
+       band = wiphy->bands[NL80211_BAND_2GHZ];
+       if (band && idx >= band->n_channels) {
+               idx -= band->n_channels;
+               band = NULL;
+       }
+
+       if (!band || idx >= band->n_channels) {
+               /* Move to 5G band */
+               band = wiphy->bands[NL80211_BAND_5GHZ];
+               if (idx >= band->n_channels) {
+                       return -ENOENT;
+               }
+       }
+
+       chan = &band->channels[idx];
+       /*
+        * Avoid unnecessary time spent on getting obss on channels
+        * which are not used by hostapd in current mode.
+        */
+       for (cache_idx = 0; cache_idx < g_hostap_chan_count; cache_idx++) {
+               if (g_hostap_chan_cache[cache_idx] == chan->center_freq)
+                       break;
+       }
+       if (cache_idx == g_hostap_chan_count)
+       {
+               WL_DBG(("%s channel %d is ignored & dummy value is passed \n",
+                       __func__, ieee80211_frequency_to_channel(chan->center_freq)));
+               info->channel = chan;
+               info->noise = 0;
+               info->channel_time = 0;
+               info->channel_time_busy = 0;
+               info->channel_time_rx = 0;
+               info->channel_time_tx = 0;
+               info->filled = SURVEY_INFO_NOISE_DBM |SURVEY_INFO_CHANNEL_TIME |
+                       SURVEY_INFO_CHANNEL_TIME_BUSY | SURVEY_INFO_CHANNEL_TIME_RX |
+                       SURVEY_INFO_CHANNEL_TIME_TX;
+               return 0;
+       }
+
+       /* Setting current channel to the requested channel */
+       if ((err = wl_cfg80211_set_channel(wiphy, ndev, chan,
+               NL80211_CHAN_HT20) < 0)) {
+               WL_ERR(("Set channel failed \n"));
+       }
+
+       if (!idx) {
+               /* Disable mpc */
+               val = 0;
+               err = wldev_iovar_setbuf_bsscfg(ndev, "mpc", (void *)&val,
+                       sizeof(val), cfg->ioctl_buf, WLC_IOCTL_SMLEN, 0,
+                       &cfg->ioctl_buf_sync);
+               if (err < 0) {
+                       WL_ERR(("set 'mpc' failed, error = %d\n", err));
+               }
+
+               /* Set interface up, explicitly. */
+               val = 1;
+               err = wldev_ioctl(ndev, WLC_UP, (void *)&val, sizeof(val), true);
+               if (err < 0) {
+                       WL_ERR(("set interface up failed, error = %d\n", err));
+               }
+       }
+
+       /* Get noise value */
+       retry = IOCTL_RETRY_COUNT;
+       while (retry--) {
+               err = wldev_ioctl(ndev, WLC_GET_PHY_NOISE, &noise,
+                       sizeof(noise), false);
+               if (err >=  0) {
+                       break;
+               }
+               WL_DBG(("attempt = %d, err = %d, \n",
+                       (IOCTL_RETRY_COUNT - retry), err));
+       }
+
+       if (retry <= 0) {
+               WL_ERR(("Get Phy Noise failed, error = %d\n", err));
+               noise = CHAN_NOISE_DUMMY;
+       }
+
+       survey = (struct wl_dump_survey *) kzalloc(sizeof(struct wl_dump_survey),
+               GFP_KERNEL);
+       if (unlikely(!survey)) {
+               WL_ERR(("%s: alloc failed\n", __func__));
+               return -ENOMEM;
+       }
+
+       /* Start Measurement for obss stats on current channel */
+       req.msrmnt_query = 0;
+       req.time_req = ACS_MSRMNT_DELAY;
+       if ((err = wl_dump_obss(ndev, req, survey)) < 0) {
+               goto exit;
+       }
+
+       /*
+        * Wait for the meaurement to complete, adding a buffer value of 10 to take
+        * into consideration any delay in IOVAR completion
+        */
+       msleep(ACS_MSRMNT_DELAY + 10);
+
+       /* Issue IOVAR to collect measurement results */
+       req.msrmnt_query = 1;
+       if ((err = wl_dump_obss(ndev, req, survey)) < 0) {
+               goto exit;
+       }
+
+       info->channel = chan;
+       info->noise = noise;
+       info->channel_time = ACS_MSRMNT_DELAY;
+       info->channel_time_busy = ACS_MSRMNT_DELAY - survey->idle;
+       info->channel_time_rx = survey->obss + survey->ibss + survey->no_ctg +
+               survey->no_pckt;
+       info->channel_time_tx = survey->tx;
+       info->filled = SURVEY_INFO_NOISE_DBM |SURVEY_INFO_CHANNEL_TIME |
+               SURVEY_INFO_CHANNEL_TIME_BUSY | SURVEY_INFO_CHANNEL_TIME_RX |
+               SURVEY_INFO_CHANNEL_TIME_TX;
+       kfree(survey);
+
+       return 0;
+exit:
+       kfree(survey);
+       return err;
+}
+#endif /* WL_SUPPORT_ACS */
+
+static struct cfg80211_ops wl_cfg80211_ops = {
+       .add_virtual_intf = wl_cfg80211_add_virtual_iface,
+       .del_virtual_intf = wl_cfg80211_del_virtual_iface,
+       .change_virtual_intf = wl_cfg80211_change_virtual_iface,
+#if defined(WL_CFG80211_P2P_DEV_IF)
+       .start_p2p_device = wl_cfgp2p_start_p2p_device,
+       .stop_p2p_device = wl_cfgp2p_stop_p2p_device,
+#endif /* WL_CFG80211_P2P_DEV_IF */
+       .scan = wl_cfg80211_scan,
+       .set_wiphy_params = wl_cfg80211_set_wiphy_params,
+       .join_ibss = wl_cfg80211_join_ibss,
+       .leave_ibss = wl_cfg80211_leave_ibss,
+       .get_station = wl_cfg80211_get_station,
+       .set_tx_power = wl_cfg80211_set_tx_power,
+       .get_tx_power = wl_cfg80211_get_tx_power,
+       .add_key = wl_cfg80211_add_key,
+       .del_key = wl_cfg80211_del_key,
+       .get_key = wl_cfg80211_get_key,
+       .set_default_key = wl_cfg80211_config_default_key,
+       .set_default_mgmt_key = wl_cfg80211_config_default_mgmt_key,
+       .set_power_mgmt = wl_cfg80211_set_power_mgmt,
+       .connect = wl_cfg80211_connect,
+       .disconnect = wl_cfg80211_disconnect,
+       .suspend = wl_cfg80211_suspend,
+       .resume = wl_cfg80211_resume,
+       .set_pmksa = wl_cfg80211_set_pmksa,
+       .del_pmksa = wl_cfg80211_del_pmksa,
+       .flush_pmksa = wl_cfg80211_flush_pmksa,
+       .remain_on_channel = wl_cfg80211_remain_on_channel,
+       .cancel_remain_on_channel = wl_cfg80211_cancel_remain_on_channel,
+       .mgmt_tx = wl_cfg80211_mgmt_tx,
+       .mgmt_frame_register = wl_cfg80211_mgmt_frame_register,
+       .change_bss = wl_cfg80211_change_bss,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
+       .set_channel = wl_cfg80211_set_channel,
+#endif 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0))
+       .set_beacon = wl_cfg80211_add_set_beacon,
+       .add_beacon = wl_cfg80211_add_set_beacon,
+#else
+       .change_beacon = wl_cfg80211_change_beacon,
        .start_ap = wl_cfg80211_start_ap,
        .stop_ap = wl_cfg80211_stop_ap,
 #endif 
@@ -7121,6 +7418,9 @@ static struct cfg80211_ops wl_cfg80211_ops = {
        .tdls_mgmt = wl_cfg80211_tdls_mgmt,
        .tdls_oper = wl_cfg80211_tdls_oper,
 #endif 
+#ifdef WL_SUPPORT_ACS
+       .dump_survey = wl_cfg80211_dump_survey,
+#endif /* WL_SUPPORT_ACS */
 #ifdef WL_CFG80211_ACL
        .set_mac_acl = wl_cfg80211_set_mac_acl,
 #endif /* WL_CFG80211_ACL */
@@ -7189,22 +7489,25 @@ wl_cfg80211_reg_notifier(
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
 static const struct wiphy_wowlan_support brcm_wowlan_support = {
        .flags = WIPHY_WOWLAN_ANY,
+       .n_patterns = WL_WOWLAN_MAX_PATTERNS,
+       .pattern_min_len = WL_WOWLAN_MIN_PATTERN_LEN,
+       .pattern_max_len = WL_WOWLAN_MAX_PATTERN_LEN,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+       .max_pkt_offset = WL_WOWLAN_MAX_PATTERN_LEN,
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */
 };
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) */
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
-static struct cfg80211_wowlan brcm_wowlan_config = {
-       .disconnect = true,
-       .gtk_rekey_failure = true,
-       .eap_identity_req = true,
-       .four_way_handshake = true,
-};
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) */
 #endif /* CONFIG_PM */
 
 static s32 wl_setup_wiphy(struct wireless_dev *wdev, struct device *sdiofunc_dev, void *context)
 {
        s32 err = 0;
+#ifdef CONFIG_PM
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+       struct cfg80211_wowlan *brcm_wowlan_config = NULL;
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) */
+#endif /* CONFIG_PM */
+
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
        dhd_pub_t *dhd = (dhd_pub_t *)context;
        BCM_REFERENCE(dhd);
@@ -7338,9 +7641,28 @@ static s32 wl_setup_wiphy(struct wireless_dev *wdev, struct device *sdiofunc_dev
        /* If this is not provided cfg stack will get disconnect
        * during suspend.
        */
-       wdev->wiphy->wowlan_config = &brcm_wowlan_config;
+       brcm_wowlan_config = kmalloc(sizeof(struct cfg80211_wowlan), GFP_KERNEL);
+       if (brcm_wowlan_config) {
+               brcm_wowlan_config->disconnect = true;
+               brcm_wowlan_config->gtk_rekey_failure = true;
+               brcm_wowlan_config->eap_identity_req = true;
+               brcm_wowlan_config->four_way_handshake = true;
+               brcm_wowlan_config->patterns = NULL;
+               brcm_wowlan_config->n_patterns = 0;
+               brcm_wowlan_config->tcp = NULL;
+       } else {
+               WL_ERR(("Can not allocate memory for brcm_wowlan_config,"
+                       " So wiphy->wowlan_config is set to NULL\n"));
+       }
+       wdev->wiphy->wowlan_config = brcm_wowlan_config;
 #else
        wdev->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
+       wdev->wiphy->wowlan.n_patterns = WL_WOWLAN_MAX_PATTERNS;
+       wdev->wiphy->wowlan.pattern_min_len = WL_WOWLAN_MIN_PATTERN_LEN;
+       wdev->wiphy->wowlan.pattern_max_len = WL_WOWLAN_MAX_PATTERN_LEN;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+       wdev->wiphy->wowlan.max_pkt_offset = WL_WOWLAN_MAX_PATTERN_LEN;
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0) */
 #endif /* CONFIG_PM && WL_CFG80211_P2P_DEV_IF */
 
@@ -7379,25 +7701,25 @@ static s32 wl_setup_wiphy(struct wireless_dev *wdev, struct device *sdiofunc_dev
 static void wl_free_wdev(struct bcm_cfg80211 *cfg)
 {
        struct wireless_dev *wdev = cfg->wdev;
-       struct wiphy *wiphy;
+       struct wiphy *wiphy = NULL;
        if (!wdev) {
                WL_ERR(("wdev is invalid\n"));
                return;
        }
-       wiphy = wdev->wiphy;
-
-       wdev->wiphy->wowlan = NULL;
-       wdev->wiphy->wowlan_config = NULL;
-
+       if (wdev->wiphy) {
+               wiphy = wdev->wiphy;
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 13, 0)) || defined(WL_VENDOR_EXT_SUPPORT)
-       wl_cfgvendor_detach(wdev->wiphy);
+               wl_cfgvendor_detach(wdev->wiphy);
+               wdev->wiphy->wowlan = NULL;
 #endif /* if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 13, 0)) || defined(WL_VENDOR_EXT_SUPPORT) */
-
-       wiphy_unregister(wdev->wiphy);
-       wdev->wiphy->dev.parent = NULL;
+               wiphy_unregister(wdev->wiphy);
+               wdev->wiphy->dev.parent = NULL;
+               wdev->wiphy = NULL;
+       }
 
        wl_delete_all_netinfo(cfg);
-       wiphy_free(wiphy);
+       if (wiphy)
+               wiphy_free(wiphy);
        /* PLEASE do NOT call any function after wiphy_free, the driver's private structure "cfg",
         * which is the private part of wiphy, has been freed in wiphy_free !!!!!!!!!!!
         */
@@ -7719,32 +8041,40 @@ wl_notify_connect_status_ap(struct bcm_cfg80211 *cfg, struct net_device *ndev,
                goto exit;
        isfree = true;
 
-       if (event == WLC_E_ASSOC_IND && reason == DOT11_SC_SUCCESS) {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
-                cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
-               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len);
+       if ((event == WLC_E_ASSOC_IND && reason == DOT11_SC_SUCCESS) ||
+        (event == WLC_E_DISASSOC_IND) ||
+       ((event == WLC_E_DEAUTH_IND) || (event == WLC_E_DEAUTH))) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0, GFP_ATOMIC);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) || \
+               defined(WL_COMPAT_WIRELESS)
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, GFP_ATOMIC);
 #else
-               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len);
-#endif /* KERNEL VERSION 3, 12 */ 
+               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len, GFP_ATOMIC);
+#endif 
        } else if (event == WLC_E_DISASSOC_IND) {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
-                cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0, GFP_ATOMIC);
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
-               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len);
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, GFP_ATOMIC);
 #else
-               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len);
-#endif /* version 3.12*/ 
+               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len, GFP_ATOMIC);
+#endif 
        } else if ((event == WLC_E_DEAUTH_IND) || (event == WLC_E_DEAUTH)) {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
-                cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, 0, GFP_ATOMIC);
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
-               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len);
+               cfg80211_rx_mgmt(ndev, freq, 0, mgmt_frame, len, GFP_ATOMIC);
 #else
-               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len);
-#endif /* version 3.12 */
+               cfg80211_rx_mgmt(ndev, freq, mgmt_frame, len, GFP_ATOMIC);
+#endif 
        }
-
 exit:
        if (isfree)
                kfree(mgmt_frame);
@@ -7754,6 +8084,9 @@ exit:
        sinfo.filled = 0;
        if (((event == WLC_E_ASSOC_IND) || (event == WLC_E_REASSOC_IND)) &&
                reason == DOT11_SC_SUCCESS) {
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0))
+               sinfo.filled = STA_INFO_BIT(INFO_ASSOC_REQ_IES);
+#endif /*  (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
                if (!data) {
                        WL_ERR(("No IEs present in ASSOC/REASSOC_IND"));
                        return -EINVAL;
@@ -7873,6 +8206,10 @@ wl_notify_connect_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        struct net_device *ndev = NULL;
        s32 err = 0;
        u32 event = ntoh32(e->event_type);
+       struct wiphy *wiphy = NULL;
+       struct cfg80211_bss *bss = NULL;
+       struct wlc_ssid *ssid = NULL;
+       u8 *bssid = 0;
 
        ndev = cfgdev_to_wlc_ndev(cfgdev, cfg);
 
@@ -7904,6 +8241,18 @@ wl_notify_connect_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                } else if (wl_is_linkdown(cfg, e)) {
                        if (cfg->scan_request)
                                wl_notify_escan_complete(cfg, ndev, true, true);
+                       /* Explicitly calling unlink to remove BSS in CFG */
+                       wiphy = bcmcfg_to_wiphy(cfg);
+                       ssid = (struct wlc_ssid *)wl_read_prof(cfg, ndev, WL_PROF_SSID);
+                       bssid = (u8 *)wl_read_prof(cfg, ndev, WL_PROF_BSSID);
+                       if (ssid && bssid) {
+                               bss = cfg80211_get_bss(wiphy, NULL, bssid,
+                                               ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS,
+                                               WLAN_CAPABILITY_ESS);
+                               if (bss) {
+                                       cfg80211_unlink_bss(wiphy, bss);
+                               }
+                       }
                        if (wl_get_drv_status(cfg, CONNECTED, ndev)) {
                                scb_val_t scbval;
                                u8 *curbssid = wl_read_prof(cfg, ndev, WL_PROF_BSSID);
@@ -7925,11 +8274,8 @@ wl_notify_connect_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                                        return 0;
                                }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
-                               cfg80211_disconnected(ndev, reason, NULL, 0, false, GFP_KERNEL);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) */
-
                                wl_clr_drv_status(cfg, CONNECTED, ndev);
+
                                if (! wl_get_drv_status(cfg, DISCONNECTING, ndev)) {
                                        /* To make sure disconnect, explictly send dissassoc
                                        *  for BSSID 00:00:00:00:00:00 issue
@@ -7947,6 +8293,7 @@ wl_notify_connect_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                                        cfg80211_disconnected(ndev, reason, NULL, 0, false, GFP_KERNEL);
                                        wl_link_down(cfg);
                                        wl_init_prof(cfg, ndev);
+                                       memset(&cfg->last_roamed_addr, 0, ETHER_ADDR_LEN);
                                }
                        }
                        else if (wl_get_drv_status(cfg, CONNECTING, ndev)) {
@@ -7983,6 +8330,7 @@ wl_notify_connect_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        return err;
 }
 
+#ifdef WL_RELMCAST
 void wl_cfg80211_set_rmc_pid(int pid)
 {
        struct bcm_cfg80211 *cfg = g_bcm_cfg;
@@ -7990,8 +8338,10 @@ void wl_cfg80211_set_rmc_pid(int pid)
                cfg->rmc_event_pid = pid;
        WL_DBG(("set pid for rmc event : pid=%d\n", pid));
 }
+#endif /* WL_RELMCAST */
 
 
+#ifdef WL_RELMCAST
 static s32
 wl_notify_rmc_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        const wl_event_msg_t *e, void *data)
@@ -8015,6 +8365,7 @@ wl_notify_rmc_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        WL_DBG(("rmcevent : evt=%d, pid=%d, ret=%d\n", evt, cfg->rmc_event_pid, ret));
        return ret;
 }
+#endif /* WL_RELMCAST */
 
 static s32
 wl_notify_roaming_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
@@ -8038,10 +8389,17 @@ wl_notify_roaming_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                return err;
 
        if ((event == WLC_E_ROAM || event == WLC_E_BSSID) && status == WLC_E_STATUS_SUCCESS) {
-               if (wl_get_drv_status(cfg, CONNECTED, ndev))
+               if (wl_get_drv_status(cfg, CONNECTED, ndev)) {
+                       if (cfg->roam_offload &&
+                               memcmp(&cfg->last_roamed_addr, &e->addr, ETHER_ADDR_LEN) == 0) {
+                               WL_INFO(("BSSID already updated\n"));
+                               return err;
+                       }
                        wl_bss_roaming_done(cfg, ndev, e, data);
-               else
+                       memcpy(&cfg->last_roamed_addr, (void *)&e->addr, ETHER_ADDR_LEN);
+               } else {
                        wl_bss_connect_done(cfg, ndev, e, data, true);
+               }
                act = true;
                wl_update_prof(cfg, ndev, e, &act, WL_PROF_ACT);
                wl_update_prof(cfg, ndev, NULL, (void *)&e->addr, WL_PROF_BSSID);
@@ -8806,17 +9164,19 @@ wl_notify_rx_mgmt_frame(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        WL_DBG((" device name is ndev %s \n", ndev->name));
 #endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
        retval = cfg80211_rx_mgmt(cfgdev, freq, 0,  mgmt_frame, mgmt_frame_len, 0);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+       retval = cfg80211_rx_mgmt(cfgdev, freq, 0,  mgmt_frame, mgmt_frame_len, 0, GFP_ATOMIC);
 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) || \
        defined(WL_COMPAT_WIRELESS)
-       retval = cfg80211_rx_mgmt(cfgdev, freq, 0, mgmt_frame, mgmt_frame_len);
+       retval = cfg80211_rx_mgmt(cfgdev, freq, 0, mgmt_frame, mgmt_frame_len, GFP_ATOMIC);
 #else
-       retval = cfg80211_rx_mgmt(cfgdev, freq, mgmt_frame, mgmt_frame_len);
-#endif /* LINUX_VERSION >= VERSION(3, 12, 0) */
+       retval = cfg80211_rx_mgmt(cfgdev, freq, mgmt_frame, mgmt_frame_len, GFP_ATOMIC);
+#endif /* LINUX_VERSION >= VERSION(3, 18, 0) */
 
        WL_DBG(("mgmt_frame_len (%d) , e->datalen (%d), channel (%d), freq (%d) retval (%d)\n",
-               mgmt_frame_len, ntoh32(e->datalen), channel, freq, retval));
+       mgmt_frame_len, ntoh32(e->datalen), channel, freq, retval));
 exit:
        if (isfree)
                kfree(mgmt_frame);
@@ -9000,26 +9360,40 @@ static void wl_init_event_handler(struct bcm_cfg80211 *cfg)
        cfg->evt_handler[WLC_E_TDLS_PEER_EVENT] = wl_tdls_event_handler;
 #endif /* WLTDLS */
        cfg->evt_handler[WLC_E_BSSID] = wl_notify_roaming_status;
+#ifdef WL_RELMCAST
        cfg->evt_handler[WLC_E_RMC_EVENT] = wl_notify_rmc_status;
+#endif /* WL_RELMCAST */
 #ifdef WL_NAN
        cfg->evt_handler[WLC_E_NAN] = wl_cfgnan_notify_nan_status;
        cfg->evt_handler[WLC_E_PROXD] = wl_cfgnan_notify_proxd_status;
 #endif /* WL_NAN */
+
+       cfg->evt_handler[WLC_E_CSA_COMPLETE_IND] = wl_csa_complete_ind;
 }
 
 #if defined(STATIC_WL_PRIV_STRUCT)
-static void
+static int
 wl_init_escan_result_buf(struct bcm_cfg80211 *cfg)
 {
-       cfg->escan_info.escan_buf = DHD_OS_PREALLOC(cfg->pub, DHD_PREALLOC_WIPHY_ESCAN0, 0);
+       cfg->escan_info.escan_buf = DHD_OS_PREALLOC(cfg->pub,
+               DHD_PREALLOC_WIPHY_ESCAN0, ESCAN_BUF_SIZE);
+       if (cfg->escan_info.escan_buf == NULL) {
+               WL_ERR(("Failed to alloc ESCAN_BUF\n"));
+               return -ENOMEM;
+       }
        bzero(cfg->escan_info.escan_buf, ESCAN_BUF_SIZE);
+
+       return 0;
 }
 
 static void
 wl_deinit_escan_result_buf(struct bcm_cfg80211 *cfg)
 {
-       cfg->escan_info.escan_buf = NULL;
-
+       if (cfg->escan_info.escan_buf != NULL) {
+               DHD_OS_PREFREE(cfg->pub, DHD_PREALLOC_WIPHY_ESCAN0,
+                       cfg->escan_info.escan_buf, ESCAN_BUF_SIZE);
+               cfg->escan_info.escan_buf = NULL;
+       }
 }
 #endif /* STATIC_WL_PRIV_STRUCT */
 
@@ -9079,7 +9453,10 @@ static s32 wl_init_priv_mem(struct bcm_cfg80211 *cfg)
                WL_ERR(("cfg->ie  alloc failed\n"));
                goto init_priv_mem_out;
        }
-       wl_init_escan_result_buf(cfg);
+       if (unlikely(wl_init_escan_result_buf(cfg))) {
+               WL_ERR(("Failed to init escan result buf\n"));
+               goto init_priv_mem_out;
+       }
 #endif /* STATIC_WL_PRIV_STRUCT */
        cfg->afx_hdl = (void *)kzalloc(sizeof(*cfg->afx_hdl), GFP_KERNEL);
        if (unlikely(!cfg->afx_hdl)) {
@@ -9165,6 +9542,15 @@ static void wl_destroy_event_handler(struct bcm_cfg80211 *cfg)
                PROC_STOP(&cfg->event_tsk);
 }
 
+void wl_terminate_event_handler(void)
+{
+       struct bcm_cfg80211 *cfg = g_bcm_cfg;
+
+       if (cfg) {
+               wl_destroy_event_handler(cfg);
+       }
+}
+
 static void wl_scan_timeout(unsigned long data)
 {
        wl_event_msg_t msg;
@@ -9185,10 +9571,14 @@ static void wl_scan_timeout(unsigned long data)
 static s32
 wl_cfg80211_netdev_notifier_call(struct notifier_block * nb,
        unsigned long state,
-       void *ndev)
+       void *ptr)
 {
-       struct net_device *dev = ndev;
-       struct wireless_dev *wdev = dev->ieee80211_ptr;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0))
+       struct net_device *dev = ptr;
+#else
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+#endif /* LINUX_VERSION < VERSION(3, 11, 0) */
+       struct wireless_dev *wdev = ndev_to_wdev(dev);
        struct bcm_cfg80211 *cfg = g_bcm_cfg;
 
        WL_DBG(("Enter \n"));
@@ -9235,7 +9625,7 @@ wl_cfg80211_netdev_notifier_call(struct notifier_block * nb,
 
                case NETDEV_UNREGISTER:
                        /* after calling list_del_rcu(&wdev->list) */
-                       wl_dealloc_netinfo(cfg, ndev);
+                       wl_dealloc_netinfo(cfg, dev);
                        break;
                case NETDEV_GOING_DOWN:
                        /* At NETDEV_DOWN state, wdev_cleanup_work work will be called.
@@ -9355,6 +9745,64 @@ static s32 wl_notify_escan_complete(struct bcm_cfg80211 *cfg,
        return err;
 }
 
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+static void
+wl_cfg80211_find_removal_candidate(wl_bss_info_t *bss, removal_element_t *candidate)
+{
+       int idx;
+       for (idx = 0; idx < BUF_OVERFLOW_MGMT_COUNT; idx++) {
+               int len = BUF_OVERFLOW_MGMT_COUNT - idx - 1;
+               if (bss->RSSI < candidate[idx].RSSI) {
+                       if (len)
+                               memcpy(&candidate[idx + 1], &candidate[idx],
+                                       sizeof(removal_element_t) * len);
+                       candidate[idx].RSSI = bss->RSSI;
+                       candidate[idx].length = bss->length;
+                       memcpy(&candidate[idx].BSSID, &bss->BSSID, ETHER_ADDR_LEN);
+                       return;
+               }
+       }
+}
+
+static void
+wl_cfg80211_remove_lowRSSI_info(wl_scan_results_t *list, removal_element_t *candidate,
+       wl_bss_info_t *bi)
+{
+       int idx1, idx2;
+       int total_delete_len = 0;
+       for (idx1 = 0; idx1 < BUF_OVERFLOW_MGMT_COUNT; idx1++) {
+               int cur_len = WL_SCAN_RESULTS_FIXED_SIZE;
+               wl_bss_info_t *bss = NULL;
+               if (candidate[idx1].RSSI >= bi->RSSI)
+                       continue;
+               for (idx2 = 0; idx2 < list->count; idx2++) {
+                       bss = bss ? (wl_bss_info_t *)((uintptr)bss + dtoh32(bss->length)) :
+                               list->bss_info;
+                       if (!bcmp(&candidate[idx1].BSSID, &bss->BSSID, ETHER_ADDR_LEN) &&
+                               candidate[idx1].RSSI == bss->RSSI &&
+                               candidate[idx1].length == dtoh32(bss->length)) {
+                               u32 delete_len = dtoh32(bss->length);
+                               WL_DBG(("delete scan info of " MACDBG " to add new AP\n",
+                                       MAC2STRDBG(bss->BSSID.octet)));
+                               if (idx2 < list->count -1) {
+                                       memmove((u8 *)bss, (u8 *)bss + delete_len,
+                                               list->buflen - cur_len - delete_len);
+                               }
+                               list->buflen -= delete_len;
+                               list->count--;
+                               total_delete_len += delete_len;
+                               /* if delete_len is greater than or equal to result length */
+                               if (total_delete_len >= bi->length) {
+                                       return;
+                               }
+                               break;
+                       }
+                       cur_len += dtoh32(bss->length);
+               }
+       }
+}
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
+
 static s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        const wl_event_msg_t *e, void *data)
 {
@@ -9446,6 +9894,13 @@ static s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
 
                } else {
                        int cur_len = WL_SCAN_RESULTS_FIXED_SIZE;
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+                       removal_element_t candidate[BUF_OVERFLOW_MGMT_COUNT];
+                       int remove_lower_rssi = FALSE;
+
+                       bzero(candidate, sizeof(removal_element_t)*BUF_OVERFLOW_MGMT_COUNT);
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
+
                        list = wl_escan_get_buf(cfg, FALSE);
                        if (scan_req_match(cfg)) {
                                /* p2p scan && allow only probe response */
@@ -9459,9 +9914,22 @@ static s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                                                goto exit;
                                }
                        }
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+                       if (bi_length > ESCAN_BUF_SIZE - list->buflen)
+                               remove_lower_rssi = TRUE;
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
+
                        for (i = 0; i < list->count; i++) {
                                bss = bss ? (wl_bss_info_t *)((uintptr)bss + dtoh32(bss->length))
                                        : list->bss_info;
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+                               WL_TRACE(("%s("MACDBG"), i=%d bss: RSSI %d list->count %d\n",
+                                       bss->SSID, MAC2STRDBG(bss->BSSID.octet),
+                                       i, bss->RSSI, list->count));
+
+                               if (remove_lower_rssi)
+                                       wl_cfg80211_find_removal_candidate(bss, candidate);
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
 
                                if (!bcmp(&bi->BSSID, &bss->BSSID, ETHER_ADDR_LEN) &&
                                        (CHSPEC_BAND(wl_chspec_driver_to_host(bi->chanspec))
@@ -9540,8 +10008,17 @@ static s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                                cur_len += dtoh32(bss->length);
                        }
                        if (bi_length > ESCAN_BUF_SIZE - list->buflen) {
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+                               wl_cfg80211_remove_lowRSSI_info(list, candidate, bi);
+                               if (bi_length > ESCAN_BUF_SIZE - list->buflen) {
+                                       WL_DBG(("RSSI(" MACDBG ") is too low(%d) to add Buffer\n",
+                                               MAC2STRDBG(bi->BSSID.octet), bi->RSSI));
+                                       goto exit;
+                               }
+#else
                                WL_ERR(("Buffer is too small: ignoring\n"));
                                goto exit;
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
                        }
 
                        memcpy(&(((char *)list)[list->buflen]), bi, bi_length);
@@ -9549,6 +10026,15 @@ static s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                        list->buflen += bi_length;
                        list->count++;
 
+                       /*
+                        * !Broadcast && number of ssid = 1 && number of channels =1
+                        * means specific scan to association
+                        */
+                       if (wl_cfgp2p_is_p2p_specific_scan(cfg->scan_request)) {
+                               WL_ERR(("P2P assoc scan fast aborted.\n"));
+                               wl_notify_escan_complete(cfg, cfg->escan_info.ndev, false, true);
+                               goto exit;
+                       }
                }
 
        }
@@ -10252,8 +10738,10 @@ static s32 wl_event_handler(void *data)
 
        while (down_interruptible (&tsk->sema) == 0) {
                SMP_RD_BARRIER_DEPENDS();
-               if (tsk->terminated)
+               if (tsk->terminated) {
+                       DHD_OS_WAKE_UNLOCK(cfg->pub);
                        break;
+               }
                while ((e = wl_deq_event(cfg))) {
                        WL_DBG(("event type (%d), if idx: %d\n", e->etype, e->emsg.ifidx));
                        /* All P2P device address related events comes on primary interface since
@@ -10755,6 +11243,17 @@ s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify)
        s32 err = 0;
        s32 index = 0;
        s32 nmode = 0;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+       u32 j = 0;
+       s32 vhtmode = 0;
+       s32 txstreams = 0;
+       s32 rxstreams = 0;
+       s32 ldpc_cap = 0;
+       s32 stbc_rx = 0;
+       s32 stbc_tx = 0;
+       s32 txbf_bfe_cap = 0;
+       s32 txbf_bfr_cap = 0;
+#endif 
        bool rollback_lock = false;
        s32 bw_cap = 0;
        s32 cur_band = -1;
@@ -10784,8 +11283,58 @@ s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify)
        err = wldev_iovar_getint(dev, "nmode", &nmode);
        if (unlikely(err)) {
                WL_ERR(("error reading nmode (%d)\n", err));
-       } else {
-               /* For nmodeonly  check bw cap */
+       }
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+       err = wldev_iovar_getint(dev, "vhtmode", &vhtmode);
+       if (unlikely(err)) {
+               WL_ERR(("error reading vhtmode (%d)\n", err));
+       }
+
+       if (vhtmode) {
+               err = wldev_iovar_getint(dev, "txstreams", &txstreams);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading txstreams (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "rxstreams", &rxstreams);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading rxstreams (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "ldpc_cap", &ldpc_cap);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading ldpc_cap (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "stbc_rx", &stbc_rx);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading stbc_rx (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "stbc_tx", &stbc_tx);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading stbc_tx (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "txbf_bfe_cap", &txbf_bfe_cap);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading txbf_bfe_cap (%d)\n", err));
+               }
+
+               err = wldev_iovar_getint(dev, "txbf_bfr_cap", &txbf_bfr_cap);
+               if (unlikely(err)) {
+                       WL_ERR(("error reading txbf_bfr_cap (%d)\n", err));
+               }
+       }
+#endif 
+
+       /* For nmode and vhtmode   check bw cap */
+       if (nmode ||
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+               vhtmode ||
+#endif 
+               0) {
                err = wldev_iovar_getint(dev, "mimo_bw_cap", &bw_cap);
                if (unlikely(err)) {
                        WL_ERR(("error get mimo_bw_cap (%d)\n", err));
@@ -10808,8 +11357,94 @@ s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify)
                        bands[NL80211_BAND_5GHZ] =
                                &__wl_band_5ghz_a;
                        index = NL80211_BAND_5GHZ;
-                       if (bw_cap == WLC_N_BW_40ALL || bw_cap == WLC_N_BW_20IN2G_40IN5G)
+                       if (nmode && (bw_cap == WLC_N_BW_40ALL || bw_cap == WLC_N_BW_20IN2G_40IN5G))
                                bands[index]->ht_cap.cap |= IEEE80211_HT_CAP_SGI_40;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+                       /* VHT capabilities. */
+                       if (vhtmode) {
+                               /* Supported */
+                               bands[index]->vht_cap.vht_supported = TRUE;
+
+                               for (j = 1; j <= VHT_CAP_MCS_MAP_NSS_MAX; j++) {
+                                       /* TX stream rates. */
+                                       if (j <= txstreams) {
+                                               VHT_MCS_MAP_SET_MCS_PER_SS(j, VHT_CAP_MCS_MAP_0_9,
+                                                       bands[index]->vht_cap.vht_mcs.tx_mcs_map);
+                                       } else {
+                                               VHT_MCS_MAP_SET_MCS_PER_SS(j, VHT_CAP_MCS_MAP_NONE,
+                                                       bands[index]->vht_cap.vht_mcs.tx_mcs_map);
+                                       }
+
+                                       /* RX stream rates. */
+                                       if (j <= rxstreams) {
+                                               VHT_MCS_MAP_SET_MCS_PER_SS(j, VHT_CAP_MCS_MAP_0_9,
+                                                       bands[index]->vht_cap.vht_mcs.rx_mcs_map);
+                                       } else {
+                                               VHT_MCS_MAP_SET_MCS_PER_SS(j, VHT_CAP_MCS_MAP_NONE,
+                                                       bands[index]->vht_cap.vht_mcs.rx_mcs_map);
+                                       }
+                               }
+
+
+                               /* Capabilities */
+                               /* 80 MHz is mandatory */
+                               bands[index]->vht_cap.cap |=
+                                       IEEE80211_VHT_CAP_SHORT_GI_80;
+
+                               if (WL_BW_CAP_160MHZ(bw_cap)) {
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_SHORT_GI_160;
+                               }
+
+                               bands[index]->vht_cap.cap |=
+                                       IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
+
+                               if (ldpc_cap)
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_RXLDPC;
+
+                               if (stbc_tx)
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_TXSTBC;
+
+                               if (stbc_rx)
+                                       bands[index]->vht_cap.cap |=
+                                               (stbc_rx << VHT_CAP_INFO_RX_STBC_SHIFT);
+
+                               if (txbf_bfe_cap)
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
+
+                               if (txbf_bfr_cap) {
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
+                               }
+
+                               if (txbf_bfe_cap || txbf_bfr_cap) {
+                                       bands[index]->vht_cap.cap |=
+                                               (2 << VHT_CAP_INFO_NUM_BMFMR_ANT_SHIFT);
+                                       bands[index]->vht_cap.cap |=
+                                               ((txstreams - 1) <<
+                                                       VHT_CAP_INFO_NUM_SOUNDING_DIM_SHIFT);
+                                       bands[index]->vht_cap.cap |=
+                                               IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB;
+                               }
+
+                               /* AMPDU length limit, support max 1MB (2 ^ (13 + 7)) */
+                               bands[index]->vht_cap.cap |=
+                                       (7 << VHT_CAP_INFO_AMPDU_MAXLEN_EXP_SHIFT);
+                               WL_INFO(("%s band[%d] vht_enab=%d vht_cap=%08x "
+                                       "vht_rx_mcs_map=%04x vht_tx_mcs_map=%04x\n",
+                                       __FUNCTION__, index,
+                                       bands[index]->vht_cap.vht_supported,
+                                       bands[index]->vht_cap.cap,
+                                       bands[index]->vht_cap.vht_mcs.rx_mcs_map,
+                                       bands[index]->vht_cap.vht_mcs.tx_mcs_map));
+                       }
+#endif 
                }
                else if (bandlist[i] == WLC_BAND_2G && __wl_band_2ghz.n_channels > 0) {
                        bands[NL80211_BAND_2GHZ] =
@@ -10841,8 +11476,22 @@ s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify)
                wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
        }
 
-       if (notify)
+       if (notify) {
+               struct ieee80211_supported_band *sband;
+               enum nl80211_band wiphy_band;
+               struct ieee80211_channel *chan;
+               for (wiphy_band = 0; wiphy_band < NUM_NL80211_BANDS;
+               wiphy_band++) {
+                       sband = wiphy->bands[wiphy_band];
+                       if (!sband)
+                               continue;
+                       for (i = 0; i < sband->n_channels; i++) {
+                               chan = &sband->channels[i];
+                               chan->beacon_found = false;
+                       }
+               }
                wiphy_apply_custom_regulatory(wiphy, &brcm_regdom);
+       }
 
        end_bands:
                if (rollback_lock)
@@ -10879,6 +11528,19 @@ static s32 __wl_cfg80211_up(struct bcm_cfg80211 *cfg)
                }
        }
 
+       err = wl_create_event_handler(cfg);
+       if (err) {
+               WL_ERR(("wl_create_event_handler failed\n"));
+               return err;
+       }
+       wl_init_event_handler(cfg);
+
+       err = wl_init_scan(cfg);
+       if (err) {
+               WL_ERR(("wl_init_scan failed\n"));
+               return err;
+       }
+
        err = dhd_monitor_init(cfg->pub);
 
        INIT_DELAYED_WORK(&cfg->pm_enable_work, wl_cfg80211_work_handler);
@@ -10932,6 +11594,7 @@ static s32 __wl_cfg80211_down(struct bcm_cfg80211 *cfg)
                return err;     /* it is even not ready */
        }
 
+
        /* If primary BSS is operational (for e.g SoftAP), bring it down */
        if (!(wl_cfgp2p_find_idx(cfg, ndev, &bssidx)) &&
                wl_cfgp2p_bss_isup(ndev, bssidx)) {
@@ -10976,10 +11639,23 @@ static s32 __wl_cfg80211_down(struct bcm_cfg80211 *cfg)
                        dev_close(p2p_net);
 #endif 
        DNGL_FUNC(dhd_cfg80211_down, (cfg));
+
+       /* Avoid deadlock from wl_cfg80211_down */
+       mutex_unlock(&cfg->usr_sync);
+       wl_destroy_event_handler(cfg);
+       mutex_lock(&cfg->usr_sync);
        wl_flush_eq(cfg);
        wl_link_down(cfg);
-       if (cfg->p2p_supported)
+       if (cfg->p2p_supported) {
+               if (timer_pending(&cfg->p2p->listen_timer))
+                       del_timer_sync(&cfg->p2p->listen_timer);
                wl_cfgp2p_down(cfg);
+       }
+
+       if (timer_pending(&cfg->scan_timeout)) {
+               del_timer_sync(&cfg->scan_timeout);
+       }
+
        if (cfg->ap_info) {
                kfree(cfg->ap_info->wpa_ie);
                kfree(cfg->ap_info->rsn_ie);
@@ -11007,7 +11683,6 @@ s32 wl_cfg80211_up(void *para)
        s32 err = 0;
        int val = 1;
        dhd_pub_t *dhd;
-
        (void)para;
        WL_DBG(("In\n"));
        cfg = g_bcm_cfg;
@@ -11036,6 +11711,8 @@ s32 wl_cfg80211_up(void *para)
        err = __wl_cfg80211_up(cfg);
        if (unlikely(err))
                WL_ERR(("__wl_cfg80211_up failed\n"));
+
+
        mutex_unlock(&cfg->usr_sync);
        return err;
 }
@@ -11044,11 +11721,27 @@ s32 wl_cfg80211_up(void *para)
 int wl_cfg80211_hang(struct net_device *dev, u16 reason)
 {
        struct bcm_cfg80211 *cfg;
+#if defined(SOFTAP_SEND_HANGEVT)
+       /* specifc mac address used for hang event */
+       uint8 hang_mac[ETHER_ADDR_LEN] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11};
+       dhd_pub_t *dhd;
+#endif /* SOFTAP_SEND_HANGEVT */
+       if (!g_bcm_cfg) {
+               return BCME_ERROR;
+       }
        cfg = g_bcm_cfg;
 
        WL_ERR(("In : chip crash eventing\n"));
        wl_add_remove_pm_enable_work(cfg, FALSE, WL_HANDLER_DEL);
-       cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL);
+#if defined(SOFTAP_SEND_HANGEVT)
+       dhd = (dhd_pub_t *)(cfg->pub);
+       if (dhd->op_mode & DHD_FLAG_HOSTAP_MODE) {
+               cfg80211_del_sta(dev, hang_mac, GFP_ATOMIC);
+       } else
+#endif /* SOFTAP_SEND_HANGEVT */
+       {
+               cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL);
+       }
        if (cfg != NULL) {
                wl_link_down(cfg);
        }
@@ -11385,16 +12078,23 @@ wl_tdls_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
                break;
        case WLC_E_TDLS_PEER_CONNECTED :
                if (cfg->tdls_mgmt_frame) {
-                       #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
-                                cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq, 0,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0))
+                       cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq, 0,
                                        cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len, 0);
-                       #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) || defined(WL_COMPAT_WIRELESS)
-                               cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq, 0,
-                                       cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len);
-                       #else
-                               cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq,
-                                       cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len);
-                       #endif 
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0))
+                       cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq, 0,
+                                       cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len, 0,
+                                       GFP_ATOMIC);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) || \
+                       defined(WL_COMPAT_WIRELESS)
+                       cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq, 0,
+                                       cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len,
+                                       GFP_ATOMIC);
+#else
+                       cfg80211_rx_mgmt(cfgdev, cfg->tdls_mgmt_freq,
+                               cfg->tdls_mgmt_frame, cfg->tdls_mgmt_frame_len, GFP_ATOMIC);
+
+#endif 
                }
                msg = " TDLS PEER CONNECTED ";
                break;
@@ -11417,11 +12117,23 @@ wl_tdls_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
 #endif  /* WLTDLS */
 
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
+static s32
+wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
+        const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
+        u32 peer_capability, bool initiator, const u8 *data, size_t len)
+#else
 static s32
+#if defined(CONFIG_ARCH_MSM) && defined(TDLS_MGMT_VERSION2)
 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
-       const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
-       u32 peer_capability, bool initiator, const u8 *data,
+        u8 *peer, u8 action_code, u8 dialog_token, u16 status_code,
+        u32 peer_capability, const u8 *data, size_t len)
+#else
+wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
+       u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, const u8 *data,
        size_t len)
+#endif  /* CONFIG_ARCH_MSM && TDLS_MGMT_VERSION2 */
+#endif  /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) */
 {
        s32 ret = 0;
 #ifdef WLTDLS
@@ -11429,6 +12141,14 @@ wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
        tdls_wfd_ie_iovar_t info;
        memset(&info, 0, sizeof(tdls_wfd_ie_iovar_t));
        cfg = g_bcm_cfg;
+
+#if defined(CONFIG_ARCH_MSM) && defined(TDLS_MGMT_VERSION2)
+       /* Some customer platform back ported this feature from kernel 3.15 to kernel 3.10
+       * and that cuases build error
+       */
+       BCM_REFERENCE(peer_capability);
+#endif  /* CONFIG_ARCH_MSM && TDLS_MGMT_VERSION2 */
+
        switch (action_code) {
        /* We need to set TDLS Wifi Display IE to firmware
         * using tdls_wfd_ie iovar
@@ -11459,9 +12179,15 @@ out:
        return ret;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
 static s32
 wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
        const u8 *peer, enum nl80211_tdls_operation oper)
+#else
+static s32
+wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
+       u8 *peer, enum nl80211_tdls_operation oper)
+#endif
 {
        s32 ret = 0;
 #ifdef WLTDLS
@@ -11469,8 +12195,11 @@ wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
        tdls_iovar_t info;
        cfg = g_bcm_cfg;
        memset(&info, 0, sizeof(tdls_iovar_t));
-       if (peer)
+       if (peer) {
                memcpy(&info.ea, peer, ETHER_ADDR_LEN);
+       } else {
+               return -1;
+       }
        switch (oper) {
        case NL80211_TDLS_DISCOVERY_REQ:
                /* turn on TDLS */
@@ -12325,7 +13054,8 @@ static void wl_cfg80211_work_handler(struct work_struct * work)
                cfg->pm_enable_work_on = false;
                for_each_ndev(cfg, iter, next) {
                        if (!wl_get_drv_status(cfg, CONNECTED, iter->ndev) ||
-                               (wl_get_mode_by_netdev(cfg, iter->ndev) != WL_MODE_BSS))
+                               (wl_get_mode_by_netdev(cfg, iter->ndev) != WL_MODE_BSS &&
+                               wl_get_mode_by_netdev(cfg, iter->ndev) != WL_MODE_IBSS))
                                continue;
                        if (iter->ndev) {
                                if ((err = wldev_ioctl(iter->ndev, WLC_SET_PM,
@@ -12381,6 +13111,7 @@ wl_cfg80211_delayed_roam(struct bcm_cfg80211 *cfg, struct net_device *ndev,
        e.event_type = cpu_to_be32(WLC_E_ROAM);
        memcpy(&e.addr, bssid, ETHER_ADDR_LEN);
        /* trigger the roam event handler */
+       WL_INFO(("Delayed roam to " MACDBG "\n", MAC2STRDBG((u8*)(bssid))));
        err = wl_notify_roaming_status(cfg, ndev_to_cfgdev(ndev), &e, NULL);
 
        return err;
@@ -12443,6 +13174,158 @@ wl_cfg80211_set_mac_acl(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev,
        return ret;
 }
 #endif /* WL_CFG80211_ACL */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0))
+int wl_chspec_chandef(chanspec_t chanspec,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0))
+struct cfg80211_chan_def *chandef,
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, \
+       \
+       0)))
+struct chan_info *chaninfo,
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)) */
+struct wiphy *wiphy)
+{
+       uint16 freq = 0;
+       int chan_type;
+       int channel = 0;
+
+       if (!chandef) {
+               return -1;
+       }
+       channel = CHSPEC_CHANNEL(chanspec);
+
+       switch (CHSPEC_BW(chanspec)) {
+               case WL_CHANSPEC_BW_20:
+                       chan_type = NL80211_CHAN_HT20;
+                       break;
+               case WL_CHANSPEC_BW_40:
+               {
+                       if (CHSPEC_SB_UPPER(chanspec)) {
+                               channel += CH_10MHZ_APART;
+                       } else {
+                               channel -= CH_10MHZ_APART;
+                       }
+               }
+                       chan_type = NL80211_CHAN_HT40PLUS;
+                       break;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
+               case WL_CHANSPEC_BW_80:
+               case WL_CHANSPEC_BW_8080:
+               {
+                       uint16 sb = CHSPEC_CTL_SB(chanspec);
+
+                       if (sb == WL_CHANSPEC_CTL_SB_LL) {
+                               channel -= (CH_10MHZ_APART + CH_20MHZ_APART);
+                       } else if (sb == WL_CHANSPEC_CTL_SB_LU) {
+                               channel -= CH_10MHZ_APART;
+                       } else if (sb == WL_CHANSPEC_CTL_SB_UL) {
+                               channel += CH_10MHZ_APART;
+                       } else {
+                               /* WL_CHANSPEC_CTL_SB_UU */
+                               channel += (CH_10MHZ_APART + CH_20MHZ_APART);
+                       }
+               }
+
+                       chan_type = NL80211_CHAN_WIDTH_80P80;
+                       break;
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
+               default:
+                       chan_type = NL80211_CHAN_HT20;
+                       break;
+
+       }
+
+       if (CHSPEC_IS5G(chanspec))
+               freq = ieee80211_channel_to_frequency(channel, NL80211_BAND_5GHZ);
+       else
+               freq = ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
+       cfg80211_chandef_create(chandef, ieee80211_get_channel(wiphy, freq), chan_type);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, \
+       \
+       0)))
+       chaninfo->freq = freq;
+       chaninfo->chan_type = chan_type;
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
+       return 0;
+}
+
+void
+wl_cfg80211_ch_switch_notify(struct net_device *dev, uint16 chanspec, struct wiphy *wiphy)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
+       struct cfg80211_chan_def chandef;
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, \
+       \
+       0)))
+       struct chan_info chaninfo;
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
+
+       if (!wiphy) {
+               printk("wiphy is null\n");
+               return;
+       }
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
+       if (wl_chspec_chandef(chanspec, &chandef, wiphy)) {
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, \
+       \
+       0)))
+       if (wl_chspec_chandef(chanspec, &chaninfo, wiphy)) {
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
+
+               WL_ERR(("%s:chspec_chandef failed\n", __FUNCTION__));
+               return;
+       }
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0))
+       cfg80211_ch_switch_notify(dev, &chandef);
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 5, 0) && (LINUX_VERSION_CODE <= (3, 7, \
+       \
+       0)))
+       cfg80211_ch_switch_notify(dev, chan_info.freq, chan_info.chan_type);
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION (3, 8, 0)) */
+       return;
+}
+
+static s32
+wl_csa_complete_ind(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
+const wl_event_msg_t *e, void *data)
+{
+       int error = 0;
+       int chsp = 0;
+       struct net_device *ndev = NULL;
+       struct wiphy *wiphy = NULL;
+       chanspec_t chanspec;
+
+       WL_ERR(("%s\n", __FUNCTION__));
+       if (e->status)
+               return -1;
+       if (cfgdev) {
+               ndev = cfgdev_to_wlc_ndev(cfgdev, cfg);
+               wiphy = bcmcfg_to_wiphy(cfg);
+               error = wldev_iovar_getint(ndev, "chanspec", &chsp);
+               if (error)
+                       return -1;
+               chanspec = wl_chspec_driver_to_host(chsp);
+               wl_cfg80211_ch_switch_notify(ndev, chanspec, wiphy);
+       } else {
+               WL_ERR(("%s:cfgdev is null\n", __FUNCTION__));
+               return -1;
+       }
+
+
+       return 0;
+}
+#else
+static s32
+wl_csa_complete_ind(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
+const wl_event_msg_t *e, void *data)
+{
+       WL_ERR(("%s:Not sup for kernel < 3.5\n", __FUNCTION__));
+       return 0;
+}
+#endif /* LINUX_VERSION_CODE >= (3, 5, 0) */
 
 #ifdef WL_NAN
 int
index 414008f..fcf8231 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_cfg80211.h 505040 2014-09-26 06:39:18Z $
+ * $Id: wl_cfg80211.h 575651 2015-07-30 13:49:47Z $
  */
 
 #ifndef _wl_cfg80211_h_
@@ -178,6 +178,14 @@ do {                                                                       \
 
 #define WL_PM_ENABLE_TIMEOUT 10000
 
+/* cfg80211 wowlan definitions */
+#define WL_WOWLAN_MAX_PATTERNS                 8
+#define WL_WOWLAN_MIN_PATTERN_LEN              1
+#define WL_WOWLAN_MAX_PATTERN_LEN              255
+#define WL_WOWLAN_PKT_FILTER_ID_FIRST  201
+#define WL_WOWLAN_PKT_FILTER_ID_LAST   (WL_WOWLAN_PKT_FILTER_ID_FIRST + \
+                                                                       WL_WOWLAN_MAX_PATTERNS - 1)
+
 
 /* driver status */
 enum wl_status {
@@ -393,7 +401,7 @@ struct wl_pmk_list {
 
 struct escan_info {
        u32 escan_state;
-#if defined(STATIC_WL_PRIV_STRUCT)
+#ifdef STATIC_WL_PRIV_STRUCT
 #ifndef CONFIG_DHD_USE_STATIC_BUF
 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
 #endif /* CONFIG_DHD_USE_STATIC_BUF */
@@ -405,6 +413,15 @@ struct escan_info {
        struct net_device *ndev;
 };
 
+#ifdef ESCAN_BUF_OVERFLOW_MGMT
+#define BUF_OVERFLOW_MGMT_COUNT 3
+typedef struct {
+       int RSSI;
+       int length;
+       struct ether_addr BSSID;
+} removal_element_t;
+#endif /* ESCAN_BUF_OVERFLOW_MGMT */
+
 struct ap_info {
 /* Structure to hold WPS, WPA IEs for a AP */
        u8   probe_res_ie[VNDR_IES_MAX_BUF_LEN];
@@ -580,8 +597,10 @@ struct bcm_cfg80211 {
        struct delayed_work pm_enable_work;
        vndr_ie_setbuf_t *ibss_vsie;    /* keep the VSIE for IBSS */
        int ibss_vsie_len;
+#ifdef WL_RELMCAST
        u32 rmc_event_pid;
        u32 rmc_event_seq;
+#endif /* WL_RELMCAST */
        bool roam_offload;
 #ifdef WLTDLS
        u8 *tdls_mgmt_frame;
@@ -589,6 +608,8 @@ struct bcm_cfg80211 {
        s32 tdls_mgmt_freq;
 #endif /* WLTDLS */
        bool nan_running;
+       bool need_wait_afrx;
+       struct ether_addr last_roamed_addr;
 };
 
 
@@ -821,6 +842,12 @@ wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
        true : false)
 #endif /* WL_CFG80211_P2P_DEV_IF */
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
+#define scan_req_iftype(req) (req->dev->ieee80211_ptr->iftype)
+#else
+#define scan_req_iftype(req) (req->wdev->iftype)
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) */
+
 #define wl_to_sr(w) (w->scan_req_int)
 #if defined(STATIC_WL_PRIV_STRUCT)
 #define wl_to_ie(w) (w->ie)
@@ -925,6 +952,7 @@ extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
        struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
+extern void wl_terminate_event_handler(void);
 #define SCAN_BUF_CNT   2
 #define SCAN_BUF_NEXT  1
 #define WL_SCANTYPE_LEGACY     0x1
@@ -939,13 +967,25 @@ extern void wl_cfg80211_update_power_mode(struct net_device *dev);
 
 extern void wl_cfg80211_ibss_vsie_set_buffer(vndr_ie_setbuf_t *ibss_vsie, int ibss_vsie_len);
 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
+#ifdef WL_RELMCAST
 extern void wl_cfg80211_set_rmc_pid(int pid);
-
+#endif /* WL_RELMCAST */
 
 /* Action frame specific functions */
 extern u8 wl_get_action_category(void *frame, u32 frame_len);
 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
 
+#ifdef WL_SUPPORT_ACS
+#define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
+#define IOCTL_RETRY_COUNT 5
+#define CHAN_NOISE_DUMMY -80
+#define OBSS_TOKEN_IDX 15
+#define IBSS_TOKEN_IDX 15
+#define TX_TOKEN_IDX 14
+#define CTG_TOKEN_IDX 13
+#define PKT_TOKEN_IDX 15
+#define IDLE_TOKEN_IDX 12
+#endif /* WL_SUPPORT_ACS */
 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, bool enable);
 #ifdef WL_NAN
 extern int wl_cfg80211_nan_cmd_handler(struct net_device *ndev, char *cmd,
@@ -958,4 +998,8 @@ struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *c
 
 extern int wl_cfg80211_get_ioctl_version(void);
 
-#endif                         /* _wl_cfg80211_h_ */
+#ifdef WL_CFG80211_P2P_DEV_IF
+extern void wl_cfg80211_del_p2p_wdev(void);
+#endif /* WL_CFG80211_P2P_DEV_IF */
+
+#endif /* _wl_cfg80211_h_ */
index 7dbf3bc..9d004cd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfg80211 driver - Dongle Host Driver (DHD) related
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
 #include <dhdioctl.h>
 #include <wlioctl.h>
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
+#define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
+#else
+#define strnicmp(str1, str2, len) strnicmp((str1), (str2), (len))
+#endif
+
 #ifdef PKT_FILTER_SUPPORT
 extern uint dhd_pkt_filter_enable;
 extern uint dhd_master_mode;
@@ -434,7 +440,7 @@ int wl_cfg80211_set_btcoex_dhcp(struct net_device *dev, dhd_pub_t *dhd, char *co
        /* Figure out powermode 1 or o command */
        strncpy((char *)&powermode_val, command + strlen("BTCOEXMODE") +1, 1);
 
-       if (strncasecmp((char *)&powermode_val, "1", strlen("1")) == 0) {
+       if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
                WL_TRACE_HW4(("DHCP session starts\n"));
 
 
@@ -485,7 +491,7 @@ int wl_cfg80211_set_btcoex_dhcp(struct net_device *dev, dhd_pub_t *dhd, char *co
                        WL_ERR(("was called w/o DHCP OFF. Continue\n"));
                }
        }
-       else if (strncasecmp((char *)&powermode_val, "2", strlen("2")) == 0) {
+       else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
 
 
 
index db9a2e3..153e49b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfgp2p driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_cfgp2p.c 513084 2014-11-05 12:31:06Z $
+ * $Id: wl_cfgp2p.c 584240 2015-09-04 14:17:53Z $
  *
  */
 #include <typedefs.h>
@@ -182,6 +182,29 @@ bool wl_cfgp2p_is_gas_action(void *frame, u32 frame_len)
        else
                return false;
 }
+
+bool wl_cfgp2p_is_p2p_gas_action(void *frame, u32 frame_len)
+{
+
+       wifi_p2psd_gas_pub_act_frame_t *sd_act_frm;
+
+       if (frame == NULL)
+               return false;
+
+       sd_act_frm = (wifi_p2psd_gas_pub_act_frame_t *)frame;
+       if (frame_len < (sizeof(wifi_p2psd_gas_pub_act_frame_t) - 1))
+               return false;
+       if (sd_act_frm->category != P2PSD_ACTION_CATEGORY)
+               return false;
+
+       if (sd_act_frm->action == P2PSD_ACTION_ID_GAS_IREQ)
+               return wl_cfgp2p_find_gas_subtype(P2PSD_GAS_OUI_SUBTYPE,
+                       (u8 *)sd_act_frm->query_data,
+                       frame_len);
+       else
+               return false;
+}
+
 void wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len, u32 channel)
 {
        wifi_p2p_pub_act_frame_t *pact_frm;
@@ -1545,7 +1568,7 @@ wl_cfgp2p_listen_complete(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
        s32 ret = BCME_OK;
        struct net_device *ndev = NULL;
 
-       if (!cfg || !cfg->p2p)
+       if (!cfg || !cfg->p2p || !cfgdev)
                return BCME_ERROR;
 
        CFGP2P_DBG((" Enter\n"));
@@ -1779,6 +1802,10 @@ wl_cfgp2p_action_tx_complete(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev
                        if (status == WLC_E_STATUS_SUCCESS) {
                                wl_set_p2p_status(cfg, ACTION_TX_COMPLETED);
                                CFGP2P_DBG(("WLC_E_ACTION_FRAME_COMPLETE : ACK\n"));
+                               if (!cfg->need_wait_afrx && cfg->af_sent_channel) {
+                                       CFGP2P_DBG(("no need to wait next AF.\n"));
+                                       wl_stop_wait_next_action_frame(cfg, ndev);
+                               }
                        }
                        else if (!wl_get_p2p_status(cfg, ACTION_TX_COMPLETED)) {
                                wl_set_p2p_status(cfg, ACTION_TX_NOACK);
@@ -2719,7 +2746,8 @@ wl_cfgp2p_add_p2p_disc_if(struct bcm_cfg80211 *cfg)
 
        if (cfg->p2p_wdev) {
                CFGP2P_ERR(("p2p_wdev defined already.\n"));
-               return ERR_PTR(-ENFILE);
+               wl_cfgp2p_del_p2p_disc_if(cfg->p2p_wdev, cfg);
+               CFGP2P_ERR(("p2p_wdev deleted.\n"));
        }
 
        wdev = kzalloc(sizeof(*wdev), GFP_KERNEL);
@@ -2834,6 +2862,8 @@ wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev, struct bcm_cfg80211 *cfg)
        if (rollback_lock)
                rtnl_unlock();
 
+       synchronize_rcu();
+
        kfree(wdev);
 
        if (cfg)
@@ -2845,3 +2875,41 @@ wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev, struct bcm_cfg80211 *cfg)
        return 0;
 }
 #endif /* WL_CFG80211_P2P_DEV_IF */
+
+void
+wl_cfgp2p_need_wait_actfrmae(struct bcm_cfg80211 *cfg, void *frame, u32 frame_len, bool tx)
+{
+       wifi_p2p_pub_act_frame_t *pact_frm;
+       int status = 0;
+
+       if (!frame || (frame_len < (sizeof(*pact_frm) + WL_P2P_AF_STATUS_OFFSET - 1))) {
+               return;
+       }
+
+       if (wl_cfgp2p_is_pub_action(frame, frame_len)) {
+               pact_frm = (wifi_p2p_pub_act_frame_t *)frame;
+               if (pact_frm->subtype == P2P_PAF_GON_RSP && tx) {
+                       CFGP2P_ACTION(("Check TX P2P Group Owner Negotiation Rsp Frame status\n"));
+                       status = pact_frm->elts[WL_P2P_AF_STATUS_OFFSET];
+                       if (status) {
+                               cfg->need_wait_afrx = false;
+                               return;
+                       }
+               }
+       }
+
+       cfg->need_wait_afrx = true;
+       return;
+}
+
+int
+wl_cfgp2p_is_p2p_specific_scan(struct cfg80211_scan_request *request)
+{
+       if (request && (request->n_ssids == 1) &&
+               (request->n_channels == 1) &&
+               IS_P2P_SSID(request->ssids[0].ssid, WL_P2P_WILDCARD_SSID_LEN) &&
+               (request->ssids[0].ssid_len > WL_P2P_WILDCARD_SSID_LEN)) {
+               return true;
+       }
+       return false;
+}
index f999ddc..6605e93 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux cfgp2p driver
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_cfgp2p.h 476678 2014-05-09 14:46:37Z $
+ * $Id: wl_cfgp2p.h 518957 2014-12-04 08:52:50Z $
  */
 #ifndef _wl_cfgp2p_h_
 #define _wl_cfgp2p_h_
@@ -228,6 +228,8 @@ extern bool
 wl_cfgp2p_is_gas_action(void *frame, u32 frame_len);
 extern bool
 wl_cfgp2p_find_gas_subtype(u8 subtype, u8* data, u32 len);
+extern bool
+wl_cfgp2p_is_p2p_gas_action(void *frame, u32 frame_len);
 extern void
 wl_cfgp2p_print_actframe(bool tx, void *frame, u32 frame_len, u32 channel);
 extern s32
@@ -371,6 +373,12 @@ extern int
 wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev, struct bcm_cfg80211 *cfg);
 #endif /* WL_CFG80211_P2P_DEV_IF */
 
+extern void
+wl_cfgp2p_need_wait_actfrmae(struct bcm_cfg80211 *cfg, void *frame, u32 frame_len, bool tx);
+
+extern int
+wl_cfgp2p_is_p2p_specific_scan(struct cfg80211_scan_request *request);
+
 /* WiFi Direct */
 #define SOCIAL_CHAN_1 1
 #define SOCIAL_CHAN_2 6
@@ -384,6 +392,7 @@ wl_cfgp2p_del_p2p_disc_if(struct wireless_dev *wdev, struct bcm_cfg80211 *cfg);
 #define WL_P2P_WILDCARD_SSID_LEN 7
 #define WL_P2P_INTERFACE_PREFIX "p2p"
 #define WL_P2P_TEMP_CHAN 11
+#define WL_P2P_AF_STATUS_OFFSET 9
 
 /* If the provision discovery is for JOIN operations,
  * or the device discoverablity frame is destined to GO
index c586e7f..2fab814 100644 (file)
@@ -89,7 +89,11 @@ int wl_cfgvendor_send_async_event(struct wiphy *wiphy,
        kflags = in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
 
        /* Alloc the SKB for vendor_event */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
        skb = cfg80211_vendor_event_alloc(wiphy, NULL, len, event_id, kflags);
+#else
+       skb = cfg80211_vendor_event_alloc(wiphy, len, event_id, kflags);
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
        if (!skb) {
                WL_ERR(("skb alloc failed"));
                return -ENOMEM;
index 67349a1..33395fc 100644 (file)
@@ -2,7 +2,7 @@
  * Minimal debug/trace/assert driver definitions for
  * Broadcom 802.11 Networking Adapter.
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index c78f279..e9792d5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux Wireless Extensions support
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -45,32 +45,6 @@ typedef const struct si_pub  si_t;
 #include <wl_dbg.h>
 #include <wl_iw.h>
 
-#ifdef BCMWAPI_WPI
-/* these items should evetually go into wireless.h of the linux system headfile dir */
-#ifndef IW_ENCODE_ALG_SM4
-#define IW_ENCODE_ALG_SM4 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_ENABLED
-#define IW_AUTH_WAPI_ENABLED 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_VERSION_1
-#define IW_AUTH_WAPI_VERSION_1 0x00000008
-#endif
-
-#ifndef IW_AUTH_CIPHER_SMS4
-#define IW_AUTH_CIPHER_SMS4    0x00000020
-#endif
-
-#ifndef IW_AUTH_KEY_MGMT_WAPI_PSK
-#define IW_AUTH_KEY_MGMT_WAPI_PSK 4
-#endif
-
-#ifndef IW_AUTH_KEY_MGMT_WAPI_CERT
-#define IW_AUTH_KEY_MGMT_WAPI_CERT 8
-#endif
-#endif /* BCMWAPI_WPI */
 
 /* Broadcom extensions to WEXT, linux upstream has obsoleted WEXT */
 #ifndef IW_AUTH_KEY_MGMT_FT_802_1X
@@ -1340,42 +1314,6 @@ ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
 }
 #endif /* WIRELESS_EXT > 17 */
 
-#ifdef BCMWAPI_WPI
-static inline int _wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data,
-       size_t len, int uppercase)
-{
-       size_t i;
-       char *pos = buf, *end = buf + buf_size;
-       int ret;
-       if (buf_size == 0)
-               return 0;
-       for (i = 0; i < len; i++) {
-               ret = snprintf(pos, end - pos, uppercase ? "%02X" : "%02x",
-                       data[i]);
-               if (ret < 0 || ret >= end - pos) {
-                       end[-1] = '\0';
-                       return pos - buf;
-               }
-               pos += ret;
-       }
-       end[-1] = '\0';
-       return pos - buf;
-}
-
-/**
- * wpa_snprintf_hex - Print data as a hex string into a buffer
- * @buf: Memory area to use as the output buffer
- * @buf_size: Maximum buffer size in bytes (should be at least 2 * len + 1)
- * @data: Data to be printed
- * @len: Length of data in bytes
- * Returns: Number of bytes written
- */
-static int
-wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len)
-{
-       return _wpa_snprintf_hex(buf, buf_size, data, len, 0);
-}
-#endif /* BCMWAPI_WPI */
 
 static int
 wl_iw_handle_scanresults_ies(char **event_p, char *end,
@@ -1384,10 +1322,6 @@ wl_iw_handle_scanresults_ies(char **event_p, char *end,
 #if WIRELESS_EXT > 17
        struct iw_event iwe;
        char *event;
-#ifdef BCMWAPI_WPI
-       char *buf;
-       int custom_event_len;
-#endif
 
        event = *event_p;
        if (bi->ie_length) {
@@ -1431,38 +1365,6 @@ wl_iw_handle_scanresults_ies(char **event_p, char *end,
                        }
                }
 
-#ifdef BCMWAPI_WPI
-               ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-               ptr_len = bi->ie_length;
-
-               while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WAPI_ID))) {
-                       WL_TRACE(("%s: found a WAPI IE...\n", __FUNCTION__));
-#ifdef WAPI_IE_USE_GENIE
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = ie->len + 2;
-                       event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
-#else /* using CUSTOM event */
-                       iwe.cmd = IWEVCUSTOM;
-                       custom_event_len = strlen("wapi_ie=") + 2*(ie->len + 2);
-                       iwe.u.data.length = custom_event_len;
-
-                       buf = kmalloc(custom_event_len+1, GFP_KERNEL);
-                       if (buf == NULL)
-                       {
-                               WL_ERROR(("malloc(%d) returned NULL...\n", custom_event_len));
-                               break;
-                       }
-
-                       memcpy(buf, "wapi_ie=", 8);
-                       wpa_snprintf_hex(buf + 8, 2+1, &(ie->id), 1);
-                       wpa_snprintf_hex(buf + 10, 2+1, &(ie->len), 1);
-                       wpa_snprintf_hex(buf + 12, 2*ie->len+1, ie->data, ie->len);
-                       event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, buf);
-                       kfree(buf);
-#endif /* WAPI_IE_USE_GENIE */
-                       break;
-               }
-#endif /* BCMWAPI_WPI */
        *event_p = event;
        }
 
@@ -2373,21 +2275,6 @@ wl_iw_set_wpaie(
        char *extra
 )
 {
-#if defined(BCMWAPI_WPI)
-       uchar buf[WLC_IOCTL_SMLEN] = {0};
-       uchar *p = buf;
-       int wapi_ie_size;
-
-       WL_TRACE(("%s: SIOCSIWGENIE\n", dev->name));
-
-       if (extra[0] == DOT11_MNG_WAPI_ID)
-       {
-               wapi_ie_size = iwp->length;
-               memcpy(p, extra, iwp->length);
-               dev_wlc_bufvar_set(dev, "wapiie", buf, wapi_ie_size);
-       }
-       else
-#endif
                dev_wlc_bufvar_set(dev, "wpaie", extra, iwp->length);
 
        return 0;
@@ -2530,14 +2417,6 @@ wl_iw_set_encodeext(
                        case IW_ENCODE_ALG_CCMP:
                                key.algo = CRYPTO_ALGO_AES_CCM;
                                break;
-#ifdef BCMWAPI_WPI
-                       case IW_ENCODE_ALG_SM4:
-                               key.algo = CRYPTO_ALGO_SMS4;
-                               if (iwe->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-                                       key.flags &= ~WL_PRIMARY_KEY;
-                               }
-                               break;
-#endif
                        default:
                                break;
                }
@@ -2687,10 +2566,6 @@ wl_iw_set_wpaauth(
                        val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED;
                else if (paramval & IW_AUTH_WPA_VERSION_WPA2)
                        val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
-#ifdef BCMWAPI_WPI
-               else if (paramval & IW_AUTH_WAPI_VERSION_1)
-                       val = WAPI_AUTH_UNSPECIFIED;
-#endif
                WL_TRACE(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
                if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
                        return error;
@@ -2718,11 +2593,6 @@ wl_iw_set_wpaauth(
                        val |= TKIP_ENABLED;
                if (cipher_combined & IW_AUTH_CIPHER_CCMP)
                        val |= AES_ENABLED;
-#ifdef BCMWAPI_WPI
-               val &= ~SMS4_ENABLED;
-               if (cipher_combined & IW_AUTH_CIPHER_SMS4)
-                       val |= SMS4_ENABLED;
-#endif
 
                if (iw->privacy_invoked && !val) {
                        WL_WSEC(("%s: %s: 'Privacy invoked' TRUE but clearing wsec, assuming "
@@ -2779,10 +2649,6 @@ wl_iw_set_wpaauth(
                        if (paramval & (IW_AUTH_KEY_MGMT_FT_802_1X | IW_AUTH_KEY_MGMT_FT_PSK))
                                val |= WPA2_AUTH_FT;
                }
-#ifdef BCMWAPI_WPI
-               if (paramval & (IW_AUTH_KEY_MGMT_WAPI_PSK | IW_AUTH_KEY_MGMT_WAPI_CERT))
-                       val = WAPI_AUTH_UNSPECIFIED;
-#endif
                WL_TRACE(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
                if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
                        return error;
@@ -2865,29 +2731,6 @@ wl_iw_set_wpaauth(
 
 #endif /* WIRELESS_EXT > 17 */
 
-#ifdef BCMWAPI_WPI
-
-       case IW_AUTH_WAPI_ENABLED:
-               if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
-                       return error;
-               if (paramval) {
-                       val |= SMS4_ENABLED;
-                       if ((error = dev_wlc_intvar_set(dev, "wsec", val))) {
-                               WL_ERROR(("%s: setting wsec to 0x%0x returned error %d\n",
-                                       __FUNCTION__, val, error));
-                               return error;
-                       }
-                       if ((error = dev_wlc_intvar_set(dev, "wpa_auth", WAPI_AUTH_UNSPECIFIED))) {
-                               WL_ERROR(("%s: setting wpa_auth(%d) returned %d\n",
-                                       __FUNCTION__, WAPI_AUTH_UNSPECIFIED,
-                                       error));
-                               return error;
-                       }
-               }
-
-               break;
-
-#endif /* BCMWAPI_WPI */
 
        default:
                break;
index d58bf2f..29a199c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux Wireless Extensions support
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index 210d171..198c115 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Broadcom Dongle Host Driver (DHD), Linux monitor network interface
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
index d2d3168..a37ecac 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Common function shared by Linux WEXT, cfg80211 and p2p drivers
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wldev_common.c 513448 2014-11-06 13:44:21Z $
+ * $Id: wldev_common.c 540901 2015-03-13 11:50:58Z $
  */
 
 #include <osl.h>
@@ -358,13 +358,22 @@ int wldev_get_mode(
        uint16 band = 0;
        uint16 bandwidth = 0;
        wl_bss_info_t *bss = NULL;
-       char* buf = kmalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL);
+       char* buf = NULL;
+
+       buf = kmalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL);
+
+       if (!buf) {
+               WLDEV_ERROR(("%s:NOMEM\n", __FUNCTION__));
+               return -ENOMEM;
+       }
 
        *(u32*) buf = htod32(WL_EXTRA_BUF_MAX);
        error = wldev_ioctl(dev, WLC_GET_BSS_INFO, (void*)buf, WL_EXTRA_BUF_MAX, false);
        if (error) {
                WLDEV_ERROR(("%s:failed:%d\n", __FUNCTION__, error));
-               return -1;
+               kfree(buf);
+               buf = NULL;
+               return error;
        }
        bss = (struct  wl_bss_info *)(buf + 4);
        chanspec = wl_chspec_driver_to_host(bss->chanspec);
@@ -391,10 +400,12 @@ int wldev_get_mode(
                                strcpy(cap, "a");
                } else {
                        WLDEV_ERROR(("%s:Mode get failed\n", __FUNCTION__));
-                       return -1;
+                       error = BCME_ERROR;
                }
 
        }
+       kfree(buf);
+       buf = NULL;
        return error;
 }
 #define MAX_NUM_OF_ASSOCLIST 64
index 15b54ea..25a29dc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Common function shared by Linux WEXT, cfg80211 and p2p drivers
  *
- * Copyright (C) 1999-2014, Broadcom Corporation
+ * Copyright (C) 1999-2015, Broadcom Corporation
  * 
  *      Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you