A library for Broadcom BCM4329 SDIO WLAN/BT combo devices.
So far, the following modules have been verified:
(1) Samsung SWL-B23
+
+ config BCM4319
+ depends on WLAN_80211 && MMC
+ select WIRELESS_EXT
+ select WEXT_PRIV
+ select IEEE80211
+ select FW_LOADER
+ bool "Broadcom BCM4319 WiFi SDIO"
+ ---help---
+ A library for Broadcom BCM4319 SDIO WLAN devices.
config MV8686
depends on WLAN_80211 && MMC
(3) USI WM-G-MR-09
(4) Murata SP-8HEP-P
-source "drivers/net/wireless/bcm4319/Kconfig"
source "drivers/net/wireless/rtl8192c/Kconfig"
endchoice
-#source "drivers/net/wireless/bcm4329/Kconfig"
-
endif
+++ /dev/null
-===========================================================================\r
-=== Version 1.05 @ 2011-03-26 ===\r
-===========================================================================\r
-\r
-1. ½â¾öÁËÉî¶È˯Ãß15·ÖÖÓºó»½ÐÑÒì³£µÄÎÊÌâ\r
-2. ¿ªÆôCombo-SCANÒÔÖ§³Öwpa_supplicant_6\r
-\r
-===========================================================================\r
-=== Version 1.04 @ 2011-03-21 ===\r
-===========================================================================\r
-\r
-1. ½â¾öÁ˲»ÄÜÕý³£Á¬½ÓAPµÄÎÊÌâ\r
-\r
-===========================================================================\r
-=== Version 1.03 @ 2011-01-24 ===\r
-===========================================================================\r
-\r
-1. Ìí¼Ó¶ÔRK29ƽ̨µÄÖ§³Ö¡£\r
-\r
-===========================================================================\r
-=== Version 1.02 @ 20101102 ===\r
-===========================================================================\r
-\r
-1. ÔÚɨÃèÁбíÖУ¬ÓÐһЩAP¼´Ê¹½Ï½ü£¬ÈÔÈ»»áËÑË÷²»µ½¡£\r
- =>½«tplinklai¸ÄΪͨµÀ13ºó£¬ÈÔÈ»ÕÒ²»µ½Ëü¡£\r
- =>·¢ÏÖµ±Ç°µÄ¹¤×÷ģʽÖУ¬Ö»Ö§³ÖɨÃ赽ͨµÀ11¡£\r
- =>dhd_preinit_ioctlsº¯ÊýÖÐÌí¼ÓÈçϺ¯Êý£º\r
- dhdcdc_query_ioctl(dhd, 0, WLC_GET_COUNTRY,\r
- dhd->country_code, sizeof(dhd->country_code));\r
- ·¢ÏÖÄ¿Ç°Ä£×éĬÈϵÄCOUNTRY CODEÊÇUS£¬¶øUSÖÐÊÇÖ»Ö§³Ö11¸öͨµÀµÄ¡£\r
- =>\r
-===========================================================================\r
-=== Version 1.01 @ 20101027 ===\r
-===========================================================================\r
-\r
-1. ¸ÄΪʹÓÃwifi_version.hÖеİ汾¶¨Òå¡£\r
-\r
-2. ͨ¹ýÔÚ°åÉÏnetperf -H 192.168.1.200 -t TCP_STREAM½øÐвâÊÔ£¬»á³öÏÖ£º\r
- [204] dhd_bus_txdata: out of bus->txq !!!\r
- [204] dhd_bus_txdata: out of bus->txq !!!\r
- [205] CMD: 53 <arg=21000020> FAIL raw_ints: 12034 masked ints: 4\r
- [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
- [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
- [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
- [207] CMD: 52 <arg=12003600> FAIL raw_ints: 11030 masked ints: 1000\r
- [207] CMD: 52 <arg=12003600> FAIL raw_ints: 11030 masked ints: 1000\r
-\r
- ÊÖ¶¯ÅäÖÃÃüÁ\r
- iwconfig wlan0 mode managed\r
- iwconfig wlan0 essid tplinklai\r
- ifconfig wlan0 192.168.1.21\r
- netperf -H 192.168.1.200 -t TCP_STREAM\r
- \r
- ÔÚSDIOÇý¶¯ÖУ¬´ò¿ªDATA BUSYµÄ¼ì²â£¬ÔòûÓгöÏÖÎÊÌâ¡£\r
+++ /dev/null
-config BCM4319
- bool "Broadcom 4319 wireless cards support"
- depends on WLAN_80211 && MMC
- select WIRELESS_EXT
- select IEEE80211
- select FW_LOADER
- ---help---
- This module adds support for wireless adapters based on
- Broadcom 4319 chipset.
-
- This driver uses the kernel's wireless extensions subsystem.
-
- If you choose to build a module, it'll be called dhd. Say M if
- unsure.
+++ /dev/null
-config BCM4319
- bool "Broadcom 4319 wireless cards support"
- depends on WLAN_80211 && MMC
- select WIRELESS_EXT
- select IEEE80211
- select FW_LOADER
- ---help---
- This module adds support for wireless adapters based on
- Broadcom 4319 chipset.
-
- This driver uses the kernel's wireless extensions subsystem.
-
- If you choose to build a module, it'll be called dhd. Say M if
- unsure.
-
-RKWLCFGDIR = ../wifi_power
-BROADCOM_SRC_DIR = drivers/net/wireless/bcm4319
-
-EXTRA_CFLAGS += -I$(src) -I$(src)/include -I$(src)/$(RKWLCFGDIR)/
-EXTRA_CFLAGS += -DLINUX -DSRCBASE=\"$(BROADCOM_SRC_DIR)\" -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD\
- -DBCMWPA2 -DBCMWAPI_WPI
-EXTRA_CFLAGS += -DUNRELEASEDCHIP -DOEM_ANDROID -DEMBEDDED_PLATFORM -DARP_OFFLOAD_SUPPORT -DPKT_FILTER_SUPPORT
-EXTRA_CFLAGS += -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS
-EXTRA_CFLAGS += -DSDIO_ISR_THREAD
-EXTRA_CFLAGS += -DBDC -DTOE -DDHD_BCMEVENTS -DDHD_SCHED -DCSCAN
-#EXTRA_CFLAGS += -DSHOW_EVENTS -DDHD_DEBUG -DSDTEST
-#EXTRA_CFLAGS += -DBCMSDH_MODULE
-#EXTRA_CFLAGS += -DCONFIG_WIFI_CONTROL_FUNC
-
-
-bcmsdio-objs := bcmsdh.o bcmsdh_linux.o bcmsdh_sdmmc.o \
- bcmsdh_sdmmc_linux.o
-
-dhd-objs := dhd_common.o dhd_linux.o dhd_linux_sched.o dhd_sdio.o \
- dhd_custom_gpio.o dhd_cdc.o
-
-shared-objs := aiutils.o bcmutils.o bcmwifi.o hndpmu.o \
- linux_osl.o sbutils.o siutils.o
-
-wl-objs := wl_iw.o
-
-bcm4319-objs := $(bcmsdio-objs) $(dhd-objs) $(shared-objs) $(wl-objs) $(RKWLCFGDIR)/wifi_power_ops.o
-
-obj-$(CONFIG_BCM4319) += bcm4319.o $(RKWLCFGDIR)/wifi_power.o
-
-default:
- $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules
-clean:
- rm -rvf *.o *.ko *.mod.c *.o.cmd *.tmp_versions *.mod.o *.cmd modules.order Module.symvers .tmp_versions rkpub
- find . -name '*.o' -exec rm -f {} \;
- find . -name '.*.cmd' -exec rm -f {} \;
-.PHONY: clean
-
-
-
-
+# bcm4319
+DHDCFLAGS = -DLINUX -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD -DBCMWPA2 \
+ -DUNRELEASEDCHIP -Dlinux -DDHD_SDALIGN=64 -DMAX_HDR_READ=64 \
+ -DDHD_FIRSTREAD=64 -DDHD_GPL -DDHD_SCHED -DBDC -DTOE -DDHD_BCMEVENTS \
+ -DSHOW_EVENTS -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS \
+ -Wall -Wstrict-prototypes -Werror -DCUSTOMER_HW2 \
+ -DDHD_USE_STATIC_BUF -DDHD_DEBUG_TRAP -DSOFTAP -DSDIO_ISR_THREAD \
+ -DEMBEDDED_PLATFORM -DARP_OFFLOAD_SUPPORT -DPKT_FILTER_SUPPORT \
+ -DGET_CUSTOM_MAC_ENABLE -DSET_RANDOM_MAC_SOFTAP -DCSCAN \
+ -DKEEP_ALIVE -DCONFIG_US_NON_DFS_CHANNELS_ONLY \
+ -Idrivers/net/wireless/bcm4319 -Idrivers/net/wireless/bcm4319/include
+
+#options defines dependent on platform board and applicantion requirements:
+#-DOOB_INTR_ONLY -DMMC_SDIO_ABORT -DHW_OOB
+
+DHDOFILES = dhd_linux.o linux_osl.o bcmutils.o dhd_common.o dhd_custom_gpio.o \
+ wl_iw.o siutils.o sbutils.o aiutils.o hndpmu.o bcmwifi.o dhd_sdio.o \
+ dhd_linux_sched.o dhd_cdc.o bcmsdh_sdmmc.o bcmsdh.o bcmsdh_linux.o \
+ bcmsdh_sdmmc_linux.o
+
+obj-$(CONFIG_BCM4319) += bcm4319.o
+bcm4319-objs += $(DHDOFILES)
+EXTRA_CFLAGS = $(DHDCFLAGS)
+EXTRA_LDFLAGS += --strip-debug
+++ /dev/null
-
-EXTRA_CFLAGS += -I$(src)
-
-rkcfg-y := \
- wifi_power.o \
-
-obj-$(CONFIG_BCM4319) += bcm4319.o rkcfg.o
-
-$(obj)/bcm4319.o: $(obj)/bcm4319.uu
- @echo "UUDE bcm4319.uu"
- @uudecode $(obj)/bcm4319.uu -o $(obj)/bcm4319.o
-
-
* 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: bcmpcispi.c,v 1.22.2.4.4.5 2008/07/09 21:23:30 Exp $
+ * $Id: bcmpcispi.c,v 1.22.2.4.4.5.6.1 2010/08/13 00:26:05 Exp $
*/
#include <typedefs.h>
spin_count = 0;
while ((SPIPCI_RREG(sd->osh, ®s->spih_stat) & SPIH_WFEMPTY) == 0) {
if (spin_count > SPI_SPIN_BOUND) {
- ASSERT(FALSE); /* Spin bound exceeded */
+ sd_err(("%s: SPIH_WFEMPTY spin bits out of bound %u times \n",
+ __FUNCTION__, spin_count));
+ ASSERT(FALSE);
}
spin_count++;
}
- spin_count = 0;
+
/* Wait for SPI Transfer state machine to return to IDLE state.
* The state bits are only implemented in Rev >= 5 FPGA. These
* bits are hardwired to 00 for Rev < 5, so this check doesn't cause
* any problems.
*/
+ spin_count = 0;
while ((SPIPCI_RREG(osh, ®s->spih_stat) & SPIH_STATE_MASK) != 0) {
if (spin_count > SPI_SPIN_BOUND) {
+ sd_err(("%s: SPIH_STATE_MASK spin bits out of bound %u times \n",
+ __FUNCTION__, spin_count));
ASSERT(FALSE);
}
spin_count++;
* 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_linux.c,v 1.42.10.10.2.12 2010/03/10 03:09:48 Exp $
+ * $Id: bcmsdh_linux.c,v 1.42.10.10.2.14.4.2 2010/09/15 00:30:11 Exp $
*/
/**
void *ch;
unsigned int oob_irq;
unsigned long oob_flags; /* OOB Host specifiction as edge and etc */
+ bool oob_irq_registered;
+#if defined(OOB_INTR_ONLY)
+ spinlock_t irq_lock;
+#endif
};
static bcmsdh_hc_t *sdhcinfo = NULL;
#endif /* BCMLXSDMMC */
#if defined(OOB_INTR_ONLY)
- irq_flags = IRQF_TRIGGER_FALLING;
+#ifdef HW_OOB
+ irq_flags = \
+ IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE;
+#else
+ irq_flags = IRQF_TRIGGER_FALLING;
+#endif /* HW_OOB */
irq = dhd_customer_oob_irq_map(&irq_flags);
if (irq < 0) {
SDLX_MSG(("%s: Host irq is not defined\n", __FUNCTION__));
sdhc->sdh = sdh;
sdhc->oob_irq = irq;
sdhc->oob_flags = irq_flags;
+ sdhc->oob_irq_registered = FALSE; /* to make sure.. */
+#if defined(OOB_INTR_ONLY)
+ spin_lock_init(&sdhc->irq_lock);
+#endif
/* chain SDIO Host Controller info together */
sdhc->next = sdhcinfo;
#endif
suspend: NULL,
resume: NULL,
- };
+};
extern uint sd_pci_slot; /* Force detection to a particular PCI */
- /* slot only . Allows for having multiple */
- /* WL devices at once in a PC */
- /* Only one instance of dhd will be */
- /* useable at a time */
- /* Upper word is bus number, */
- /* lower word is slot number */
- /* Default value of 0xFFFFffff turns this */
- /* off */
+ /* slot only . Allows for having multiple */
+ /* WL devices at once in a PC */
+ /* Only one instance of dhd will be */
+ /* usable at a time */
+ /* Upper word is bus number, */
+ /* lower word is slot number */
+ /* Default value of 0xFFFFffff turns this */
+ /* off */
module_param(sd_pci_slot, uint, 0);
if (pdev->bus->number != (sd_pci_slot>>16) ||
PCI_SLOT(pdev->devfn) != (sd_pci_slot&0xffff)) {
SDLX_MSG(("%s: %s: bus %X, slot %X, vend %X, dev %X\n",
- __FUNCTION__,
- bcmsdh_chipmatch(pdev->vendor, pdev->device)
- ?"Found compatible SDIOHC"
- :"Probing unknown device",
- pdev->bus->number, PCI_SLOT(pdev->devfn), pdev->vendor,
- pdev->device));
+ __FUNCTION__,
+ bcmsdh_chipmatch(pdev->vendor, pdev->device) ?
+ "Found compatible SDIOHC" :
+ "Probing unknown device",
+ pdev->bus->number, PCI_SLOT(pdev->devfn),
+ pdev->vendor, pdev->device));
return -ENODEV;
}
SDLX_MSG(("%s: %s: bus %X, slot %X, vendor %X, device %X (good PCI location)\n",
- __FUNCTION__,
- bcmsdh_chipmatch(pdev->vendor, pdev->device)
- ?"Using compatible SDIOHC"
- :"WARNING, forced use of unkown device",
- pdev->bus->number, PCI_SLOT(pdev->devfn), pdev->vendor, pdev->device));
+ __FUNCTION__,
+ bcmsdh_chipmatch(pdev->vendor, pdev->device) ?
+ "Using compatible SDIOHC" :
+ "WARNING, forced use of unkown device",
+ pdev->bus->number, PCI_SLOT(pdev->devfn),
+ pdev->vendor, pdev->device));
}
if ((pdev->vendor == VENDOR_TI) && ((pdev->device == PCIXX21_FLASHMEDIA_ID) ||
pci_set_master(pdev);
rc = pci_enable_device(pdev);
if (rc) {
- SDLX_MSG(("%s: Cannot enble PCI device\n", __FUNCTION__));
+ SDLX_MSG(("%s: Cannot enable PCI device\n", __FUNCTION__));
goto err;
}
if (!(sdh = bcmsdh_attach(osh, (void *)(uintptr)pci_resource_start(pdev, 0),
drvinfo = *driver;
+#if defined(BCMPLATFORM_BUS)
+#if defined(BCMLXSDMMC)
SDLX_MSG(("Linux Kernel SDIO/MMC Driver\n"));
error = sdio_function_init();
+#else
+ SDLX_MSG(("Intel PXA270 SDIO Driver\n"));
+ error = driver_register(&bcmsdh_driver);
+#endif /* defined(BCMLXSDMMC) */
+ return error;
+#endif /* defined(BCMPLATFORM_BUS) */
+
+#if !defined(BCMPLATFORM_BUS) && !defined(BCMLXSDMMC)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
+ if (!(error = pci_module_init(&bcmsdh_pci_driver)))
+ return 0;
+#else
+ if (!(error = pci_register_driver(&bcmsdh_pci_driver)))
+ return 0;
+#endif
+
+ SDLX_MSG(("%s: pci_module_init failed 0x%x\n", __FUNCTION__, error));
+#endif /* BCMPLATFORM_BUS */
return error;
}
}
#if defined(OOB_INTR_ONLY)
+void bcmsdh_oob_intr_set(bool enable)
+{
+ static bool curstate = 1;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sdhcinfo->irq_lock, flags);
+ if (curstate != enable) {
+ if (enable)
+ enable_irq(sdhcinfo->oob_irq);
+ else
+ disable_irq_nosync(sdhcinfo->oob_irq);
+ curstate = enable;
+ }
+ spin_unlock_irqrestore(&sdhcinfo->irq_lock, flags);
+}
+
static irqreturn_t wlan_oob_irq(int irq, void *dev_id)
{
dhd_pub_t *dhdp;
dhdp = (dhd_pub_t *)dev_get_drvdata(sdhcinfo->dev);
+ bcmsdh_oob_intr_set(0);
+
if (dhdp == NULL) {
- disable_irq(sdhcinfo->oob_irq);
SDLX_MSG(("Out of band GPIO interrupt fired way too early\n"));
return IRQ_HANDLED;
}
- WAKE_LOCK_TIMEOUT(dhdp, WAKE_LOCK_TMOUT, 25);
-
dhdsdio_isr((void *)dhdp->bus);
return IRQ_HANDLED;
SDLX_MSG(("%s Enter\n", __FUNCTION__));
- dev_set_drvdata(sdhcinfo->dev, dhdp);
-
+/* Example of HW_OOB for HW2: please refer to your host specifiction */
+/* sdhcinfo->oob_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE; */
- /* Refer to customer Host IRQ docs about proper irqflags definition */
- error = request_irq(sdhcinfo->oob_irq, wlan_oob_irq, sdhcinfo->oob_flags,
- "bcmsdh_sdmmc", NULL);
+ dev_set_drvdata(sdhcinfo->dev, dhdp);
- if (error)
- return -ENODEV;
+ if (!sdhcinfo->oob_irq_registered) {
+ SDLX_MSG(("%s IRQ=%d Type=%X \n", __FUNCTION__, \
+ (int)sdhcinfo->oob_irq, (int)sdhcinfo->oob_flags));
+ /* Refer to customer Host IRQ docs about proper irqflags definition */
+ error = request_irq(sdhcinfo->oob_irq, wlan_oob_irq, sdhcinfo->oob_flags,
+ "bcmsdh_sdmmc", NULL);
+ if (error)
+ return -ENODEV;
- set_irq_wake(sdhcinfo->oob_irq, 1);
+ set_irq_wake(sdhcinfo->oob_irq, 1);
+ sdhcinfo->oob_irq_registered = TRUE;
+ }
return 0;
}
+void bcmsdh_set_irq(int flag)
+{
+ if (sdhcinfo->oob_irq_registered) {
+ SDLX_MSG(("%s Flag = %d", __FUNCTION__, flag));
+ if (flag) {
+ enable_irq(sdhcinfo->oob_irq);
+ enable_irq_wake(sdhcinfo->oob_irq);
+ } else {
+ disable_irq_wake(sdhcinfo->oob_irq);
+ disable_irq(sdhcinfo->oob_irq);
+ }
+ }
+}
+
void bcmsdh_unregister_oob_intr(void)
{
SDLX_MSG(("%s: Enter\n", __FUNCTION__));
set_irq_wake(sdhcinfo->oob_irq, 0);
disable_irq(sdhcinfo->oob_irq); /* just in case.. */
free_irq(sdhcinfo->oob_irq, NULL);
-}
-
-void bcmsdh_oob_intr_set(bool enable)
-{
- if (enable)
- enable_irq(sdhcinfo->oob_irq);
- else
- disable_irq(sdhcinfo->oob_irq);
+ sdhcinfo->oob_irq_registered = FALSE;
}
#endif /* defined(OOB_INTR_ONLY) */
/* Module parameters specific to each host-controller driver */
* 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,v 1.1.2.5.6.29 2010/03/19 17:16:08 Exp $
+ * $Id: bcmsdh_sdmmc.c,v 1.1.2.5.6.30.4.1 2010/09/02 23:12:21 Exp $
*/
#include <typedefs.h>
#if !defined(OOB_INTR_ONLY)
static void IRQHandler(struct sdio_func *func);
static void IRQHandlerF2(struct sdio_func *func);
-#endif
+#endif /* !defined(OOB_INTR_ONLY) */
static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, uint32 regaddr);
extern int sdio_reset_comm(struct mmc_card *card);
data = 3; /* enable hw oob interrupt */
else
data = 4; /* disable hw oob interrupt */
+ data |= 4; /* Active HIGH */
status = sdioh_request_byte(sd, SDIOH_WRITE, 0, 0xf2, &data);
return status;
return (Status);
}
+/* this function performs "abort" for both of host & device */
extern int
sdioh_abort(sdioh_info_t *sd, uint func)
{
+#if defined(MMC_SDIO_ABORT)
+ char t_func = (char) func;
+#endif /* defined(MMC_SDIO_ABORT) */
sd_trace(("%s: Enter\n", __FUNCTION__));
#if defined(MMC_SDIO_ABORT)
/* issue abort cmd52 command through F1 */
- sdioh_request_byte(sd, SD_IO_OP_WRITE, SDIO_FUNC_0, SDIOD_CCCR_IOABORT, (uint8 *)&func);
+ sdioh_request_byte(sd, SD_IO_OP_WRITE, SDIO_FUNC_0, SDIOD_CCCR_IOABORT, &t_func);
#endif /* defined(MMC_SDIO_ABORT) */
sd_trace(("%s: Exit\n", __FUNCTION__));
2.6.27. The implementation prior to that is buggy, and needs broadcom's
patch for it
*/
-// if ((ret = sdio_reset_comm(gInstance->func[0]->card)))
-// sd_err(("%s Failed, error = %d\n", __FUNCTION__, ret));
-// else {
+ if ((ret = sdio_reset_comm(gInstance->func[0]->card)))
+ sd_err(("%s Failed, error = %d\n", __FUNCTION__, ret));
+ else {
sd->num_funcs = 2;
sd->sd_blockmode = TRUE;
sd->use_client_ints = TRUE;
}
sdioh_sdmmc_card_enablefuncs(sd);
-// }
+ }
} else {
#if !defined(OOB_INTR_ONLY)
sdio_claim_host(gInstance->func[0]);
* 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,v 1.1.2.5.6.15 2010/04/14 21:11:46 Exp $
+ * $Id: bcmsdh_sdmmc_linux.c,v 1.1.2.5.6.17 2010/08/13 00:36:19 Exp $
*/
#include <typedefs.h>
#include <linux/mmc/core.h>
#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/sdio_ids.h>
#if !defined(SDIO_VENDOR_ID_BROADCOM)
#define SDIO_VENDOR_ID_BROADCOM 0x02d0
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
+#endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */
+
+#define SDIO_DEVICE_ID_BROADCOM_DEFAULT 0x0000
+
+#if !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)
+#define SDIO_DEVICE_ID_BROADCOM_4325_SDGWB 0x0492 /* BCM94325SDGWB */
+#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) */
#if !defined(SDIO_DEVICE_ID_BROADCOM_4325)
-#define SDIO_DEVICE_ID_BROADCOM_4325 0x0000
+#define SDIO_DEVICE_ID_BROADCOM_4325 0x0493
#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
#if !defined(SDIO_DEVICE_ID_BROADCOM_4329)
#define SDIO_DEVICE_ID_BROADCOM_4329 0x4329
#define SDIO_DEVICE_ID_BROADCOM_4319 0x4319
#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */
-
#include <bcmsdh_sdmmc.h>
#include <dhd_dbg.h>
-
-struct sdio_func *wifi_sdio_func = NULL;
-EXPORT_SYMBOL(wifi_sdio_func);
-
extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
ret = bcmsdh_probe(&sdmmc_dev);
}
- wifi_sdio_func = func;
- //printk("get wifi_sdio_func\n");
-
return ret;
}
-extern int wifi_func_removed;
static void bcmsdh_sdmmc_remove(struct sdio_func *func)
{
sd_trace(("bcmsdh_sdmmc: %s Enter\n", __FUNCTION__));
sd_info(("Function#: 0x%04x\n", func->num));
if (func->num == 2) {
- sd_trace(("F2 found, calling bcmsdh_probe...\n"));
+ sd_trace(("F2 found, calling bcmsdh_remove...\n"));
bcmsdh_remove(&sdmmc_dev);
}
- wifi_func_removed = 1;
-
- wifi_sdio_func = NULL;
}
/* devices we support, null terminated */
static const struct sdio_device_id bcmsdh_sdmmc_ids[] = {
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_DEFAULT) },
+ { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) },
{ SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325) },
{ SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329) },
{ SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4319) },
sdio_function_cleanup();
}
-//module_init(bcmsdh_module_init);
-//module_exit(bcmsdh_module_cleanup);
+module_init(bcmsdh_module_init);
+module_exit(bcmsdh_module_cleanup);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION(DESCRIPTION);
bzero(&sdmmc_dev, sizeof(sdmmc_dev));
error = sdio_register_driver(&bcmsdh_sdmmc_driver);
+
return error;
}
* 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: bcmsdstd.c,v 1.64.4.1.4.4.2.17 2010/03/10 03:09:48 Exp $
+ * $Id: bcmsdstd.c,v 1.64.4.1.4.4.2.18 2010/08/17 17:00:48 Exp $
*/
#include <typedefs.h>
void
sdstd_wreg16(sdioh_info_t *sd, uint reg, uint16 data)
{
- *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16) data;
+ *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
sd_ctrl(("16: W Reg 0x%02x, Data 0x%x\n", reg, data));
}
volatile uint16 data = *(volatile uint16 *)(sd->mem_space + reg);
sd_ctrl(("16: OR Reg 0x%02x, Val 0x%x\n", reg, val));
data |= val;
- *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16)data;
+ *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
}
static void
sd_ctrl(("16: MOD Reg 0x%02x, Mask 0x%x, Val 0x%x\n", reg, mask, val));
data &= ~mask;
data |= (val & mask);
- *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16)data;
+ *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
}
static inline void
sdstd_wreg(sdioh_info_t *sd, uint reg, uint32 data)
{
- *(volatile uint32 *)(sd->mem_space + reg) = (volatile uint32)data;
+ *(volatile uint32 *)(sd->mem_space + reg) = (uint32)data;
sd_ctrl(("32: W Reg 0x%02x, Data 0x%x\n", reg, data));
}
static inline void
sdstd_wreg8(sdioh_info_t *sd, uint reg, uint8 data)
{
- *(volatile uint8 *)(sd->mem_space + reg) = (volatile uint8)data;
+ *(volatile uint8 *)(sd->mem_space + reg) = (uint8)data;
sd_ctrl(("08: W Reg 0x%02x, Data 0x%x\n", reg, data));
}
static uint8
return SDIOH_API_RC_SUCCESS;
}
-/* Configure callback to client when we recieve client interrupt */
+/* Configure callback to client when we receive client interrupt */
extern SDIOH_API_RC
sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
{
data++;
}
- /* Handle < 4 bytes. wlc_pio.c currently (as of 12/20/05) truncates buflen
- * to be evenly divisable by 4. However dongle passes arbitrary lengths,
- * so handle it here
- */
bytes = blocksize % 4;
/* If no leftover bytes, go to next block */
}
/* Reset and re-initialize the device */
-int sdioh_sdio_reset(sdioh_info_t *si)
+int
+sdioh_sdio_reset(sdioh_info_t *si)
{
uint8 hreg;
* 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: bcmsdstd_linux.c,v 1.11.18.2 2008/05/28 18:36:56 Exp $
+ * $Id: bcmsdstd_linux.c,v 1.11.18.2.16.1 2010/08/17 17:03:13 Exp $
*/
#include <typedefs.h>
spin_lock_irqsave(&sdos->lock, flags);
if (sd->lockcount) {
- sd_err(("%s: Already locked!\n", __FUNCTION__));
+ sd_err(("%s: Already locked! called from %p\n",
+ __FUNCTION__,
+ __builtin_return_address(0)));
ASSERT(sd->lockcount == 0);
}
sdstd_devintr_off(sd);
--- /dev/null
+/*
+ * Broadcom BCMSDH to gSPI Protocol Conversion Layer
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: bcmspibrcm.c,v 1.11.2.10.2.9.6.11 2009/05/21 13:21:57 Exp $
+ */
+
+#define HSMODE
+
+#include <typedefs.h>
+
+#include <bcmdevs.h>
+#include <bcmendian.h>
+#include <bcmutils.h>
+#include <osl.h>
+#include <hndsoc.h>
+#include <siutils.h>
+#include <sbchipc.h>
+#include <sbsdio.h>
+#include <spid.h>
+
+#include <bcmsdbus.h> /* bcmsdh to/from specific controller APIs */
+#include <sdiovar.h> /* ioctl/iovars */
+#include <sdio.h>
+
+#include <pcicfg.h>
+
+
+#include <bcmspibrcm.h>
+#include <bcmspi.h>
+
+#define F0_RESPONSE_DELAY 16
+#define F1_RESPONSE_DELAY 16
+#define F2_RESPONSE_DELAY F0_RESPONSE_DELAY
+
+#define CMDLEN 4
+
+#define DWORDMODE_ON (sd->chip == BCM4329_CHIP_ID) && (sd->chiprev == 2) && (sd->dwordmode == TRUE)
+
+/* Globals */
+uint sd_msglevel = 0;
+
+uint sd_hiok = FALSE; /* Use hi-speed mode if available? */
+uint sd_sdmode = SDIOH_MODE_SPI; /* Use SD4 mode by default */
+uint sd_f2_blocksize = 64; /* Default blocksize */
+
+
+uint sd_divisor = 2;
+uint sd_power = 1; /* Default to SD Slot powered ON */
+uint sd_clock = 1; /* Default to SD Clock turned ON */
+uint sd_crc = 0; /* Default to SPI CRC Check turned OFF */
+
+uint8 spi_outbuf[SPI_MAX_PKT_LEN];
+uint8 spi_inbuf[SPI_MAX_PKT_LEN];
+
+/* 128bytes buffer is enough to clear data-not-available and program response-delay F0 bits
+ * assuming we will not exceed F0 response delay > 100 bytes at 48MHz.
+ */
+#define BUF2_PKT_LEN 128
+uint8 spi_outbuf2[BUF2_PKT_LEN];
+uint8 spi_inbuf2[BUF2_PKT_LEN];
+
+/* Prototypes */
+static bool bcmspi_test_card(sdioh_info_t *sd);
+static bool bcmspi_host_device_init_adapt(sdioh_info_t *sd);
+static int bcmspi_set_highspeed_mode(sdioh_info_t *sd, bool hsmode);
+static int bcmspi_cmd_issue(sdioh_info_t *sd, bool use_dma, uint32 cmd_arg,
+ uint32 *data, uint32 datalen);
+static int bcmspi_card_regread(sdioh_info_t *sd, int func, uint32 regaddr,
+ int regsize, uint32 *data);
+static int bcmspi_card_regwrite(sdioh_info_t *sd, int func, uint32 regaddr,
+ int regsize, uint32 data);
+static int bcmspi_card_bytewrite(sdioh_info_t *sd, int func, uint32 regaddr,
+ uint8 *data);
+static int bcmspi_driver_init(sdioh_info_t *sd);
+static int bcmspi_card_buf(sdioh_info_t *sd, int rw, int func, bool fifo,
+ uint32 addr, int nbytes, uint32 *data);
+static int bcmspi_card_regread_fixedaddr(sdioh_info_t *sd, int func, uint32 regaddr, int regsize,
+ uint32 *data);
+static void bcmspi_cmd_getdstatus(sdioh_info_t *sd, uint32 *dstatus_buffer);
+static int bcmspi_update_stats(sdioh_info_t *sd, uint32 cmd_arg);
+
+/*
+ * Public entry points & extern's
+ */
+extern sdioh_info_t *
+sdioh_attach(osl_t *osh, void *bar0, uint irq)
+{
+ sdioh_info_t *sd;
+
+ sd_trace(("%s\n", __FUNCTION__));
+ if ((sd = (sdioh_info_t *)MALLOC(osh, sizeof(sdioh_info_t))) == NULL) {
+ sd_err(("%s: out of memory, malloced %d bytes\n", __FUNCTION__, MALLOCED(osh)));
+ return NULL;
+ }
+ bzero((char *)sd, sizeof(sdioh_info_t));
+ sd->osh = osh;
+ if (spi_osinit(sd) != 0) {
+ sd_err(("%s: spi_osinit() failed\n", __FUNCTION__));
+ MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+ return NULL;
+ }
+
+ sd->bar0 = bar0;
+ sd->irq = irq;
+ sd->intr_handler = NULL;
+ sd->intr_handler_arg = NULL;
+ sd->intr_handler_valid = FALSE;
+
+ /* Set defaults */
+ sd->use_client_ints = TRUE;
+ sd->sd_use_dma = FALSE; /* DMA Not supported */
+
+ /* Spi device default is 16bit mode, change to 4 when device is changed to 32bit
+ * mode
+ */
+ sd->wordlen = 2;
+
+ if (!spi_hw_attach(sd)) {
+ sd_err(("%s: spi_hw_attach() failed\n", __FUNCTION__));
+ spi_osfree(sd);
+ MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+ return (NULL);
+ }
+
+ if (bcmspi_driver_init(sd) != SUCCESS) {
+ sd_err(("%s: bcmspi_driver_init() failed()\n", __FUNCTION__));
+ spi_hw_detach(sd);
+ spi_osfree(sd);
+ MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+ return (NULL);
+ }
+
+ if (spi_register_irq(sd, irq) != SUCCESS) {
+ sd_err(("%s: spi_register_irq() failed for irq = %d\n", __FUNCTION__, irq));
+ spi_hw_detach(sd);
+ spi_osfree(sd);
+ MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+ return (NULL);
+ }
+
+ sd_trace(("%s: Done\n", __FUNCTION__));
+
+ return sd;
+}
+
+extern SDIOH_API_RC
+sdioh_detach(osl_t *osh, sdioh_info_t *sd)
+{
+ sd_trace(("%s\n", __FUNCTION__));
+ if (sd) {
+ sd_err(("%s: detaching from hardware\n", __FUNCTION__));
+ spi_free_irq(sd->irq, sd);
+ spi_hw_detach(sd);
+ spi_osfree(sd);
+ MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+ }
+ return SDIOH_API_RC_SUCCESS;
+}
+
+/* Configure callback to client when we recieve client interrupt */
+extern SDIOH_API_RC
+sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
+{
+ sd_trace(("%s: Entering\n", __FUNCTION__));
+ sd->intr_handler = fn;
+ sd->intr_handler_arg = argh;
+ sd->intr_handler_valid = TRUE;
+ return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_interrupt_deregister(sdioh_info_t *sd)
+{
+ sd_trace(("%s: Entering\n", __FUNCTION__));
+ sd->intr_handler_valid = FALSE;
+ sd->intr_handler = NULL;
+ sd->intr_handler_arg = NULL;
+ return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_interrupt_query(sdioh_info_t *sd, bool *onoff)
+{
+ sd_trace(("%s: Entering\n", __FUNCTION__));
+ *onoff = sd->client_intr_enabled;
+ return SDIOH_API_RC_SUCCESS;
+}
+
+#if defined(DHD_DEBUG)
+extern bool
+sdioh_interrupt_pending(sdioh_info_t *sd)
+{
+ return 0;
+}
+#endif
+
+extern SDIOH_API_RC
+sdioh_query_device(sdioh_info_t *sd)
+{
+ /* Return a BRCM ID appropriate to the dongle class */
+ return (sd->num_funcs > 1) ? BCM4329_D11NDUAL_ID : BCM4318_D11G_ID;
+}
+
+/* Provide dstatus bits of spi-transaction for dhd layers. */
+extern uint32
+sdioh_get_dstatus(sdioh_info_t *sd)
+{
+ return sd->card_dstatus;
+}
+
+extern void
+sdioh_chipinfo(sdioh_info_t *sd, uint32 chip, uint32 chiprev)
+{
+ sd->chip = chip;
+ sd->chiprev = chiprev;
+}
+
+extern void
+sdioh_dwordmode(sdioh_info_t *sd, bool set)
+{
+ uint8 reg = 0;
+ int status;
+
+ if ((status = sdioh_request_byte(sd, SDIOH_READ, SPI_FUNC_0, SPID_STATUS_ENABLE, ®)) !=
+ SUCCESS) {
+ sd_err(("%s: Failed to set dwordmode in gSPI\n", __FUNCTION__));
+ return;
+ }
+
+ if (set) {
+ reg |= DWORD_PKT_LEN_EN;
+ sd->dwordmode = TRUE;
+ sd->client_block_size[SPI_FUNC_2] = 4096; /* h2spi's limit is 4KB, we support 8KB */
+ } else {
+ reg &= ~DWORD_PKT_LEN_EN;
+ sd->dwordmode = FALSE;
+ sd->client_block_size[SPI_FUNC_2] = 2048;
+ }
+
+ if ((status = sdioh_request_byte(sd, SDIOH_WRITE, SPI_FUNC_0, SPID_STATUS_ENABLE, ®)) !=
+ SUCCESS) {
+ sd_err(("%s: Failed to set dwordmode in gSPI\n", __FUNCTION__));
+ return;
+ }
+}
+
+
+uint
+sdioh_query_iofnum(sdioh_info_t *sd)
+{
+ return sd->num_funcs;
+}
+
+/* IOVar table */
+enum {
+ IOV_MSGLEVEL = 1,
+ IOV_BLOCKMODE,
+ IOV_BLOCKSIZE,
+ IOV_DMA,
+ IOV_USEINTS,
+ IOV_NUMINTS,
+ IOV_NUMLOCALINTS,
+ IOV_HOSTREG,
+ IOV_DEVREG,
+ IOV_DIVISOR,
+ IOV_SDMODE,
+ IOV_HISPEED,
+ IOV_HCIREGS,
+ IOV_POWER,
+ IOV_CLOCK,
+ IOV_SPIERRSTATS,
+ IOV_RESP_DELAY_ALL
+};
+
+const bcm_iovar_t sdioh_iovars[] = {
+ {"sd_msglevel", IOV_MSGLEVEL, 0, IOVT_UINT32, 0 },
+ {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0 }, /* ((fn << 16) | size) */
+ {"sd_dma", IOV_DMA, 0, IOVT_BOOL, 0 },
+ {"sd_ints", IOV_USEINTS, 0, IOVT_BOOL, 0 },
+ {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0 },
+ {"sd_numlocalints", IOV_NUMLOCALINTS, 0, IOVT_UINT32, 0 },
+ {"sd_hostreg", IOV_HOSTREG, 0, IOVT_BUFFER, sizeof(sdreg_t) },
+ {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(sdreg_t) },
+ {"sd_divisor", IOV_DIVISOR, 0, IOVT_UINT32, 0 },
+ {"sd_power", IOV_POWER, 0, IOVT_UINT32, 0 },
+ {"sd_clock", IOV_CLOCK, 0, IOVT_UINT32, 0 },
+ {"sd_mode", IOV_SDMODE, 0, IOVT_UINT32, 100},
+ {"sd_highspeed", IOV_HISPEED, 0, IOVT_UINT32, 0},
+ {"spi_errstats", IOV_SPIERRSTATS, 0, IOVT_BUFFER, sizeof(struct spierrstats_t) },
+ {"spi_respdelay", IOV_RESP_DELAY_ALL, 0, IOVT_BOOL, 0 },
+ {NULL, 0, 0, 0, 0 }
+};
+
+int
+sdioh_iovar_op(sdioh_info_t *si, const char *name,
+ void *params, int plen, void *arg, int len, bool set)
+{
+ const bcm_iovar_t *vi = NULL;
+ int bcmerror = 0;
+ int val_size;
+ int32 int_val = 0;
+ bool bool_val;
+ uint32 actionid;
+/*
+ sdioh_regs_t *regs;
+*/
+
+ ASSERT(name);
+ ASSERT(len >= 0);
+
+ /* Get must have return space; Set does not take qualifiers */
+ ASSERT(set || (arg && len));
+ ASSERT(!set || (!params && !plen));
+
+ sd_trace(("%s: Enter (%s %s)\n", __FUNCTION__, (set ? "set" : "get"), name));
+
+ if ((vi = bcm_iovar_lookup(sdioh_iovars, name)) == NULL) {
+ bcmerror = BCME_UNSUPPORTED;
+ goto exit;
+ }
+
+ if ((bcmerror = bcm_iovar_lencheck(vi, arg, len, set)) != 0)
+ goto exit;
+
+ /* Set up params so get and set can share the convenience variables */
+ if (params == NULL) {
+ params = arg;
+ plen = len;
+ }
+
+ if (vi->type == IOVT_VOID)
+ val_size = 0;
+ else if (vi->type == IOVT_BUFFER)
+ val_size = len;
+ else
+ val_size = sizeof(int);
+
+ if (plen >= (int)sizeof(int_val))
+ bcopy(params, &int_val, sizeof(int_val));
+
+ bool_val = (int_val != 0) ? TRUE : FALSE;
+
+ actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
+ switch (actionid) {
+ case IOV_GVAL(IOV_MSGLEVEL):
+ int_val = (int32)sd_msglevel;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_MSGLEVEL):
+ sd_msglevel = int_val;
+ break;
+
+ case IOV_GVAL(IOV_BLOCKSIZE):
+ if ((uint32)int_val > si->num_funcs) {
+ bcmerror = BCME_BADARG;
+ break;
+ }
+ int_val = (int32)si->client_block_size[int_val];
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_GVAL(IOV_DMA):
+ int_val = (int32)si->sd_use_dma;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_DMA):
+ si->sd_use_dma = (bool)int_val;
+ break;
+
+ case IOV_GVAL(IOV_USEINTS):
+ int_val = (int32)si->use_client_ints;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_USEINTS):
+ break;
+
+ case IOV_GVAL(IOV_DIVISOR):
+ int_val = (uint32)sd_divisor;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_DIVISOR):
+ sd_divisor = int_val;
+ if (!spi_start_clock(si, (uint16)sd_divisor)) {
+ sd_err(("%s: set clock failed\n", __FUNCTION__));
+ bcmerror = BCME_ERROR;
+ }
+ break;
+
+ case IOV_GVAL(IOV_POWER):
+ int_val = (uint32)sd_power;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_POWER):
+ sd_power = int_val;
+ break;
+
+ case IOV_GVAL(IOV_CLOCK):
+ int_val = (uint32)sd_clock;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_CLOCK):
+ sd_clock = int_val;
+ break;
+
+ case IOV_GVAL(IOV_SDMODE):
+ int_val = (uint32)sd_sdmode;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_SDMODE):
+ sd_sdmode = int_val;
+ break;
+
+ case IOV_GVAL(IOV_HISPEED):
+ int_val = (uint32)sd_hiok;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_HISPEED):
+ sd_hiok = int_val;
+
+ if (!bcmspi_set_highspeed_mode(si, (bool)sd_hiok)) {
+ sd_err(("%s: Failed changing highspeed mode to %d.\n",
+ __FUNCTION__, sd_hiok));
+ bcmerror = BCME_ERROR;
+ return ERROR;
+ }
+ break;
+
+ case IOV_GVAL(IOV_NUMINTS):
+ int_val = (int32)si->intrcount;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_GVAL(IOV_NUMLOCALINTS):
+ int_val = (int32)si->local_intrcount;
+ bcopy(&int_val, arg, val_size);
+ break;
+ case IOV_GVAL(IOV_DEVREG):
+ {
+ sdreg_t *sd_ptr = (sdreg_t *)params;
+ uint8 data;
+
+ if (sdioh_cfg_read(si, sd_ptr->func, sd_ptr->offset, &data)) {
+ bcmerror = BCME_SDIO_ERROR;
+ break;
+ }
+
+ int_val = (int)data;
+ bcopy(&int_val, arg, sizeof(int_val));
+ break;
+ }
+
+ case IOV_SVAL(IOV_DEVREG):
+ {
+ sdreg_t *sd_ptr = (sdreg_t *)params;
+ uint8 data = (uint8)sd_ptr->value;
+
+ if (sdioh_cfg_write(si, sd_ptr->func, sd_ptr->offset, &data)) {
+ bcmerror = BCME_SDIO_ERROR;
+ break;
+ }
+ break;
+ }
+
+
+ case IOV_GVAL(IOV_SPIERRSTATS):
+ {
+ bcopy(&si->spierrstats, arg, sizeof(struct spierrstats_t));
+ break;
+ }
+
+ case IOV_SVAL(IOV_SPIERRSTATS):
+ {
+ bzero(&si->spierrstats, sizeof(struct spierrstats_t));
+ break;
+ }
+
+ case IOV_GVAL(IOV_RESP_DELAY_ALL):
+ int_val = (int32)si->resp_delay_all;
+ bcopy(&int_val, arg, val_size);
+ break;
+
+ case IOV_SVAL(IOV_RESP_DELAY_ALL):
+ si->resp_delay_all = (bool)int_val;
+ int_val = STATUS_ENABLE|INTR_WITH_STATUS;
+ if (si->resp_delay_all)
+ int_val |= RESP_DELAY_ALL;
+ else {
+ if (bcmspi_card_regwrite(si, SPI_FUNC_0, SPID_RESPONSE_DELAY, 1,
+ F1_RESPONSE_DELAY) != SUCCESS) {
+ sd_err(("%s: Unable to set response delay.\n", __FUNCTION__));
+ bcmerror = BCME_SDIO_ERROR;
+ break;
+ }
+ }
+
+ if (bcmspi_card_regwrite(si, SPI_FUNC_0, SPID_STATUS_ENABLE, 1, int_val)
+ != SUCCESS) {
+ sd_err(("%s: Unable to set response delay.\n", __FUNCTION__));
+ bcmerror = BCME_SDIO_ERROR;
+ break;
+ }
+ break;
+
+ default:
+ bcmerror = BCME_UNSUPPORTED;
+ break;
+ }
+exit:
+
+ return bcmerror;
+}
+
+extern SDIOH_API_RC
+sdioh_cfg_read(sdioh_info_t *sd, uint fnc_num, uint32 addr, uint8 *data)
+{
+ SDIOH_API_RC status;
+ /* No lock needed since sdioh_request_byte does locking */
+ status = sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data);
+ return status;
+}
+
+extern SDIOH_API_RC
+sdioh_cfg_write(sdioh_info_t *sd, uint fnc_num, uint32 addr, uint8 *data)
+{
+ /* No lock needed since sdioh_request_byte does locking */
+ SDIOH_API_RC status;
+
+ if ((fnc_num == SPI_FUNC_1) && (addr == SBSDIO_FUNC1_FRAMECTRL)) {
+ uint8 dummy_data;
+ status = sdioh_cfg_read(sd, fnc_num, addr, &dummy_data);
+ if (status) {
+ sd_err(("sdioh_cfg_read() failed.\n"));
+ return status;
+ }
+ }
+
+ status = sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data);
+ return status;
+}
+
+extern SDIOH_API_RC
+sdioh_cis_read(sdioh_info_t *sd, uint func, uint8 *cisd, uint32 length)
+{
+ uint32 count;
+ int offset;
+ uint32 cis_byte;
+ uint16 *cis = (uint16 *)cisd;
+ uint bar0 = SI_ENUM_BASE;
+ int status;
+ uint8 data;
+
+ sd_trace(("%s: Func %d\n", __FUNCTION__, func));
+
+ spi_lock(sd);
+
+ /* Set sb window address to 0x18000000 */
+ data = (bar0 >> 8) & SBSDIO_SBADDRLOW_MASK;
+ status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, &data);
+ if (status == SUCCESS) {
+ data = (bar0 >> 16) & SBSDIO_SBADDRMID_MASK;
+ status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, &data);
+ } else {
+ sd_err(("%s: Unable to set sb-addr-windows\n", __FUNCTION__));
+ spi_unlock(sd);
+ return (BCME_ERROR);
+ }
+ if (status == SUCCESS) {
+ data = (bar0 >> 24) & SBSDIO_SBADDRHIGH_MASK;
+ status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, &data);
+ } else {
+ sd_err(("%s: Unable to set sb-addr-windows\n", __FUNCTION__));
+ spi_unlock(sd);
+ return (BCME_ERROR);
+ }
+
+ offset = CC_OTP; /* OTP offset in chipcommon. */
+ for (count = 0; count < length/2; count++) {
+ if (bcmspi_card_regread (sd, SDIO_FUNC_1, offset, 2, &cis_byte) < 0) {
+ sd_err(("%s: regread failed: Can't read CIS\n", __FUNCTION__));
+ spi_unlock(sd);
+ return (BCME_ERROR);
+ }
+
+ *cis = (uint16)cis_byte;
+ cis++;
+ offset += 2;
+ }
+
+ spi_unlock(sd);
+
+ return (BCME_OK);
+}
+
+extern SDIOH_API_RC
+sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr, uint8 *byte)
+{
+ int status;
+ uint32 cmd_arg;
+ uint32 dstatus;
+ uint32 data = (uint32)(*byte);
+
+ spi_lock(sd);
+
+ cmd_arg = 0;
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1); /* Incremental access */
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, rw == SDIOH_READ ? 0 : 1);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, 1);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+ sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, rw, func,
+ regaddr, data));
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma,
+ cmd_arg, &data, 1)) != SUCCESS) {
+ spi_unlock(sd);
+ return status;
+ }
+
+ if (rw == SDIOH_READ)
+ *byte = (uint8)data;
+
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ if (dstatus)
+ sd_trace(("dstatus =0x%x\n", dstatus));
+
+ spi_unlock(sd);
+ return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func, uint addr,
+ uint32 *word, uint nbytes)
+{
+ int status;
+
+ spi_lock(sd);
+
+ if (rw == SDIOH_READ)
+ status = bcmspi_card_regread(sd, func, addr, nbytes, word);
+ else
+ status = bcmspi_card_regwrite(sd, func, addr, nbytes, *word);
+
+ spi_unlock(sd);
+ return (status == SUCCESS ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
+}
+
+extern SDIOH_API_RC
+sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint rw, uint func,
+ uint addr, uint reg_width, uint buflen_u, uint8 *buffer, void *pkt)
+{
+ int len;
+ int buflen = (int)buflen_u;
+ bool fifo = (fix_inc == SDIOH_DATA_FIX);
+
+ spi_lock(sd);
+
+ ASSERT(reg_width == 4);
+ ASSERT(buflen_u < (1 << 30));
+ ASSERT(sd->client_block_size[func]);
+
+ sd_data(("%s: %c len %d r_cnt %d t_cnt %d, pkt @0x%p\n",
+ __FUNCTION__, rw == SDIOH_READ ? 'R' : 'W',
+ buflen_u, sd->r_cnt, sd->t_cnt, pkt));
+
+ /* Break buffer down into blocksize chunks. */
+ while (buflen > 0) {
+ len = MIN(sd->client_block_size[func], buflen);
+ if (bcmspi_card_buf(sd, rw, func, fifo, addr, len, (uint32 *)buffer) != SUCCESS) {
+ sd_err(("%s: bcmspi_card_buf %s failed\n",
+ __FUNCTION__, rw == SDIOH_READ ? "Read" : "Write"));
+ spi_unlock(sd);
+ return SDIOH_API_RC_FAIL;
+ }
+ buffer += len;
+ buflen -= len;
+ if (!fifo)
+ addr += len;
+ }
+ spi_unlock(sd);
+ return SDIOH_API_RC_SUCCESS;
+}
+
+/* This function allows write to gspi bus when another rd/wr function is deep down the call stack.
+ * Its main aim is to have simpler spi writes rather than recursive writes.
+ * e.g. When there is a need to program response delay on the fly after detecting the SPI-func
+ * this call will allow to program the response delay.
+ */
+static int
+bcmspi_card_byterewrite(sdioh_info_t *sd, int func, uint32 regaddr, uint8 byte)
+{
+ uint32 cmd_arg;
+ uint32 datalen = 1;
+ uint32 hostlen;
+
+ cmd_arg = 0;
+
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1); /* Incremental access */
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, datalen);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+
+
+ /* Set up and issue the SPI command. MSByte goes out on bus first. Increase datalen
+ * according to the wordlen mode(16/32bit) the device is in.
+ */
+ ASSERT(sd->wordlen == 4 || sd->wordlen == 2);
+ datalen = ROUNDUP(datalen, sd->wordlen);
+
+ /* Start by copying command in the spi-outbuffer */
+ if (sd->wordlen == 4) { /* 32bit spid */
+ *(uint32 *)spi_outbuf2 = bcmswap32(cmd_arg);
+ if (datalen & 0x3)
+ datalen += (4 - (datalen & 0x3));
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ *(uint16 *)spi_outbuf2 = bcmswap16(cmd_arg & 0xffff);
+ *(uint16 *)&spi_outbuf2[2] = bcmswap16((cmd_arg & 0xffff0000) >> 16);
+ if (datalen & 0x1)
+ datalen++;
+ } else {
+ sd_err(("%s: Host is %d bit spid, could not create SPI command.\n",
+ __FUNCTION__, 8 * sd->wordlen));
+ return ERROR;
+ }
+
+ /* for Write, put the data into the output buffer */
+ if (datalen != 0) {
+ if (sd->wordlen == 4) { /* 32bit spid */
+ *(uint32 *)&spi_outbuf2[CMDLEN] = bcmswap32(byte);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ *(uint16 *)&spi_outbuf2[CMDLEN] = bcmswap16(byte & 0xffff);
+ *(uint16 *)&spi_outbuf2[CMDLEN + 2] =
+ bcmswap16((byte & 0xffff0000) >> 16);
+ }
+ }
+
+ /* +4 for cmd, +4 for dstatus */
+ hostlen = datalen + 8;
+ hostlen += (4 - (hostlen & 0x3));
+ spi_sendrecv(sd, spi_outbuf2, spi_inbuf2, hostlen);
+
+ /* Last 4bytes are dstatus. Device is configured to return status bits. */
+ if (sd->wordlen == 4) { /* 32bit spid */
+ sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf2[datalen + CMDLEN ]);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN ]) |
+ (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN + 2]) << 16));
+ } else {
+ sd_err(("%s: Host is %d bit machine, could not read SPI dstatus.\n",
+ __FUNCTION__, 8 * sd->wordlen));
+ return ERROR;
+ }
+
+ if (sd->card_dstatus)
+ sd_trace(("dstatus after byte rewrite = 0x%x\n", sd->card_dstatus));
+
+ return (BCME_OK);
+}
+
+/* Program the response delay corresponding to the spi function */
+static int
+bcmspi_prog_resp_delay(sdioh_info_t *sd, int func, uint8 resp_delay)
+{
+ if (sd->resp_delay_all == FALSE)
+ return (BCME_OK);
+
+ if (sd->prev_fun == func)
+ return (BCME_OK);
+
+ if (F0_RESPONSE_DELAY == F1_RESPONSE_DELAY)
+ return (BCME_OK);
+
+ bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_RESPONSE_DELAY, resp_delay);
+
+ /* Remember function for which to avoid reprogramming resp-delay in next iteration */
+ sd->prev_fun = func;
+
+ return (BCME_OK);
+
+}
+
+#define GSPI_RESYNC_PATTERN 0x0
+
+/* A resync pattern is a 32bit MOSI line with all zeros. Its a special command in gSPI.
+ * It resets the spi-bkplane logic so that all F1 related ping-pong buffer logic is
+ * synchronised and all queued resuests are cancelled.
+ */
+static int
+bcmspi_resync_f1(sdioh_info_t *sd)
+{
+ uint32 cmd_arg = GSPI_RESYNC_PATTERN, data = 0, datalen = 0;
+
+
+ /* Set up and issue the SPI command. MSByte goes out on bus first. Increase datalen
+ * according to the wordlen mode(16/32bit) the device is in.
+ */
+ ASSERT(sd->wordlen == 4 || sd->wordlen == 2);
+ datalen = ROUNDUP(datalen, sd->wordlen);
+
+ /* Start by copying command in the spi-outbuffer */
+ *(uint32 *)spi_outbuf2 = cmd_arg;
+
+ /* for Write, put the data into the output buffer */
+ *(uint32 *)&spi_outbuf2[CMDLEN] = data;
+
+ /* +4 for cmd, +4 for dstatus */
+ spi_sendrecv(sd, spi_outbuf2, spi_inbuf2, datalen + 8);
+
+ /* Last 4bytes are dstatus. Device is configured to return status bits. */
+ if (sd->wordlen == 4) { /* 32bit spid */
+ sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf2[datalen + CMDLEN ]);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN ]) |
+ (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN + 2]) << 16));
+ } else {
+ sd_err(("%s: Host is %d bit machine, could not read SPI dstatus.\n",
+ __FUNCTION__, 8 * sd->wordlen));
+ return ERROR;
+ }
+
+ if (sd->card_dstatus)
+ sd_trace(("dstatus after resync pattern write = 0x%x\n", sd->card_dstatus));
+
+ return (BCME_OK);
+}
+
+uint32 dstatus_count = 0;
+
+static int
+bcmspi_update_stats(sdioh_info_t *sd, uint32 cmd_arg)
+{
+ uint32 dstatus = sd->card_dstatus;
+ struct spierrstats_t *spierrstats = &sd->spierrstats;
+ int err = SUCCESS;
+
+ sd_trace(("cmd = 0x%x, dstatus = 0x%x\n", cmd_arg, dstatus));
+
+ /* Store dstatus of last few gSPI transactions */
+ spierrstats->dstatus[dstatus_count % NUM_PREV_TRANSACTIONS] = dstatus;
+ spierrstats->spicmd[dstatus_count % NUM_PREV_TRANSACTIONS] = cmd_arg;
+ dstatus_count++;
+
+ if (sd->card_init_done == FALSE)
+ return err;
+
+ if (dstatus & STATUS_DATA_NOT_AVAILABLE) {
+ spierrstats->dna++;
+ sd_trace(("Read data not available on F1 addr = 0x%x\n",
+ GFIELD(cmd_arg, SPI_REG_ADDR)));
+ /* Clear dna bit */
+ bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_INTR_REG, DATA_UNAVAILABLE);
+ }
+
+ if (dstatus & STATUS_UNDERFLOW) {
+ spierrstats->rdunderflow++;
+ sd_err(("FIFO underflow happened due to current F2 read command.\n"));
+ }
+
+ if (dstatus & STATUS_OVERFLOW) {
+ spierrstats->wroverflow++;
+ sd_err(("FIFO overflow happened due to current (F1/F2) write command.\n"));
+ if ((sd->chip == BCM4329_CHIP_ID) && (sd->chiprev == 0)) {
+ bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_INTR_REG, F1_OVERFLOW);
+ bcmspi_resync_f1(sd);
+ sd_err(("Recovering from F1 FIFO overflow.\n"));
+ } else {
+ err = ERROR_OF;
+ }
+ }
+
+ if (dstatus & STATUS_F2_INTR) {
+ spierrstats->f2interrupt++;
+ sd_trace(("Interrupt from F2. SW should clear corresponding IntStatus bits\n"));
+ }
+
+ if (dstatus & STATUS_F3_INTR) {
+ spierrstats->f3interrupt++;
+ sd_err(("Interrupt from F3. SW should clear corresponding IntStatus bits\n"));
+ }
+
+ if (dstatus & STATUS_HOST_CMD_DATA_ERR) {
+ spierrstats->hostcmddataerr++;
+ sd_err(("Error in CMD or Host data, detected by CRC/Checksum (optional)\n"));
+ }
+
+ if (dstatus & STATUS_F2_PKT_AVAILABLE) {
+ spierrstats->f2pktavailable++;
+ sd_trace(("Packet is available/ready in F2 TX FIFO\n"));
+ sd_trace(("Packet length = %d\n", sd->dwordmode ?
+ ((dstatus & STATUS_F2_PKT_LEN_MASK) >> (STATUS_F2_PKT_LEN_SHIFT - 2)) :
+ ((dstatus & STATUS_F2_PKT_LEN_MASK) >> STATUS_F2_PKT_LEN_SHIFT)));
+ }
+
+ if (dstatus & STATUS_F3_PKT_AVAILABLE) {
+ spierrstats->f3pktavailable++;
+ sd_err(("Packet is available/ready in F3 TX FIFO\n"));
+ sd_err(("Packet length = %d\n",
+ (dstatus & STATUS_F3_PKT_LEN_MASK) >> STATUS_F3_PKT_LEN_SHIFT));
+ }
+
+ return err;
+}
+
+extern int
+sdioh_abort(sdioh_info_t *sd, uint func)
+{
+ return 0;
+}
+
+int
+sdioh_start(sdioh_info_t *sd, int stage)
+{
+ return SUCCESS;
+}
+
+int
+sdioh_stop(sdioh_info_t *sd)
+{
+ return SUCCESS;
+}
+
+
+
+/*
+ * Private/Static work routines
+ */
+static int
+bcmspi_host_init(sdioh_info_t *sd)
+{
+
+ /* Default power on mode */
+ sd->sd_mode = SDIOH_MODE_SPI;
+ sd->polled_mode = TRUE;
+ sd->host_init_done = TRUE;
+ sd->card_init_done = FALSE;
+ sd->adapter_slot = 1;
+
+ return (SUCCESS);
+}
+
+static int
+get_client_blocksize(sdioh_info_t *sd)
+{
+ uint32 regdata[2];
+ int status;
+
+ /* Find F1/F2/F3 max packet size */
+ if ((status = bcmspi_card_regread(sd, 0, SPID_F1_INFO_REG,
+ 8, regdata)) != SUCCESS) {
+ return status;
+ }
+
+ sd_trace(("pkt_size regdata[0] = 0x%x, regdata[1] = 0x%x\n",
+ regdata[0], regdata[1]));
+
+ sd->client_block_size[1] = (regdata[0] & F1_MAX_PKT_SIZE) >> 2;
+ sd_trace(("Func1 blocksize = %d\n", sd->client_block_size[1]));
+ ASSERT(sd->client_block_size[1] == BLOCK_SIZE_F1);
+
+ sd->client_block_size[2] = ((regdata[0] >> 16) & F2_MAX_PKT_SIZE) >> 2;
+ sd_trace(("Func2 blocksize = %d\n", sd->client_block_size[2]));
+ ASSERT(sd->client_block_size[2] == BLOCK_SIZE_F2);
+
+ sd->client_block_size[3] = (regdata[1] & F3_MAX_PKT_SIZE) >> 2;
+ sd_trace(("Func3 blocksize = %d\n", sd->client_block_size[3]));
+ ASSERT(sd->client_block_size[3] == BLOCK_SIZE_F3);
+
+ return 0;
+}
+
+static int
+bcmspi_client_init(sdioh_info_t *sd)
+{
+ uint32 status_en_reg = 0;
+ sd_trace(("%s: Powering up slot %d\n", __FUNCTION__, sd->adapter_slot));
+
+#ifdef HSMODE
+ if (!spi_start_clock(sd, (uint16)sd_divisor)) {
+ sd_err(("spi_start_clock failed\n"));
+ return ERROR;
+ }
+#else
+ /* Start at ~400KHz clock rate for initialization */
+ if (!spi_start_clock(sd, 128)) {
+ sd_err(("spi_start_clock failed\n"));
+ return ERROR;
+ }
+#endif /* HSMODE */
+
+ if (!bcmspi_host_device_init_adapt(sd)) {
+ sd_err(("bcmspi_host_device_init_adapt failed\n"));
+ return ERROR;
+ }
+
+ if (!bcmspi_test_card(sd)) {
+ sd_err(("bcmspi_test_card failed\n"));
+ return ERROR;
+ }
+
+ sd->num_funcs = SPI_MAX_IOFUNCS;
+
+ get_client_blocksize(sd);
+
+ /* Apply resync pattern cmd with all zeros to reset spi-bkplane F1 logic */
+ bcmspi_resync_f1(sd);
+
+ sd->dwordmode = FALSE;
+
+ bcmspi_card_regread(sd, 0, SPID_STATUS_ENABLE, 1, &status_en_reg);
+
+ sd_trace(("%s: Enabling interrupt with dstatus \n", __FUNCTION__));
+ status_en_reg |= INTR_WITH_STATUS;
+
+
+ if (bcmspi_card_regwrite(sd, SPI_FUNC_0, SPID_STATUS_ENABLE, 1,
+ status_en_reg & 0xff) != SUCCESS) {
+ sd_err(("%s: Unable to set response delay for all fun's.\n", __FUNCTION__));
+ return ERROR;
+ }
+
+
+#ifndef HSMODE
+ /* After configuring for High-Speed mode, set the desired clock rate. */
+ if (!spi_start_clock(sd, 4)) {
+ sd_err(("spi_start_clock failed\n"));
+ return ERROR;
+ }
+#endif /* HSMODE */
+
+ sd->card_init_done = TRUE;
+
+
+ return SUCCESS;
+}
+
+static int
+bcmspi_set_highspeed_mode(sdioh_info_t *sd, bool hsmode)
+{
+ uint32 regdata;
+ int status;
+
+ if ((status = bcmspi_card_regread(sd, 0, SPID_CONFIG,
+ 4, ®data)) != SUCCESS)
+ return status;
+
+ sd_trace(("In %s spih-ctrl = 0x%x \n", __FUNCTION__, regdata));
+
+
+ if (hsmode == TRUE) {
+ sd_trace(("Attempting to enable High-Speed mode.\n"));
+
+ if (regdata & HIGH_SPEED_MODE) {
+ sd_trace(("Device is already in High-Speed mode.\n"));
+ return status;
+ } else {
+ regdata |= HIGH_SPEED_MODE;
+ sd_trace(("Writing %08x to device at %08x\n", regdata, SPID_CONFIG));
+ if ((status = bcmspi_card_regwrite(sd, 0, SPID_CONFIG,
+ 4, regdata)) != SUCCESS) {
+ return status;
+ }
+ }
+ } else {
+ sd_trace(("Attempting to disable High-Speed mode.\n"));
+
+ if (regdata & HIGH_SPEED_MODE) {
+ regdata &= ~HIGH_SPEED_MODE;
+ sd_trace(("Writing %08x to device at %08x\n", regdata, SPID_CONFIG));
+ if ((status = bcmspi_card_regwrite(sd, 0, SPID_CONFIG,
+ 4, regdata)) != SUCCESS)
+ return status;
+ }
+ else {
+ sd_trace(("Device is already in Low-Speed mode.\n"));
+ return status;
+ }
+ }
+
+ spi_controller_highspeed_mode(sd, hsmode);
+
+ return TRUE;
+}
+
+#define bcmspi_find_curr_mode(sd) { \
+ sd->wordlen = 2; \
+ status = bcmspi_card_regread_fixedaddr(sd, 0, SPID_TEST_READ, 4, ®data); \
+ regdata &= 0xff; \
+ if ((regdata == 0xad) || (regdata == 0x5b) || \
+ (regdata == 0x5d) || (regdata == 0x5a)) \
+ break; \
+ sd->wordlen = 4; \
+ status = bcmspi_card_regread_fixedaddr(sd, 0, SPID_TEST_READ, 4, ®data); \
+ regdata &= 0xff; \
+ if ((regdata == 0xad) || (regdata == 0x5b) || \
+ (regdata == 0x5d) || (regdata == 0x5a)) \
+ break; \
+ sd_trace(("Silicon testability issue: regdata = 0x%x." \
+ " Expected 0xad, 0x5a, 0x5b or 0x5d.\n", regdata)); \
+ OSL_DELAY(100000); \
+}
+
+#define INIT_ADAPT_LOOP 100
+
+/* Adapt clock-phase-speed-bitwidth between host and device */
+static bool
+bcmspi_host_device_init_adapt(sdioh_info_t *sd)
+{
+ uint32 wrregdata, regdata = 0;
+ int status;
+ int i;
+
+ /* Due to a silicon testability issue, the first command from the Host
+ * to the device will get corrupted (first bit will be lost). So the
+ * Host should poll the device with a safe read request. ie: The Host
+ * should try to read F0 addr 0x14 using the Fixed address mode
+ * (This will prevent a unintended write command to be detected by device)
+ */
+ for (i = 0; i < INIT_ADAPT_LOOP; i++) {
+ /* If device was not power-cycled it will stay in 32bit mode with
+ * response-delay-all bit set. Alternate the iteration so that
+ * read either with or without response-delay for F0 to succeed.
+ */
+ bcmspi_find_curr_mode(sd);
+ sd->resp_delay_all = (i & 0x1) ? TRUE : FALSE;
+
+ bcmspi_find_curr_mode(sd);
+ sd->dwordmode = TRUE;
+
+ bcmspi_find_curr_mode(sd);
+ sd->dwordmode = FALSE;
+ }
+
+ /* Bail out, device not detected */
+ if (i == INIT_ADAPT_LOOP)
+ return FALSE;
+
+ /* Softreset the spid logic */
+ if ((sd->dwordmode) || (sd->wordlen == 4)) {
+ bcmspi_card_regwrite(sd, 0, SPID_RESET_BP, 1, RESET_ON_WLAN_BP_RESET|RESET_SPI);
+ bcmspi_card_regread(sd, 0, SPID_RESET_BP, 1, ®data);
+ sd_trace(("reset reg read = 0x%x\n", regdata));
+ sd_trace(("dwordmode = %d, wordlen = %d, resp_delay_all = %d\n", sd->dwordmode,
+ sd->wordlen, sd->resp_delay_all));
+ /* Restore default state after softreset */
+ sd->wordlen = 2;
+ sd->dwordmode = FALSE;
+ }
+
+ if (sd->wordlen == 4) {
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, ®data)) !=
+ SUCCESS)
+ return FALSE;
+ if (regdata == TEST_RO_DATA_32BIT_LE) {
+ sd_trace(("Spid is already in 32bit LE mode. Value read = 0x%x\n",
+ regdata));
+ sd_trace(("Spid power was left on.\n"));
+ } else {
+ sd_err(("Spid power was left on but signature read failed."
+ " Value read = 0x%x\n", regdata));
+ return FALSE;
+ }
+ } else {
+ sd->wordlen = 2;
+
+#define CTRL_REG_DEFAULT 0x00010430 /* according to the host m/c */
+
+ wrregdata = (CTRL_REG_DEFAULT);
+ sd->resp_delay_all = TRUE;
+ if (sd->resp_delay_all == TRUE) {
+ /* Enable response delay for all */
+ wrregdata |= (RESP_DELAY_ALL << 16);
+ /* Program response delay value */
+ wrregdata &= 0xffff00ff;
+ wrregdata |= (F1_RESPONSE_DELAY << 8);
+ sd->prev_fun = SPI_FUNC_1;
+ bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+ }
+
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, ®data)) != SUCCESS)
+ return FALSE;
+ sd_trace(("(we are still in 16bit mode) 32bit READ LE regdata = 0x%x\n", regdata));
+
+#ifndef HSMODE
+ wrregdata |= (CLOCK_PHASE | CLOCK_POLARITY);
+ wrregdata &= ~HIGH_SPEED_MODE;
+ bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+#endif /* HSMODE */
+
+ for (i = 0; i < INIT_ADAPT_LOOP; i++) {
+ if ((regdata == 0xfdda7d5b) || (regdata == 0xfdda7d5a)) {
+ sd_trace(("0xfeedbead was leftshifted by 1-bit.\n"));
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4,
+ ®data)) != SUCCESS)
+ return FALSE;
+ }
+ OSL_DELAY(1000);
+ }
+
+
+ /* Change to host controller intr-polarity of active-low */
+ wrregdata &= ~INTR_POLARITY;
+ sd_trace(("(we are still in 16bit mode) 32bit Write LE reg-ctrl-data = 0x%x\n",
+ wrregdata));
+ /* Change to 32bit mode */
+ wrregdata |= WORD_LENGTH_32;
+ bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+
+ /* Change command/data packaging in 32bit LE mode */
+ sd->wordlen = 4;
+
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, ®data)) != SUCCESS)
+ return FALSE;
+
+ if (regdata == TEST_RO_DATA_32BIT_LE) {
+ sd_trace(("Read spid passed. Value read = 0x%x\n", regdata));
+ sd_trace(("Spid had power-on cycle OR spi was soft-resetted \n"));
+ } else {
+ sd_err(("Stale spid reg values read as it was kept powered. Value read ="
+ "0x%x\n", regdata));
+ return FALSE;
+ }
+ }
+
+
+ return TRUE;
+}
+
+static bool
+bcmspi_test_card(sdioh_info_t *sd)
+{
+ uint32 regdata;
+ int status;
+
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, ®data)) != SUCCESS)
+ return FALSE;
+
+ if (regdata == (TEST_RO_DATA_32BIT_LE))
+ sd_trace(("32bit LE regdata = 0x%x\n", regdata));
+ else {
+ sd_trace(("Incorrect 32bit LE regdata = 0x%x\n", regdata));
+ return FALSE;
+ }
+
+
+#define RW_PATTERN1 0xA0A1A2A3
+#define RW_PATTERN2 0x4B5B6B7B
+
+ regdata = RW_PATTERN1;
+ if ((status = bcmspi_card_regwrite(sd, 0, SPID_TEST_RW, 4, regdata)) != SUCCESS)
+ return FALSE;
+ regdata = 0;
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_RW, 4, ®data)) != SUCCESS)
+ return FALSE;
+ if (regdata != RW_PATTERN1) {
+ sd_err(("Write-Read spid failed. Value wrote = 0x%x, Value read = 0x%x\n",
+ RW_PATTERN1, regdata));
+ return FALSE;
+ } else
+ sd_trace(("R/W spid passed. Value read = 0x%x\n", regdata));
+
+ regdata = RW_PATTERN2;
+ if ((status = bcmspi_card_regwrite(sd, 0, SPID_TEST_RW, 4, regdata)) != SUCCESS)
+ return FALSE;
+ regdata = 0;
+ if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_RW, 4, ®data)) != SUCCESS)
+ return FALSE;
+ if (regdata != RW_PATTERN2) {
+ sd_err(("Write-Read spid failed. Value wrote = 0x%x, Value read = 0x%x\n",
+ RW_PATTERN2, regdata));
+ return FALSE;
+ } else
+ sd_trace(("R/W spid passed. Value read = 0x%x\n", regdata));
+
+ return TRUE;
+}
+
+static int
+bcmspi_driver_init(sdioh_info_t *sd)
+{
+ sd_trace(("%s\n", __FUNCTION__));
+ if ((bcmspi_host_init(sd)) != SUCCESS) {
+ return ERROR;
+ }
+
+ if (bcmspi_client_init(sd) != SUCCESS) {
+ return ERROR;
+ }
+
+ return SUCCESS;
+}
+
+/* Read device reg */
+static int
+bcmspi_card_regread(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 *data)
+{
+ int status;
+ uint32 cmd_arg, dstatus;
+
+ ASSERT(regsize);
+
+ if (func == 2)
+ sd_trace(("Reg access on F2 will generate error indication in dstatus bits.\n"));
+
+ cmd_arg = 0;
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 0);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1); /* Incremental access */
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize == BLOCK_SIZE_F2 ? 0 : regsize);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+ sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 0, func,
+ regaddr, *data));
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, data, regsize))
+ != SUCCESS)
+ return status;
+
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ if (dstatus)
+ sd_trace(("dstatus =0x%x\n", dstatus));
+
+ return SUCCESS;
+}
+
+static int
+bcmspi_card_regread_fixedaddr(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 *data)
+{
+
+ int status;
+ uint32 cmd_arg;
+ uint32 dstatus;
+
+ ASSERT(regsize);
+
+ if (func == 2)
+ sd_trace(("Reg access on F2 will generate error indication in dstatus bits.\n"));
+
+ cmd_arg = 0;
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 0);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 0); /* Fixed access */
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, data, regsize))
+ != SUCCESS)
+ return status;
+
+ sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 0, func,
+ regaddr, *data));
+
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ sd_trace(("dstatus =0x%x\n", dstatus));
+ return SUCCESS;
+}
+
+/* write a device register */
+static int
+bcmspi_card_regwrite(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 data)
+{
+ int status;
+ uint32 cmd_arg, dstatus;
+
+ ASSERT(regsize);
+
+ cmd_arg = 0;
+
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1); /* Incremental access */
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize == BLOCK_SIZE_F2 ? 0 : regsize);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+ sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 1, func,
+ regaddr, data));
+
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, &data, regsize))
+ != SUCCESS)
+ return status;
+
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ if (dstatus)
+ sd_trace(("dstatus =0x%x\n", dstatus));
+
+ return SUCCESS;
+}
+
+/* write a device register - 1 byte */
+static int
+bcmspi_card_bytewrite(sdioh_info_t *sd, int func, uint32 regaddr, uint8 *byte)
+{
+ int status;
+ uint32 cmd_arg;
+ uint32 dstatus;
+ uint32 data = (uint32)(*byte);
+
+ cmd_arg = 0;
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1); /* Incremental access */
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, 1);
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+ sd_trace(("%s: func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, func,
+ regaddr, data));
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma,
+ cmd_arg, &data, 1)) != SUCCESS) {
+ return status;
+ }
+
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ if (dstatus)
+ sd_trace(("dstatus =0x%x\n", dstatus));
+
+ return SUCCESS;
+}
+
+void
+bcmspi_cmd_getdstatus(sdioh_info_t *sd, uint32 *dstatus_buffer)
+{
+ *dstatus_buffer = sd->card_dstatus;
+}
+
+/* 'data' is of type uint32 whereas other buffers are of type uint8 */
+static int
+bcmspi_cmd_issue(sdioh_info_t *sd, bool use_dma, uint32 cmd_arg,
+ uint32 *data, uint32 datalen)
+{
+ uint32 i, j;
+ uint8 resp_delay = 0;
+ int err = SUCCESS;
+ uint32 hostlen;
+ uint32 spilen = 0;
+ uint32 dstatus_idx = 0;
+ uint16 templen, buslen, len, *ptr = NULL;
+
+ sd_trace(("spi cmd = 0x%x\n", cmd_arg));
+
+ if (DWORDMODE_ON) {
+ spilen = GFIELD(cmd_arg, SPI_LEN);
+ if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_0) ||
+ (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_1))
+ dstatus_idx = spilen * 3;
+
+ if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) &&
+ (GFIELD(cmd_arg, SPI_RW_FLAG) == 1)) {
+ spilen = spilen << 2;
+ dstatus_idx = (spilen % 16) ? (16 - (spilen % 16)) : 0;
+ /* convert len to mod16 size */
+ spilen = ROUNDUP(spilen, 16);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, (spilen >> 2));
+ }
+ }
+
+ /* Set up and issue the SPI command. MSByte goes out on bus first. Increase datalen
+ * according to the wordlen mode(16/32bit) the device is in.
+ */
+ if (sd->wordlen == 4) { /* 32bit spid */
+ *(uint32 *)spi_outbuf = bcmswap32(cmd_arg);
+ if (datalen & 0x3)
+ datalen += (4 - (datalen & 0x3));
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ *(uint16 *)spi_outbuf = bcmswap16(cmd_arg & 0xffff);
+ *(uint16 *)&spi_outbuf[2] = bcmswap16((cmd_arg & 0xffff0000) >> 16);
+ if (datalen & 0x1)
+ datalen++;
+ if (datalen < 4)
+ datalen = ROUNDUP(datalen, 4);
+ } else {
+ sd_err(("Host is %d bit spid, could not create SPI command.\n",
+ 8 * sd->wordlen));
+ return ERROR;
+ }
+
+ /* for Write, put the data into the output buffer */
+ if (GFIELD(cmd_arg, SPI_RW_FLAG) == 1) {
+ /* We send len field of hw-header always a mod16 size, both from host and dongle */
+ if (DWORDMODE_ON) {
+ if (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) {
+ ptr = (uint16 *)&data[0];
+ templen = *ptr;
+ /* ASSERT(*ptr == ~*(ptr + 1)); */
+ templen = ROUNDUP(templen, 16);
+ *ptr = templen;
+ sd_trace(("actual tx len = %d\n", (uint16)(~*(ptr+1))));
+ }
+ }
+
+ if (datalen != 0) {
+ for (i = 0; i < datalen/4; i++) {
+ if (sd->wordlen == 4) { /* 32bit spid */
+ *(uint32 *)&spi_outbuf[i * 4 + CMDLEN] =
+ bcmswap32(data[i]);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ *(uint16 *)&spi_outbuf[i * 4 + CMDLEN] =
+ bcmswap16(data[i] & 0xffff);
+ *(uint16 *)&spi_outbuf[i * 4 + CMDLEN + 2] =
+ bcmswap16((data[i] & 0xffff0000) >> 16);
+ }
+ }
+ }
+ }
+
+ /* Append resp-delay number of bytes and clock them out for F0/1/2 reads. */
+ if (GFIELD(cmd_arg, SPI_RW_FLAG) == 0) {
+ int func = GFIELD(cmd_arg, SPI_FUNCTION);
+ switch (func) {
+ case 0:
+ resp_delay = sd->resp_delay_all ? F0_RESPONSE_DELAY : 0;
+ break;
+ case 1:
+ resp_delay = F1_RESPONSE_DELAY;
+ break;
+ case 2:
+ resp_delay = sd->resp_delay_all ? F2_RESPONSE_DELAY : 0;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ /* Program response delay */
+ bcmspi_prog_resp_delay(sd, func, resp_delay);
+ }
+
+ /* +4 for cmd and +4 for dstatus */
+ hostlen = datalen + 8 + resp_delay;
+ hostlen += dstatus_idx;
+ hostlen += (4 - (hostlen & 0x3));
+ spi_sendrecv(sd, spi_outbuf, spi_inbuf, hostlen);
+
+ /* for Read, get the data into the input buffer */
+ if (datalen != 0) {
+ if (GFIELD(cmd_arg, SPI_RW_FLAG) == 0) { /* if read cmd */
+ for (j = 0; j < datalen/4; j++) {
+ if (sd->wordlen == 4) { /* 32bit spid */
+ data[j] = bcmswap32(*(uint32 *)&spi_inbuf[j * 4 +
+ CMDLEN + resp_delay]);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ data[j] = (bcmswap16(*(uint16 *)&spi_inbuf[j * 4 +
+ CMDLEN + resp_delay])) |
+ ((bcmswap16(*(uint16 *)&spi_inbuf[j * 4 +
+ CMDLEN + resp_delay + 2])) << 16);
+ }
+ }
+
+ if ((DWORDMODE_ON) && (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2)) {
+ ptr = (uint16 *)&data[0];
+ templen = *ptr;
+ buslen = len = ~(*(ptr + 1));
+ buslen = ROUNDUP(buslen, 16);
+ /* populate actual len in hw-header */
+ if (templen == buslen)
+ *ptr = len;
+ }
+ }
+ }
+
+ /* Restore back the len field of the hw header */
+ if (DWORDMODE_ON) {
+ if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) &&
+ (GFIELD(cmd_arg, SPI_RW_FLAG) == 1)) {
+ ptr = (uint16 *)&data[0];
+ *ptr = (uint16)(~*(ptr+1));
+ }
+ }
+
+ dstatus_idx += (datalen + CMDLEN + resp_delay);
+ /* Last 4bytes are dstatus. Device is configured to return status bits. */
+ if (sd->wordlen == 4) { /* 32bit spid */
+ sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf[dstatus_idx]);
+ } else if (sd->wordlen == 2) { /* 16bit spid */
+ sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf[dstatus_idx]) |
+ (bcmswap16(*(uint16 *)&spi_inbuf[dstatus_idx + 2]) << 16));
+ } else {
+ sd_err(("Host is %d bit machine, could not read SPI dstatus.\n",
+ 8 * sd->wordlen));
+ return ERROR;
+ }
+ if (sd->card_dstatus == 0xffffffff) {
+ sd_err(("looks like not a GSPI device or device is not powered.\n"));
+ }
+
+ err = bcmspi_update_stats(sd, cmd_arg);
+
+ return err;
+
+}
+
+static int
+bcmspi_card_buf(sdioh_info_t *sd, int rw, int func, bool fifo,
+ uint32 addr, int nbytes, uint32 *data)
+{
+ int status;
+ uint32 cmd_arg;
+ bool write = rw == SDIOH_READ ? 0 : 1;
+ uint retries = 0;
+
+ bool enable;
+ uint32 spilen;
+
+ cmd_arg = 0;
+
+ ASSERT(nbytes);
+ ASSERT(nbytes <= sd->client_block_size[func]);
+
+ if (write) sd->t_cnt++; else sd->r_cnt++;
+
+ if (func == 2) {
+ /* Frame len check limited by gSPI. */
+ if ((nbytes > 2000) && write) {
+ sd_trace((">2KB write: F2 wr of %d bytes\n", nbytes));
+ }
+ /* ASSERT(nbytes <= 2048); Fix bigger len gspi issue and uncomment. */
+ /* If F2 fifo on device is not ready to receive data, don't do F2 transfer */
+ if (write) {
+ uint32 dstatus;
+ /* check F2 ready with cached one */
+ bcmspi_cmd_getdstatus(sd, &dstatus);
+ if ((dstatus & STATUS_F2_RX_READY) == 0) {
+ retries = WAIT_F2RXFIFORDY;
+ enable = 0;
+ while (retries-- && !enable) {
+ OSL_DELAY(WAIT_F2RXFIFORDY_DELAY * 1000);
+ bcmspi_card_regread(sd, SPI_FUNC_0, SPID_STATUS_REG, 4,
+ &dstatus);
+ if (dstatus & STATUS_F2_RX_READY)
+ enable = TRUE;
+ }
+ if (!enable) {
+ struct spierrstats_t *spierrstats = &sd->spierrstats;
+ spierrstats->f2rxnotready++;
+ sd_err(("F2 FIFO is not ready to receive data.\n"));
+ return ERROR;
+ }
+ sd_trace(("No of retries on F2 ready %d\n",
+ (WAIT_F2RXFIFORDY - retries)));
+ }
+ }
+ }
+
+ /* F2 transfers happen on 0 addr */
+ addr = (func == 2) ? 0 : addr;
+
+ /* In pio mode buffer is read using fixed address fifo in func 1 */
+ if ((func == 1) && (fifo))
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 0);
+ else
+ cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);
+
+ cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+ cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, addr);
+ cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, write);
+ spilen = sd->data_xfer_count = MIN(sd->client_block_size[func], nbytes);
+ if ((sd->dwordmode == TRUE) && (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2)) {
+ /* convert len to mod4 size */
+ spilen = spilen + ((spilen & 0x3) ? (4 - (spilen & 0x3)): 0);
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, (spilen >> 2));
+ } else
+ cmd_arg = SFIELD(cmd_arg, SPI_LEN, spilen);
+
+ if ((func == 2) && (fifo == 1)) {
+ sd_data(("%s: %s func %d, %s, addr 0x%x, len %d bytes, r_cnt %d t_cnt %d\n",
+ __FUNCTION__, write ? "Wr" : "Rd", func, "INCR",
+ addr, nbytes, sd->r_cnt, sd->t_cnt));
+ }
+
+ sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+ sd_data(("%s: %s func %d, %s, addr 0x%x, len %d bytes, r_cnt %d t_cnt %d\n",
+ __FUNCTION__, write ? "Wd" : "Rd", func, "INCR",
+ addr, nbytes, sd->r_cnt, sd->t_cnt));
+
+
+ if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg,
+ data, nbytes)) != SUCCESS) {
+ sd_err(("%s: cmd_issue failed for %s\n", __FUNCTION__,
+ (write ? "write" : "read")));
+ return status;
+ }
+
+ /* gSPI expects that hw-header-len is equal to spi-command-len */
+ if ((func == 2) && (rw == SDIOH_WRITE) && (sd->dwordmode == FALSE)) {
+ ASSERT((uint16)sd->data_xfer_count == (uint16)(*data & 0xffff));
+ ASSERT((uint16)sd->data_xfer_count == (uint16)(~((*data & 0xffff0000) >> 16)));
+ }
+
+ if ((nbytes > 2000) && !write) {
+ sd_trace((">2KB read: F2 rd of %d bytes\n", nbytes));
+ }
+
+ return SUCCESS;
+}
+
+/* Reset and re-initialize the device */
+int
+sdioh_sdio_reset(sdioh_info_t *si)
+{
+ si->card_init_done = FALSE;
+ return bcmspi_client_init(si);
+}
* 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,v 1.32.4.7.2.4.14.44 2010/06/03 21:27:48 Exp $
+ * $Id: dhd.h,v 1.32.4.7.2.4.14.49.4.7 2010/11/12 22:48:36 Exp $
*/
/****************
#define _dhd_h_
#if defined(LINUX)
-#if defined(CHROMIUMOS_COMPAT_WIRELESS)
-#include <linux/sched.h>
-#endif
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/spinlock.h>
#include <linux/ethtool.h>
+#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-#include <linux/wakelock.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
+
/* The kernel threading is sdio-specific */
#else /* LINUX */
#define ENOMEM 1
#include <wlioctl.h>
+#ifdef DHD_DEBUG
+#ifndef DHD_DEBUG_TRAP
+#define DHD_DEBUG_TRAP
+#endif
+#endif
/* Forward decls */
struct dhd_bus;
WAKE_LOCK_TMOUT,
WAKE_LOCK_WATCHDOG,
WAKE_LOCK_LINK_DOWN_TMOUT,
+ WAKE_LOCK_PNO_FIND_TMOUT,
WAKE_LOCK_SOFTAP_SET,
WAKE_LOCK_SOFTAP_STOP,
WAKE_LOCK_SOFTAP_START,
+ WAKE_LOCK_SOFTAP_THREAD,
WAKE_LOCK_MAX
};
enum dhd_prealloc_index {
ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
- ulong fc_packets; /* Number of flow control pkts recvd */
+ ulong fc_packets; /* Number of flow control pkts recvd */
/* Last error return */
int bcmerror;
/* Last error from dongle */
int dongle_error;
+ /* Suspend disable flag and "in suspend" flag */
+ int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
+ int in_suspend; /* flag set to 1 when early suspend called */
+#ifdef PNO_SUPPORT
+ int pno_enable; /* pno status : "1" is pno enable */
+#endif /* PNO_SUPPORT */
+ int dtim_skip; /* dtim skip , default 0 means wake each dtim */
+
/* Pkt filter defination */
char * pktfilter[100];
int pktfilter_count;
uint8 country_code[WLC_CNTRY_BUF_SZ];
char eventmask[WL_EVENTING_MASK_LEN];
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- struct wake_lock wakelock[WAKE_LOCK_MAX];
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
- struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
-#endif
} dhd_pub_t;
-
- #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
#define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
- #define _DHD_PM_RESUME_WAIT(a, b) do {\
+ #define _DHD_PM_RESUME_WAIT(a, b) do { \
int retry = 0; \
+ smp_mb(); \
while (dhd_mmc_suspend && retry++ != b) { \
- wait_event_timeout(a, FALSE, HZ/100); \
+ wait_event_interruptible_timeout(a, FALSE, HZ/100); \
} \
} while (0)
- #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 30)
+ #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 30)
#define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
#define DHD_PM_RESUME_RETURN_ERROR(a) do { if (dhd_mmc_suspend) return a; } while (0)
#define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
#define SPINWAIT_SLEEP(a, exp, us) do { \
uint countdown = (us) + 9999; \
while ((exp) && (countdown >= 10000)) { \
- wait_event_timeout(a, FALSE, HZ/100); \
+ wait_event_interruptible_timeout(a, FALSE, HZ/100); \
countdown -= 10000; \
} \
} while (0)
- #else
+#else
#define DHD_PM_RESUME_WAIT_INIT(a)
#define DHD_PM_RESUME_WAIT(a)
} \
} while (0)
- #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+
#define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
-inline static void MUTEX_LOCK_INIT(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_init(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_lock(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_unlock(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_init(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_lock(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_unlock(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-extern struct mutex g_wl_ss_scan_lock; /* lock/unlock for Scan/Cache settings */
-#endif
-
-inline static void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_init(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_WL_SCAN_SET(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_lock(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK_WL_SCAN_SET(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- mutex_unlock(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void WAKE_LOCK_INIT(dhd_pub_t * dhdp, int index, char * y)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- wake_lock_init(&dhdp->wakelock[index], WAKE_LOCK_SUSPEND, y);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- wake_lock(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_UNLOCK(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- wake_unlock(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK_TIMEOUT(dhd_pub_t * dhdp, int index, long time)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- wake_lock_timeout(&dhdp->wakelock[index], time);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK_DESTROY(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
- wake_lock_destroy(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
+/* Wakelock Functions */
+extern int dhd_os_wake_lock(dhd_pub_t *pub);
+extern int dhd_os_wake_unlock(dhd_pub_t *pub);
+extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
+extern int dhd_os_wake_lock_timeout_enable(dhd_pub_t *pub);
+extern void dhd_os_start_lock(dhd_pub_t *pub);
+extern void dhd_os_start_unlock(dhd_pub_t *pub);
+extern unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
+extern void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
typedef struct dhd_if_event {
uint8 ifidx;
extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
extern void dhd_customer_gpio_wlan_ctrl(int onoff);
-extern int dhd_custom_get_mac_address(unsigned char *buf);
+extern int dhd_custom_get_mac_address(unsigned char *buf);
extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
WLAN_POWER_ON,
WLAN_POWER_OFF
} cust_gpio_modes_t;
+
extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
+extern int net_os_send_hang_message(struct net_device *dev);
+
/*
* Insmod parameters for debug/test
*/
/* Override to force tx queueing all the time */
extern uint dhd_force_tx_queueing;
+/* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
+#define KEEP_ALIVE_PERIOD 55000
+#define NULL_PKT_STR "null_pkt"
+
#ifdef SDTEST
/* Echo packet generator (SDIO), pkts/s */
extern uint dhd_pktgen;
#define DHD_DEL_IF -0xe
#define DHD_BAD_IF -0xf
-#ifdef APSTA_PINGTEST
-#define MAX_GUEST 8
-#endif
extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
-//hojie: for wifi power control
-#define ANDROID_POWER_SAVE 1
-
-#ifndef CONFIG_BCM4319_FW_PATH
-#define CONFIG_BCM4319_FW_PATH "/etc/firmware/sdio-g-cdc-full11n-reclaim-roml-wme.bin"
-#endif
-#ifndef CONFIG_BCM4319_NVRAM_PATH
-#define CONFIG_BCM4319_NVRAM_PATH "/etc/firmware/nvram_4319_201008.txt"
-#endif
-
#endif /* _dhd_h_ */
* 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_bus.h,v 1.4.6.3.2.3.6.6 2010/05/17 18:18:13 Exp $
+ * $Id: dhd_bus.h,v 1.4.6.3.2.3.6.7 2010/08/13 01:35:24 Exp $
*/
#ifndef _dhd_bus_h_
#ifdef DHD_DEBUG
/* Device console input function */
extern int dhd_bus_console_in(dhd_pub_t *dhd, uchar *msg, uint msglen);
-#endif
+#endif /* DHD_DEBUG */
/* Deferred processing for the bus, return TRUE requests reschedule */
extern bool dhd_bus_dpc(struct dhd_bus *bus);
#include <dhd_proto.h>
#include <dhd_bus.h>
#include <dhd_dbg.h>
-#ifdef CUSTOMER_HW2
-int wifi_get_mac_addr(unsigned char *buf);
-#endif
-extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
+uint8 wlan_mac_addr[ETHER_ADDR_LEN];
+extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
/* Packet alignment for most efficient SDIO (can change based on platform) */
#ifndef DHD_SDALIGN
{
dhd_prot_t *prot = dhd->prot;
int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t);
+ int ret;
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
- /*
- * NOTE : cdc->msg.len holds the desired length of the buffer to be
+ dhd_os_wake_lock(dhd);
+
+ /* NOTE : cdc->msg.len holds the desired length of the buffer to be
* returned. Only up to CDC_MAX_MSG_SIZE of this buffer area
* is actually sent to the dongle
*/
len = CDC_MAX_MSG_SIZE;
/* Send request */
- return dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
+ ret = dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
+ dhd_os_wake_unlock(dhd);
+ return ret;
}
static int
cdc_ioctl_t *msg = &prot->msg;
int ret = 0;
uint32 flags, id;
-
+
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len));
{
dhd_prot_t *prot = dhd->prot;
int ret = -1;
-
+
if (dhd->busstate == DHD_BUS_DOWN) {
DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
return ret;
bcm_bprintf(strbuf, "Protocol CDC: reqid %d\n", dhdp->prot->reqid);
}
-#ifdef APSTA_PINGTEST
-extern struct ether_addr guest_eas[MAX_GUEST];
-#endif
void
dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, void *pktbuf)
{
#ifdef BDC
struct bdc_header *h;
-#ifdef APSTA_PINGTEST
- struct ether_header *eh;
- int i;
-#ifdef DHD_DEBUG
- char eabuf1[ETHER_ADDR_STR_LEN];
- char eabuf2[ETHER_ADDR_STR_LEN];
-#endif /* DHD_DEBUG */
-#endif /* APSTA_PINGTEST */
#endif /* BDC */
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
#ifdef BDC
/* Push BDC header used to convey priority for buses that don't */
-#ifdef APSTA_PINGTEST
- eh = (struct ether_header *)PKTDATA(dhd->osh, pktbuf);
-#endif
PKTPUSH(dhd->osh, pktbuf, BDC_HEADER_LEN);
h->priority = (PKTPRIO(pktbuf) & BDC_PRIORITY_MASK);
h->flags2 = 0;
-#ifdef APSTA_PINGTEST
- for (i = 0; i < MAX_GUEST; ++i) {
- if (!ETHER_ISNULLADDR(eh->ether_dhost) &&
- bcmp(eh->ether_dhost, guest_eas[i].octet, ETHER_ADDR_LEN) == 0) {
- DHD_TRACE(("send on if 1; sa %s, da %s\n",
- bcm_ether_ntoa((struct ether_addr *)(eh->ether_shost), eabuf1),
- bcm_ether_ntoa((struct ether_addr *)(eh->ether_dhost), eabuf2)));
- /* assume all guest STAs are on interface 1 */
- h->flags2 = 1;
- break;
- }
- }
-#endif /* APSTA_PINGTEST */
h->rssi = 0;
#endif /* BDC */
BDC_SET_IF_IDX(h, ifidx);
return ret;
}
memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);
+ memcpy(wlan_mac_addr, buf, ETHER_ADDR_LEN);
dhd_os_proto_unblock(dhd);
* 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,v 1.5.6.8.2.6.6.65 2010/07/07 00:05:07 Exp $
+ * $Id: dhd_common.c,v 1.5.6.8.2.6.6.69.4.20 2010/12/20 23:37:28 Exp $
*/
#include <typedefs.h>
#include <osl.h>
#include <dhd_dbg.h>
#include <msgtrace.h>
-
#include <wlioctl.h>
-int dhd_msg_level;
+#define CONFIG_BCM4319_FW_PATH "/system/etc/firmware/fw_bcm4319.bin"
+#define CONFIG_BCM4319_NVRAM_PATH "/system/etc/firmware/nvram.txt"
+#ifdef SET_RANDOM_MAC_SOFTAP
+#include <linux/random.h>
+#include <linux/jiffies.h>
+#endif
+
+#ifdef GET_CUSTOM_MAC_ENABLE
+int wifi_get_mac_addr(unsigned char *buf);
+#endif /* GET_CUSTOM_MAC_ENABLE */
+
+int dhd_msg_level;
-#if defined(CSCAN)
#include <wl_iw.h>
-#endif
char fw_path[MOD_PARAM_PATHLEN];
char nv_path[MOD_PARAM_PATHLEN];
void dhd_iscan_lock(void);
void dhd_iscan_unlock(void);
+#if defined(SOFTAP)
+extern bool ap_fw_loaded;
+#endif
+#if defined(KEEP_ALIVE)
+int dhd_keep_alive_onoff(dhd_pub_t *dhd, int ka_on);
+#endif /* KEEP_ALIVE */
+
/* Packet alignment for most efficient SDIO (can change based on platform) */
#ifndef DHD_SDALIGN
#define DHD_SDALIGN 32
dhd_msg_level = int_val;
break;
-
case IOV_GVAL(IOV_BCMERRORSTR):
strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror), BCME_STRLEN);
((char *)arg)[BCME_STRLEN - 1] = 0x00;
return bcmerror;
}
-#ifdef APSTA_PINGTEST
-struct ether_addr guest_eas[MAX_GUEST];
-#endif
#ifdef SHOW_EVENTS
static void
case WLC_E_ASSOC_IND:
case WLC_E_REASSOC_IND:
-#ifdef APSTA_PINGTEST
- {
- int i;
- for (i = 0; i < MAX_GUEST; ++i)
- if (ETHER_ISNULLADDR(&guest_eas[i]))
- break;
- if (i < MAX_GUEST)
- bcopy(event->addr.octet, guest_eas[i].octet, ETHER_ADDR_LEN);
- }
-#endif /* APSTA_PINGTEST */
DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf));
break;
case WLC_E_DEAUTH_IND:
case WLC_E_DISASSOC_IND:
-#ifdef APSTA_PINGTEST
- {
- int i;
- for (i = 0; i < MAX_GUEST; ++i) {
- if (bcmp(guest_eas[i].octet, event->addr.octet,
- ETHER_ADDR_LEN) == 0) {
- bzero(guest_eas[i].octet, ETHER_ADDR_LEN);
- break;
- }
- }
- }
-#endif /* APSTA_PINGTEST */
DHD_EVENT(("MACEVENT: %s, MAC %s, reason %d\n", event_name, eabuf, (int)reason));
break;
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
+#ifdef PKT_FILTER_SUPPORT
/* Convert user's input in hex pattern to byte-size mask */
static int
wl_pattern_atoh(char *src, char *dst)
if (buf)
MFREE(dhd->osh, buf, BUF_SIZE);
}
+#endif
+#ifdef ARP_OFFLOAD_SUPPORT
void
dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode)
{
DHD_TRACE(("%s: successfully enabed ARP offload to %d\n",
__FUNCTION__, arp_enable));
}
+#endif
int
dhd_preinit_ioctls(dhd_pub_t *dhd)
uint power_mode = PM_FAST;
uint32 dongle_align = DHD_SDALIGN;
uint32 glom = 0;
- uint bcn_timeout = 3;
+ uint bcn_timeout = 4;
int scan_assoc_time = 40;
- int scan_unassoc_time = 80;
-#ifdef GET_CUSTOM_MAC_ENABLE
+ int scan_unassoc_time = 40;
+ uint32 listen_interval = LISTEN_INTERVAL; /* Default Listen Interval in Beacons */
+#if defined(SOFTAP)
+ uint dtim = 1;
+#endif
int ret = 0;
+#ifdef GET_CUSTOM_MAC_ENABLE
struct ether_addr ea_addr;
#endif /* GET_CUSTOM_MAC_ENABLE */
dhd_os_proto_block(dhd);
#ifdef GET_CUSTOM_MAC_ENABLE
- /* Read MAC address from external customer place
- ** NOTE that default mac address has to be present in otp or nvram file to bring up
- ** firmware but unique per board mac address maybe provided by customer code
+ /*
+ ** Read MAC address from external customer place
+ ** NOTE that default mac address has to be present in otp or nvram file
+ ** to bring up firmware but unique per board mac address maybe provided
+ ** by customer code
*/
ret = dhd_custom_get_mac_address(ea_addr.octet);
if (!ret) {
ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
if (ret < 0) {
DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
- }
- else
+ } else
memcpy(dhd->mac.octet, (void *)&ea_addr, ETHER_ADDR_LEN);
}
-#endif /* GET_CUSTOM_MAC_ENABLE */
+#endif /* GET_CUSTOM_MAC_ENABLE */
- /*
- * Initially, country code maybe US, in this situation,
- * Just 11 channels are supported, but 13 channels should be supported
- * in China, so we change contry code to EU (Eurapor). -- Yongle Lai
- */
- strcpy(dhd->country_code, "EU");
- dhd->country_code[2] = '\0';
-
- /*
- * Set Country code.
- */
+#ifdef SET_RANDOM_MAC_SOFTAP
+ if (strstr(fw_path, "apsta") != NULL) {
+ uint rand_mac;
+
+ srandom32((uint)jiffies);
+ rand_mac = random32();
+ iovbuf[0] = 0x02; /* locally administered bit */
+ iovbuf[1] = 0x1A;
+ iovbuf[2] = 0x11;
+ iovbuf[3] = (unsigned char)(rand_mac & 0x0F) | 0xF0;
+ iovbuf[4] = (unsigned char)(rand_mac >> 8);
+ iovbuf[5] = (unsigned char)(rand_mac >> 16);
+
+ printk("Broadcom Dongle Host Driver mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
+ iovbuf[0], iovbuf[1], iovbuf[2], iovbuf[3], iovbuf[4], iovbuf[5]);
+
+ bcm_mkiovar("cur_etheraddr", (void *)iovbuf, ETHER_ADDR_LEN, buf, sizeof(buf));
+ ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
+ if (ret < 0) {
+ DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
+ } else
+ memcpy(dhd->mac.octet, iovbuf, ETHER_ADDR_LEN);
+ }
+#endif /* SET_RANDOM_MAC_SOFTAP */
+
+ /* Set Country code
+ * "US" ---> 11 channels, this is default setting.
+ * "EU" ---> 13 channels
+ * "JP" ---> 14 channels
+ */
+ strcpy(dhd->country_code, "EU");
if (dhd->country_code[0] != 0) {
if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY,
dhd->country_code, sizeof(dhd->country_code)) < 0) {
}
}
- //dhdcdc_query_ioctl(dhd, 0, WLC_GET_COUNTRY,
- // dhd->country_code, sizeof(dhd->country_code));
- //printk("============>%s: Current country code: %s\n", __func__, dhd->country_code);
-
+ /* Set Listen Interval */
+ bcm_mkiovar("assoc_listen", (char *)&listen_interval, 4, iovbuf, sizeof(iovbuf));
+ if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0)
+ DHD_ERROR(("%s assoc_listen failed %d\n", __FUNCTION__, ret));
+
/* query for 'ver' to get version info from firmware */
memset(buf, 0, sizeof(buf));
ptr = buf;
bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf));
dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+#if defined(SOFTAP)
+ if (ap_fw_loaded == TRUE) {
+ dhdcdc_set_ioctl(dhd, 0, WLC_SET_DTIMPRD, (char *)&dtim, sizeof(dtim));
+ }
+#endif
+
+ if (dhd_roam == 0)
+ {
+ /* set internal roaming roaming parameters */
+ int roam_scan_period = 30; /* in sec */
+ int roam_fullscan_period = 120; /* in sec */
+ int roam_trigger = -85;
+ int roam_delta = 15;
+ int band;
+ int band_temp_set = WLC_BAND_2G;
+
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_SCAN_PERIOD, \
+ (char *)&roam_scan_period, sizeof(roam_scan_period)) < 0)
+ DHD_ERROR(("%s: roam scan setup failed\n", __FUNCTION__));
+
+ bcm_mkiovar("fullroamperiod", (char *)&roam_fullscan_period, \
+ 4, iovbuf, sizeof(iovbuf));
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, \
+ iovbuf, sizeof(iovbuf)) < 0)
+ DHD_ERROR(("%s: roam fullscan setup failed\n", __FUNCTION__));
+
+ if (dhdcdc_query_ioctl(dhd, 0, WLC_GET_BAND, \
+ (char *)&band, sizeof(band)) < 0)
+ DHD_ERROR(("%s: roam delta setting failed\n", __FUNCTION__));
+ else {
+ if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_ALL))
+ {
+ /* temp set band to insert new roams values */
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_BAND, \
+ (char *)&band_temp_set, sizeof(band_temp_set)) < 0)
+ DHD_ERROR(("%s: local band seting failed\n", __FUNCTION__));
+ }
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_DELTA, \
+ (char *)&roam_delta, sizeof(roam_delta)) < 0)
+ DHD_ERROR(("%s: roam delta setting failed\n", __FUNCTION__));
+
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_TRIGGER, \
+ (char *)&roam_trigger, sizeof(roam_trigger)) < 0)
+ DHD_ERROR(("%s: roam trigger setting failed\n", __FUNCTION__));
+
+ /* Restore original band settinngs */
+ if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_BAND, \
+ (char *)&band, sizeof(band)) < 0)
+ DHD_ERROR(("%s: Original band restore failed\n", __FUNCTION__));
+ }
+ }
+
/* Force STA UP */
if (dhd_radio_up)
dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up));
}
#endif /* PKT_FILTER_SUPPORT */
+#if defined(KEEP_ALIVE)
+ {
+ /* Set Keep Alive : be sure to use FW with -keepalive */
+ int res;
+
+ if (ap_fw_loaded == FALSE) {
+ if ((res = dhd_keep_alive_onoff(dhd, 1)) < 0)
+ DHD_ERROR(("%s set keeplive failed %d\n", \
+ __FUNCTION__, res));
+ }
+ }
+#endif
+
dhd_os_proto_unblock(dhd);
return 0;
iscanbuf_alloc->next = NULL;
iscanbuf_head = *iscanbuf;
- DHD_ISCAN(("%s: addr of allocated node = 0x%X, addr of iscanbuf_head \
- = 0x%X dhd = 0x%X\n", __FUNCTION__, iscanbuf_alloc,
- iscanbuf_head, dhd));
+ DHD_ISCAN(("%s: addr of allocated node = 0x%X"
+ "addr of iscanbuf_head = 0x%X dhd = 0x%X\n",
+ __FUNCTION__, iscanbuf_alloc, iscanbuf_head, dhd));
if (iscanbuf_head == NULL) {
*iscanbuf = iscanbuf_alloc;
dhd_pub_t *dhd = dhd_bus_pub(dhdp);
dhd_iscan_lock();
- /* If iscan_delete is null then delete the entire
+ /* If iscan_delete is null then delete the entire
* chain or else delete specific one provided
*/
if (!iscan_delete) {
break;
if (!memcmp(bi->BSSID.octet, addr, ETHER_ADDR_LEN)) {
- DHD_ISCAN(("%s: Del BSS[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n", \
- __FUNCTION__, l, i, bi->BSSID.octet[0], \
- bi->BSSID.octet[1], bi->BSSID.octet[2], \
- bi->BSSID.octet[3], bi->BSSID.octet[4], \
+ DHD_ISCAN(("%s: Del BSS[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n",
+ __FUNCTION__, l, i, bi->BSSID.octet[0],
+ bi->BSSID.octet[1], bi->BSSID.octet[2],
+ bi->BSSID.octet[3], bi->BSSID.octet[4],
bi->BSSID.octet[5]));
bi_new = bi;
for (j = i; j < results->count; j++) {
if (bi && bi_new) {
- DHD_ISCAN(("%s: Moved up BSS[%2.2d:%2.2d] \
- %X:%X:%X:%X:%X:%X\n",
+ DHD_ISCAN(("%s: Moved up BSS[%2.2d:%2.2d]"
+ "%X:%X:%X:%X:%X:%X\n",
__FUNCTION__, l, j, bi->BSSID.octet[0],
bi->BSSID.octet[1], bi->BSSID.octet[2],
bi->BSSID.octet[3], bi->BSSID.octet[4],
return status;
}
-#endif
+#endif
+
+/* Function to estimate possible DTIM_SKIP value */
+int dhd_get_dtim_skip(dhd_pub_t *dhd)
+{
+ int bcn_li_dtim;
+ char buf[128];
+ int ret;
+ int dtim_assoc = 0;
+
+ if ((dhd->dtim_skip == 0) || (dhd->dtim_skip == 1))
+ bcn_li_dtim = 3;
+ else
+ bcn_li_dtim = dhd->dtim_skip;
+
+ /* Read DTIM value if associated */
+ memset(buf, 0, sizeof(buf));
+ bcm_mkiovar("dtim_assoc", 0, 0, buf, sizeof(buf));
+ if ((ret = dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf))) < 0) {
+ DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+ bcn_li_dtim = 1;
+ goto exit;
+ }
+ else
+ dtim_assoc = dtoh32(*(int *)buf);
+
+ DHD_ERROR(("%s bcn_li_dtim=%d DTIM=%d Listen=%d\n", \
+ __FUNCTION__, bcn_li_dtim, dtim_assoc, LISTEN_INTERVAL));
+
+ /* if not assocated just eixt */
+ if (dtim_assoc == 0) {
+ goto exit;
+ }
+
+ /* check if sta listen interval fits into AP dtim */
+ if (dtim_assoc > LISTEN_INTERVAL) {
+ /* AP DTIM to big for our Listen Interval : no dtim skiping */
+ bcn_li_dtim = 1;
+ DHD_ERROR(("%s DTIM=%d > Listen=%d : too big ...\n", \
+ __FUNCTION__, dtim_assoc, LISTEN_INTERVAL));
+ goto exit;
+ }
+
+ if ((bcn_li_dtim * dtim_assoc) > LISTEN_INTERVAL) {
+ /* Round up dtim_skip to fit into STAs Listen Interval */
+ bcn_li_dtim = (int)(LISTEN_INTERVAL / dtim_assoc);
+ DHD_TRACE(("%s agjust dtim_skip as %d\n", __FUNCTION__, bcn_li_dtim));
+ }
+
+exit:
+ return bcn_li_dtim;
+}
+
+#ifdef PNO_SUPPORT
+int dhd_pno_clean(dhd_pub_t *dhd)
+{
+ char iovbuf[128];
+ int pfn_enabled = 0;
+ int iov_len = 0;
+ int ret;
+
+ /* Disable pfn */
+ iov_len = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf));
+ if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) >= 0) {
+ /* clear pfn */
+ iov_len = bcm_mkiovar("pfnclear", 0, 0, iovbuf, sizeof(iovbuf));
+ if (iov_len) {
+ if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0) {
+ DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+ }
+ }
+ else {
+ ret = -1;
+ DHD_ERROR(("%s failed code %d\n", __FUNCTION__, iov_len));
+ }
+ }
+ else
+ DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+
+ return ret;
+}
+
+int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
+{
+ char iovbuf[128];
+ int ret = -1;
+
+ if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) {
+ DHD_ERROR(("%s error exit\n", __FUNCTION__));
+ return ret;
+ }
+
+ /* Enable/disable PNO */
+ if ((ret = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf))) > 0) {
+ if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0) {
+ DHD_ERROR(("%s failed for error=%d\n", __FUNCTION__, ret));
+ return ret;
+ }
+ else {
+ dhd->pno_enable = pfn_enabled;
+ DHD_TRACE(("%s set pno as %d\n", __FUNCTION__, dhd->pno_enable));
+ }
+ }
+ else DHD_ERROR(("%s failed err=%d\n", __FUNCTION__, ret));
+
+ return ret;
+}
+
+/* Function to execute combined scan */
+int
+dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid, ushort scan_fr)
+{
+ int err = -1;
+ char iovbuf[128];
+ int k, i;
+ wl_pfn_param_t pfn_param;
+ wl_pfn_t pfn_element;
+
+ DHD_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, scan_fr));
+
+ if ((!dhd) && (!ssids_local)) {
+ DHD_ERROR(("%s error exit\n", __FUNCTION__));
+ err = -1;
+ }
+
+ /* Check for broadcast ssid */
+ for (k = 0; k < nssid; k++) {
+ if (!ssids_local[k].SSID_len) {
+ DHD_ERROR(("%d: Broadcast SSID is ilegal for PNO setting\n", k));
+ return err;
+ }
+ }
+/* #define PNO_DUMP 1 */
+#ifdef PNO_DUMP
+ {
+ int j;
+ for (j = 0; j < nssid; j++) {
+ DHD_ERROR(("%d: scan for %s size =%d\n", j,
+ ssids_local[j].SSID, ssids_local[j].SSID_len));
+ }
+ }
+#endif /* PNO_DUMP */
+
+ /* clean up everything */
+ if ((err = dhd_pno_clean(dhd)) < 0) {
+ DHD_ERROR(("%s failed error=%d\n", __FUNCTION__, err));
+ return err;
+ }
+ memset(&pfn_param, 0, sizeof(pfn_param));
+ memset(&pfn_element, 0, sizeof(pfn_element));
+
+ /* set pfn parameters */
+ pfn_param.version = htod32(PFN_VERSION);
+ pfn_param.flags = htod16((PFN_LIST_ORDER << SORT_CRITERIA_BIT));
+
+ /* set up pno scan fr */
+ if (scan_fr != 0)
+ pfn_param.scan_freq = htod32(scan_fr);
+
+ if (pfn_param.scan_freq > PNO_SCAN_MAX_FW) {
+ DHD_ERROR(("%s pno freq above %d sec\n", __FUNCTION__, PNO_SCAN_MAX_FW));
+ return err;
+ }
+
+ bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf, sizeof(iovbuf));
+ dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+
+ /* set all pfn ssid */
+ for (i = 0; i < nssid; i++) {
+
+ pfn_element.bss_type = htod32(DOT11_BSSTYPE_INFRASTRUCTURE);
+ pfn_element.auth = (DOT11_OPEN_SYSTEM);
+ pfn_element.wpa_auth = htod32(WPA_AUTH_PFN_ANY);
+ pfn_element.wsec = htod32(0);
+ pfn_element.infra = htod32(1);
+
+ memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID, ssids_local[i].SSID_len);
+ pfn_element.ssid.SSID_len = ssids_local[i].SSID_len;
+
+ if ((err =
+ bcm_mkiovar("pfn_add", (char *)&pfn_element,
+ sizeof(pfn_element), iovbuf, sizeof(iovbuf))) > 0) {
+ if ((err =
+ dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0) {
+ DHD_ERROR(("%s failed for i=%d error=%d\n",
+ __FUNCTION__, i, err));
+ return err;
+ }
+ else
+ DHD_ERROR(("%s set OK with PNO time=%d\n", __FUNCTION__, \
+ pfn_param.scan_freq));
+ }
+ else DHD_ERROR(("%s failed err=%d\n", __FUNCTION__, err));
+ }
+
+ /* Enable PNO */
+ /* dhd_pno_enable(dhd, 1); */
+ return err;
+}
+
+int dhd_pno_get_status(dhd_pub_t *dhd)
+{
+ int ret = -1;
+
+ if (!dhd)
+ return ret;
+ else
+ return (dhd->pno_enable);
+}
+
+#endif /* PNO_SUPPORT */
+
+#if defined(KEEP_ALIVE)
+int dhd_keep_alive_onoff(dhd_pub_t *dhd, int ka_on)
+{
+ char buf[256];
+ char *buf_ptr = buf;
+ wl_keep_alive_pkt_t keep_alive_pkt;
+ char * str;
+ int str_len, buf_len;
+ int res = 0;
+ int keep_alive_period = KEEP_ALIVE_PERIOD; /* in ms */
+
+ DHD_TRACE(("%s: ka:%d\n", __FUNCTION__, ka_on));
+
+ if (ka_on) { /* on suspend */
+ keep_alive_pkt.period_msec = keep_alive_period;
+
+ } else {
+ /* on resume, turn off keep_alive packets */
+ keep_alive_pkt.period_msec = 0;
+ }
+
+ /* IOC var name */
+ str = "keep_alive";
+ str_len = strlen(str);
+ strncpy(buf, str, str_len);
+ buf[str_len] = '\0';
+ buf_len = str_len + 1;
+
+ /* set ptr to IOCTL payload after the var name */
+ buf_ptr += buf_len; /* include term Z */
+
+ /* copy Keep-alive attributes from local var keep_alive_pkt */
+ str = NULL_PKT_STR;
+ keep_alive_pkt.len_bytes = strlen(str);
+
+ memcpy(buf_ptr, &keep_alive_pkt, WL_KEEP_ALIVE_FIXED_LEN);
+ buf_ptr += WL_KEEP_ALIVE_FIXED_LEN;
+
+ /* copy packet data */
+ memcpy(buf_ptr, str, keep_alive_pkt.len_bytes);
+ buf_len += (WL_KEEP_ALIVE_FIXED_LEN + keep_alive_pkt.len_bytes);
+
+ res = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len);
+ return res;
+}
+#endif /* defined(KEEP_ALIVE) */
-/* Android ComboSCAN support */
#if defined(CSCAN)
+/* Androd ComboSCAN support */
/*
* data parsing from ComboScan tlv list
*/
int
-wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token, \
- int input_size, int *bytes_left)
+wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token,
+ int input_size, int *bytes_left)
{
char* str = *list_str;
uint16 short_temp;
while (*bytes_left > 0) {
if (str[0] != token) {
- DHD_TRACE(("%s NOT Type=%d get=%d left_parse=%d \n", __FUNCTION__, \
- token, str[0], *bytes_left));
+ DHD_TRACE(("%s NOT Type=%d get=%d left_parse=%d \n",
+ __FUNCTION__, token, str[0], *bytes_left));
return -1;
}
memcpy(dst, str, input_size);
}
else if (input_size == 2) {
- memcpy(dst, (char *)htod16(memcpy(&short_temp, str, input_size)), \
- input_size);
+ memcpy(dst, (char *)htod16(memcpy(&short_temp, str, input_size)),
+ input_size);
}
else if (input_size == 4) {
- memcpy(dst, (char *)htod32(memcpy(&int_temp, str, input_size)), \
+ memcpy(dst, (char *)htod32(memcpy(&int_temp, str, input_size)),
input_size);
}
* channel list parsing from cscan tlv list
*/
int
-wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list, \
- int channel_num, int *bytes_left)
+wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list,
+ int channel_num, int *bytes_left)
{
char* str = *list_str;
int idx = 0;
/* Get SSID */
if (ssid[idx].SSID_len > *bytes_left) {
- DHD_ERROR(("%s out of memory range len=%d but left=%d\n", \
+ DHD_ERROR(("%s out of memory range len=%d but left=%d\n",
__FUNCTION__, ssid[idx].SSID_len, *bytes_left));
return -1;
}
*bytes_left -= ssid[idx].SSID_len;
str += ssid[idx].SSID_len;
- DHD_TRACE(("%s :size=%d left=%d\n", (char*)ssid[idx].SSID, \
- ssid[idx].SSID_len, *bytes_left));
+ DHD_TRACE(("%s :size=%d left=%d\n",
+ (char*)ssid[idx].SSID, ssid[idx].SSID_len, *bytes_left));
}
else {
DHD_ERROR(("### SSID size more that %d\n", str[0]));
return num;
}
-#endif
+#endif
* 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_custom_gpio.c,v 1.1.4.7 2010/06/03 21:27:48 Exp $
+* $Id: dhd_custom_gpio.c,v 1.1.4.8.4.1 2010/09/02 23:13:16 Exp $
*/
#include <wlioctl.h>
#include <wl_iw.h>
-#include <dhd_dbg.h>
-#define WL_ERROR(x) DHD_ERROR(x)
+#define WL_ERROR(x) printf x
#define WL_TRACE(x)
#ifdef CUSTOMER_HW
int wifi_set_carddetect(int on);
int wifi_set_power(int on, unsigned long msec);
int wifi_get_irq_number(unsigned long *irq_flags_ptr);
+int wifi_get_mac_addr(unsigned char *buf);
#endif
#if defined(OOB_INTR_ONLY)
dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
}
#endif
- *irq_flags_ptr = IRQF_TRIGGER_FALLING;
+
if (dhd_oob_gpio_num < 0) {
WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
__FUNCTION__));
__FUNCTION__));
#ifdef CUSTOMER_HW
bcm_wlan_power_on(1);
-#endif /* CUSTOMER_HW */
/* Lets customer power to get stable */
- OSL_DELAY(500);
+ OSL_DELAY(50);
+#endif /* CUSTOMER_HW */
break;
}
}
int
dhd_custom_get_mac_address(unsigned char *buf)
{
+ int ret = 0;
+
WL_TRACE(("%s Enter\n", __FUNCTION__));
if (!buf)
return -EINVAL;
/* Customer access to MAC address stored outside of DHD driver */
+#ifdef CUSTOMER_HW2
+ ret = wifi_get_mac_addr(buf);
+#endif
#ifdef EXAMPLE_GET_MAC
/* EXAMPLE code */
}
#endif /* EXAMPLE_GET_MAC */
- return 0;
+ return ret;
}
#endif /* GET_CUSTOM_MAC_ENABLE */
#ifndef _dhd_dbg_
#define _dhd_dbg_
-#if 0 || (defined DHD_DEBUG)
+#ifdef DHD_DEBUG
#define DHD_ERROR(args) do {if ((dhd_msg_level & DHD_ERROR_VAL) && (net_ratelimit())) \
printf args;} while (0)
#define DHD_BTA_ON() (dhd_msg_level & DHD_BTA_VAL)
#define DHD_ISCAN_ON() (dhd_msg_level & DHD_ISCAN_VAL)
-#else /* (defined BCMDBG) || (defined DHD_DEBUG) */
+#else /* DHD_DEBUG */
#define DHD_ERROR(args) do {if (net_ratelimit()) printf args;} while (0)
#define DHD_TRACE(args)
#define DHD_EVENT_ON() 0
#define DHD_BTA_ON() 0
#define DHD_ISCAN_ON() 0
-#endif
+#endif /* DHD_DEBUG */
#define DHD_LOG(args)
* 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,v 1.65.4.9.2.12.2.89 2010/07/21 18:07:11 Exp $
+ * $Id: dhd_linux.c,v 1.65.4.9.2.12.2.104.4.35 2010/11/17 03:13:21 Exp $
*/
-
-#ifdef CONFIG_WIFI_CONTROL_FUNC_BCM4319
+#ifdef CONFIG_WIFI_CONTROL_FUNC
#include <linux/platform_device.h>
#endif
#include <typedefs.h>
#include <asm/uaccess.h>
#include <asm/unaligned.h>
+#include <wifi_version.h>
#include <epivers.h>
#include <bcmutils.h>
#include <bcmendian.h>
#include <dhd_bus.h>
#include <dhd_proto.h>
#include <dhd_dbg.h>
+#include <wl_iw.h>
+#ifdef CONFIG_HAS_WAKELOCK
+#include <linux/wakelock.h>
+#endif
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
+//#include <linux/wlan_plat.h>
+#include <mach/board.h>
+
+struct semaphore wifi_control_sem;
+
+struct dhd_bus *g_bus;
+
+extern void bcm4329_power_save_exit(void);
+extern void bcm4329_power_save_init(void);
+
+static struct wifi_platform_data *wifi_control_data = NULL;
+static struct resource *wifi_irqres = NULL;
+
+int wifi_get_irq_number(unsigned long *irq_flags_ptr)
+{
+ if (wifi_irqres) {
+ *irq_flags_ptr = wifi_irqres->flags & IRQF_TRIGGER_MASK;
+ return (int)wifi_irqres->start;
+ }
+#ifdef CUSTOM_OOB_GPIO_NUM
+ return CUSTOM_OOB_GPIO_NUM;
+#else
+ return -1;
+#endif
+}
+
+int wifi_set_carddetect(int on)
+{
+ printk("%s = %d\n", __FUNCTION__, on);
+ if (wifi_control_data && wifi_control_data->set_carddetect) {
+ wifi_control_data->set_carddetect(on);
+ }
+ return 0;
+}
+
+int wifi_set_power(int on, unsigned long msec)
+{
+ printk("%s = %d\n", __FUNCTION__, on);
+ if (wifi_control_data && wifi_control_data->set_power) {
+ wifi_control_data->set_power(on);
+ }
+ if (msec)
+ mdelay(msec);
+ return 0;
+}
+
+int wifi_set_reset(int on, unsigned long msec)
+{
+ DHD_TRACE(("%s = %d\n", __FUNCTION__, on));
+ if (wifi_control_data && wifi_control_data->set_reset) {
+ wifi_control_data->set_reset(on);
+ }
+ if (msec)
+ mdelay(msec);
+ return 0;
+}
+
+int wifi_get_mac_addr(unsigned char *buf)
+{
+ DHD_TRACE(("%s\n", __FUNCTION__));
+ if (!buf)
+ return -EINVAL;
+ if (wifi_control_data && wifi_control_data->get_mac_addr) {
+ return wifi_control_data->get_mac_addr(buf);
+ }
+ return -EOPNOTSUPP;
+}
+
+static int wifi_probe(struct platform_device *pdev)
+{
+ struct wifi_platform_data *wifi_ctrl =
+ (struct wifi_platform_data *)(pdev->dev.platform_data);
+
+ DHD_TRACE(("## %s\n", __FUNCTION__));
+ wifi_irqres = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcm4329_wlan_irq");
+ wifi_control_data = wifi_ctrl;
+
+ /* make sure power-off */
+ wifi_set_reset(0, 5);
+ wifi_set_power(0, 5);
+
+ wifi_set_power(1, 50); /* Power On */
+ wifi_set_reset(1, 150); /* Reset */
+ wifi_set_carddetect(1); /* CardDetect (0->1) */
+
+ up(&wifi_control_sem);
+ return 0;
+}
+
+static int wifi_remove(struct platform_device *pdev)
+{
+ struct wifi_platform_data *wifi_ctrl =
+ (struct wifi_platform_data *)(pdev->dev.platform_data);
+
+ DHD_TRACE(("## %s\n", __FUNCTION__));
+ wifi_control_data = wifi_ctrl;
+
+ wifi_set_reset(0, 5); /* Reset */
+ wifi_set_power(0, 5); /* Power Off */
+ wifi_set_carddetect(0); /* CardDetect (1->0) */
+
+ up(&wifi_control_sem);
+ return 0;
+}
+static int wifi_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ DHD_TRACE(("##> %s\n", __FUNCTION__));
+ return 0;
+}
+static int wifi_resume(struct platform_device *pdev)
+{
+ DHD_TRACE(("##> %s\n", __FUNCTION__));
+ return 0;
+}
+
+static struct platform_driver wifi_device = {
+ .probe = wifi_probe,
+ .remove = wifi_remove,
+ .suspend = wifi_suspend,
+ .resume = wifi_resume,
+ .driver = {
+ .name = "bcm4329_wlan",
+ }
+};
+
+int wifi_add_dev(void)
+{
+ DHD_TRACE(("## Calling platform_driver_register\n"));
+ return platform_driver_register(&wifi_device);
+}
-#include <linux/mmc/card.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/host.h>
+void wifi_del_dev(void)
+{
+ DHD_TRACE(("## Unregister platform_driver_register\n"));
+ platform_driver_unregister(&wifi_device);
+}
+#endif /* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
-int wifi_func_removed = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
#include <linux/suspend.h>
#include <wl_iw.h>
#endif /* defined(CONFIG_WIRELESS_EXT) */
+extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
+
#if defined(CONFIG_HAS_EARLYSUSPEND)
#include <linux/earlysuspend.h>
-extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
+#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+
+#ifdef PKT_FILTER_SUPPORT
extern void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg);
extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
-#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+#endif
/* Interface control information */
typedef struct dhd_if {
/* OS/stack specifics */
dhd_if_t *iflist[DHD_MAX_IFS];
- struct semaphore proto_sem;
+ struct mutex proto_sem;
wait_queue_head_t ioctl_resp_wait;
struct timer_list timer;
bool wd_timer_valid;
struct tasklet_struct tasklet;
spinlock_t sdlock;
spinlock_t txqlock;
+ spinlock_t dhd_lock;
+
/* Thread based operation */
bool threads_only;
- struct semaphore sdsem;
+ struct mutex sdsem;
long watchdog_pid;
struct semaphore watchdog_sem;
struct completion watchdog_exited;
struct semaphore dpc_sem;
struct completion dpc_exited;
+ /* Wakelocks */
+#ifdef CONFIG_HAS_WAKELOCK
+ struct wake_lock wl_wifi; /* Wifi wakelock */
+ struct wake_lock wl_rxwake; /* Wifi rx wakelock */
+#endif
+ spinlock_t wl_lock;
+ int wl_count;
+ int wl_packet;
+
+ int hang_was_sent; /* flag that message was send at least once */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+ struct mutex wl_start_lock; /* mutex when START called to prevent any other Linux calls */
+#endif
/* Thread to issue ioctl for multicast */
long sysioc_pid;
struct semaphore sysioc_sem;
/* Definitions to provide path to the firmware and nvram
* example nvram_path[MOD_PARAM_PATHLEN]="/projects/wlan/nvram.txt"
*/
-char firmware_path[MOD_PARAM_PATHLEN] = "/etc/firmware/sdio-g-cdc-full11n-reclaim-roml-wme.bin";
-char nvram_path[MOD_PARAM_PATHLEN] = "/etc/firmware/nvram_4319_201008.txt";
+char firmware_path[MOD_PARAM_PATHLEN];
+char nvram_path[MOD_PARAM_PATHLEN];
-extern int wl_control_wl_start(struct net_device *dev);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
struct semaphore dhd_registration_sem;
-#define DHD_REGISTRATION_TIMEOUT 8000 /* msec : allowed time to finished dhd registration */
+#define DHD_REGISTRATION_TIMEOUT 12000 /* msec : allowed time to finished dhd registration */
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
/* load firmware and/or nvram values from the filesystem */
module_param_string(firmware_path, firmware_path, MOD_PARAM_PATHLEN, 0);
extern int dhd_dongle_memsize;
module_param(dhd_dongle_memsize, int, 0);
-/* Contorl fw roaming */
+/* Control fw roaming */
#ifdef CUSTOMER_HW2
uint dhd_roam = 0;
#else
uint dhd_radio_up = 1;
/* Network inteface name */
-char iface_name[IFNAMSIZ];
+char iface_name[IFNAMSIZ] = "wlan0";
module_param_string(iface_name, iface_name, IFNAMSIZ, 0);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
module_param(dhd_pktgen_len, uint, 0);
#endif
-
/* Version string to report */
#ifdef DHD_DEBUG
+#ifndef SRCBASE
+#define SRCBASE "drivers/net/wireless/bcm4329"
+#endif
#define DHD_COMPILED "\nCompiled in " SRCBASE
#else
#define DHD_COMPILED
static int dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
wl_event_msg_t *event_ptr, void **data_ptr);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
static int dhd_sleep_pm_callback(struct notifier_block *nfb, unsigned long action, void *ignored)
{
- switch (action)
- {
- case PM_HIBERNATION_PREPARE:
- case PM_SUSPEND_PREPARE:
- dhd_mmc_suspend = TRUE;
- return NOTIFY_OK;
- case PM_POST_HIBERNATION:
- case PM_POST_SUSPEND:
- dhd_mmc_suspend = FALSE;
- return NOTIFY_OK;
+ int ret = NOTIFY_DONE;
+
+ switch (action) {
+ case PM_HIBERNATION_PREPARE:
+ case PM_SUSPEND_PREPARE:
+ dhd_mmc_suspend = TRUE;
+ ret = NOTIFY_OK;
+ break;
+ case PM_POST_HIBERNATION:
+ case PM_POST_SUSPEND:
+ dhd_mmc_suspend = FALSE;
+ ret = NOTIFY_OK;
+ break;
}
- return 0;
+ smp_mb();
+ return ret;
}
static struct notifier_block dhd_sleep_pm_notifier = {
extern int register_pm_notifier(struct notifier_block *nb);
extern int unregister_pm_notifier(struct notifier_block *nb);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
- /* && defined(DHD_GPL) */
+static void dhd_set_packet_filter(int value, dhd_pub_t *dhd)
+{
+#ifdef PKT_FILTER_SUPPORT
+ DHD_TRACE(("%s: %d\n", __FUNCTION__, value));
+ /* 1 - Enable packet filter, only allow unicast packet to send up */
+ /* 0 - Disable packet filter */
+ if (dhd_pkt_filter_enable) {
+ int i;
-#if defined(CONFIG_HAS_EARLYSUSPEND)
+ for (i = 0; i < dhd->pktfilter_count; i++) {
+ dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
+ dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
+ value, dhd_master_mode);
+ }
+ }
+#endif
+}
-int dhd_set_suspend(int value, dhd_pub_t *dhd)
+
+
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+static int dhd_set_suspend(int value, dhd_pub_t *dhd)
{
int power_mode = PM_MAX;
/* wl_pkt_filter_enable_t enable_parm; */
#ifdef CUSTOMER_HW2
uint roamvar = 1;
#endif /* CUSTOMER_HW2 */
- int i;
-#define htod32(i) i
+ DHD_TRACE(("%s: enter, value = %d in_suspend = %d\n",
+ __FUNCTION__, value, dhd->in_suspend));
if (dhd && dhd->up) {
- dhd_os_proto_block(dhd);
- if (value) {
+ if (value && dhd->in_suspend) {
/* Kernel suspended */
+ DHD_TRACE(("%s: force extra Suspend setting \n", __FUNCTION__));
+
dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM,
(char *)&power_mode, sizeof(power_mode));
/* Enable packet filter, only allow unicast packet to send up */
- if (dhd_pkt_filter_enable) {
- for (i = 0; i < dhd->pktfilter_count; i++) {
- dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
- dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
- 1, dhd_master_mode);
- }
- }
+ dhd_set_packet_filter(1, dhd);
- /* set bcn_li_dtim */
+ /* if dtim skip setup as default force it to wake each thrid dtim
+ * for better power saving.
+ * Note that side effect is chance to miss BC/MC packet
+ */
+ bcn_li_dtim = dhd_get_dtim_skip(dhd);
bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
4, iovbuf, sizeof(iovbuf));
dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
#ifdef CUSTOMER_HW2
- /* Disable build-in roaming to allowed ext supplicant to take of romaing */
+ /* Disable build-in roaming during suspend */
bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
#endif /* CUSTOMER_HW2 */
+
} else {
/* Kernel resumed */
+ DHD_TRACE(("%s: Remove extra suspend setting \n", __FUNCTION__));
+
power_mode = PM_FAST;
dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode,
sizeof(power_mode));
/* disable pkt filter */
- if (dhd_pkt_filter_enable) {
- for (i = 0; i < dhd->pktfilter_count; i++) {
- dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
- dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
- 0, dhd_master_mode);
- }
- }
+ dhd_set_packet_filter(0, dhd);
- /* set bcn_li_dtim */
- bcn_li_dtim = 0;
- bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
+ /* restore pre-suspend setting for dtim_skip */
+ bcm_mkiovar("bcn_li_dtim", (char *)&dhd->dtim_skip,
4, iovbuf, sizeof(iovbuf));
+
dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
#ifdef CUSTOMER_HW2
- roamvar = 0;
+ roamvar = dhd_roam;
bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
#endif /* CUSTOMER_HW2 */
}
- dhd_os_proto_unblock(dhd);
}
return 0;
}
+static void dhd_suspend_resume_helper(struct dhd_info *dhd, int val)
+{
+ dhd_pub_t *dhdp = &dhd->pub;
+
+ dhd_os_wake_lock(dhdp);
+ dhd_os_proto_block(dhdp);
+ /* Set flag when early suspend was called */
+ dhdp->in_suspend = val;
+ if (!dhdp->suspend_disable_flag)
+ dhd_set_suspend(val, dhdp);
+ dhd_os_proto_unblock(dhdp);
+ dhd_os_wake_unlock(dhdp);
+}
+
static void dhd_early_suspend(struct early_suspend *h)
{
- struct dhd_info *dhdp;
- dhdp = container_of(h, struct dhd_info, early_suspend);
+ struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
DHD_TRACE(("%s: enter\n", __FUNCTION__));
- dhd_set_suspend(1, &dhdp->pub);
+ if (dhd)
+ dhd_suspend_resume_helper(dhd, 1);
}
static void dhd_late_resume(struct early_suspend *h)
{
- struct dhd_info *dhdp;
- dhdp = container_of(h, struct dhd_info, early_suspend);
+ struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
DHD_TRACE(("%s: enter\n", __FUNCTION__));
- dhd_set_suspend(0, &dhdp->pub);
+ if (dhd)
+ dhd_suspend_resume_helper(dhd, 0);
}
#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
_dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
{
struct net_device *dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+ struct netdev_hw_addr *ha;
+#else
struct dev_mc_list *mclist;
+#endif
uint32 allmulti, cnt;
wl_ioctl_t ioc;
ASSERT(dhd && dhd->iflist[ifidx]);
dev = dhd->iflist[ifidx]->net;
- mclist = dev->mc_list;
+
+ netif_addr_lock_bh(dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+ cnt = netdev_mc_count(dev);
+#else
cnt = dev->mc_count;
+#endif
+ netif_addr_unlock_bh(dev);
/* Determine initial value of allmulti flag */
allmulti = (dev->flags & IFF_ALLMULTI) ? TRUE : FALSE;
/* Send down the multicast list first. */
-
-
buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETHER_ADDR_LEN);
if (!(bufp = buf = MALLOC(dhd->pub.osh, buflen))) {
DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
memcpy(bufp, &cnt, sizeof(cnt));
bufp += sizeof(cnt);
- for (cnt = 0; mclist && (cnt < dev->mc_count); cnt++, mclist = mclist->next) {
+ netif_addr_lock_bh(dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+ netdev_for_each_mc_addr(ha, dev) {
+ if (!cnt)
+ break;
+ memcpy(bufp, ha->addr, ETHER_ADDR_LEN);
+ bufp += ETHER_ADDR_LEN;
+ cnt--;
+ }
+#else
+ for (mclist = dev->mc_list;(mclist && (cnt > 0)); cnt--, mclist = mclist->next) {
memcpy(bufp, (void *)mclist->dmi_addr, ETHER_ADDR_LEN);
bufp += ETHER_ADDR_LEN;
}
+#endif
+ netif_addr_unlock_bh(dev);
memset(&ioc, 0, sizeof(ioc));
ioc.cmd = WLC_SET_VAR;
#ifdef SOFTAP
extern struct net_device *ap_net_dev;
+/* semaphore that the soft AP CODE waits on */
+extern struct semaphore ap_eth_sema;
#endif
static void
dhd_op_if(dhd_if_t *ifp)
{
- dhd_info_t *dhd;
- int ret = 0, err = 0;
+ dhd_info_t *dhd;
+ int ret = 0, err = 0;
+#ifdef SOFTAP
+ unsigned long flags;
+#endif
ASSERT(ifp && ifp->info && ifp->idx); /* Virtual interfaces only */
ret = -EOPNOTSUPP;
} else {
#ifdef SOFTAP
- /* semaphore that the soft AP CODE waits on */
- extern struct semaphore ap_eth_sema;
-
+ flags = dhd_os_spin_lock(&dhd->pub);
/* save ptr to wl0.1 netdev for use in wl_iw.c */
ap_net_dev = ifp->net;
/* signal to the SOFTAP 'sleeper' thread, wl0.1 is ready */
up(&ap_eth_sema);
+ dhd_os_spin_unlock(&dhd->pub, flags);
#endif
DHD_TRACE(("\n ==== pid:%x, net_device for if:%s created ===\n\n",
current->pid, ifp->net->name));
break;
case WLC_E_IF_DEL:
if (ifp->net != NULL) {
- DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n", __FUNCTION__));
+ DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n", __FUNCTION__));
netif_stop_queue(ifp->net);
unregister_netdev(ifp->net);
ret = DHD_DEL_IF; /* Make sure the free_netdev() is called */
dhd->iflist[ifp->idx] = NULL;
MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
#ifdef SOFTAP
+ flags = dhd_os_spin_lock(&dhd->pub);
if (ifp->net == ap_net_dev)
- ap_net_dev = NULL; /* NULL SOFTAP global wl0.1 as well */
+ ap_net_dev = NULL; /* NULL SOFTAP global as well */
+ dhd_os_spin_unlock(&dhd->pub, flags);
#endif /* SOFTAP */
}
}
int i;
#ifdef SOFTAP
bool in_ap = FALSE;
+ unsigned long flags;
#endif
DAEMONIZE("dhd_sysioc");
while (down_interruptible(&dhd->sysioc_sem) == 0) {
+ dhd_os_start_lock(&dhd->pub);
+ dhd_os_wake_lock(&dhd->pub);
for (i = 0; i < DHD_MAX_IFS; i++) {
if (dhd->iflist[i]) {
+ DHD_TRACE(("%s: interface %d\n",__FUNCTION__, i));
#ifdef SOFTAP
+ flags = dhd_os_spin_lock(&dhd->pub);
in_ap = (ap_net_dev != NULL);
+ dhd_os_spin_unlock(&dhd->pub, flags);
#endif /* SOFTAP */
if (dhd->iflist[i]->state)
dhd_op_if(dhd->iflist[i]);
#ifdef SOFTAP
if (dhd->iflist[i] == NULL) {
- DHD_TRACE(("\n\n %s: interface %d just been removed,"
- "!\n\n", __FUNCTION__, i));
+ DHD_TRACE(("%s: interface %d just been removed!\n\n", __FUNCTION__, i));
continue;
}
- if (in_ap && dhd->set_macaddress) {
- DHD_TRACE(("attempt to set MAC for %s in AP Mode,"
- "blocked. \n", dhd->iflist[i]->net->name));
+ if (in_ap && dhd->set_macaddress) {
+ DHD_TRACE(("attempt to set MAC for %s in AP Mode blocked.\n", dhd->iflist[i]->net->name));
dhd->set_macaddress = FALSE;
continue;
}
if (in_ap && dhd->set_multicast) {
- DHD_TRACE(("attempt to set MULTICAST list for %s"
- "in AP Mode, blocked. \n", dhd->iflist[i]->net->name));
+ DHD_TRACE(("attempt to set MULTICAST list for %s in AP Mode blocked.\n", dhd->iflist[i]->net->name));
dhd->set_multicast = FALSE;
continue;
}
}
}
}
+ dhd_os_wake_unlock(&dhd->pub);
+ dhd_os_start_unlock(&dhd->pub);
}
+ DHD_TRACE(("%s: stopped\n",__FUNCTION__));
complete_and_exit(&dhd->sysioc_exited, 0);
}
struct sockaddr *sa = (struct sockaddr *)addr;
int ifidx;
+ DHD_TRACE(("%s: Enter\n",__FUNCTION__));
ifidx = dhd_net2idx(dhd, dev);
if (ifidx == DHD_BAD_IF)
return -1;
dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
int ifidx;
+ DHD_TRACE(("%s: Enter\n",__FUNCTION__));
ifidx = dhd_net2idx(dhd, dev);
if (ifidx == DHD_BAD_IF)
return;
#ifdef BCMDBUS
ret = dbus_send_pkt(dhdp->dbus, pktbuf, NULL /* pktinfo */);
#else
- WAKE_LOCK_TIMEOUT(dhdp, WAKE_LOCK_TMOUT, 25);
ret = dhd_bus_txdata(dhdp->bus, pktbuf);
#endif /* BCMDBUS */
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
+ dhd_os_wake_lock(&dhd->pub);
+
/* Reject if down */
if (!dhd->pub.up || (dhd->pub.busstate == DHD_BUS_DOWN)) {
- DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d \n",
- __FUNCTION__, dhd->pub.up, dhd->pub.busstate));
+ DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
+ __FUNCTION__, dhd->pub.up, dhd->pub.busstate));
netif_stop_queue(net);
/* Send Event when bus down detected during data session */
if (dhd->pub.busstate == DHD_BUS_DOWN) {
- DHD_ERROR(("%s: Event RELOAD send up\n", __FUNCTION__));
- wl_iw_send_priv_event(net, "RELOAD");
+ DHD_ERROR(("%s: Event HANG send up\n", __FUNCTION__));
+ net_os_send_hang_message(net);
}
+ dhd_os_wake_unlock(&dhd->pub);
return -ENODEV;
}
if (ifidx == DHD_BAD_IF) {
DHD_ERROR(("%s: bad ifidx %d\n", __FUNCTION__, ifidx));
netif_stop_queue(net);
+ dhd_os_wake_unlock(&dhd->pub);
return -ENODEV;
}
ret = dhd_sendpkt(&dhd->pub, ifidx, pktbuf);
-
done:
if (ret)
dhd->pub.dstats.tx_dropped++;
else
dhd->pub.tx_packets++;
+ dhd_os_wake_unlock(&dhd->pub);
+
/* Return ok: we always eat the packet */
return 0;
}
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) */
}
}
+ dhd_os_wake_lock_timeout_enable(dhdp);
}
void
dhd_watchdog_thread(void *data)
{
dhd_info_t *dhd = (dhd_info_t *)data;
- WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_WATCHDOG, "dhd_watchdog_thread");
/* This thread doesn't need any user-level access,
* so get rid of all our resources
/* Run until signal received */
while (1) {
if (down_interruptible (&dhd->watchdog_sem) == 0) {
+ dhd_os_sdlock(&dhd->pub);
if (dhd->pub.dongle_reset == FALSE) {
- WAKE_LOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
+ DHD_TIMER(("%s:\n", __FUNCTION__));
/* Call the bus module watchdog */
dhd_bus_watchdog(&dhd->pub);
- WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
- }
- /* Count the tick for reference */
- dhd->pub.tickcnt++;
- /* Reschedule the watchdog */
- if (dhd->wd_timer_valid) {
- mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+ /* Count the tick for reference */
+ dhd->pub.tickcnt++;
+
+ /* Reschedule the watchdog */
+ if (dhd->wd_timer_valid)
+ mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
}
- }
- else
+ dhd_os_sdunlock(&dhd->pub);
+ dhd_os_wake_unlock(&dhd->pub);
+ } else {
break;
+ }
}
- WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_WATCHDOG);
complete_and_exit(&dhd->watchdog_exited, 0);
}
{
dhd_info_t *dhd = (dhd_info_t *)data;
+ dhd_os_wake_lock(&dhd->pub);
+ if (dhd->pub.dongle_reset) {
+ dhd_os_wake_unlock(&dhd->pub);
+ return;
+ }
+
if (dhd->watchdog_pid >= 0) {
up(&dhd->watchdog_sem);
return;
}
+ dhd_os_sdlock(&dhd->pub);
/* Call the bus module watchdog */
dhd_bus_watchdog(&dhd->pub);
/* Reschedule the watchdog */
if (dhd->wd_timer_valid)
mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+ dhd_os_sdunlock(&dhd->pub);
+ dhd_os_wake_unlock(&dhd->pub);
}
static int
{
dhd_info_t *dhd = (dhd_info_t *)data;
- WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_DPC, "dhd_dpc_thread");
/* This thread doesn't need any user-level access,
* so get rid of all our resources
*/
if (down_interruptible(&dhd->dpc_sem) == 0) {
/* Call bus dpc unless it indicated down (then clean stop) */
if (dhd->pub.busstate != DHD_BUS_DOWN) {
- WAKE_LOCK(&dhd->pub, WAKE_LOCK_DPC);
if (dhd_bus_dpc(dhd->pub.bus)) {
up(&dhd->dpc_sem);
- WAKE_LOCK_TIMEOUT(&dhd->pub, WAKE_LOCK_TMOUT, 25);
}
- WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_DPC);
+ else {
+ dhd_os_wake_unlock(&dhd->pub);
+ }
} else {
dhd_bus_stop(dhd->pub.bus, TRUE);
+ dhd_os_wake_unlock(&dhd->pub);
}
}
else
break;
}
- WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_DPC);
-
complete_and_exit(&dhd->dpc_exited, 0);
}
{
dhd_info_t *dhd = (dhd_info_t *)dhdp->info;
+ dhd_os_wake_lock(dhdp);
if (dhd->dpc_pid >= 0) {
up(&dhd->dpc_sem);
return;
uint driver = 0;
int ifidx;
bool is_set_key_cmd;
-
+ int ret;
+
+ dhd_os_wake_lock(&dhd->pub);
+
ifidx = dhd_net2idx(dhd, net);
DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __FUNCTION__, ifidx, cmd));
- if (ifidx == DHD_BAD_IF)
+ if (ifidx == DHD_BAD_IF) {
+ dhd_os_wake_unlock(&dhd->pub);
return -1;
+ }
#if defined(CONFIG_WIRELESS_EXT)
/* linux wireless extensions */
if ((cmd >= SIOCIWFIRST) && (cmd <= SIOCIWLAST)) {
/* may recurse, do NOT lock */
- return wl_iw_ioctl(net, ifr, cmd);
+ ret = wl_iw_ioctl(net, ifr, cmd);
+ dhd_os_wake_unlock(&dhd->pub);
+ return ret;
}
#endif /* defined(CONFIG_WIRELESS_EXT) */
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 2)
- if (cmd == SIOCETHTOOL)
- return (dhd_ethtool(dhd, (void*)ifr->ifr_data));
+ if (cmd == SIOCETHTOOL) {
+ ret = dhd_ethtool(dhd, (void*)ifr->ifr_data);
+ dhd_os_wake_unlock(&dhd->pub);
+ return ret;
+ }
#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 2) */
- if (cmd != SIOCDEVPRIVATE)
+ if (cmd != SIOCDEVPRIVATE) {
+ dhd_os_wake_unlock(&dhd->pub);
return -EOPNOTSUPP;
+ }
memset(&ioc, 0, sizeof(ioc));
/* check for local dhd ioctl and handle it */
if (driver == DHD_IOCTL_MAGIC) {
- printk("%s: Is local dhd ioctl\n", __func__);
bcmerror = dhd_ioctl((void *)&dhd->pub, &ioc, buf, buflen);
if (bcmerror)
dhd->pub.bcmerror = bcmerror;
}
/* send to dongle (must be up, and wl) */
- if (
- (dhd->pub.busstate != DHD_BUS_DATA)) {
- DHD_ERROR(("%s DONGLE_DOWN,__FUNCTION__\n", __FUNCTION__));
+ if (dhd->pub.busstate != DHD_BUS_DATA) {
+ DHD_ERROR(("%s DONGLE_DOWN\n", __FUNCTION__));
bcmerror = BCME_DONGLE_DOWN;
goto done;
}
if (is_set_key_cmd) {
dhd_wait_pend8021x(net);
}
- WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_IOCTL, "dhd_ioctl_entry");
- WAKE_LOCK(&dhd->pub, WAKE_LOCK_IOCTL);
bcmerror = dhd_prot_ioctl(&dhd->pub, ifidx, (wl_ioctl_t *)&ioc, buf, buflen);
- WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_IOCTL);
- WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_IOCTL);
- if (bcmerror == -ETIMEDOUT) {
- DHD_ERROR(("%s: Event RELOAD send up\n", __FUNCTION__));
- wl_iw_send_priv_event(net, "RELOAD");
- }
done:
+ if ((bcmerror == -ETIMEDOUT) || ((dhd->pub.busstate == DHD_BUS_DOWN) &&
+ (!dhd->pub.dongle_reset))) {
+ DHD_ERROR(("%s: Event HANG send up\n", __FUNCTION__));
+ net_os_send_hang_message(net);
+ }
+
if (!bcmerror && buf && ioc.buf) {
if (copy_to_user(ioc.buf, buf, buflen))
bcmerror = -EFAULT;
if (buf)
MFREE(dhd->pub.osh, buf, buflen);
+ dhd_os_wake_unlock(&dhd->pub);
+
return OSL_ERROR(bcmerror);
}
#if !defined(IGNORE_ETH0_DOWN)
dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(net);
- DHD_TRACE(("%s: Enter\n", __FUNCTION__));
+ DHD_TRACE(("%s: Enter %s\n", __FUNCTION__, net->name));
if (dhd->pub.up == 0) {
return 0;
}
#ifdef TOE
uint32 toe_ol;
#endif
- int ifidx = dhd_net2idx(dhd, net);
- int32 ret = 0;
-
- DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
+ int ifidx;
/* Force start if ifconfig_up gets called before START command */
wl_control_wl_start(net);
+ ifidx = dhd_net2idx(dhd, net);
+ if (ifidx == DHD_BAD_IF)
+ return -1;
+ DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
+
+ if ((dhd->iflist[ifidx]) && (dhd->iflist[ifidx]->state == WLC_E_IF_DEL)) {
+ DHD_ERROR(("%s: Error: called when IF already deleted\n", __FUNCTION__));
+ return -1;
+ }
+
if (ifidx == 0) { /* do it only for primary eth0 */
atomic_set(&dhd->pend_8021x_cnt, 0);
netif_start_queue(net);
dhd->pub.up = 1;
-
OLD_MOD_INC_USE_COUNT;
- return ret;
+ return 0;
}
osl_t *
DHD_ERROR(("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh)));
}
osl_detach(osh);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && 1
up(&dhd_registration_sem);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
}
if ((ch > '9' || ch < '0') && (len < IFNAMSIZ - 2))
strcat(net->name, "%d");
}
-
- /* we rename the netdevice interface name wlan0 */
- dev_alloc_name(net, "wlan%d");
if (dhd_add_if(dhd, 0, (void *)net, net->name, NULL, 0, 0) == DHD_BAD_IF)
goto fail;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
net->open = NULL;
#else
net->netdev_ops = NULL;
#endif
- init_MUTEX(&dhd->proto_sem);
+
+ mutex_init(&dhd->proto_sem);
/* Initialize other structure content */
init_waitqueue_head(&dhd->ioctl_resp_wait);
init_waitqueue_head(&dhd->ctrl_wait);
/* Initialize the spinlocks */
spin_lock_init(&dhd->sdlock);
spin_lock_init(&dhd->txqlock);
-
+ spin_lock_init(&dhd->dhd_lock);
+
+ /* Initialize Wakelock stuff */
+ spin_lock_init(&dhd->wl_lock);
+ dhd->wl_count = 0;
+ dhd->wl_packet = 0;
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_lock_init(&dhd->wl_wifi, WAKE_LOCK_SUSPEND, "wlan_wake");
+ wake_lock_init(&dhd->wl_rxwake, WAKE_LOCK_SUSPEND, "wlan_rx_wake");
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+ mutex_init(&dhd->wl_start_lock);
+#endif
/* Link to info module */
dhd->pub.info = dhd;
}
#endif /* defined(CONFIG_WIRELESS_EXT) */
-
/* Set up the watchdog timer */
init_timer(&dhd->timer);
dhd->timer.data = (ulong)dhd;
dhd->timer.function = dhd_watchdog;
/* Initialize thread based operation and lock */
- init_MUTEX(&dhd->sdsem);
+ mutex_init(&dhd->sdsem);
if ((dhd_watchdog_prio >= 0) && (dhd_dpc_prio >= 0)) {
dhd->threads_only = TRUE;
}
*/
memcpy(netdev_priv(net), &dhd, sizeof(dhd));
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
g_bus = bus;
#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
register_pm_notifier(&dhd_sleep_pm_notifier);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
- /* && defined(DHD_GPL) */
- /* Init lock suspend to prevent kernel going to suspend */
- WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_TMOUT, "dhd_wake_lock");
- WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_LINK_DOWN_TMOUT, "dhd_wake_lock_link_dw_event");
#ifdef CONFIG_HAS_EARLYSUSPEND
dhd->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 20;
ASSERT(dhd);
DHD_TRACE(("%s: \n", __FUNCTION__));
- printk ("%s: firmware downloading. firmware = %s nvram = %s\n", __FUNCTION__, fw_path, nv_path);
/* try to download image and nvram to the dongle */
if (dhd->pub.busstate == DHD_BUS_DOWN) {
- WAKE_LOCK_INIT(dhdp, WAKE_LOCK_DOWNLOAD, "dhd_bus_start");
- WAKE_LOCK(dhdp, WAKE_LOCK_DOWNLOAD);
if (!(dhd_bus_download_firmware(dhd->pub.bus, dhd->pub.osh,
fw_path, nv_path))) {
DHD_ERROR(("%s: dhdsdio_probe_download failed. firmware = %s nvram = %s\n",
__FUNCTION__, fw_path, nv_path));
- WAKE_UNLOCK(dhdp, WAKE_LOCK_DOWNLOAD);
- WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_DOWNLOAD);
return -1;
}
-
- WAKE_UNLOCK(dhdp, WAKE_LOCK_DOWNLOAD);
- WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_DOWNLOAD);
}
/* Start the watchdog timer */
#if defined(OOB_INTR_ONLY)
/* Host registration for OOB interrupt */
if (bcmsdh_register_oob_intr(dhdp)) {
- del_timer(&dhd->timer);
dhd->wd_timer_valid = FALSE;
+ del_timer_sync(&dhd->timer);
DHD_ERROR(("%s Host failed to resgister for OOB\n", __FUNCTION__));
return -ENODEV;
}
/* If bus is not ready, can't come up */
if (dhd->pub.busstate != DHD_BUS_DATA) {
- del_timer(&dhd->timer);
dhd->wd_timer_valid = FALSE;
+ del_timer_sync(&dhd->timer);
DHD_ERROR(("%s failed bus is not ready\n", __FUNCTION__));
return -ENODEV;
}
setbit(dhdp->eventmask, WLC_E_TXFAIL);
setbit(dhdp->eventmask, WLC_E_JOIN_START);
setbit(dhdp->eventmask, WLC_E_SCAN_COMPLETE);
+ setbit(dhdp->eventmask, WLC_E_RELOAD);
+#ifdef PNO_SUPPORT
+ setbit(dhdp->eventmask, WLC_E_PFN_NET_FOUND);
+#endif /* PNO_SUPPORT */
+
+/* enable dongle roaming event */
+ setbit(dhdp->eventmask, WLC_E_ROAM);
dhdp->pktfilter_count = 1;
/* Setup filter to allow only unicast */
return ret;
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
static struct net_device_ops dhd_ops_pri = {
.ndo_open = dhd_open,
.ndo_stop = dhd_stop,
.ndo_do_ioctl = dhd_ioctl_entry,
.ndo_start_xmit = dhd_start_xmit,
.ndo_set_mac_address = dhd_set_mac_address,
- .ndo_set_multicast_list = dhd_set_multicast_list
+ .ndo_set_multicast_list = dhd_set_multicast_list,
};
static struct net_device_ops dhd_ops_virt = {
.ndo_do_ioctl = dhd_ioctl_entry,
.ndo_start_xmit = dhd_start_xmit,
.ndo_set_mac_address = dhd_set_mac_address,
- .ndo_set_multicast_list = dhd_set_multicast_list
+ .ndo_set_multicast_list = dhd_set_multicast_list,
};
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) */
+#endif
+
int
dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
{
DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
ASSERT(dhd && dhd->iflist[ifidx]);
-
net = dhd->iflist[ifidx]->net;
- ASSERT(net);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+ ASSERT(net);
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
ASSERT(!net->open);
net->get_stats = dhd_get_stats;
net->do_ioctl = dhd_ioctl_entry;
net->netdev_ops = &dhd_ops_virt;
#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
net->open = dhd_open;
net->stop = dhd_stop;
#else
if (ifidx != 0) {
/* for virtual interfaces use the primary MAC */
memcpy(temp_addr, dhd->pub.mac.octet, ETHER_ADDR_LEN);
-
}
if (ifidx == 1) {
DHD_TRACE(("%s ACCESS POINT MAC: \n", __FUNCTION__));
/* ACCESSPOINT INTERFACE CASE */
- temp_addr[0] |= 0X02; /* set bit 2 , - Locally Administered address */
-
+ temp_addr[0] |= 0x02; /* set bit 2 , - Locally Administered address */
}
net->hard_header_len = ETH_HLEN + dhd->pub.hdrlen;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
#endif /* WIRELESS_EXT > 12 */
#endif /* defined(CONFIG_WIRELESS_EXT) */
-
dhd->pub.rxsz = net->mtu + net->hard_header_len + dhd->pub.hdrlen;
memcpy(net->dev_addr, temp_addr, ETHER_ADDR_LEN);
dhd->pub.mac.octet[0], dhd->pub.mac.octet[1], dhd->pub.mac.octet[2],
dhd->pub.mac.octet[3], dhd->pub.mac.octet[4], dhd->pub.mac.octet[5]);
-#if defined(CONFIG_WIRELESS_EXT) && !defined(CSCAN)
+#if defined(CONFIG_WIRELESS_EXT)
+#if defined(CONFIG_FIRST_SCAN)
#ifdef SOFTAP
if (ifidx == 0)
/* Don't call for SOFTAP Interface in SOFTAP MODE */
#else
wl_iw_iscan_set_scan_broadcast_prep(net, 1);
#endif /* SOFTAP */
+#endif /* CONFIG_FIRST_SCAN */
#endif /* CONFIG_WIRELESS_EXT */
-
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
up(&dhd_registration_sem);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
return 0;
fail:
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
net->open = NULL;
#else
net->netdev_ops = NULL;
#endif /* defined(OOB_INTR_ONLY) */
/* Clear the watchdog timer */
- del_timer(&dhd->timer);
dhd->wd_timer_valid = FALSE;
+ del_timer_sync(&dhd->timer);
}
}
}
int i;
#if defined(CONFIG_HAS_EARLYSUSPEND)
- unregister_early_suspend(&dhd->early_suspend);
+ if (dhd->early_suspend.suspend)
+ unregister_early_suspend(&dhd->early_suspend);
#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+#if defined(CONFIG_WIRELESS_EXT)
+ /* Attach and link in the iw */
+ wl_iw_detach();
+#endif
+ if (dhd->sysioc_pid >= 0) {
+ KILL_PROC(dhd->sysioc_pid, SIGTERM);
+ wait_for_completion(&dhd->sysioc_exited);
+ }
for (i = 1; i < DHD_MAX_IFS; i++)
- if (dhd->iflist[i])
- dhd_del_if(dhd, i);
+ if (dhd->iflist[i]) {
+ dhd->iflist[i]->state = WLC_E_IF_DEL;
+ dhd->iflist[i]->idx = i;
+ dhd_op_if(dhd->iflist[i]);
+ }
ifp = dhd->iflist[0];
ASSERT(ifp);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
if (ifp->net->open) {
#else
if (ifp->net->netdev_ops == &dhd_ops_pri) {
unregister_netdev(ifp->net);
}
+ if (dhd->watchdog_pid >= 0)
+ {
+ KILL_PROC(dhd->watchdog_pid, SIGTERM);
+ wait_for_completion(&dhd->watchdog_exited);
+ }
- if (dhd->watchdog_pid >= 0)
- {
- KILL_PROC(dhd->watchdog_pid, SIGTERM);
- wait_for_completion(&dhd->watchdog_exited);
- }
-
- if (dhd->dpc_pid >= 0)
- {
- KILL_PROC(dhd->dpc_pid, SIGTERM);
- wait_for_completion(&dhd->dpc_exited);
- }
- else
- tasklet_kill(&dhd->tasklet);
-
- if (dhd->sysioc_pid >= 0) {
- KILL_PROC(dhd->sysioc_pid, SIGTERM);
- wait_for_completion(&dhd->sysioc_exited);
- }
-
- dhd_bus_detach(dhdp);
-
- if (dhdp->prot)
- dhd_prot_detach(dhdp);
+ if (dhd->dpc_pid >= 0)
+ {
+ KILL_PROC(dhd->dpc_pid, SIGTERM);
+ wait_for_completion(&dhd->dpc_exited);
+ }
+ else
+ tasklet_kill(&dhd->tasklet);
-#if defined(CONFIG_WIRELESS_EXT)
- /* Attach and link in the iw */
- wl_iw_detach();
-#endif
+ dhd_bus_detach(dhdp);
+ if (dhdp->prot)
+ dhd_prot_detach(dhdp);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
- unregister_pm_notifier(&dhd_sleep_pm_notifier);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
+ unregister_pm_notifier(&dhd_sleep_pm_notifier);
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
- /* && defined(DHD_GPL) */
- WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_TMOUT);
- WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_LINK_DOWN_TMOUT);
- free_netdev(ifp->net);
- MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
- MFREE(dhd->pub.osh, dhd, sizeof(*dhd));
+ free_netdev(ifp->net);
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_lock_destroy(&dhd->wl_wifi);
+ wake_lock_destroy(&dhd->wl_rxwake);
+#endif
+ MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
+ MFREE(dhd->pub.osh, dhd, sizeof(*dhd));
+ }
}
}
-}
-static void
-dhd_module_cleanup(void)
+
+void
+rockchip_wifi_exit_module(void)
{
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
- printk("hojie: dhd_module_cleanup()\n");
-
dhd_bus_unregister();
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
wifi_del_dev();
#endif
/* Call customer gpio to turn off power with WL_REG_ON signal */
dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF);
+ bcm4329_power_save_exit();
}
-
-static int
-dhd_module_init(void)
+int
+rockchip_wifi_init_module(void)
{
int error;
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
+ printk("BCM4319 Wi-Fi driver (Powered by Rockchip,Ver %s) init.\n", BCM4319_DRV_VERSION);
/* Sanity check on the module parameters */
do {
/* Both watchdog and DPC as tasklets are ok */
DHD_ERROR(("Invalid module parameters.\n"));
return -EINVAL;
} while (0);
+
/* Call customer gpio to turn on power with WL_REG_ON signal */
dhd_customer_gpio_wlan_ctrl(WLAN_POWER_ON);
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
sema_init(&wifi_control_sem, 0);
error = wifi_add_dev();
if (error) {
DHD_ERROR(("%s: platform_driver_register failed\n", __FUNCTION__));
- goto faild;
+ goto fail_0;
}
/* Waiting callback after platform_driver_register is done or exit with error */
- if (down_timeout(&wifi_control_sem, msecs_to_jiffies(1000)) != 0) {
- printk("%s: platform_driver_register timeout\n", __FUNCTION__);
- /* renove device */
- wifi_del_dev();
- goto faild;
+ if (down_timeout(&wifi_control_sem, msecs_to_jiffies(5000)) != 0) {
+ error = -EINVAL;
+ DHD_ERROR(("%s: platform_driver_register timeout\n", __FUNCTION__));
+ goto fail_1;
}
-#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319) */
+#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
sema_init(&dhd_registration_sem, 0);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
+#endif
error = dhd_bus_register();
printf("\n%s\n", dhd_version);
else {
DHD_ERROR(("%s: sdio_register_driver failed\n", __FUNCTION__));
- goto faild;
+ goto fail_1;
}
-
-//#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-#if 0
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
/*
* Wait till MMC sdio_register_driver callback called and made driver attach.
* It's needed to make sync up exit from dhd insmod and
if (down_timeout(&dhd_registration_sem, msecs_to_jiffies(DHD_REGISTRATION_TIMEOUT)) != 0) {
error = -EINVAL;
DHD_ERROR(("%s: sdio_register_driver timeout\n", __FUNCTION__));
- dhd_bus_unregister();
+ goto fail_2;
}
#endif
+ bcm4329_power_save_init();
+
return error;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+fail_2:
+ dhd_bus_unregister();
+#endif
+fail_1:
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
+ wifi_del_dev();
+fail_0:
+#endif /* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
-faild:
- /* turn off power and exit */
+ /* Call customer gpio to turn off power with WL_REG_ON signal */
dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF);
- return -EINVAL;
-}
-//hojie: 2010.10.11
-//for wifi power control
-
-//#if (ANDROID_POWER_SAVE == 1)
-#if 0
-//#include <linux/android_power.h>
-//#include <linux/suspend.h>
-//android_suspend_lock_t wifi_android_lock;
+ return error;
+}
-/*
- * Suspend request from android power manager.
- */
-int wifi_suspend(suspend_state_t state)
+//module_init(dhd_module_init);
+//module_exit(dhd_module_cleanup);
+int mv88w8686_if_sdio_init_module(void)
{
- printk("System want WIFI to suspend.\n");
- printk("Not yet implemented.\n");
- return 0;
- struct lbs_private *priv = lbs_wifi_priv;
-
- if (priv == NULL)
- {
- printk("WiFi is disabled for now.\n");
- return 0;
- }
-
- if (wifi_ps_status == WIFI_PS_DRV_SLEEP)
- {
- printk("WiFi is in driver sleep already.\n");
- return 0;
- }
- else /* This should be never occured. */
-/* {
- printk("ERROR: WiFi is active for now!!!!!!!!!!\n");
- return 1;
- }
-*/
+ return rockchip_wifi_init_module();
}
-
-void wifi_resume(void)
+void mv88w8686_if_sdio_exit_module(void)
{
- printk("Android want wifi to be resumed.\n");
+ rockchip_wifi_exit_module();
}
-#endif //(ANDROID_POWER_SAVE == 1)
+EXPORT_SYMBOL(rockchip_wifi_init_module);
+EXPORT_SYMBOL(rockchip_wifi_exit_module);
+EXPORT_SYMBOL(mv88w8686_if_sdio_init_module);
+EXPORT_SYMBOL(mv88w8686_if_sdio_exit_module);
-//#include "wifi_power.h"
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)
-extern int rk29sdk_wifi_set_carddetect(int val);
-#endif
-
-extern struct mmc_host *wifi_mmc_host;
-extern struct sdio_func *wifi_sdio_func;
-
-extern int wifi_turn_on_card(int module);
-extern int wifi_turn_off_card(void);
-
-#include "wifi_version.h"
-
-int rockchip_wifi_init_module(void)
-{
- int ret = 0, timeout;
-
-// printk("Broadcom BCM4319 WiFi driver (Ver %s) init.\n", "0.99");
-// return dhd_module_init();
-
- wifi_sdio_func = NULL;
- wifi_func_removed = 0;
-// wifi_no_power_gpio = 0;
-
- /* Make sure we are in awake. -- Yongle Lai */
-// wifi_ps_status = WIFI_PS_AWAKE;
-
- printk("Broadcom BCM4319 WiFi (Powered by Rockchip, Ver %s).\n", BCM4319_DRV_VERSION);
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- if (wifi_mmc_host == NULL)
- {
- printk("SDIO host (mmc1) for WiFi is inactive.\n");
- return -ENODEV;
- }
-#endif
-
- ret = dhd_module_init();
-
- if(ret) {
- printk("dhd_module_init() fail, ret = %d\n", ret);
- return ret;
- }
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- if (wifi_mmc_host->bus_ops != NULL) /* mmc/card is attached already. */
- {
- printk("SDIO maybe be attached already.\n");
- // wifi_no_power_gpio = 1;
- //return 0;
- goto wait_wifi;
- }
-#endif
- wifi_turn_on_card(2);
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- mmc_detect_change(wifi_mmc_host, 1);
-#else
- rk29sdk_wifi_set_carddetect(1);
-#endif
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-wait_wifi:
-#endif
- //printk("Waiting for SDIO card to be attached.\n");
- for (timeout = 50; timeout >=0; timeout--)
- {
- if (wifi_sdio_func != NULL)
- break;
- msleep(100);
- }
- if (timeout <= 0)
- {
- printk("No WiFi function card has been attached (5s).\n");
-
- // sdio_unregister_driver(&if_sdio_driver);
- dhd_module_cleanup();
-
- wifi_turn_off_card();
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- mmc_detect_change(wifi_mmc_host, 1);
-#else
- rk29sdk_wifi_set_carddetect(0);
-#endif
- return -ENODEV;
- }
- printk("%s: timeout = %d (interval = 100 ms)\n", __func__, timeout);
-
-//#endif
-
- return 0;
-
-}
-EXPORT_SYMBOL(rockchip_wifi_init_module);
-
-void rockchip_wifi_exit_module(void)
-{
- int timeout;
- /*
-
- lbs_deb_enter(LBS_DEB_SDIO);
-
- wifi_ps_status = WIFI_PS_AWAKE;
-
- sdio_unregister_driver(&if_sdio_driver);
-
-#ifdef WIFI_GPIO_POWER_CONTROL
-
- //if (wifi_no_power_gpio == 1)
- // return;
-
- if (wifi_mmc_host == NULL)
- {
- printk("No SDIO host is present.\n");
- return;
- }
-*/
-
- dhd_module_cleanup();
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- if (wifi_mmc_host == NULL)
- {
- printk("No SDIO host is present.\n");
- return;
- }
-#endif
- wifi_turn_off_card();
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- mmc_detect_change(wifi_mmc_host, 2);
-#else
- rk29sdk_wifi_set_carddetect(0);
-#endif
-
- //printk("Waiting for sdio card to be released ... \n");
- for (timeout = 40; timeout >= 0; timeout--)
- {
- msleep(100);
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
- if (wifi_mmc_host->bus_ops == NULL)
-#else
- if (wifi_func_removed == 1)
-#endif
- break;
- }
- if (timeout < 0)
- printk("Fail to release SDIO card.\n");
- //else
- //printk("Success to release SDIO card.\n");
- printk("%s: timeout = %d (interval = 100 ms)\n", __func__, timeout);
-//#endif
-
-/* lbs_deb_leave(LBS_DEB_SDIO);*/
-
-}
-EXPORT_SYMBOL(rockchip_wifi_exit_module);
-
-int mv88w8686_if_sdio_init_module(void)
-{
- return rockchip_wifi_init_module();
-}
-
-void mv88w8686_if_sdio_exit_module(void)
-{
- rockchip_wifi_exit_module();
-}
-
-EXPORT_SYMBOL(mv88w8686_if_sdio_init_module);
-EXPORT_SYMBOL(mv88w8686_if_sdio_exit_module);
-
-#ifdef BCMSDH_MODULE
-module_init(dhd_module_init);
-module_exit(dhd_module_cleanup);
-#endif
-/* mobile version
-int if_sdio_init_module2(void)
-{
- return dhd_module_init();
-}
-
-void if_sdio_exit_module(void)
-{
- dhd_module_cleanup();
-}
-
-EXPORT_SYMBOL(if_sdio_init_module2);
-EXPORT_SYMBOL(if_sdio_exit_module);
-*/
-/*
- * OS specific functions required to implement DHD driver in OS independent way
- */
-int
-dhd_os_proto_block(dhd_pub_t *pub)
-{
- dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+/*
+ * OS specific functions required to implement DHD driver in OS independent way
+ */
+int
+dhd_os_proto_block(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
if (dhd) {
- down(&dhd->proto_sem);
+ mutex_lock(&dhd->proto_sem);
return 1;
}
+
return 0;
}
dhd_info_t *dhd = (dhd_info_t *)(pub->info);
if (dhd) {
- up(&dhd->proto_sem);
+ mutex_unlock(&dhd->proto_sem);
return 1;
}
int timeout = dhd_ioctl_timeout_msec;
/* Convert timeout in millsecond to jiffies */
- timeout = timeout * HZ / 1000;
+ /* timeout = timeout * HZ / 1000; */
+ timeout = msecs_to_jiffies(timeout);
/* Wait until control frame is available */
add_wait_queue(&dhd->ioctl_resp_wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);
-
- while (!(*condition) && (!signal_pending(current) && timeout))
+ smp_mb();
+ while (!(*condition) && (!signal_pending(current) && timeout)) {
timeout = schedule_timeout(timeout);
+ smp_mb();
+ }
if (signal_pending(current))
*pending = TRUE;
dhd_os_wd_timer(void *bus, uint wdtick)
{
dhd_pub_t *pub = bus;
- static uint save_dhd_watchdog_ms = 0;
dhd_info_t *dhd = (dhd_info_t *)pub->info;
+ unsigned long flags;
+ int del_timer_flag = FALSE;
- /* don't start the wd until fw is loaded */
- if (pub->busstate == DHD_BUS_DOWN)
- return;
-
- /* Totally stop the timer */
- if (!wdtick && dhd->wd_timer_valid == TRUE) {
- del_timer(&dhd->timer);
- dhd->wd_timer_valid = FALSE;
- save_dhd_watchdog_ms = wdtick;
- return;
- }
-
- if (wdtick) {
- dhd_watchdog_ms = (uint) wdtick;
- if (save_dhd_watchdog_ms != dhd_watchdog_ms) {
-
- if (dhd->wd_timer_valid == TRUE)
- /* Stop timer and restart at new value */
- del_timer(&dhd->timer);
+ flags = dhd_os_spin_lock(pub);
- /* Create timer again when watchdog period is
- dynamically changed or in the first instance
- */
- dhd->timer.expires = jiffies + dhd_watchdog_ms * HZ / 1000;
- add_timer(&dhd->timer);
- } else {
+ /* don't start the wd until fw is loaded */
+ if (pub->busstate != DHD_BUS_DOWN) {
+ if (wdtick) {
+ dhd_watchdog_ms = (uint)wdtick;
+ dhd->wd_timer_valid = TRUE;
/* Re arm the timer, at last watchdog period */
mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+ } else if (dhd->wd_timer_valid == TRUE) {
+ /* Totally stop the timer */
+ dhd->wd_timer_valid = FALSE;
+ del_timer_flag = TRUE;
}
-
- dhd->wd_timer_valid = TRUE;
- save_dhd_watchdog_ms = wdtick;
+ }
+ dhd_os_spin_unlock(pub, flags);
+ if (del_timer_flag) {
+ del_timer_sync(&dhd->timer);
}
}
{
struct file *fp;
-
fp = filp_open(filename, O_RDONLY, 0);
/*
* 2.6.11 (FC4) supports filp_open() but later revs don't?
struct file *fp = (struct file *)image;
int rdlen;
-
if (!image)
return 0;
dhd = (dhd_info_t *)(pub->info);
if (dhd->threads_only)
- down(&dhd->sdsem);
+ mutex_lock(&dhd->sdsem);
else
- spin_lock_bh(&dhd->sdlock);
+ spin_lock_bh(&dhd->sdlock);
}
void
dhd = (dhd_info_t *)(pub->info);
if (dhd->threads_only)
- up(&dhd->sdsem);
+ mutex_unlock(&dhd->sdsem);
else
- spin_unlock_bh(&dhd->sdlock);
+ spin_unlock_bh(&dhd->sdlock);
}
void
#ifdef DHD_USE_STATIC_BUF
void * dhd_os_prealloc(int section, unsigned long size)
{
-#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
void *alloc_ptr = NULL;
if (wifi_control_data && wifi_control_data->mem_prealloc)
{
return 0;
#else
return MALLOC(0, size);
-#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319) */
+#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
}
#endif /* DHD_USE_STATIC_BUF */
#if defined(CONFIG_WIRELESS_EXT)
#if defined(CONFIG_WIRELESS_EXT)
ASSERT(dhd->iflist[*ifidx] != NULL);
+
+ if (ntoh32(event->event_type) == WLC_E_IF) {
+ DHD_INFO(("<0> interface:%d OP:%d don't pass to wext,"
+ "net_device might not be created yet\n",
+ *ifidx, ntoh32(event->event_type)));
+ return bcmerror;
+ }
+
ASSERT(dhd->iflist[*ifidx]->net != NULL);
if (dhd->iflist[*ifidx]->net)
wl_iw_event(dhd->iflist[*ifidx]->net, event, *data);
-#endif /* defined(CONFIG_WIRELESS_EXT) */
-
+#endif /* defined(CONFIG_WIRELESS_EXT) */
return (bcmerror);
}
void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar)
{
-#if 1 && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
struct dhd_info *dhdinfo = dhd->info;
dhd_os_sdunlock(dhd);
wait_event_interruptible_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), HZ * 2);
void dhd_wait_event_wakeup(dhd_pub_t *dhd)
{
-#if 1 && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
struct dhd_info *dhdinfo = dhd->info;
if (waitqueue_active(&dhdinfo->ctrl_wait))
wake_up_interruptible(&dhdinfo->ctrl_wait);
#endif
return;
}
+
int
dhd_dev_reset(struct net_device *dev, uint8 flag)
{
+ int ret;
+
dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
- /* Turning off watchdog */
- if (flag)
- dhd_os_wd_timer(&dhd->pub, 0);
+ ret = dhd_bus_devreset(&dhd->pub, flag);
+ if (ret) {
+ DHD_ERROR(("%s: dhd_bus_devreset: %d\n", __FUNCTION__, ret));
+ return ret;
+ }
+ DHD_ERROR(("%s: WLAN %s DONE\n", __FUNCTION__, flag ? "OFF" : "ON"));
- dhd_bus_devreset(&dhd->pub, flag);
+ return ret;
+}
- /* Turning on watchdog back */
- if (!flag)
- dhd_os_wd_timer(&dhd->pub, dhd_watchdog_ms);
- DHD_ERROR(("%s: WLAN OFF DONE\n", __FUNCTION__));
+int net_os_set_suspend_disable(struct net_device *dev, int val)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
- return 1;
+ if (dhd) {
+ ret = dhd->pub.suspend_disable_flag;
+ dhd->pub.suspend_disable_flag = val;
+ }
+ return ret;
}
+int net_os_set_suspend(struct net_device *dev, int val)
+{
+ int ret = 0;
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ if (dhd) {
+ dhd_os_proto_block(&dhd->pub);
+ ret = dhd_set_suspend(val, &dhd->pub);
+ dhd_os_proto_unblock(&dhd->pub);
+ }
+#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+ return ret;
+}
+
+int net_os_set_dtim_skip(struct net_device *dev, int val)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ if (dhd)
+ dhd->pub.dtim_skip = val;
+
+ return 0;
+}
+
+int net_os_set_packet_filter(struct net_device *dev, int val)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ /* Packet filtering is set only if we still in early-suspend and
+ * we need either to turn it ON or turn it OFF
+ * We can always turn it OFF in case of early-suspend, but we turn it
+ * back ON only if suspend_disable_flag was not set
+ */
+ if (dhd && dhd->pub.up) {
+ dhd_os_proto_block(&dhd->pub);
+ if (dhd->pub.in_suspend) {
+ if (!val || (val && !dhd->pub.suspend_disable_flag))
+ dhd_set_packet_filter(val, &dhd->pub);
+ }
+ dhd_os_proto_unblock(&dhd->pub);
+ }
+ return ret;
+}
+
+
void
dhd_dev_init_ioctl(struct net_device *dev)
{
dhd_preinit_ioctls(&dhd->pub);
}
+#ifdef PNO_SUPPORT
+/* Linux wrapper to call common dhd_pno_clean */
+int
+dhd_dev_pno_reset(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ return (dhd_pno_clean(&dhd->pub));
+}
+
+
+/* Linux wrapper to call common dhd_pno_enable */
+int
+dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ return (dhd_pno_enable(&dhd->pub, pfn_enabled));
+}
+
+
+/* Linux wrapper to call common dhd_pno_set */
+int
+dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nssid, ushort scan_fr)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ return (dhd_pno_set(&dhd->pub, ssids_local, nssid, scan_fr));
+}
+
+/* Linux wrapper to get pno status */
+int
+dhd_dev_get_pno_status(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ return (dhd_pno_get_status(&dhd->pub));
+}
+
+#endif /* PNO_SUPPORT */
+
+int net_os_send_hang_message(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ if (dhd) {
+ if (!dhd->hang_was_sent) {
+ dhd->hang_was_sent = 1;
+ ret = wl_iw_send_priv_event(dev, "HANG");
+ }
+ }
+ return ret;
+}
+
+void dhd_bus_country_set(struct net_device *dev, char *country_code)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ if (dhd && dhd->pub.up)
+ strncpy(dhd->pub.country_code, country_code, WLC_CNTRY_BUF_SZ);
+}
+
+char *dhd_bus_country_get(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+ if (dhd && (dhd->pub.country_code[0] != 0))
+ return dhd->pub.country_code;
+ return NULL;
+}
+
+void dhd_os_start_lock(dhd_pub_t *pub)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+ if (dhd)
+ mutex_lock(&dhd->wl_start_lock);
+#endif
+}
+
+void dhd_os_start_unlock(dhd_pub_t *pub)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+ if (dhd)
+ mutex_unlock(&dhd->wl_start_lock);
+#endif
+}
+
static int
dhd_get_pend_8021x_cnt(dhd_info_t *dhd)
{
return ret;
}
#endif /* DHD_DEBUG */
+
+int dhd_os_wake_lock_timeout(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+ unsigned long flags;
+ int ret = 0;
+
+ if (dhd) {
+ spin_lock_irqsave(&dhd->wl_lock, flags);
+ ret = dhd->wl_packet;
+#ifdef CONFIG_HAS_WAKELOCK
+ if (dhd->wl_packet)
+ wake_lock_timeout(&dhd->wl_rxwake, HZ);
+#endif
+ dhd->wl_packet = 0;
+ spin_unlock_irqrestore(&dhd->wl_lock, flags);
+ }
+ /* printk("%s: %d\n", __FUNCTION__, ret); */
+ return ret;
+}
+
+int net_os_wake_lock_timeout(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ if (dhd)
+ ret = dhd_os_wake_lock_timeout(&dhd->pub);
+ return ret;
+}
+
+int dhd_os_wake_lock_timeout_enable(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+ unsigned long flags;
+
+ if (dhd) {
+ spin_lock_irqsave(&dhd->wl_lock, flags);
+ dhd->wl_packet = 1;
+ spin_unlock_irqrestore(&dhd->wl_lock, flags);
+ }
+ /* printk("%s\n",__func__); */
+ return 0;
+}
+
+int net_os_wake_lock_timeout_enable(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ if (dhd)
+ ret = dhd_os_wake_lock_timeout_enable(&dhd->pub);
+ return ret;
+}
+
+int dhd_os_wake_lock(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+ unsigned long flags;
+ int ret = 0;
+
+ if (dhd) {
+ spin_lock_irqsave(&dhd->wl_lock, flags);
+#ifdef CONFIG_HAS_WAKELOCK
+ if (!dhd->wl_count)
+ wake_lock(&dhd->wl_wifi);
+#endif
+ dhd->wl_count++;
+ ret = dhd->wl_count;
+ spin_unlock_irqrestore(&dhd->wl_lock, flags);
+ }
+ /* printk("%s: %d\n", __FUNCTION__, ret); */
+ return ret;
+}
+
+int net_os_wake_lock(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ if (dhd)
+ ret = dhd_os_wake_lock(&dhd->pub);
+ return ret;
+}
+
+int dhd_os_wake_unlock(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+ unsigned long flags;
+ int ret = 0;
+
+ dhd_os_wake_lock_timeout(pub);
+ if (dhd) {
+ spin_lock_irqsave(&dhd->wl_lock, flags);
+ if (dhd->wl_count) {
+ dhd->wl_count--;
+#ifdef CONFIG_HAS_WAKELOCK
+ if (!dhd->wl_count)
+ wake_unlock(&dhd->wl_wifi);
+#endif
+ ret = dhd->wl_count;
+ }
+ spin_unlock_irqrestore(&dhd->wl_lock, flags);
+ }
+ /* printk("%s: %d\n", __FUNCTION__, ret); */
+ return ret;
+}
+
+int net_os_wake_unlock(struct net_device *dev)
+{
+ dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+ int ret = 0;
+
+ if (dhd)
+ ret = dhd_os_wake_unlock(&dhd->pub);
+ return ret;
+}
+
+unsigned long dhd_os_spin_lock(dhd_pub_t *pub)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+ unsigned long flags = 0;
+
+ if (dhd)
+ spin_lock_irqsave(&dhd->dhd_lock, flags);
+
+ return flags;
+}
+
+void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags)
+{
+ dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+ if (dhd)
+ spin_unlock_irqrestore(&dhd->dhd_lock, flags);
+}
#include <wlioctl.h>
#ifndef IOCTL_RESP_TIMEOUT
-#define IOCTL_RESP_TIMEOUT 2000 /* In milli second */
+#define IOCTL_RESP_TIMEOUT 3000 /* In milli second */
#endif
#ifndef IOCTL_CHIP_ACTIVE_TIMEOUT
* 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,v 1.157.2.27.2.33.2.126 2010/06/15 23:38:39 Exp $
+ * $Id: dhd_sdio.c,v 1.157.2.27.2.33.2.129.4.1 2010/09/02 23:13:16 Exp $
*/
#include <typedefs.h>
#include <bcmutils.h>
#include <bcmendian.h>
#include <bcmdevs.h>
-
#include <siutils.h>
#include <hndpmu.h>
#include <hndsoc.h>
-#ifdef DHD_DEBUG
-#include <hndrte_armtrap.h>
-#include <hndrte_cons.h>
-#endif /* DHD_DEBUG */
#include <sbchipc.h>
#include <sbhnddma.h>
-
#include <sdio.h>
#include <sbsdio.h>
#include <sbsdpcmdev.h>
#include <dhdioctl.h>
#include <sdiovar.h>
-#ifndef DHDSDIO_MEM_DUMP_FNAME
-#define DHDSDIO_MEM_DUMP_FNAME "mem_dump"
-#endif
+#ifdef DHD_DEBUG
+#include <hndrte_cons.h>
+#endif /* DHD_DEBUG */
+#ifdef DHD_DEBUG_TRAP
+#include <hndrte_armtrap.h>
+#endif /* DHD_DEBUG_TRAP */
#define QLEN 256 /* bulk rx and tx queue lengths */
#define FCHI (QLEN - 10)
/* Bump up limit on waiting for HT to account for first startup;
* if the image is doing a CRC calculation before programming the PMU
* for HT availability, it could take a couple hundred ms more, so
- * max out at a half second (500000us).
+ * max out at a 1 second (1000000us).
*/
-#if (PMU_MAX_TRANSITION_DLY <= 500000)
+#if (PMU_MAX_TRANSITION_DLY < 1000000)
#undef PMU_MAX_TRANSITION_DLY
-#define PMU_MAX_TRANSITION_DLY 500000
+#define PMU_MAX_TRANSITION_DLY 1000000
#endif
/* Value for ChipClockCSR during initial setup */
DHD_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep);
extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
+extern void bcmsdh_set_irq(int flag);
+
#ifdef DHD_DEBUG
/* Device console log buffer state */
typedef struct dhd_console {
static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start);
#endif
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
static int dhdsdio_checkdied(dhd_bus_t *bus, uint8 *data, uint size);
static int dhdsdio_mem_dump(dhd_bus_t *bus);
-#endif /* DHD_DEBUG */
+#endif /* DHD_DEBUG_TRAP */
static int dhdsdio_download_state(dhd_bus_t *bus, bool enter);
static void dhdsdio_release(dhd_bus_t *bus, osl_t *osh);
void * regsva, uint16 devid);
static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh);
static bool dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh);
-static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh);
+static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, int reset_flag);
static uint process_nvram_vars(char *varbuf, uint len);
bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err);
DHD_INFO(("CLKCTL: set PENDING\n"));
bus->clkstate = CLK_PENDING;
-
return BCME_OK;
} else if (bus->clkstate == CLK_PENDING) {
/* Cancel CA-only interrupt filter */
dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
bus->activity = TRUE;
}
- return BCME_OK;
+ return ret;
}
switch (target) {
else
DHD_ERROR(("dhdsdio_clkctl: request for %d -> %d\n",
bus->clkstate, target));
- if (ret == BCME_OK) {
+ if (ret == BCME_OK)
dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
- }
break;
case CLK_NONE:
bus->ctrl_frame_stat = FALSE;
ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC,
frame, len, NULL, NULL, NULL);
-
ASSERT(ret != BCME_PENDING);
if (ret < 0) {
__FUNCTION__, rxlen, msglen));
} else if (timeleft == 0) {
DHD_ERROR(("%s: resumed on timeout\n", __FUNCTION__));
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
dhd_os_sdlock(bus->dhd);
dhdsdio_checkdied(bus, NULL, 0);
dhd_os_sdunlock(bus->dhd);
-#endif /* DHD_DEBUG */
+#endif /* DHD_DEBUG_TRAP */
} else if (pending == TRUE) {
DHD_CTL(("%s: cancelled\n", __FUNCTION__));
return -ERESTARTSYS;
} else {
DHD_CTL(("%s: resumed for unknown reason?\n", __FUNCTION__));
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
dhd_os_sdlock(bus->dhd);
dhdsdio_checkdied(bus, NULL, 0);
dhd_os_sdunlock(bus->dhd);
-#endif /* DHD_DEBUG */
+#endif /* DHD_DEBUG_TRAP */
}
if (rxlen)
IOV_SDCIS,
IOV_MEMBYTES,
IOV_MEMSIZE,
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
IOV_CHECKDIED,
#endif
IOV_DOWNLOAD,
{"rxbound", IOV_RXBOUND, 0, IOVT_UINT32, 0 },
{"txminmax", IOV_TXMINMAX, 0, IOVT_UINT32, 0 },
{"cpu", IOV_CPU, 0, IOVT_BOOL, 0 },
-#ifdef DHD_DEBUG
- {"checkdied", IOV_CHECKDIED, 0, IOVT_BUFFER, 0 },
-#endif /* DHD_DEBUG */
#endif /* DHD_DEBUG */
+#ifdef DHD_DEBUG_TRAP
+ {"checkdied", IOV_CHECKDIED, 0, IOVT_BUFFER, 0 },
+#endif /* DHD_DEBUG_TRAP */
#ifdef SDTEST
{"extloop", IOV_EXTLOOP, 0, IOVT_BOOL, 0 },
{"pktgen", IOV_PKTGEN, 0, IOVT_BUFFER, sizeof(dhd_pktgen_t) },
return bcmerror;
}
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
static int
dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
{
DHD_ERROR(("%s: %s\n", __FUNCTION__, strbuf.origbuf));
}
-#ifdef DHD_DEBUG
if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) {
- /* Mem dump to a file on device */
- dhdsdio_mem_dump(bus);
+ /* Mem dump to a file on device */
+ dhdsdio_mem_dump(bus);
}
-#endif /* DHD_DEBUG */
done:
if (mbuffer)
}
printf("Done\n");
+#ifdef DHD_DEBUG
/* free buf before return !!! */
if (write_to_file(bus->dhd, buf, bus->ramsize))
{
printf("%s: Error writing to files\n", __FUNCTION__);
return -1;
}
-
/* buf free handled in write_to_file, not here */
+#else
+ MFREE(bus->dhd->osh, buf, size);
+#endif
return 0;
}
+#endif /* DHD_DEBUG_TRAP */
+#ifdef DHD_DEBUG
#define CONSOLE_LINE_MAX 192
static int
BUS_WAKE(bus);
+ /* Change our idea of bus state */
+ bus->dhd->busstate = DHD_BUS_DOWN;
+
/* Enable clock for device interrupts */
dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
local_hostintmask = bus->hostintmask;
bus->hostintmask = 0;
- /* Change our idea of bus state */
- bus->dhd->busstate = DHD_BUS_DOWN;
-
/* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) {
dhd_timeout_t tmo;
uint retries = 0;
uint8 ready, enable;
- int err, ret = 0;
+ int err, ret = BCME_ERROR;
uint8 saveclk;
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
ASSERT(bus->dhd);
if (!bus->dhd)
- return 0;
+ return BCME_OK;
if (enforce_mutex)
dhd_os_sdlock(bus->dhd);
/* Make sure backplane clock is on, needed to generate F2 interrupt */
- dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
- if (bus->clkstate != CLK_AVAIL)
+ err = dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
+ if ((err != BCME_OK) || (bus->clkstate != CLK_AVAIL)) {
+ DHD_ERROR(("%s: Failed to set backplane clock: err %d\n", __FUNCTION__, err));
goto exit;
-
+ }
/* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (dhdp->busstate != DHD_BUS_DATA)
dhdsdio_clkctl(bus, CLK_NONE, FALSE);
+ ret = BCME_OK;
exit:
if (enforce_mutex)
dhd_os_sdunlock(bus->dhd);
DHD_INTR(("%s: enable SDIO interrupts, rxdone %d framecnt %d\n",
__FUNCTION__, rxdone, framecnt));
bus->intdis = FALSE;
+#if defined(OOB_INTR_ONLY)
+ bcmsdh_oob_intr_set(1);
+#endif /* (OOB_INTR_ONLY) */
bcmsdh_intr_enable(sdh);
}
#if defined(SDIO_ISR_THREAD)
DHD_TRACE(("Calling dhdsdio_dpc() from %s\n", __FUNCTION__));
+ dhd_os_wake_lock(bus->dhd);
while (dhdsdio_dpc(bus));
+ dhd_os_wake_unlock(bus->dhd);
#else
bus->dpc_sched = TRUE;
dhd_sched_dpc(bus->dhd);
#endif
-
}
#ifdef SDTEST
if (bus->sleeping)
return FALSE;
- dhd_os_sdlock(bus->dhd);
-
/* Poll period: check device if appropriate. */
if (bus->poll && (++bus->polltick >= bus->pollrate)) {
uint32 intstatus = 0;
bus->idlecount = 0;
if (bus->activity) {
bus->activity = FALSE;
- dhd_os_wd_timer(bus->dhd,dhd_watchdog_ms);
- } else {
dhdsdio_clkctl(bus, CLK_NONE, FALSE);
}
}
}
- dhd_os_sdunlock(bus->dhd);
-
return bus->ipend;
}
/* if firmware path present try to download and bring up bus */
if ((ret = dhd_bus_start(bus->dhd)) != 0) {
+#if 1
DHD_ERROR(("%s: failed\n", __FUNCTION__));
goto fail;
+#else
if (ret == BCME_NOTUP) {
DHD_ERROR(("%s: dongle is not responding\n", __FUNCTION__));
goto fail;
}
+#endif
}
/* Ok, have the per-port tell the stack we're open for business */
if (dhd_net_attach(bus->dhd, 0) != 0) {
ret = dhdsdio_download_firmware(bus, osh, bus->sdh);
-
return ret;
}
bool ret;
/* Download the firmware */
+ dhd_os_wake_lock(bus->dhd);
dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
ret = _dhdsdio_download_firmware(bus) == 0;
dhdsdio_clkctl(bus, CLK_SDONLY, FALSE);
-
+ dhd_os_wake_unlock(bus->dhd);
return ret;
}
if (bus->dhd) {
- dhdsdio_release_dongle(bus, osh);
+ dhdsdio_release_dongle(bus, osh, TRUE);
dhd_detach(bus->dhd);
bus->dhd = NULL;
static void
-dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh)
+dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, int reset_flag)
{
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
- if (bus->dhd && bus->dhd->dongle_reset)
+ if ((bus->dhd && bus->dhd->dongle_reset) && reset_flag)
return;
if (bus->sih) {
if (flag == TRUE) {
if (!bus->dhd->dongle_reset) {
+ dhd_os_sdlock(dhdp);
+ /* Turning off watchdog */
+ dhd_os_wd_timer(dhdp, 0);
#if !defined(IGNORE_ETH0_DOWN)
/* Force flow control as protection when stop come before ifconfig_down */
dhd_txflowcontrol(bus->dhd, 0, ON);
#endif /* !defined(IGNORE_ETH0_DOWN) */
- /* save country settinng if was pre-setup with priv ioctl */
- dhd_os_proto_block(dhdp);
- dhdcdc_query_ioctl(bus->dhd, 0, WLC_GET_COUNTRY,
- bus->dhd->country_code, sizeof(bus->dhd->country_code));
- dhd_os_proto_unblock(dhdp);
/* Expect app to have torn down any connection before calling */
/* Stop the bus, disable F2 */
dhd_bus_stop(bus, FALSE);
-
+#if defined(OOB_INTR_ONLY)
+ bcmsdh_set_irq(FALSE);
+#endif /* defined(OOB_INTR_ONLY) */
/* Clean tx/rx buffer pointers, detach from the dongle */
- dhdsdio_release_dongle(bus, bus->dhd->osh);
+ dhdsdio_release_dongle(bus, bus->dhd->osh, TRUE);
bus->dhd->dongle_reset = TRUE;
bus->dhd->up = FALSE;
+ dhd_os_sdunlock(dhdp);
DHD_TRACE(("%s: WLAN OFF DONE\n", __FUNCTION__));
/* App can now remove power from device */
if (bus->dhd->dongle_reset) {
/* Turn on WLAN */
+ dhd_os_sdlock(dhdp);
+
/* Reset SD client */
bcmsdh_reset(bus->sdh);
dhdsdio_download_firmware(bus, bus->dhd->osh, bus->sdh)) {
/* Re-init bus, enable F2 transfer */
- dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
-
+ bcmerror = dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
+ if (bcmerror == BCME_OK) {
#if defined(OOB_INTR_ONLY)
- dhd_enable_oob_intr(bus, TRUE);
+ bcmsdh_set_irq(TRUE);
+ dhd_enable_oob_intr(bus, TRUE);
#endif /* defined(OOB_INTR_ONLY) */
-
- bus->dhd->dongle_reset = FALSE;
- bus->dhd->up = TRUE;
-
+ bus->dhd->dongle_reset = FALSE;
+ bus->dhd->up = TRUE;
#if !defined(IGNORE_ETH0_DOWN)
- /* Restore flow control */
- dhd_txflowcontrol(bus->dhd, 0, OFF);
-#endif
+ /* Restore flow control */
+ dhd_txflowcontrol(bus->dhd, 0, OFF);
+#endif
+ /* Turning on watchdog back */
+ dhd_os_wd_timer(dhdp, dhd_watchdog_ms);
- DHD_TRACE(("%s: WLAN ON DONE\n", __FUNCTION__));
+ DHD_TRACE(("%s: WLAN ON DONE\n", __FUNCTION__));
+ } else {
+ dhd_bus_stop(bus, FALSE);
+ dhdsdio_release_dongle(bus, bus->dhd->osh, FALSE);
+ }
} else
bcmerror = BCME_SDIO_ERROR;
} else
bcmerror = BCME_SDIO_ERROR;
+
+ dhd_os_sdunlock(dhdp);
} else {
bcmerror = BCME_NOTDOWN;
DHD_ERROR(("%s: Set DEVRESET=FALSE invoked when device is on\n",
+++ /dev/null
-# bcm94319wlusbn4l board\r
-# $Copyright (C) 2008 Broadcom Corporation$\r
-# $Id: bcm94319lcsdn4l.txt,v 1.18 2009/11/11 17:44:06 jayaramn Exp $\r
-\r
-sromrev=3\r
-vendid=0x14e4\r
-devid=0x4338\r
-\r
-boardtype=0x507\r
-boardrev=0x1402\r
-boardflags=0x02000200\r
-\r
-# On board crystal frequency in KHz\r
-xtalfreq=30000\r
-\r
-aa2g=1\r
-aa5g=0\r
-ag0=3\r
-\r
-ccode=ww\r
-regrev=5\r
-opo=0\r
-pa0b0=0x15E0\r
-pa0b1=0xFAC6\r
-pa0b2=0xFEC3\r
-pa0itssit=62\r
-pa0maxpwr=74\r
-\r
-rssismf2g=0xa \r
-rssismc2g=0xb \r
-rssisav2g=0x3 \r
-bxa2g=0\r
-tri2g=0x6B\r
-cckdigfilttype=3\r
-rxpo2g=2\r
-\r
-cckpo=0\r
-ofdmpo=0x44444444\r
-mcs2gpo0=0x6666\r
-mcs2gpo1=0x6666\r
-mcs2gpo2=0x0000\r
-mcs2gpo3=0x0000\r
-mcs2gpo4=0x6666\r
-mcs2gpo5=0x6666\r
-boardnum=1\r
-macaddr=00:90:4c:14:43:19\r
-\r
-#for mfgc\r
-otpimagesize=182\r
#define STATIC static
-
#define SI_BUS 0
#define PCI_BUS 1
#define PCMCIA_BUS 2
#define __BCMSDH_SDMMC_H__
#define sd_err(x)
-#define sd_trace(x)
+#define sd_trace(x)
#define sd_info(x)
#define sd_debug(x)
#define sd_data(x)
--- /dev/null
+/*
+ * SD-SPI Protocol Conversion - BCMSDH->gSPI Translation Layer
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: bcmspibrcm.h,v 1.4.4.1.4.3.6.1 2008/09/27 17:03:25 Exp $
+ */
+
+/* global msglevel for debug messages - bitvals come from sdiovar.h */
+
+#define sd_err(x)
+#define sd_trace(x)
+#define sd_info(x)
+#define sd_debug(x)
+#define sd_data(x)
+#define sd_ctrl(x)
+
+#define sd_log(x)
+
+#define SDIOH_ASSERT(exp) \
+ do { if (!(exp)) \
+ printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
+ } while (0)
+
+#define BLOCK_SIZE_F1 64
+#define BLOCK_SIZE_F2 2048
+#define BLOCK_SIZE_F3 2048
+
+/* internal return code */
+#define SUCCESS 0
+#undef ERROR
+#define ERROR 1
+#define ERROR_UF 2
+#define ERROR_OF 3
+
+/* private bus modes */
+#define SDIOH_MODE_SPI 0
+
+#define USE_BLOCKMODE 0x2 /* Block mode can be single block or multi */
+#define USE_MULTIBLOCK 0x4
+
+struct sdioh_info {
+ uint cfg_bar; /* pci cfg address for bar */
+ uint32 caps; /* cached value of capabilities reg */
+ void *bar0; /* BAR0 for PCI Device */
+ osl_t *osh; /* osh handler */
+ void *controller; /* Pointer to SPI Controller's private data struct */
+
+ uint lockcount; /* nest count of spi_lock() calls */
+ bool client_intr_enabled; /* interrupt connnected flag */
+ bool intr_handler_valid; /* client driver interrupt handler valid */
+ sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
+ void *intr_handler_arg; /* argument to call interrupt handler */
+ bool initialized; /* card initialized */
+ uint32 target_dev; /* Target device ID */
+ uint32 intmask; /* Current active interrupts */
+ void *sdos_info; /* Pointer to per-OS private data */
+
+ uint32 controller_type; /* Host controller type */
+ uint8 version; /* Host Controller Spec Compliance Version */
+ uint irq; /* Client irq */
+ uint32 intrcount; /* Client interrupts */
+ uint32 local_intrcount; /* Controller interrupts */
+ bool host_init_done; /* Controller initted */
+ bool card_init_done; /* Client SDIO interface initted */
+ bool polled_mode; /* polling for command completion */
+
+ bool sd_use_dma; /* DMA on CMD53 */
+ bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
+ /* Must be on for sd_multiblock to be effective */
+ bool use_client_ints; /* If this is false, make sure to restore */
+ /* polling hack in wl_linux.c:wl_timer() */
+ int adapter_slot; /* Maybe dealing with multiple slots/controllers */
+ int sd_mode; /* SD1/SD4/SPI */
+ int client_block_size[SPI_MAX_IOFUNCS]; /* Blocksize */
+ uint32 data_xfer_count; /* Current transfer */
+ uint16 card_rca; /* Current Address */
+ uint8 num_funcs; /* Supported funcs on client */
+ uint32 card_dstatus; /* 32bit device status */
+ uint32 com_cis_ptr;
+ uint32 func_cis_ptr[SPI_MAX_IOFUNCS];
+ void *dma_buf;
+ ulong dma_phys;
+ int r_cnt; /* rx count */
+ int t_cnt; /* tx_count */
+ uint32 wordlen; /* host processor 16/32bits */
+ uint32 prev_fun;
+ uint32 chip;
+ uint32 chiprev;
+ bool resp_delay_all;
+ bool dwordmode;
+
+ struct spierrstats_t spierrstats;
+};
+
+/************************************************************
+ * Internal interfaces: per-port references into bcmspibrcm.c
+ */
+
+/* Global message bits */
+extern uint sd_msglevel;
+
+/**************************************************************
+ * Internal interfaces: bcmspibrcm.c references to per-port code
+ */
+
+/* Interrupt (de)registration routines */
+extern int spi_register_irq(sdioh_info_t *sd, uint irq);
+extern void spi_free_irq(uint irq, sdioh_info_t *sd);
+
+/* OS-specific interrupt wrappers (atomic interrupt enable/disable) */
+extern void spi_lock(sdioh_info_t *sd);
+extern void spi_unlock(sdioh_info_t *sd);
+
+/* Allocate/init/free per-OS private data */
+extern int spi_osinit(sdioh_info_t *sd);
+extern void spi_osfree(sdioh_info_t *sd);
+
+#define SPI_RW_FLAG_M BITFIELD_MASK(1) /* Bit [31] - R/W Command Bit */
+#define SPI_RW_FLAG_S 31
+#define SPI_ACCESS_M BITFIELD_MASK(1) /* Bit [30] - Fixed/Incr Access */
+#define SPI_ACCESS_S 30
+#define SPI_FUNCTION_M BITFIELD_MASK(2) /* Bit [29:28] - Function Number */
+#define SPI_FUNCTION_S 28
+#define SPI_REG_ADDR_M BITFIELD_MASK(17) /* Bit [27:11] - Address */
+#define SPI_REG_ADDR_S 11
+#define SPI_LEN_M BITFIELD_MASK(11) /* Bit [10:0] - Packet length */
+#define SPI_LEN_S 0
#define EPI_MINOR_VERSION 218
-#define EPI_RC_NUMBER 245
+#define EPI_RC_NUMBER 248
-#define EPI_INCREMENTAL_NUMBER 0
+#define EPI_INCREMENTAL_NUMBER 18
#define EPI_BUILD_NUMBER 0
-#define EPI_VERSION 4, 218, 245, 0
+#define EPI_VERSION 4, 218, 248, 18
-#define EPI_VERSION_NUM 0x04daf500
+#define EPI_VERSION_NUM 0x04daf812
-#define EPI_VERSION_STR "4.218.245.0"
-#define EPI_ROUTER_VERSION_STR "4.219.245.0"
+#define EPI_VERSION_STR "4.218.248.18"
+#define EPI_ROUTER_VERSION_STR "4.219.248.18"
#endif
#include <linux/version.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
#include <linux/config.h>
-#else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
-#include <generated/autoconf.h>
-#else
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33))
#include <linux/autoconf.h>
#endif
-#endif
#include <linux/module.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0))
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
+#include <linux/semaphore.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
#undef IP_TOS
#endif
#define CHECKSUM_HW CHECKSUM_PARTIAL
#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
-#define KILL_PROC(nr, sig) \
-{ \
-struct task_struct *tsk; \
-struct pid *pid; \
-pid = find_get_pid((pid_t)nr); \
-tsk = pid_task(pid, PIDTYPE_PID); \
-if (tsk) send_sig(sig, tsk, 1); \
-}
-#else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && (LINUX_VERSION_CODE <= \
- KERNEL_VERSION(2, 6, 30))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
#define KILL_PROC(pid, sig) \
{ \
struct task_struct *tsk; \
- tsk = find_task_by_vpid(pid); \
+ tsk = pid_task(find_vpid(pid), PIDTYPE_PID); \
if (tsk) send_sig(sig, tsk, 1); \
}
#else
kill_proc(pid, sig, 1); \
}
#endif
-#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
#define netdev_priv(dev) dev->priv
*
* Dependencies: proto/bcmeth.h
*
- * $Id: bcmevent.h,v 9.34.4.1.20.16 2009/09/25 23:52:38 Exp $
+ * $Id: bcmevent.h,v 9.34.4.1.20.16.64.1 2010/11/08 21:57:03 Exp $
*
*/
#define WLC_E_ACTION_FRAME 58
#define WLC_E_ACTION_FRAME_COMPLETE 59
-#define WLC_E_ESCAN_RESULT 69
-#define WLC_E_WAKE_EVENT 70
-#define WLC_E_LAST 71
-
+#define WLC_E_ESCAN_RESULT 69
+#define WLC_E_WAKE_EVENT 70
+#define WLC_E_RELOAD 71
+#define WLC_E_LAST 72
#define WLC_E_IF_ADD 1
#define WLC_E_IF_DEL 2
+#define WLC_E_RELOAD_STATUS1 1
#include <packed_section_end.h>
#define CST4315_CBUCK_MODE_BURST 0x00000400
#define CST4315_CBUCK_MODE_LPBURST 0x00000c00
-
#define PMU_MAX_TRANSITION_DLY 15000
--- /dev/null
+/*
+ * SPI device spec header file
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: spid.h,v 1.7.10.1.16.3 2009/04/09 19:23:14 Exp $
+ */
+
+#ifndef _SPI_H
+#define _SPI_H
+
+/*
+ * Brcm SPI Device Register Map.
+ *
+ */
+
+typedef volatile struct {
+ uint8 config; /* 0x00, len, endian, clock, speed, polarity, wakeup */
+ uint8 response_delay; /* 0x01, read response delay in bytes (corerev < 3) */
+ uint8 status_enable; /* 0x02, status-enable, intr with status, response_delay
+ * function selection, command/data error check
+ */
+ uint8 reset_bp; /* 0x03, reset on wlan/bt backplane reset (corerev >= 1) */
+ uint16 intr_reg; /* 0x04, Intr status register */
+ uint16 intr_en_reg; /* 0x06, Intr mask register */
+ uint32 status_reg; /* 0x08, RO, Status bits of last spi transfer */
+ uint16 f1_info_reg; /* 0x0c, RO, enabled, ready for data transfer, blocksize */
+ uint16 f2_info_reg; /* 0x0e, RO, enabled, ready for data transfer, blocksize */
+ uint16 f3_info_reg; /* 0x10, RO, enabled, ready for data transfer, blocksize */
+ uint32 test_read; /* 0x14, RO 0xfeedbead signature */
+ uint32 test_rw; /* 0x18, RW */
+ uint8 resp_delay_f0; /* 0x1c, read resp delay bytes for F0 (corerev >= 3) */
+ uint8 resp_delay_f1; /* 0x1d, read resp delay bytes for F1 (corerev >= 3) */
+ uint8 resp_delay_f2; /* 0x1e, read resp delay bytes for F2 (corerev >= 3) */
+ uint8 resp_delay_f3; /* 0x1f, read resp delay bytes for F3 (corerev >= 3) */
+} spi_regs_t;
+
+/* SPI device register offsets */
+#define SPID_CONFIG 0x00
+#define SPID_RESPONSE_DELAY 0x01
+#define SPID_STATUS_ENABLE 0x02
+#define SPID_RESET_BP 0x03 /* (corerev >= 1) */
+#define SPID_INTR_REG 0x04 /* 16 bits - Interrupt status */
+#define SPID_INTR_EN_REG 0x06 /* 16 bits - Interrupt mask */
+#define SPID_STATUS_REG 0x08 /* 32 bits */
+#define SPID_F1_INFO_REG 0x0C /* 16 bits */
+#define SPID_F2_INFO_REG 0x0E /* 16 bits */
+#define SPID_F3_INFO_REG 0x10 /* 16 bits */
+#define SPID_TEST_READ 0x14 /* 32 bits */
+#define SPID_TEST_RW 0x18 /* 32 bits */
+#define SPID_RESP_DELAY_F0 0x1c /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F1 0x1d /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F2 0x1e /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F3 0x1f /* 8 bits (corerev >= 3) */
+
+/* Bit masks for SPID_CONFIG device register */
+#define WORD_LENGTH_32 0x1 /* 0/1 16/32 bit word length */
+#define ENDIAN_BIG 0x2 /* 0/1 Little/Big Endian */
+#define CLOCK_PHASE 0x4 /* 0/1 clock phase delay */
+#define CLOCK_POLARITY 0x8 /* 0/1 Idle state clock polarity is low/high */
+#define HIGH_SPEED_MODE 0x10 /* 1/0 High Speed mode / Normal mode */
+#define INTR_POLARITY 0x20 /* 1/0 Interrupt active polarity is high/low */
+#define WAKE_UP 0x80 /* 0/1 Wake-up command from Host to WLAN */
+
+/* Bit mask for SPID_RESPONSE_DELAY device register */
+#define RESPONSE_DELAY_MASK 0xFF /* Configurable rd response delay in multiples of 8 bits */
+
+/* Bit mask for SPID_STATUS_ENABLE device register */
+#define STATUS_ENABLE 0x1 /* 1/0 Status sent/not sent to host after read/write */
+#define INTR_WITH_STATUS 0x2 /* 0/1 Do-not / do-interrupt if status is sent */
+#define RESP_DELAY_ALL 0x4 /* Applicability of resp delay to F1 or all func's read */
+#define DWORD_PKT_LEN_EN 0x8 /* Packet len denoted in dwords instead of bytes */
+#define CMD_ERR_CHK_EN 0x20 /* Command error check enable */
+#define DATA_ERR_CHK_EN 0x40 /* Data error check enable */
+
+/* Bit mask for SPID_RESET_BP device register */
+#define RESET_ON_WLAN_BP_RESET 0x4 /* enable reset for WLAN backplane */
+#define RESET_ON_BT_BP_RESET 0x8 /* enable reset for BT backplane */
+#define RESET_SPI 0x80 /* reset the above enabled logic */
+
+/* Bit mask for SPID_INTR_REG device register */
+#define DATA_UNAVAILABLE 0x0001 /* Requested data not available; Clear by writing a "1" */
+#define F2_F3_FIFO_RD_UNDERFLOW 0x0002
+#define F2_F3_FIFO_WR_OVERFLOW 0x0004
+#define COMMAND_ERROR 0x0008 /* Cleared by writing 1 */
+#define DATA_ERROR 0x0010 /* Cleared by writing 1 */
+#define F2_PACKET_AVAILABLE 0x0020
+#define F3_PACKET_AVAILABLE 0x0040
+#define F1_OVERFLOW 0x0080 /* Due to last write. Bkplane has pending write requests */
+#define MISC_INTR0 0x0100
+#define MISC_INTR1 0x0200
+#define MISC_INTR2 0x0400
+#define MISC_INTR3 0x0800
+#define MISC_INTR4 0x1000
+#define F1_INTR 0x2000
+#define F2_INTR 0x4000
+#define F3_INTR 0x8000
+
+/* Bit mask for 32bit SPID_STATUS_REG device register */
+#define STATUS_DATA_NOT_AVAILABLE 0x00000001
+#define STATUS_UNDERFLOW 0x00000002
+#define STATUS_OVERFLOW 0x00000004
+#define STATUS_F2_INTR 0x00000008
+#define STATUS_F3_INTR 0x00000010
+#define STATUS_F2_RX_READY 0x00000020
+#define STATUS_F3_RX_READY 0x00000040
+#define STATUS_HOST_CMD_DATA_ERR 0x00000080
+#define STATUS_F2_PKT_AVAILABLE 0x00000100
+#define STATUS_F2_PKT_LEN_MASK 0x000FFE00
+#define STATUS_F2_PKT_LEN_SHIFT 9
+#define STATUS_F3_PKT_AVAILABLE 0x00100000
+#define STATUS_F3_PKT_LEN_MASK 0xFFE00000
+#define STATUS_F3_PKT_LEN_SHIFT 21
+
+/* Bit mask for 16 bits SPID_F1_INFO_REG device register */
+#define F1_ENABLED 0x0001
+#define F1_RDY_FOR_DATA_TRANSFER 0x0002
+#define F1_MAX_PKT_SIZE 0x01FC
+
+/* Bit mask for 16 bits SPID_F2_INFO_REG device register */
+#define F2_ENABLED 0x0001
+#define F2_RDY_FOR_DATA_TRANSFER 0x0002
+#define F2_MAX_PKT_SIZE 0x3FFC
+
+/* Bit mask for 16 bits SPID_F3_INFO_REG device register */
+#define F3_ENABLED 0x0001
+#define F3_RDY_FOR_DATA_TRANSFER 0x0002
+#define F3_MAX_PKT_SIZE 0x3FFC
+
+/* Bit mask for 32 bits SPID_TEST_READ device register read in 16bit LE mode */
+#define TEST_RO_DATA_32BIT_LE 0xFEEDBEAD
+
+/* Maximum number of I/O funcs */
+#define SPI_MAX_IOFUNCS 4
+
+#define SPI_MAX_PKT_LEN (2048*4)
+
+/* Misc defines */
+#define SPI_FUNC_0 0
+#define SPI_FUNC_1 1
+#define SPI_FUNC_2 2
+#define SPI_FUNC_3 3
+
+#define WAIT_F2RXFIFORDY 100
+#define WAIT_F2RXFIFORDY_DELAY 20
+
+#endif /* _SPI_H */
--- /dev/null
+#ifndef WIFI_VERSION_H
+#define WIFI_VERSION_H
+
+/*
+ * Broadcom BCM4319 driver version.
+ */
+#define BCM4319_DRV_VERSION "2.00"
+
+#endif /* WIFI_BCM4319_VERSION_H */
* 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,v 1.601.4.15.2.14.2.61 2010/05/04 20:26:25 Exp $
+ * $Id: wlioctl.h,v 1.601.4.15.2.14.2.62.4.1 2010/11/17 03:09:28 Exp $
*/
#define PM_MAX 1
#define PM_FAST 2
+#define LISTEN_INTERVAL 20
#define INTERFERE_NONE 0
#define NON_WLAN 1
#define PFN_VERSION 1
+#define MAX_PFN_LIST_COUNT 16
+
typedef struct wl_pfn_param {
int32 version;
#define LINUX_OSL
-#if defined(CHROMIUMOS_COMPAT_WIRELESS)
-#include <linux/sched.h>
-#endif
+
#include <typedefs.h>
#include <bcmendian.h>
#include <linuxver.h>
#include <bcmutils.h>
#include <linux/delay.h>
#include <pcicfg.h>
+#include <linux/mutex.h>
#define PCI_CFG_RETRY 10
#define STATIC_BUF_SIZE (PAGE_SIZE*2)
#define STATIC_BUF_TOTAL_LEN (MAX_STATIC_BUF_NUM*STATIC_BUF_SIZE)
typedef struct bcm_static_buf {
- struct semaphore static_sem;
+ struct mutex static_sem;
unsigned char *buf_ptr;
unsigned char buf_use[MAX_STATIC_BUF_NUM];
} bcm_static_buf_t;
typedef struct bcm_static_pkt {
struct sk_buff *skb_4k[MAX_STATIC_PKT_NUM];
struct sk_buff *skb_8k[MAX_STATIC_PKT_NUM];
- struct semaphore osl_pkt_sem;
+ struct mutex osl_pkt_sem;
unsigned char pkt_use[MAX_STATIC_PKT_NUM*2];
} bcm_static_pkt_t;
static bcm_static_pkt_t *bcm_static_skb = 0;
osl_attach(void *pdev, uint bustype, bool pkttag)
{
osl_t *osh;
+ gfp_t flags;
- osh = kmalloc(sizeof(osl_t), GFP_ATOMIC);
+ flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+ osh = kmalloc(sizeof(osl_t), flags);
ASSERT(osh);
bzero(osh, sizeof(osl_t));
STATIC_BUF_TOTAL_LEN))) {
printk("can not alloc static buf!\n");
}
- else
- printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf);
-
+ else {
+ /* printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); */
+ }
- init_MUTEX(&bcm_static_buf->static_sem);
+ mutex_init(&bcm_static_buf->static_sem);
bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE;
for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++)
bcm_static_skb->pkt_use[i] = 0;
- init_MUTEX(&bcm_static_skb->osl_pkt_sem);
+ mutex_init(&bcm_static_skb->osl_pkt_sem);
}
#endif
return osh;
}
- down(&bcm_static_skb->osl_pkt_sem);
+ mutex_lock(&bcm_static_skb->osl_pkt_sem);
if (len <= PAGE_SIZE)
{
if (i != MAX_STATIC_PKT_NUM)
{
bcm_static_skb->pkt_use[i] = 1;
- up(&bcm_static_skb->osl_pkt_sem);
+ mutex_unlock(&bcm_static_skb->osl_pkt_sem);
skb = bcm_static_skb->skb_4k[i];
skb->tail = skb->data + len;
if (i != MAX_STATIC_PKT_NUM)
{
bcm_static_skb->pkt_use[i+MAX_STATIC_PKT_NUM] = 1;
- up(&bcm_static_skb->osl_pkt_sem);
+ mutex_unlock(&bcm_static_skb->osl_pkt_sem);
skb = bcm_static_skb->skb_8k[i];
skb->tail = skb->data + len;
skb->len = len;
- up(&bcm_static_skb->osl_pkt_sem);
+ mutex_unlock(&bcm_static_skb->osl_pkt_sem);
printk("all static pkt in use!\n");
return osl_pktget(osh, len);
}
{
if (p == bcm_static_skb->skb_4k[i])
{
- down(&bcm_static_skb->osl_pkt_sem);
+ mutex_lock(&bcm_static_skb->osl_pkt_sem);
bcm_static_skb->pkt_use[i] = 0;
- up(&bcm_static_skb->osl_pkt_sem);
+ mutex_unlock(&bcm_static_skb->osl_pkt_sem);
return;
osl_malloc(osl_t *osh, uint size)
{
void *addr;
+ gfp_t flags;
-
if (osh)
ASSERT(osh->magic == OS_HANDLE_MAGIC);
int i = 0;
if ((size >= PAGE_SIZE)&&(size <= STATIC_BUF_SIZE))
{
- down(&bcm_static_buf->static_sem);
+ mutex_lock(&bcm_static_buf->static_sem);
for (i = 0; i < MAX_STATIC_BUF_NUM; i++)
{
if (i == MAX_STATIC_BUF_NUM)
{
- up(&bcm_static_buf->static_sem);
+ mutex_unlock(&bcm_static_buf->static_sem);
printk("all static buff in use!\n");
goto original;
}
bcm_static_buf->buf_use[i] = 1;
- up(&bcm_static_buf->static_sem);
+ mutex_unlock(&bcm_static_buf->static_sem);
bzero(bcm_static_buf->buf_ptr+STATIC_BUF_SIZE*i, size);
if (osh)
}
original:
#endif
-
- if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) {
+ flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+ if ((addr = kmalloc(size, flags)) == NULL) {
if (osh)
osh->failed++;
return (NULL);
buf_idx = ((unsigned char *)addr - bcm_static_buf->buf_ptr)/STATIC_BUF_SIZE;
- down(&bcm_static_buf->static_sem);
+ mutex_lock(&bcm_static_buf->static_sem);
bcm_static_buf->buf_use[buf_idx] = 0;
- up(&bcm_static_buf->static_sem);
+ mutex_unlock(&bcm_static_buf->static_sem);
if (osh) {
ASSERT(osh->magic == OS_HANDLE_MAGIC);
osl_pktdup(osl_t *osh, void *skb)
{
void * p;
+ gfp_t flags;
- if ((p = skb_clone((struct sk_buff*)skb, GFP_ATOMIC)) == NULL)
+ flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+ if ((p = skb_clone((struct sk_buff*)skb, flags)) == NULL)
return NULL;
+++ /dev/null
-
-
-rm -f *.o
-rm -f ../wifi_power/*.o
-rm -f *.uu
-rm -rf bcm4319
-rm -f .*.cmd
-rm -f ../wifi_power/.*.cmd
-rm -f modules.order Module.symvers
-
-find . -name '*.o' -exec rm -f {} \;
-find . -name '.*.cmd' -exec rm -f {} \;
-
+++ /dev/null
-#!/bin/sh
-
-echo "Begin to make BCM4319 wifi driver package ..."
-
-RKWLCFGDIR=../wifi_power
-PKGNAME="bcm4319"
-RKPUB="rkpub"
-PKGVER=`grep -r '#define BCM4319_DRV_VERSION' ${RKWLCFGDIR}/wifi_version.h | sed 's/[^"]*\"\([0-9A-Za-z\.]*\)*\"/\1/'`
-
-[ `dirname $0` = '.' ] || exit
-
-
-rm -rf ${RKPUB}
-mkdir -p ${RKPUB}/${PKGNAME}
-
-cp Makefile.${PKGNAME} ${RKPUB}/${PKGNAME}/Makefile
-cp Kconfig.${PKGNAME} ${RKPUB}/${PKGNAME}/Kconfig
-cp ${RKWLCFGDIR}/wifi_power.c ${RKPUB}/${PKGNAME}/wifi_power.c
-cp ${RKWLCFGDIR}/wifi_power.h ${RKPUB}/${PKGNAME}/wifi_power.h
-cp ${RKWLCFGDIR}/wifi_version.h ${RKPUB}/${PKGNAME}/wifi_version.h
-chmod 644 ${RKPUB}/${PKGNAME}/*
-cp -dpR firmware ${RKPUB}/${PKGNAME}/
-find ${RKPUB}/${PKGNAME}/firmware -type d -name '.svn' | xargs rm -rf
-uuencode ${PKGNAME}.o ${PKGNAME}.o > ${RKPUB}/${PKGNAME}/${PKGNAME}.uu
-cd ${RKPUB} && tar -jcvf ${PKGNAME}-${PKGVER}.tar.bz2 ${PKGNAME}
-
-echo "Done"
results->buflen = dtoh32(results->buflen);
results->version = dtoh32(results->version);
results->count = dtoh32(results->count);
- //WL_DBG(("results->count = %d\n", results->count));
- //WL_DBG(("results->buflen = %d\n", results->buflen));
+ WL_DBG(("results->count = %d\n", results->count));
+ WL_DBG(("results->buflen = %d\n", results->buflen));
*status = dtoh32(list_buf->status);
*bss_list = results;
* 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_iw.c,v 1.51.4.9.2.6.4.124 2010/07/27 20:46:02 Exp $
+ * $Id: wl_iw.c,v 1.51.4.9.2.6.4.142.4.69 2010/12/21 03:00:08 Exp $
*/
-#include <wlioctl.h>
#include <typedefs.h>
#include <linuxver.h>
#include <proto/ethernet.h>
#include <dngl_stats.h>
#include <dhd.h>
-#include <dhd_dbg.h>
-#define WL_ERROR(x) DHD_ERROR(x)
-#define WL_TRACE(x) DHD_TRACE(x)
+#define WL_ERROR(x) printf x
+#define WL_TRACE(x)
#define WL_ASSOC(x)
#define WL_INFORM(x)
#define WL_WSEC(x)
#define WL_SCAN(x)
+#define WL_TRACE_COEX(x)
#include <wl_iw.h>
+#include <linux/wakelock.h>
+
#ifndef IW_ENCODE_ALG_SM4
#define IW_ENCODE_ALG_SM4 0x20
#define IW_WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
#include <linux/rtnetlink.h>
+#include <linux/mutex.h>
#define WL_IW_USE_ISCAN 1
#define ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS 1
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- struct mutex g_wl_ss_scan_lock;
-#endif
-
#if defined(SOFTAP)
-#define WL_SOFTAP(x) DHD_TRACE(x)
+#define WL_SOFTAP(x) printk x
static struct net_device *priv_dev;
-static bool ap_cfg_running = FALSE;
-static bool ap_fw_loaded = FALSE;
+static bool ap_cfg_running = FALSE;
+bool ap_fw_loaded = FALSE;
+static long ap_cfg_pid = -1;
struct net_device *ap_net_dev = NULL;
struct semaphore ap_eth_sema;
+static struct completion ap_cfg_exited;
static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap);
-static int wl_iw_softap_deassoc_stations(struct net_device *dev);
-#endif
+static int wl_iw_softap_deassoc_stations(struct net_device *dev, u8 *mac);
+#endif
#define WL_IW_IOCTL_CALL(func_call) \
do { \
} while (0)
static int g_onoff = G_WLAN_SET_ON;
+wl_iw_extra_params_t g_wl_iw_params;
+static struct mutex wl_cache_lock;
+
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+static bool use_non_dfs_channels = true;
+#endif
extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
uint32 reason, char* stringBuf, uint buflen);
#define MAX_WLIW_IOCTL_LEN 1024
+
#if defined(IL_BIGENDIAN)
#include <bcmendian.h>
#define htod32(i) (bcmswap32(i))
static wlc_ssid_t g_ssid;
static wl_iw_ss_cache_ctrl_t g_ss_cache_ctrl;
-static volatile uint g_first_broadcast_scan;
+#if defined(CONFIG_FIRST_SCAN)
+static volatile uint g_first_broadcast_scan;
+static volatile uint g_first_counter_scans;
+#define MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN 3
+#endif
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
#define DAEMONIZE(a) daemonize(a); \
#endif
#if defined(WL_IW_USE_ISCAN)
-#if !defined(CSCAN)
+#if !defined(CSCAN)
static void wl_iw_free_ss_cache(void);
static int wl_iw_run_ss_cache_timer(int kick_off);
-#endif
+#endif
+#if defined(CONFIG_FIRST_SCAN)
int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
+#endif
static int dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len);
#define ISCAN_STATE_IDLE 0
#define ISCAN_STATE_SCANING 1
int iscan_state;
iscan_buf_t * list_hdr;
iscan_buf_t * list_cur;
+
long sysioc_pid;
struct semaphore sysioc_sem;
char ioctlbuf[WLC_IOCTL_MEDLEN];
#else
char ioctlbuf[WLC_IOCTL_SMLEN];
-#endif
-
+#endif
wl_iscan_params_t *iscan_ex_params_p;
int iscan_ex_param_size;
} iscan_info_t;
-#define COEX_DHCP 1
+#define COEX_DHCP 1
+
+#define BT_DHCP_eSCO_FIX
+#define BT_DHCP_USE_FLAGS
+#define BT_DHCP_OPPORTUNITY_WINDOW_TIME 2500
+#define BT_DHCP_FLAG_FORCE_TIME 5500
static void wl_iw_bt_flag_set(struct net_device *dev, bool set);
static void wl_iw_bt_release(void);
BT_DHCP_OPPORTUNITY_WINDOW,
BT_DHCP_FLAG_FORCE_TIMEOUT
} coex_status_t;
-#define BT_DHCP_OPPORTUNITY_WINDOW_TIEM 2500
-#define BT_DHCP_FLAG_FORCE_TIME 5500
typedef struct bt_info {
struct net_device *dev;
struct timer_list timer;
uint32 timer_ms;
uint32 timer_on;
- int bt_state;
+ bool dhcp_done;
+ int bt_state;
-
- long bt_pid;
+ long bt_pid;
struct semaphore bt_sem;
struct completion bt_exited;
} bt_info_t;
union iwreq_data *wrqu,
char *extra
);
+
+#ifndef CSCAN
static int
wl_iw_get_scan(
struct net_device *dev,
char *extra,
short max_size
);
-
+#endif
static void swap_key_from_BE(
wl_wsec_key_t *key
key->iv_initialized = dtoh32(key->iv_initialized);
}
-static int dev_wlc_ioctl( struct net_device *dev,
+static int
+dev_wlc_ioctl(
+ struct net_device *dev,
int cmd,
void *arg,
int len
return ret;
}
+ net_os_wake_lock(dev);
+
WL_INFORM(("\n%s, PID:%x: send Local IOCTL -> dhd: cmd:0x%x, buf:%p, len:%d ,\n",
__FUNCTION__, current->pid, cmd, arg, len));
- if (g_onoff == G_WLAN_SET_ON)
- {
+ if (g_onoff == G_WLAN_SET_ON) {
memset(&ioc, 0, sizeof(ioc));
ioc.cmd = cmd;
ioc.buf = arg;
strcpy(ifr.ifr_name, dev->name);
ifr.ifr_data = (caddr_t) &ioc;
-
ret = dev_open(dev);
if (ret) {
WL_ERROR(("%s: Error dev_open: %d\n", __func__, ret));
+ net_os_wake_unlock(dev);
return ret;
}
fs = get_fs();
set_fs(get_ds());
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- //printk("Calling dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE)\n");
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
#else
ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif
+#endif
set_fs(fs);
}
else {
WL_TRACE(("%s: call after driver stop : ignored\n", __FUNCTION__));
}
+
+ net_os_wake_unlock(dev);
+
return ret;
}
+
static int
dev_wlc_intvar_get_reg(
struct net_device *dev,
}
-
-
static int
dev_wlc_intvar_set(
struct net_device *dev,
char *name,
char *buf, int len)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif
uint buflen;
buflen = bcm_mkiovar(name, buf, len, ioctlbuf, sizeof(ioctlbuf));
return (dev_wlc_ioctl(dev, WLC_SET_VAR, ioctlbuf, buflen));
}
-#endif
+#endif
static int
char *name,
char *buf, int buflen)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif
int error;
uint len;
return error;
}
+static int
+wl_iw_set_country_code(struct net_device *dev, char *ccode)
+{
+ char country_code[WLC_CNTRY_BUF_SZ];
+ int ret = -1;
+ WL_TRACE(("%s\n", __FUNCTION__));
+ if (!ccode)
+ ccode = dhd_bus_country_get(dev);
+ strncpy(country_code, ccode, sizeof(country_code));
+ if (ccode && (country_code[0] != 0)) {
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+ if (use_non_dfs_channels && !strncmp(country_code, "US", 2))
+ strncpy(country_code, "Q2", WLC_CNTRY_BUF_SZ);
+ if (!use_non_dfs_channels && !strncmp(country_code, "Q2", 2))
+ strncpy(country_code, "US", WLC_CNTRY_BUF_SZ);
+#endif
+ ret = dev_wlc_ioctl(dev, WLC_SET_COUNTRY, &country_code, sizeof(country_code));
+ if (ret >= 0) {
+ WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
+ dhd_bus_country_set(dev, &country_code[0]);
+ }
+ }
+ return ret;
+}
static int
wl_iw_set_country(
int country_offset;
int country_code_size;
+ WL_TRACE(("%s\n", __FUNCTION__));
memset(country_code, 0, sizeof(country_code));
-
country_offset = strcspn(extra, " ");
country_code_size = strlen(extra) - country_offset;
-
if (country_offset != 0) {
- strncpy(country_code, extra + country_offset +1,
+ strncpy(country_code, extra + country_offset + 1,
MIN(country_code_size, sizeof(country_code)));
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
- &country_code, sizeof(country_code))) >= 0) {
+ error = wl_iw_set_country_code(dev, country_code);
+ if (error >= 0) {
p += snprintf(p, MAX_WX_STRING, "OK");
WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
goto exit;
return error;
}
+static int
+wl_iw_get_country(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ char *ccode;
+ int current_channels;
+
+ WL_TRACE(("%s\n", __FUNCTION__));
+
+ ccode = dhd_bus_country_get(dev);
+ if(ccode){
+ if(0 == strcmp(ccode, "Q2"))
+ current_channels = 11;
+ else if(0 == strcmp(ccode, "EU"))
+ current_channels = 13;
+ else if(0 == strcmp(ccode, "JP"))
+ current_channels = 14;
+ }
+ sprintf(extra, "Scan-Channels = %d", current_channels);
+ printk("Get Channels return %d,(country code = %s)\n",current_channels, ccode);
+ return 0;
+}
+
#ifdef CUSTOMER_HW2
static int
wl_iw_set_power_mode(
{
int error = 0;
char *p = extra;
- static int pm = PM_FAST;
- int pm_local = PM_OFF;
+ static int pm = PM_FAST;
+ int pm_local = PM_OFF;
char powermode_val = 0;
- strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
+ WL_TRACE_COEX(("%s: DHCP session cmd:%s\n", __FUNCTION__, extra));
- if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
+ strncpy((char *)&powermode_val, extra + strlen("POWERMODE") + 1, 1);
- WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
+ if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm));
dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
- }
- else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
- WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
+ /* Disable packet filtering if necessary */
+ net_os_set_packet_filter(dev, 0);
+
+ g_bt->dhcp_done = false;
+ WL_TRACE_COEX(("%s: DHCP start, pm:%d changed to pm:%d\n",
+ __FUNCTION__, pm, pm_local));
+ } else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
- }
- else {
- WL_ERROR(("Unkwown yet power setting, ignored\n"));
+
+ /* Enable packet filtering if was turned off */
+ net_os_set_packet_filter(dev, 1);
+
+ g_bt->dhcp_done = true;
+
+ } else {
+ WL_ERROR(("%s Unkwown yet power setting, ignored\n",
+ __FUNCTION__));
}
p += snprintf(p, MAX_WX_STRING, "OK");
return error;
}
-#endif
+#endif
+
+
+static bool btcoex_is_sco_active(struct net_device *dev)
+{
+ int ioc_res = 0;
+ bool res = false;
+ int temp = 0;
+
+ ioc_res = dev_wlc_intvar_get_reg(dev, "btc_params", 4, &temp);
+
+ if (ioc_res == 0) {
+ WL_TRACE_COEX(("%s: read btc_params[4] = %x\n", __FUNCTION__, temp));
+
+ if ((temp > 0xea0) && (temp < 0xed8)) {
+ WL_TRACE_COEX(("%s: BT SCO/eSCO is ACTIVE\n", __FUNCTION__));
+ res = true;
+ } else {
+ WL_TRACE_COEX(("%s: BT SCO/eSCO is NOT detected\n", __FUNCTION__));
+ }
+ } else {
+ WL_ERROR(("%s ioc read btc params error\n", __FUNCTION__));
+ }
+ return res;
+}
+
+#if defined(BT_DHCP_eSCO_FIX)
+
+static int set_btc_esco_params(struct net_device *dev, bool trump_sco)
+{
+ static bool saved_status = false;
+
+ char buf_reg50va_dhcp_on[8] = { 50, 00, 00, 00, 0x22, 0x80, 0x00, 0x00 };
+ char buf_reg51va_dhcp_on[8] = { 51, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+ char buf_reg64va_dhcp_on[8] = { 64, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+ char buf_reg65va_dhcp_on[8] = { 65, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+ char buf_reg71va_dhcp_on[8] = { 71, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+
+ uint32 regaddr;
+ static uint32 saved_reg50;
+ static uint32 saved_reg51;
+ static uint32 saved_reg64;
+ static uint32 saved_reg65;
+ static uint32 saved_reg71;
+
+ if (trump_sco) {
+
+ WL_TRACE_COEX(("Do new SCO/eSCO coex algo {save & override} \n"));
+
+ if ((!dev_wlc_intvar_get_reg(dev, "btc_params", 50, &saved_reg50)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 51, &saved_reg51)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 64, &saved_reg64)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 65, &saved_reg65)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 71, &saved_reg71))) {
+
+ saved_status = TRUE;
+ WL_TRACE_COEX(("%s saved bt_params[50,51,64,65,71]:"
+ " 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ __FUNCTION__, saved_reg50, saved_reg51,
+ saved_reg64, saved_reg65, saved_reg71));
+
+ } else {
+ WL_ERROR((":%s: save btc_params failed\n",
+ __FUNCTION__));
+ saved_status = false;
+ return -1;
+ }
+
+ WL_TRACE_COEX(("override with [50,51,64,65,71]:"
+ " 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ *(u32 *)(buf_reg50va_dhcp_on+4),
+ *(u32 *)(buf_reg51va_dhcp_on+4),
+ *(u32 *)(buf_reg64va_dhcp_on+4),
+ *(u32 *)(buf_reg65va_dhcp_on+4),
+ *(u32 *)(buf_reg71va_dhcp_on+4)));
+
+ dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg50va_dhcp_on[0], 8);
+ dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg51va_dhcp_on[0], 8);
+ dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg64va_dhcp_on[0], 8);
+ dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg65va_dhcp_on[0], 8);
+ dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg71va_dhcp_on[0], 8);
+
+ saved_status = true;
+
+ } else if (saved_status) {
+
+ WL_TRACE_COEX(("Do new SCO/eSCO coex algo {save & override} \n"));
+
+ regaddr = 50;
+ dev_wlc_intvar_set_reg(dev, "btc_params",
+ (char *)®addr, (char *)&saved_reg50);
+ regaddr = 51;
+ dev_wlc_intvar_set_reg(dev, "btc_params",
+ (char *)®addr, (char *)&saved_reg51);
+ regaddr = 64;
+ dev_wlc_intvar_set_reg(dev, "btc_params",
+ (char *)®addr, (char *)&saved_reg64);
+ regaddr = 65;
+ dev_wlc_intvar_set_reg(dev, "btc_params",
+ (char *)®addr, (char *)&saved_reg65);
+ regaddr = 71;
+ dev_wlc_intvar_set_reg(dev, "btc_params",
+ (char *)®addr, (char *)&saved_reg71);
+
+ WL_TRACE_COEX(("restore bt_params[50,51,64,65,71]: 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ saved_reg50, saved_reg51, saved_reg64,
+ saved_reg65, saved_reg71));
+
+ saved_status = false;
+ } else {
+ WL_ERROR((":%s att to restore not saved BTCOEX params\n",
+ __FUNCTION__));
+ return -1;
+ }
+ return 0;
+}
+#endif
+
+static int
+wl_iw_get_power_mode(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ int error;
+ char *p = extra;
+ int pm_local = PM_FAST;
+
+ error = dev_wlc_ioctl(dev, WLC_GET_PM, &pm_local, sizeof(pm_local));
+ if (!error) {
+ WL_TRACE(("%s: Powermode = %d\n", __func__, pm_local));
+ if (pm_local == PM_OFF)
+ pm_local = 1; /* Active */
+ else
+ pm_local = 0; /* Auto */
+ p += snprintf(p, MAX_WX_STRING, "powermode = %d", pm_local);
+ }
+ else {
+ WL_TRACE(("%s: Error = %d\n", __func__, error));
+ p += snprintf(p, MAX_WX_STRING, "FAIL");
+ }
+ wrqu->data.length = p - extra + 1;
+ return error;
+}
+
static int
wl_iw_set_btcoex_dhcp(
struct net_device *dev,
static bool saved_status = FALSE;
char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-#ifndef CUSTOMER_HW2
- uint32 temp1, temp2;
-#endif
-
-#ifdef CUSTOMER_HW2
- strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") +1, 1);
+#ifdef CUSTOMER_HW2
+ strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") + 1, 1);
#else
- strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
+ strncpy((char *)&powermode_val, extra + strlen("POWERMODE") + 1, 1);
#endif
if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
- WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
+ WL_TRACE_COEX(("%s: DHCP session start, cmd:%s\n", __FUNCTION__, extra));
-
if ((saved_status == FALSE) &&
#ifndef CUSTOMER_HW2
- (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
+ (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
#endif
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 66, &saved_reg66)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 41, &saved_reg41)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 68, &saved_reg68))) {
- saved_status = TRUE;
- WL_TRACE(("Saved 0x%x 0x%x 0x%x\n", \
- saved_reg66, saved_reg41, saved_reg68));
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 66, &saved_reg66)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 41, &saved_reg41)) &&
+ (!dev_wlc_intvar_get_reg(dev, "btc_params", 68, &saved_reg68))) {
+ WL_TRACE_COEX(("save regs {66,41,68} ->: 0x%x 0x%x 0x%x\n", \
+ saved_reg66, saved_reg41, saved_reg68));
-
#ifndef CUSTOMER_HW2
- dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
+ dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
#endif
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg66va_dhcp_on[0], \
+ if (btcoex_is_sco_active(dev)) {
+
+ dev_wlc_bufvar_set(dev, "btc_params", \
+ (char *)&buf_reg66va_dhcp_on[0], \
sizeof(buf_reg66va_dhcp_on));
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg41va_dhcp_on[0], \
+
+ dev_wlc_bufvar_set(dev, "btc_params", \
+ (char *)&buf_reg41va_dhcp_on[0], \
sizeof(buf_reg41va_dhcp_on));
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg68va_dhcp_on[0], \
+
+ dev_wlc_bufvar_set(dev, "btc_params", \
+ (char *)&buf_reg68va_dhcp_on[0], \
sizeof(buf_reg68va_dhcp_on));
-
-#ifndef CUSTOMER_HW2
- if ((!dev_wlc_intvar_get_reg(dev, "btc_params", 12, &temp1)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 13, &temp2)))
- {
- if ((temp1 != 0) && (temp2 != 0)) {
-#endif
- g_bt->bt_state = BT_DHCP_START;
- g_bt->timer_on = 1;
- mod_timer(&g_bt->timer, g_bt->timer.expires);
- WL_TRACE(("%s enable BT DHCP Timer\n", \
- __FUNCTION__));
-#ifndef CUSTOMER_HW2
- }
- }
-#endif
+ saved_status = TRUE;
+
+ g_bt->bt_state = BT_DHCP_START;
+ g_bt->timer_on = 1;
+ mod_timer(&g_bt->timer, g_bt->timer.expires);
+ WL_TRACE_COEX(("%s enable BT DHCP Timer\n", \
+ __FUNCTION__));
+ }
}
else if (saved_status == TRUE) {
WL_ERROR(("%s was called w/o DHCP OFF. Continue\n", __FUNCTION__));
}
}
-#ifdef CUSTOMER_HW2
+#ifdef CUSTOMER_HW2
else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
#else
else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
#endif
- WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-
#ifndef CUSTOMER_HW2
dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
#endif
-
- WL_TRACE(("%s disable BT DHCP Timer\n", __FUNCTION__));
+ WL_TRACE_COEX(("%s disable BT DHCP Timer\n", __FUNCTION__));
if (g_bt->timer_on) {
g_bt->timer_on = 0;
del_timer_sync(&g_bt->timer);
+
+ if (g_bt->bt_state != BT_DHCP_IDLE) {
+ WL_TRACE_COEX(("%s bt->bt_state:%d\n",
+ __FUNCTION__, g_bt->bt_state));
+
+ up(&g_bt->bt_sem);
+ }
}
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
+ if (saved_status == TRUE) {
+ dev_wlc_bufvar_set(dev, "btc_flags", \
(char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
-
- if (saved_status) {
regaddr = 66;
dev_wlc_intvar_set_reg(dev, "btc_params", \
(char *)®addr, (char *)&saved_reg66);
regaddr = 68;
dev_wlc_intvar_set_reg(dev, "btc_params", \
(char *)®addr, (char *)&saved_reg68);
+
+ WL_TRACE_COEX(("restore regs {66,41,68} <- 0x%x 0x%x 0x%x\n", \
+ saved_reg66, saved_reg41, saved_reg68));
}
saved_status = FALSE;
-
}
else {
- WL_ERROR(("Unkwown yet power setting, ignored\n"));
+ WL_ERROR(("%s Unkwown yet power setting, ignored\n",
+ __FUNCTION__));
}
p += snprintf(p, MAX_WX_STRING, "OK");
return error;
}
+static int
+wl_iw_set_suspend(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ int suspend_flag;
+ int ret_now;
+ int ret = 0;
+
+ suspend_flag = *(extra + strlen(SETSUSPEND_CMD) + 1) - '0';
+
+ if (suspend_flag != 0)
+ suspend_flag = 1;
+
+ ret_now = net_os_set_suspend_disable(dev, suspend_flag);
+
+ if (ret_now != suspend_flag) {
+ if (!(ret = net_os_set_suspend(dev, ret_now)))
+ WL_ERROR(("%s: Suspend Flag %d -> %d\n", \
+ __FUNCTION__, ret_now, suspend_flag));
+ else
+ WL_ERROR(("%s: failed %d\n", __FUNCTION__, ret));
+ }
+
+ return ret;
+}
+
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+static int
+wl_iw_set_dfs_channels(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ use_non_dfs_channels = *(extra + strlen(SETDFSCHANNELS_CMD) + 1) - '0';
+ use_non_dfs_channels = (use_non_dfs_channels != 0) ? false : true;
+ wl_iw_set_country_code(dev, NULL);
+ return 0;
+}
+#endif
+
int
wl_format_ssid(char* ssid_buf, uint8* ssid, int ssid_len)
{
char *p = extra;
static int link_speed;
-
+ net_os_wake_lock(dev);
if (g_onoff == G_WLAN_SET_ON) {
error = dev_wlc_ioctl(dev, WLC_GET_RATE, &link_speed, sizeof(link_speed));
link_speed *= 500000;
wrqu->data.length = p - extra + 1;
+ net_os_wake_unlock(dev);
return error;
}
static int
-wl_iw_get_band(
+wl_iw_get_dtim_skip(
struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
{
int error = -1;
char *p = extra;
- static int band;
+ char iovbuf[32];
+ net_os_wake_lock(dev);
if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
- p += snprintf(p, MAX_WX_STRING, "Band %d", band);
+ memset(iovbuf, 0, sizeof(iovbuf));
+ strcpy(iovbuf, "bcn_li_dtim");
- wrqu->data.length = p - extra + 1;
+ if ((error = dev_wlc_ioctl(dev, WLC_GET_VAR,
+ &iovbuf, sizeof(iovbuf))) >= 0) {
+
+ p += snprintf(p, MAX_WX_STRING, "Dtim_skip %d", iovbuf[0]);
+ WL_TRACE(("%s: get dtim_skip = %d\n", __FUNCTION__, iovbuf[0]));
+ wrqu->data.length = p - extra + 1;
+ }
+ else
+ WL_ERROR(("%s: get dtim_skip failed code %d\n", \
+ __FUNCTION__, error));
}
+ net_os_wake_unlock(dev);
return error;
}
static int
-wl_iw_set_band(
+wl_iw_set_dtim_skip(
struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
{
int error = -1;
char *p = extra;
- char band;
+ int bcn_li_dtim;
+ char iovbuf[32];
+ net_os_wake_lock(dev);
if (g_onoff == G_WLAN_SET_ON) {
- band = *(extra + strlen(BAND_SET_CMD) + 1) - '0';
+ bcn_li_dtim = htod32((uint)*(extra + strlen(DTIM_SKIP_SET_CMD) + 1) - '0');
- if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
+ if ((bcn_li_dtim >= 0) || ((bcn_li_dtim <= 5))) {
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
- &band, sizeof(band))) >= 0) {
+ memset(iovbuf, 0, sizeof(iovbuf));
+ bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
+ 4, iovbuf, sizeof(iovbuf));
+
+ if ((error = dev_wlc_ioctl(dev, WLC_SET_VAR,
+ &iovbuf, sizeof(iovbuf))) >= 0) {
p += snprintf(p, MAX_WX_STRING, "OK");
- WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
+
+ net_os_set_dtim_skip(dev, bcn_li_dtim);
+
+ WL_TRACE(("%s: set dtim_skip %d OK\n", __FUNCTION__, \
+ bcn_li_dtim));
goto exit;
}
- else WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
- band, error));
+ else WL_ERROR(("%s: set dtim_skip %d failed code %d\n", \
+ __FUNCTION__, bcn_li_dtim, error));
}
- else WL_ERROR(("%s Incorrect band setting, ignored\n", __FUNCTION__));
+ else WL_ERROR(("%s Incorrect dtim_skip setting %d, ignored\n", \
+ __FUNCTION__, bcn_li_dtim));
}
p += snprintf(p, MAX_WX_STRING, "FAIL");
exit:
wrqu->data.length = p - extra + 1;
+ net_os_wake_unlock(dev);
return error;
}
static int
-wl_iw_get_rssi(
+wl_iw_get_band(
struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra
)
{
- static int rssi = 0;
- static wlc_ssid_t ssid = {0};
- int error = 0;
+ int error = -1;
char *p = extra;
- static char ssidbuf[SSID_FMT_BUF_LEN];
- scb_val_t scb_val;
+ static int band;
- bzero(&scb_val, sizeof(scb_val_t));
+ net_os_wake_lock(dev);
if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
- rssi = dtoh32(scb_val.val);
+ error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
- error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
+ p += snprintf(p, MAX_WX_STRING, "Band %d", band);
- ssid.SSID_len = dtoh32(ssid.SSID_len);
+ wrqu->data.length = p - extra + 1;
}
- wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
- p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
- wrqu->data.length = p - extra + 1;
-
+ net_os_wake_unlock(dev);
return error;
}
-int
-wl_iw_send_priv_event(
+
+static int
+wl_iw_set_band(
struct net_device *dev,
- char *flag
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
)
{
- union iwreq_data wrqu;
- char extra[IW_CUSTOM_MAX + 1];
- int cmd;
+ int error = -1;
+ char *p = extra;
+ uint band;
- cmd = IWEVCUSTOM;
- memset(&wrqu, 0, sizeof(wrqu));
- if (strlen(flag) > sizeof(extra))
+ net_os_wake_lock(dev);
+
+ if (g_onoff == G_WLAN_SET_ON) {
+
+ band = htod32((uint)*(extra + strlen(BAND_SET_CMD) + 1) - '0');
+
+ if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
+
+ if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
+ &band, sizeof(band))) >= 0) {
+ p += snprintf(p, MAX_WX_STRING, "OK");
+ WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
+ goto exit;
+ }
+ else WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
+ band, error));
+ }
+ else WL_ERROR(("%s Incorrect band setting %d, ignored\n", __FUNCTION__, band));
+ }
+
+ p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+ wrqu->data.length = p - extra + 1;
+ net_os_wake_unlock(dev);
+ return error;
+}
+
+#ifdef PNO_SUPPORT
+
+static int
+wl_iw_set_pno_reset(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ int error = -1;
+ char *p = extra;
+
+ net_os_wake_lock(dev);
+ if ((g_onoff == G_WLAN_SET_ON) && (dev != NULL)) {
+
+ if ((error = dhd_dev_pno_reset(dev)) >= 0) {
+ p += snprintf(p, MAX_WX_STRING, "OK");
+ WL_TRACE(("%s: set OK\n", __FUNCTION__));
+ goto exit;
+ }
+ else WL_ERROR(("%s: failed code %d\n", __FUNCTION__, error));
+ }
+
+ p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+ wrqu->data.length = p - extra + 1;
+ net_os_wake_unlock(dev);
+ return error;
+}
+
+
+
+static int
+wl_iw_set_pno_enable(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ int error = -1;
+ char *p = extra;
+ int pfn_enabled;
+
+ net_os_wake_lock(dev);
+ pfn_enabled = htod32((uint)*(extra + strlen(PNOENABLE_SET_CMD) + 1) - '0');
+
+ if ((g_onoff == G_WLAN_SET_ON) && (dev != NULL)) {
+
+ if ((error = dhd_dev_pno_enable(dev, pfn_enabled)) >= 0) {
+ p += snprintf(p, MAX_WX_STRING, "OK");
+ WL_TRACE(("%s: set OK\n", __FUNCTION__));
+ goto exit;
+ }
+ else WL_ERROR(("%s: failed code %d\n", __FUNCTION__, error));
+ }
+
+ p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+ wrqu->data.length = p - extra + 1;
+ net_os_wake_unlock(dev);
+ return error;
+}
+
+
+
+static int
+wl_iw_set_pno_set(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ int res = -1;
+ wlc_ssid_t ssids_local[MAX_PFN_LIST_COUNT];
+ int nssid = 0;
+ cmd_tlv_t *cmd_tlv_temp;
+ char *str_ptr;
+ char *str_ptr_end;
+ int tlv_size_left;
+ int pno_time;
+
+#ifdef PNO_SET_DEBUG
+ int i;
+ char pno_in_example[] = {'P', 'N', 'O', 'S', 'E', 'T', 'U', 'P', ' ', \
+ 'S', '1', '2', '0',
+ 'S',
+ 0x04,
+ 'B', 'R', 'C', 'M',
+ 'S',
+ 0x04,
+ 'G', 'O', 'O', 'G',
+ 'T',
+ '1','E',
+ 0x00
+ };
+#endif
+
+ net_os_wake_lock(dev);
+ WL_ERROR(("\n### %s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
+ __FUNCTION__, info->cmd, info->flags,
+ wrqu->data.pointer, wrqu->data.length));
+
+ if (g_onoff == G_WLAN_SET_OFF) {
+ WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
+ goto exit_proc;
+ }
+
+ if (wrqu->data.length < (strlen(PNOSETUP_SET_CMD) + sizeof(cmd_tlv_t))) {
+ WL_ERROR(("%s aggument=%d less %d\n", __FUNCTION__, \
+ wrqu->data.length, strlen(PNOSETUP_SET_CMD) + sizeof(cmd_tlv_t)));
+ goto exit_proc;
+ }
+
+#ifdef PNO_SET_DEBUG
+ if (!(extra = kmalloc(sizeof(pno_in_example) +100, GFP_KERNEL))) {
+ res = -ENOMEM;
+ goto exit_proc;
+ }
+ memcpy(extra, pno_in_example, sizeof(pno_in_example));
+ wrqu->data.length = sizeof(pno_in_example);
+ for (i = 0; i < wrqu->data.length; i++)
+ printf("%02X ", extra[i]);
+ printf("\n");
+#endif
+
+ str_ptr = extra;
+#ifdef PNO_SET_DEBUG
+ str_ptr += strlen("PNOSETUP ");
+ tlv_size_left = wrqu->data.length - strlen("PNOSETUP ");
+#else
+ str_ptr += strlen(PNOSETUP_SET_CMD);
+ tlv_size_left = wrqu->data.length - strlen(PNOSETUP_SET_CMD);
+#endif
+
+ cmd_tlv_temp = (cmd_tlv_t *)str_ptr;
+ memset(ssids_local, 0, sizeof(ssids_local));
+
+ if ((cmd_tlv_temp->prefix == PNO_TLV_PREFIX) && \
+ (cmd_tlv_temp->version == PNO_TLV_VERSION) && \
+ (cmd_tlv_temp->subver == PNO_TLV_SUBVERSION))
+ {
+ str_ptr += sizeof(cmd_tlv_t);
+ tlv_size_left -= sizeof(cmd_tlv_t);
+
+ if ((nssid = wl_iw_parse_ssid_list_tlv(&str_ptr, ssids_local, \
+ MAX_PFN_LIST_COUNT, &tlv_size_left)) <= 0) {
+ WL_ERROR(("SSID is not presented or corrupted ret=%d\n", nssid));
+ goto exit_proc;
+ }
+ else {
+ if ((str_ptr[0] != PNO_TLV_TYPE_TIME) || (tlv_size_left <= 1)) {
+ WL_ERROR(("%s scan duration corrupted field size %d\n", \
+ __FUNCTION__, tlv_size_left));
+ goto exit_proc;
+ }
+ str_ptr++;
+ pno_time = simple_strtoul(str_ptr, &str_ptr_end, 16);
+ WL_ERROR((" got %d bytes left pno_time %d or %#x\n", \
+ tlv_size_left, pno_time, pno_time));
+ }
+ }
+ else {
+ WL_ERROR(("%s get wrong TLV command\n", __FUNCTION__));
+ goto exit_proc;
+ }
+
+ res = dhd_dev_pno_set(dev, ssids_local, nssid, pno_time);
+
+exit_proc:
+ net_os_wake_unlock(dev);
+ return res;
+}
+#endif
+
+static int
+wl_iw_get_rssi(
+ struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra
+)
+{
+ static int rssi = 0;
+ static wlc_ssid_t ssid = {0};
+ int error = 0;
+ char *p = extra;
+ static char ssidbuf[SSID_FMT_BUF_LEN];
+ scb_val_t scb_val;
+
+ net_os_wake_lock(dev);
+
+ bzero(&scb_val, sizeof(scb_val_t));
+
+ if (g_onoff == G_WLAN_SET_ON) {
+ error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
+ if (error) {
+ WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
+ } else {
+ rssi = dtoh32(scb_val.val);
+
+ error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
+ if (!error) {
+ ssid.SSID_len = dtoh32(ssid.SSID_len);
+ wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
+ }
+ }
+ }
+
+ WL_ASSOC(("%s ssid_len:%d, rssi:%d\n", __FUNCTION__, ssid.SSID_len, rssi));
+
+ if (error || (ssid.SSID_len == 0)) {
+ p += snprintf(p, MAX_WX_STRING, "FAIL");
+ } else {
+ p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
+ }
+ wrqu->data.length = p - extra + 1;
+
+ net_os_wake_unlock(dev);
+ return error;
+}
+
+int
+wl_iw_send_priv_event(
+ struct net_device *dev,
+ char *flag
+)
+{
+ union iwreq_data wrqu;
+ char extra[IW_CUSTOM_MAX + 1];
+ int cmd;
+
+ cmd = IWEVCUSTOM;
+ memset(&wrqu, 0, sizeof(wrqu));
+ if (strlen(flag) > sizeof(extra))
return -1;
strcpy(extra, flag);
wrqu.data.length = strlen(extra);
wireless_send_event(dev, cmd, &wrqu, extra);
+ net_os_wake_lock_timeout_enable(dev);
WL_TRACE(("Send IWEVCUSTOM Event as %s\n", extra));
return 0;
}
iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK(iw->pub);
+
+ if (!iw) {
+ WL_ERROR(("%s: wl is null\n", __FUNCTION__));
+ return -1;
+ }
+ dhd_os_start_lock(iw->pub);
if (g_onoff == G_WLAN_SET_OFF) {
dhd_customer_gpio_wlan_ctrl(WLAN_RESET_ON);
-#if 0
+
#if defined(BCMLXSDMMC)
sdioh_start(NULL, 0);
#endif
- dhd_dev_reset(dev, 0);
+ ret = dhd_dev_reset(dev, 0);
+ if (ret == BCME_OK) {
#if defined(BCMLXSDMMC)
- sdioh_start(NULL, 1);
-#endif
-
- dhd_dev_init_ioctl(dev);
+ sdioh_start(NULL, 1);
#endif
- g_onoff = G_WLAN_SET_ON;
+ dhd_dev_init_ioctl(dev);
+ g_onoff = G_WLAN_SET_ON;
+ }
}
WL_TRACE(("Exited %s \n", __FUNCTION__));
- MUTEX_UNLOCK(iw->pub);
+ dhd_os_start_unlock(iw->pub);
return ret;
}
+
+
static int
wl_iw_control_wl_off(
struct net_device *dev,
}
iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK(iw->pub);
+ if (!iw) {
+ WL_ERROR(("%s: dev is null\n", __FUNCTION__));
+ return -1;
+ }
+ dhd_os_start_lock(iw->pub);
#ifdef SOFTAP
ap_cfg_running = FALSE;
-#endif
+#endif
if (g_onoff == G_WLAN_SET_ON) {
g_onoff = G_WLAN_SET_OFF;
-
#if defined(WL_IW_USE_ISCAN)
g_iscan->iscan_state = ISCAN_STATE_IDLE;
-#endif
-#if 0
- dhd_dev_reset(dev, 1);
#endif
+
+ dhd_dev_reset(dev, 1);
+
#if defined(WL_IW_USE_ISCAN)
#if !defined(CSCAN)
-
wl_iw_free_ss_cache();
wl_iw_run_ss_cache_timer(0);
-
+
g_ss_cache_ctrl.m_link_down = 1;
-#endif
+#endif
memset(g_scan, 0, G_SCAN_RESULTS);
g_scan_specified_ssid = 0;
-
+#if defined(CONFIG_FIRST_SCAN)
g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
-#endif
-#if 0
+ g_first_counter_scans = 0;
+#endif
+#endif
+
#if defined(BCMLXSDMMC)
sdioh_stop(NULL);
#endif
-#endif
+
+ net_os_set_dtim_skip(dev, 0);
+
dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
wl_iw_send_priv_event(dev, "STOP");
-
}
- MUTEX_UNLOCK(iw->pub);
+ dhd_os_start_unlock(iw->pub);
WL_TRACE(("Exited %s\n", __FUNCTION__));
WL_TRACE(("Enter %s \n", __FUNCTION__));
- ret = wl_control_wl_start(dev);
+ if ((ret = wl_control_wl_start(dev)) != BCME_OK) {
+ WL_ERROR(("%s failed first attemp\n", __FUNCTION__));
+ dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
+ if ((ret = wl_control_wl_start(dev)) != BCME_OK) {
+ WL_ERROR(("%s failed second attemp\n", __FUNCTION__));
+ net_os_send_hang_message(dev);
+ return ret;
+ }
+ }
wl_iw_send_priv_event(dev, "START");
-#if !defined(CSCAN)
#ifdef SOFTAP
if (!ap_fw_loaded) {
wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
#else
wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
#endif
-#endif
WL_TRACE(("Exited %s \n", __FUNCTION__));
#ifdef SOFTAP
static struct ap_profile my_ap;
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap);
+static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap);
static int get_assoc_sta_list(struct net_device *dev, char *buf, int len);
-static int set_ap_mac_list(struct net_device *dev, char *buf);
-#endif /* SOFTAP */
+static int set_ap_mac_list(struct net_device *dev, void *buf);
+
+#define PTYPE_STRING 0
+#define PTYPE_INTDEC 1
+#define PTYPE_INTHEX 2
+#define PTYPE_STR_HEX 3
+int get_parmeter_from_string(
+ char **str_ptr, const char *token, int param_type, void *dst, int param_max_len);
+
+#endif
int hex2num(char c)
{
return 0;
}
-
-
-#if defined(SOFTAP) || defined(CSCAN)
-
-/* parameter type */
-#define PTYPE_STRING 0
-#define PTYPE_INTDEC 1
-#define PTYPE_INTHEX 2
-#define PTYPE_STR_HEX 3
-
-int get_parmeter_from_string(
- char **str_ptr, const char *token,
- int param_type, void *dst, int param_max_len)
-{
- char int_str[7] = "0";
- int parm_str_len;
- char *param_str_begin;
- char *param_str_end;
- char *orig_str = *str_ptr;
-
- if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
-
- strsep(str_ptr, "=,");
- param_str_begin = *str_ptr;
- strsep(str_ptr, "=,");
-
- if (*str_ptr == NULL) {
-
- parm_str_len = strlen(param_str_begin);
- } else {
- param_str_end = *str_ptr-1;
- parm_str_len = param_str_end - param_str_begin;
- }
-
- WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
-
- if (parm_str_len > param_max_len) {
- WL_ERROR((" WARNING: extracted param len:%d is > MAX:%d\n",
- parm_str_len, param_max_len));
-
- parm_str_len = param_max_len;
- }
-
- switch (param_type) {
-
- case PTYPE_INTDEC: {
-
- int *pdst_int = dst;
- char *eptr;
- if (parm_str_len > sizeof(int_str))
- parm_str_len = sizeof(int_str);
-
- memcpy(int_str, param_str_begin, parm_str_len);
-
- *pdst_int = simple_strtoul(int_str, &eptr, 10);
-
- WL_TRACE((" written as integer:%d\n", *pdst_int));
- }
- break;
- case PTYPE_STR_HEX: {
- u8 *buf = dst;
-
- param_max_len = param_max_len >> 1;
- hstr_2_buf(param_str_begin, buf, param_max_len);
- print_buf(buf, param_max_len, 0);
- }
- break;
- default:
-
- memcpy(dst, param_str_begin, parm_str_len);
- *((char *)dst + parm_str_len) = 0;
- WL_ERROR((" written as a string:%s\n", (char *)dst));
- break;
-
- }
-
- return 0;
- } else {
- WL_ERROR(("\n %s: ERROR: can't find token:%s in str:%s \n",
- __FUNCTION__, token, orig_str));
-
- return -1;
- }
-}
-
-#endif
-
-
#ifdef SOFTAP
int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
{
memset(sub_cmd, 0, sizeof(sub_cmd));
memset(ap_cfg, 0, sizeof(struct ap_profile));
-
if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=",
PTYPE_STRING, sub_cmd, SSID_LEN) != 0) {
- return -1;
+ return -1;
}
if (strncmp(sub_cmd, "AP_CFG", 6)) {
- WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
+ WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
return -1;
}
-
-
ret = get_parmeter_from_string(&str_ptr, "SSID=", PTYPE_STRING, ap_cfg->ssid, SSID_LEN);
ret |= get_parmeter_from_string(&str_ptr, "SEC=", PTYPE_STRING, ap_cfg->sec, SEC_LEN);
ret |= get_parmeter_from_string(&str_ptr, "CHANNEL=", PTYPE_INTDEC, &ap_cfg->channel, 5);
- ret |= get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
+ get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
+
+ get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC, &ap_cfg->max_scb, 5);
- ret |= get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC, &ap_cfg->max_scb, 5);
+ get_parmeter_from_string(&str_ptr, "HIDDEN=", PTYPE_INTDEC, &ap_cfg->closednet, 5);
+
+ get_parmeter_from_string(&str_ptr, "COUNTRY=", PTYPE_STRING, &ap_cfg->country_code, 3);
return ret;
}
-#endif
-
+#endif
#ifdef SOFTAP
static int iwpriv_set_ap_config(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *ext)
{
int res = 0;
char *extra = NULL;
struct ap_profile *ap_cfg = &my_ap;
- WL_TRACE(("> Got IWPRIV SET_AP IOCTL: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
+ WL_TRACE(("%s: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
+ __FUNCTION__,
info->cmd, info->flags,
wrqu->data.pointer, wrqu->data.length));
-
if (wrqu->data.length != 0) {
char *str_ptr;
memset(ap_cfg, 0, sizeof(struct ap_profile));
-
-
str_ptr = extra;
if ((res = init_ap_profile_from_string(extra, ap_cfg)) < 0) {
}
} else {
-
- WL_ERROR(("IWPRIV argument len = 0 \n"));
- return -1;
+ WL_ERROR(("IWPRIV argument len = 0 \n"));
+ return -1;
}
if ((res = set_ap_cfg(dev, ap_cfg)) < 0)
return res;
}
-#endif
-
+#endif
#ifdef SOFTAP
static int iwpriv_get_assoc_list(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *p_iwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *p_iwrq,
+ char *extra)
{
int i, ret = 0;
char mac_buf[256];
struct maclist *sta_maclist = (struct maclist *)mac_buf;
- char mac_lst[256];
+ char mac_lst[384];
char *p_mac_str;
+ char *p_mac_str_end;
+
+ if ((!dev) || (!extra)) {
+ return -EINVAL;
+ }
+
+ net_os_wake_lock(dev);
WL_TRACE(("\n %s: IWPRIV IOCTL: cmd:%hx, flags:%hx, extra:%p, iwp.len:%d, \
iwp.len:%p, iwp.flags:%x \n", __FUNCTION__, info->cmd, info->flags, \
extra, p_iwrq->data.length, p_iwrq->data.pointer, p_iwrq->data.flags));
- WL_SOFTAP(("extra:%s\n", extra));
- print_buf((u8 *)p_iwrq, 16, 0);
-
memset(sta_maclist, 0, sizeof(mac_buf));
sta_maclist->count = 8;
- WL_TRACE((" net device:%s, buf_sz:%d\n", dev->name, sizeof(mac_buf)));
- get_assoc_sta_list(dev, mac_buf, 256);
- WL_TRACE((" got %d stations\n", sta_maclist->count));
+ WL_SOFTAP(("%s: net device:%s, buf_sz:%d\n",
+ __FUNCTION__, dev->name, sizeof(mac_buf)));
+
+ if ((ret = get_assoc_sta_list(dev, mac_buf, sizeof(mac_buf))) < 0) {
+ WL_ERROR(("%s: sta list ioctl error:%d\n",
+ __FUNCTION__, ret));
+ goto func_exit;
+ }
+
+ WL_SOFTAP(("%s: got %d stations\n", __FUNCTION__,
+ sta_maclist->count));
-
memset(mac_lst, 0, sizeof(mac_lst));
p_mac_str = mac_lst;
+ p_mac_str_end = &mac_lst[sizeof(mac_lst)-1];
for (i = 0; i < 8; i++) {
- struct ether_addr * id = &sta_maclist->ea[i];
+ struct ether_addr *id = &sta_maclist->ea[i];
+ if (!ETHER_ISNULLADDR(id->octet)) {
+ scb_val_t scb_val;
+ int rssi = 0;
- WL_SOFTAP(("dhd_drv>> sta_mac[%d] :", i));
- print_buf((unsigned char *)&sta_maclist->ea[i], 6, 0);
+ bzero(&scb_val, sizeof(scb_val_t));
-
- p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
- "Mac[%d]=%02X:%02X:%02X:%02X:%02X:%02X\n", i,
+ if ((p_mac_str_end - p_mac_str) <= 36) {
+ WL_ERROR(("%s: mac list buf is < 36 for item[%i] item\n",
+ __FUNCTION__, i));
+ break;
+ }
+
+ p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
+ "\nMac[%d]=%02X:%02X:%02X:%02X:%02X:%02X,", i,
id->octet[0], id->octet[1], id->octet[2],
id->octet[3], id->octet[4], id->octet[5]);
+ bcopy(id->octet, &scb_val.ea, 6);
+ ret = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
+ if (ret < 0) {
+ snprintf(p_mac_str, MAX_WX_STRING, "RSSI:ERR");
+ WL_ERROR(("%s: RSSI ioctl error:%d\n",
+ __FUNCTION__, ret));
+ break;
+ }
+
+ rssi = dtoh32(scb_val.val);
+ p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
+ "RSSI:%d", rssi);
+ }
}
- p_iwrq->data.length = strlen(mac_lst);
+ p_iwrq->data.length = strlen(mac_lst) + 1;
- WL_TRACE(("u.pointer:%p\n", p_iwrq->data.pointer));
- WL_TRACE(("resulting str:\n%s \n len:%d\n\n", mac_lst, p_iwrq->data.length));
+ WL_SOFTAP(("%s: data to user:\n%s\n usr_ptr:%p\n", __FUNCTION__,
+ mac_lst, p_iwrq->data.pointer));
if (p_iwrq->data.length) {
- if (copy_to_user(p_iwrq->data.pointer, mac_lst, p_iwrq->data.length)) {
- WL_ERROR(("%s: Can't copy to user\n", __FUNCTION__));
- return -EFAULT;
- }
+ bcopy(mac_lst, extra, p_iwrq->data.length);
}
- WL_ERROR(("Exited %s \n", __FUNCTION__));
+func_exit:
+ net_os_wake_unlock(dev);
+
+ WL_TRACE(("Exited %s \n", __FUNCTION__));
return ret;
}
-#endif
+#endif
#ifdef SOFTAP
+#define MAC_FILT_MAX 8
static int iwpriv_set_mac_filters(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *ext)
{
-
int i, ret = -1;
char * extra = NULL;
- u8 macfilt[8][6];
- int mac_cnt = 0;
- char sub_cmd[16];
+ int mac_cnt = 0;
+ int mac_mode = 0;
+ struct ether_addr *p_ea;
+ struct mac_list_set mflist_set;
- WL_TRACE((">>> Got IWPRIV SET_MAC_FILTER IOCTL: info->cmd:%x, \
+ WL_SOFTAP((">>> Got IWPRIV SET_MAC_FILTER IOCTL: info->cmd:%x, \
info->flags:%x, u.data:%p, u.len:%d\n",
info->cmd, info->flags,
wrqu->data.pointer, wrqu->data.length));
extra[wrqu->data.length] = 0;
WL_SOFTAP((" Got parameter string in iw_point:\n %s \n", extra));
- memset(macfilt, 0, sizeof(macfilt));
- memset(sub_cmd, 0, sizeof(sub_cmd));
+ memset(&mflist_set, 0, sizeof(mflist_set));
-
str_ptr = extra;
-
- if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=", PTYPE_STRING, sub_cmd, 15) != 0) {
- goto exit_proc;
- }
-
-#define MAC_FILT_MAX 8
-
- if (strncmp(sub_cmd, "MAC_FLT_W", strlen("MAC_FLT_W"))) {
- WL_ERROR(("ERROR: sub_cmd:%s != 'MAC_FLT_W'!\n", sub_cmd));
+ if (get_parmeter_from_string(&str_ptr, "MAC_MODE=",
+ PTYPE_INTDEC, &mac_mode, 4) != 0) {
+ WL_ERROR(("ERROR: 'MAC_MODE=' token is missing\n"));
goto exit_proc;
}
+ p_ea = &mflist_set.mac_list.ea[0];
+
if (get_parmeter_from_string(&str_ptr, "MAC_CNT=",
PTYPE_INTDEC, &mac_cnt, 4) != 0) {
- WL_ERROR(("ERROR: MAC_CNT param is missing \n"));
+ WL_ERROR(("ERROR: 'MAC_CNT=' token param is missing \n"));
goto exit_proc;
}
goto exit_proc;
}
- for (i=0; i< mac_cnt; i++)
- if (get_parmeter_from_string(&str_ptr, "MAC=",
- PTYPE_STR_HEX, macfilt[i], 12) != 0) {
- WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
- goto exit_proc;
- }
+ for (i=0; i < mac_cnt; i++)
+ if (get_parmeter_from_string(&str_ptr, "MAC=",
+ PTYPE_STR_HEX, &p_ea[i], 12) != 0) {
+ WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
+ goto exit_proc;
+ }
+ WL_SOFTAP(("MAC_MODE=:%d, MAC_CNT=%d, MACs:..\n", mac_mode, mac_cnt));
for (i = 0; i < mac_cnt; i++) {
WL_SOFTAP(("mac_filt[%d]:", i));
- print_buf(macfilt[i], 6, 0);
+ print_buf(&p_ea[i], 6, 0);
}
-
+ mflist_set.mode = mac_mode;
+ mflist_set.mac_list.count = mac_cnt;
+ set_ap_mac_list(dev, &mflist_set);
+
wrqu->data.pointer = NULL;
wrqu->data.length = 0;
ret = 0;
} else {
-
- WL_ERROR(("IWPRIV argument len is 0\n"));
- return -1;
+ WL_ERROR(("IWPRIV argument len is 0\n"));
+ return -1;
}
exit_proc:
kfree(extra);
return ret;
}
-#endif
+#endif
+
+
+#ifdef SOFTAP
+static int iwpriv_set_ap_sta_disassoc(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *ext)
+{
+ int res = 0;
+ char sta_mac[6] = {0, 0, 0, 0, 0, 0};
+ char cmd_buf[256];
+ char *str_ptr = cmd_buf;
+
+ WL_SOFTAP((">>%s called\n args: info->cmd:%x,"
+ " info->flags:%x, u.data.p:%p, u.data.len:%d\n",
+ __FUNCTION__, info->cmd, info->flags,
+ wrqu->data.pointer, wrqu->data.length));
+
+ if (wrqu->data.length != 0) {
+
+ if (copy_from_user(cmd_buf, wrqu->data.pointer, wrqu->data.length)) {
+ return -EFAULT;
+ }
+
+ if (get_parmeter_from_string(&str_ptr,
+ "MAC=", PTYPE_STR_HEX, sta_mac, 12) == 0) {
+ res = wl_iw_softap_deassoc_stations(dev, sta_mac);
+ } else {
+ WL_ERROR(("ERROR: STA_MAC= token not found\n"));
+ }
+ }
+
+ return res;
+}
+#endif
+
+#endif
-#endif
#if WIRELESS_EXT < 13
struct iw_request_info
};
typedef int (*iw_handler)(struct net_device *dev,
- struct iw_request_info *info,
- void *wrqu,
- char *extra);
+ struct iw_request_info *info,
+ void *wrqu,
+ char *extra);
#endif
static int
void *zwrq,
char *extra
)
-{
+{
wlc_ssid_t ssid;
int error;
struct sockaddr bssid;
int error, chan;
uint sf = 0;
- WL_TRACE(("%s %s: SIOCSIWFREQ : e=%d m=%d\n", __func__, dev->name, fwrq->e, fwrq->m));
+ WL_TRACE(("%s %s: SIOCSIWFREQ\n", __FUNCTION__, dev->name));
#if defined(SOFTAP)
if (ap_cfg_running) {
#endif
- if (fwrq->e == 0 && fwrq->m < MAXCHANNEL)
- {
+ if (fwrq->e == 0 && fwrq->m < MAXCHANNEL) {
chan = fwrq->m;
}
- else
- {
- if (fwrq->e >= 6)
- {
+
+
+ else {
+
+ if (fwrq->e >= 6) {
fwrq->e -= 6;
while (fwrq->e--)
fwrq->m *= 10;
- }
- else if (fwrq->e < 6)
- {
+ } else if (fwrq->e < 6) {
while (fwrq->e++ < 6)
fwrq->m /= 10;
}
- if (fwrq->m > 4000 && fwrq->m < 5000)
- sf = WF_CHAN_FACTOR_4_G;
+ if (fwrq->m > 4000 && fwrq->m < 5000)
+ sf = WF_CHAN_FACTOR_4_G;
chan = wf_mhz2channel(fwrq->m, sf);
}
- chan = htod32(chan);
+ chan = htod32(chan);
if ((error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan))))
return error;
+ g_wl_iw_params.target_channel = chan;
return -EINPROGRESS;
}
if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
return error;
-
fwrq->m = dtoh32(ci.hw_channel);
fwrq->e = dtoh32(0);
return 0;
return error;
- return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_mode(
- struct net_device *dev,
- struct iw_request_info *info,
- __u32 *uwrq,
- char *extra
-)
-{
- int error, infra = 0, ap = 0;
-
- WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
- (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
- return error;
-
- infra = dtoh32(infra);
- ap = dtoh32(ap);
- *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
-
- return 0;
-}
-
-static int
-wl_iw_set_sens(
- struct net_device *dev,
- struct iw_request_info *info,
- __u32 *uwrq,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCSIWSENS\n", dev->name));
- return 0;
+ return -EINPROGRESS;
}
static int
-wl_iw_get_sens(
+wl_iw_get_mode(
struct net_device *dev,
struct iw_request_info *info,
- union iwreq_data *wrqu,
+ __u32 *uwrq,
char *extra
)
{
- static int rssi = 0;
- static wlc_ssid_t ssid = {0};
- int error = 0;
- static char ssidbuf[SSID_FMT_BUF_LEN];
- scb_val_t scb_val;
+ int error, infra = 0, ap = 0;
- WL_TRACE(("%s: SIOCGIWSENS\n", dev->name));
-
- bzero(&scb_val, sizeof(scb_val_t));
-
- if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
- if (error) {
- WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
- return error;
- }
- rssi = dtoh32(scb_val.val);
-
- error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
- if (!error) {
- ssid.SSID_len = dtoh32(ssid.SSID_len);
- wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
- }
- }
-
- wrqu->sens.value = -rssi;
-
- return error;
+ WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
+
+ if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
+ (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
+ return error;
+
+ infra = dtoh32(infra);
+ ap = dtoh32(ap);
+ *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
+
+ return 0;
}
static int
dwrq->length = sizeof(struct iw_range);
memset(range, 0, sizeof(range));
-
range->min_nwid = range->max_nwid = 0;
-
list->count = htod32(MAXCHANNEL);
if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, (MAXCHANNEL+1)*4))) {
kfree(channels);
}
range->num_frequency = range->num_channels = i;
-
range->max_qual.qual = 5;
range->max_qual.level = 0x100 - 200;
range->avg_qual.noise = 0x100 - 75;
#endif
-
if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset)))) {
kfree(channels);
return error;
}
}
-
if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i)))) {
kfree(channels);
return error;
else
range->throughput = 1500000;
-
range->min_rts = 0;
range->max_rts = 2347;
range->min_frag = 256;
#endif
range->encoding_size[3] = AES_KEY_SIZE;
-
range->min_pmp = 0;
range->max_pmp = 0;
range->min_pmt = 0;
range->pmp_flags = 0;
range->pm_capa = 0;
-
range->num_txpower = 2;
range->txpower[0] = 1;
range->txpower[1] = 255;
range->we_version_compiled = WIRELESS_EXT;
range->we_version_source = 19;
-
range->retry_capa = IW_RETRY_LIMIT;
range->retry_flags = IW_RETRY_LIMIT;
range->r_time_flags = 0;
range->enc_capa |= IW_ENC_CAPA_WPA2;
#endif
-
IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
-
+
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
return 0;
}
+
+static int
+wl_iw_ch_to_chanspec(int ch, wl_join_params_t *join_params, int *join_params_size)
+{
+ chanspec_t chanspec = 0;
+
+ if (ch != 0) {
+
+ join_params->params.chanspec_num = 1;
+ join_params->params.chanspec_list[0] = ch;
+
+ if (join_params->params.chanspec_list[0])
+ chanspec |= WL_CHANSPEC_BAND_2G;
+ else
+ chanspec |= WL_CHANSPEC_BAND_5G;
+
+ chanspec |= WL_CHANSPEC_BW_20;
+ chanspec |= WL_CHANSPEC_CTL_SB_NONE;
+
+ *join_params_size += WL_ASSOC_PARAMS_FIXED_SIZE +
+ join_params->params.chanspec_num * sizeof(chanspec_t);
+
+ join_params->params.chanspec_list[0] &= WL_CHANSPEC_CHAN_MASK;
+ join_params->params.chanspec_list[0] |= chanspec;
+ join_params->params.chanspec_list[0] =
+ htodchanspec(join_params->params.chanspec_list[0]);
+
+ join_params->params.chanspec_num = htod32(join_params->params.chanspec_num);
+
+ WL_TRACE(("%s join_params->params.chanspec_list[0]= %X\n", \
+ __FUNCTION__, join_params->params.chanspec_list[0]));
+ }
+ return 1;
+}
+
static int
wl_iw_set_wap(
struct net_device *dev,
{
int error = -EINVAL;
wl_join_params_t join_params;
+ int join_params_size;
WL_TRACE(("%s: SIOCSIWAP\n", dev->name));
memset(&join_params, 0, sizeof(join_params));
+ join_params_size = sizeof(join_params.ssid);
memcpy(join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
memcpy(&join_params.params.bssid, awrq->sa_data, ETHER_ADDR_LEN);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, sizeof(join_params)))) {
- WL_ERROR(("Invalid ioctl data.\n"));
+ WL_ASSOC(("%s target_channel=%d\n", __FUNCTION__, g_wl_iw_params.target_channel));
+ wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params, &join_params_size);
+
+ if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size))) {
+ WL_ERROR(("%s Invalid ioctl data=%d\n", __FUNCTION__, error));
return error;
}
+ if (g_ssid.SSID_len) {
+ WL_ASSOC(("%s: join SSID=%s BSSID="MACSTR" ch=%d\n", __FUNCTION__, \
+ g_ssid.SSID, MAC2STR((u8 *)awrq->sa_data), \
+ g_wl_iw_params.target_channel));
+ }
+
memset(&g_ssid, 0, sizeof(g_ssid));
return 0;
}
#endif
+#ifndef WL_IW_USE_ISCAN
static int
wl_iw_get_aplist(
struct net_device *dev,
if (!extra)
return -EINVAL;
-
list = kmalloc(buflen, GFP_KERNEL);
if (!list)
return -ENOMEM;
list->version = dtoh32(list->version);
list->count = dtoh32(list->count);
if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
+ WL_ERROR(("%s: list->version %d != WL_BSS_INFO_VERSION\n", \
__FUNCTION__, list->version));
kfree(list);
return -EINVAL;
for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- buflen));
-
+ if ((dtoh32(bi->length) > buflen) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + buflen))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+ kfree(list);
+ return -E2BIG;
+ }
+
if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
continue;
-
memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
addr[dwrq->length].sa_family = ARPHRD_ETHER;
qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
#if WIRELESS_EXT > 18
qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
#else
dwrq->flags = 1;
}
-
return 0;
}
+#endif
#ifdef WL_IW_USE_ISCAN
static int
return -EINVAL;
if ((!iscan) || (iscan->sysioc_pid < 0)) {
- return wl_iw_get_aplist(dev, info, dwrq, extra);
+ WL_ERROR(("%s error\n", __FUNCTION__));
+ return 0;
}
buf = iscan->list_hdr;
for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length))
: list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- WLC_IW_ISCAN_MAXLEN));
-
+ if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+ return -E2BIG;
+ }
+
if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
continue;
-
memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
addr[dwrq->length].sa_family = ARPHRD_ETHER;
qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
#if WIRELESS_EXT > 18
qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
#else
dwrq->flags = 1;
}
-
return 0;
}
params->passive_time = -1;
params->home_time = -1;
params->channel_num = 0;
-
+#if defined(CONFIG_FIRST_SCAN)
+ if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
+ params->passive_time = 30;
+#endif
params->nprobes = htod32(params->nprobes);
params->active_time = htod32(params->active_time);
params->passive_time = htod32(params->passive_time);
WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
WL_SCAN(("bss_type=%d\n", iscan->iscan_ex_params_p->params.bss_type));
-
- (void) dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
- iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf));
+ if ((err = dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
+ iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
+ WL_ERROR(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
+ err = -1;
+ }
return err;
}
if (iscan) {
iscan->timer_on = 0;
if (iscan->iscan_state != ISCAN_STATE_IDLE) {
- WL_TRACE(("timer trigger\n"));
+ WL_SCAN(("timer trigger\n"));
up(&iscan->sysioc_sem);
}
}
wl_iscan_results_t list;
wl_scan_results_t *results;
uint32 status;
+ int res;
-
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
if (iscan->list_cur) {
buf = iscan->list_cur;
iscan->list_cur = buf->next;
if (!buf) {
WL_ERROR(("%s can't alloc iscan_buf_t : going to abort currect iscan\n", \
__FUNCTION__));
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
return WL_SCAN_RESULTS_NO_MEM;
}
buf->next = NULL;
memset(&list, 0, sizeof(list));
list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
- (void) dev_iw_iovar_getbuf(
+ res = dev_iw_iovar_getbuf(
iscan->dev,
"iscanresults",
&list,
WL_ISCAN_RESULTS_FIXED_SIZE,
buf->iscan_buf,
WLC_IW_ISCAN_MAXLEN);
- results->buflen = dtoh32(results->buflen);
- results->version = dtoh32(results->version);
- results->count = dtoh32(results->count);
- WL_TRACE(("%s: results->count = %d\n", __func__, results->count));
-
- //WL_TRACE(("results->buflen = %d\n", results->buflen));
- status = dtoh32(list_buf->status);
- MUTEX_UNLOCK_WL_SCAN_SET();
+ if (res == 0) {
+ results->buflen = dtoh32(results->buflen);
+ results->version = dtoh32(results->version);
+ results->count = dtoh32(results->count);
+ WL_SCAN(("results->count = %d\n", results->count));
+
+ WL_SCAN(("results->buflen = %d\n", results->buflen));
+ status = dtoh32(list_buf->status);
+ } else {
+ WL_ERROR(("%s returns error %d\n", __FUNCTION__, res));
+ status = WL_SCAN_RESULTS_NO_MEM;
+ }
+ mutex_unlock(&wl_cache_lock);
return status;
}
static void wl_iw_force_specific_scan(iscan_info_t *iscan)
{
- WL_TRACE(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
+ WL_SCAN(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_lock();
#endif
-
(void) dev_wlc_ioctl(iscan->dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid));
-
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_unlock();
#endif
}
+
static void wl_iw_send_scan_complete(iscan_info_t *iscan)
{
#ifndef SANDGATE2G
union iwreq_data wrqu;
-#if !defined(CSCAN)
- if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
-#endif
memset(&wrqu, 0, sizeof(wrqu));
+
wireless_send_event(iscan->dev, SIOCGIWSCAN, &wrqu, NULL);
- WL_TRACE(("Send Event ISCAN complete\n"));
+#if defined(CONFIG_FIRST_SCAN)
+ if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
+ g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
+#endif
+ WL_SCAN(("Send Event ISCAN complete\n"));
#endif
}
+
static int
_iscan_sysioc_thread(void *data)
{
uint32 status;
iscan_info_t *iscan = (iscan_info_t *)data;
static bool iscan_pass_abort = FALSE;
+
DAEMONIZE("iscan_sysioc");
status = WL_SCAN_RESULTS_PARTIAL;
while (down_interruptible(&iscan->sysioc_sem) == 0) {
+ net_os_wake_lock(iscan->dev);
+
#if defined(SOFTAP)
if (ap_cfg_running) {
- WL_TRACE(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
- continue;
+ WL_SCAN(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
+ net_os_wake_unlock(iscan->dev);
+ continue;
}
-#endif
+#endif
+
if (iscan->timer_on) {
- del_timer(&iscan->timer);
iscan->timer_on = 0;
+ del_timer_sync(&iscan->timer);
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_unlock();
#endif
- if (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
- WL_TRACE(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
+
+ if (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
+ WL_SCAN(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
wl_iw_send_scan_complete(iscan);
iscan_pass_abort = FALSE;
status = -1;
switch (status) {
case WL_SCAN_RESULTS_PARTIAL:
- WL_TRACE(("iscanresults incomplete\n"));
+ WL_SCAN(("iscanresults incomplete\n"));
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_lock();
#endif
-
+
wl_iw_iscan(iscan, NULL, WL_SCAN_ACTION_CONTINUE);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_unlock();
#endif
-
+
mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
iscan->timer_on = 1;
break;
case WL_SCAN_RESULTS_SUCCESS:
- WL_TRACE(("iscanresults complete\n"));
+ WL_SCAN(("iscanresults complete\n"));
iscan->iscan_state = ISCAN_STATE_IDLE;
wl_iw_send_scan_complete(iscan);
break;
case WL_SCAN_RESULTS_PENDING:
- WL_TRACE(("iscanresults pending\n"));
-
+ WL_SCAN(("iscanresults pending\n"));
+
mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
iscan->timer_on = 1;
break;
case WL_SCAN_RESULTS_ABORTED:
- WL_TRACE(("iscanresults aborted\n"));
+ WL_SCAN(("iscanresults aborted\n"));
iscan->iscan_state = ISCAN_STATE_IDLE;
if (g_scan_specified_ssid == 0)
wl_iw_send_scan_complete(iscan);
}
break;
case WL_SCAN_RESULTS_NO_MEM:
- WL_TRACE(("iscanresults can't alloc memory: skip\n"));
+ WL_SCAN(("iscanresults can't alloc memory: skip\n"));
iscan->iscan_state = ISCAN_STATE_IDLE;
break;
default:
- WL_TRACE(("iscanresults returned unknown status %d\n", status));
+ WL_SCAN(("iscanresults returned unknown status %d\n", status));
break;
- }
+ }
+
+ net_os_wake_unlock(iscan->dev);
}
if (iscan->timer_on) {
- del_timer(&iscan->timer);
iscan->timer_on = 0;
+ del_timer_sync(&iscan->timer);
}
+
complete_and_exit(&iscan->sysioc_exited, 0);
}
#endif
wl_iw_set_ss_cache_timer_flag(void)
{
g_ss_cache_ctrl.m_timer_expired = 1;
- //WL_TRACE(("%s called\n", __FUNCTION__));
+ WL_TRACE(("%s called\n", __FUNCTION__));
}
static int
WL_TRACE(("%s called\n", __FUNCTION__));
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
node = *spec_scan_head;
kfree(cur);
}
*spec_scan_head = NULL;
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
}
if (kick_off) {
(*timer)->expires = jiffies + 30000 * HZ / 1000;
add_timer(*timer);
- //WL_TRACE(("%s : timer starts \n", __FUNCTION__));
+ WL_TRACE(("%s : timer starts \n", __FUNCTION__));
} else {
del_timer_sync(*timer);
- //WL_TRACE(("%s : timer stops \n", __FUNCTION__));
+ WL_TRACE(("%s : timer stops \n", __FUNCTION__));
}
}
wl_iw_ss_cache_t *node, *prev, *cur;
wl_iw_ss_cache_t **spec_scan_head;
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
node = *spec_scan_head;
prev = node;
prev = node;
node = node->next;
}
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
}
wl_bss_info_t *bi = NULL;
int i;
-
if (!ss_list->count) {
return 0;
}
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
+
for (i = 0; i < ss_list->count; i++) {
node = *spec_scan_head;
}
leaf = kmalloc(bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN, GFP_KERNEL);
if (!leaf) {
- MUTEX_UNLOCK_WL_SCAN_SET();
+ WL_ERROR(("Memory alloc failure %d\n", \
+ bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN));
+ mutex_unlock(&wl_cache_lock);
return -ENOMEM;
}
prev->next = leaf;
}
}
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
return 0;
-
}
wl_iw_ss_cache_t *node;
wl_scan_results_t *list_merge;
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
node = g_ss_cache_ctrl.m_cache_head;
for (;node;) {
- list_merge = (wl_scan_results_t *)node;
+ list_merge = (wl_scan_results_t *)&node->buflen;
WL_TRACE(("%s: Cached Specific APs list=%d\n", __FUNCTION__, list_merge->count));
if (buflen_from_user - *merged_len > 0) {
*merged_len += (__u16) wl_iw_get_scan_prep(list_merge, info,
}
node = node->next;
}
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
return 0;
}
wl_iw_ss_cache_t *node, *prev;
wl_iw_ss_cache_t **spec_scan_head;
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
node = *spec_scan_head;
prev = node;
}
memset(addr, 0, ETHER_ADDR_LEN);
- MUTEX_UNLOCK_WL_SCAN_SET();
+ mutex_unlock(&wl_cache_lock);
return 0;
-
}
-#endif
+#endif
static int
)
{
int error;
- WL_TRACE(("\n:%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
-
+ WL_TRACE(("%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
#if defined(CSCAN)
- WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
- return -EINVAL;
+ WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
+ return -EINVAL;
#endif
#if defined(SOFTAP)
-
if (ap_cfg_running) {
WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
return 0;
}
-#endif
+#endif
-
if (g_onoff == G_WLAN_SET_OFF)
return 0;
-
memset(&g_specific_ssid, 0, sizeof(g_specific_ssid));
#ifndef WL_IW_USE_ISCAN
-
g_scan_specified_ssid = 0;
#endif
if (wrqu->data.length == sizeof(struct iw_scan_req)) {
if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
struct iw_scan_req *req = (struct iw_scan_req *)extra;
+#if defined(CONFIG_FIRST_SCAN)
if (g_first_broadcast_scan != BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-
- WL_TRACE(("%s Ignoring SC %s first BC is not done = %d\n", \
+ WL_ERROR(("%s Ignoring SC %s first BC is not done = %d\n", \
__FUNCTION__, req->essid, \
g_first_broadcast_scan));
return -EBUSY;
}
+#endif
if (g_scan_specified_ssid) {
- WL_TRACE(("%s Specific SCAN is not done ignore scan for = %s \n", \
+ WL_SCAN(("%s Specific SCAN is not done ignore scan for = %s \n", \
__FUNCTION__, req->essid));
-
return -EBUSY;
}
else {
#endif
if ((error = dev_wlc_ioctl(dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid)))) {
- WL_TRACE(("#### Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
-
+ WL_SCAN(("Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
g_scan_specified_ssid = 0;
return -EBUSY;
}
wlc_ssid_t ssid;
iscan_info_t *iscan = g_iscan;
-#if !defined(CSCAN)
-
+#if defined(CONFIG_FIRST_SCAN)
if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_IDLE) {
g_first_broadcast_scan = BROADCAST_SCAN_FIRST_STARTED;
- WL_TRACE(("%s: First Brodcast scan was forced\n", __FUNCTION__));
+ WL_SCAN(("%s: First Brodcast scan was forced\n", __FUNCTION__));
}
else if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED) {
- WL_TRACE(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
+ WL_SCAN(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
return 0;
}
-#endif
+#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
if (flag)
dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &iscan->scan_flag, sizeof(iscan->scan_flag));
wl_iw_set_event_mask(dev);
- WL_TRACE(("+++: Set Broadcast ISCAN\n"));
+ WL_SCAN(("+++: Set Broadcast ISCAN\n"));
memset(&ssid, 0, sizeof(ssid));
return 0;
}
+
static int
wl_iw_iscan_set_scan(
struct net_device *dev,
{
wlc_ssid_t ssid;
iscan_info_t *iscan = g_iscan;
+ int ret = 0;
- WL_TRACE(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
+ WL_SCAN(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
#if defined(CSCAN)
- WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
- return -EINVAL;
-#endif
+ WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
+ return -EINVAL;
+#endif
+
+ net_os_wake_lock(dev);
-
#if defined(SOFTAP)
if (ap_cfg_running) {
- WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
- return 0;
+ WL_SCAN(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
+ goto set_scan_end;
}
#endif
-
+
if (g_onoff == G_WLAN_SET_OFF) {
- WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
- return 0;
+ WL_SCAN(("%s: driver is not up yet after START\n", __FUNCTION__));
+ goto set_scan_end;
}
-
+#ifdef PNO_SUPPORT
+ if (dhd_dev_get_pno_status(dev)) {
+ WL_SCAN(("%s: Scan called when PNO is active\n", __FUNCTION__));
+ }
+#endif
+
if ((!iscan) || (iscan->sysioc_pid < 0)) {
- WL_TRACE(("%s use backup if iscan thread is not successful\n", \
- __FUNCTION__));
- return wl_iw_set_scan(dev, info, wrqu, extra);
+ WL_ERROR(("%s error\n", __FUNCTION__));
+ goto set_scan_end;
}
if (g_scan_specified_ssid) {
- WL_TRACE(("%s Specific SCAN already running ignoring BC scan\n", \
+ WL_SCAN(("%s Specific SCAN already running ignoring BC scan\n", \
__FUNCTION__));
- return EBUSY;
+ ret = EBUSY;
+ goto set_scan_end;
}
-
memset(&ssid, 0, sizeof(ssid));
#if WIRELESS_EXT > 17
if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
int as = 0;
struct iw_scan_req *req = (struct iw_scan_req *)extra;
-#if !defined(CSCAN)
- if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-
- WL_TRACE(("%s First ISCAN in progress : ignoring SC = %s\n", \
- __FUNCTION__, req->essid));
- return -EBUSY;
- }
-#endif
ssid.SSID_len = MIN(sizeof(ssid.SSID), req->essid_len);
memcpy(ssid.SSID, req->essid, ssid.SSID_len);
ssid.SSID_len = htod32(ssid.SSID_len);
dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
wl_iw_set_event_mask(dev);
- return wl_iw_set_scan(dev, info, wrqu, extra);
+ ret = wl_iw_set_scan(dev, info, wrqu, extra);
+ goto set_scan_end;
}
else {
g_scan_specified_ssid = 0;
if (iscan->iscan_state == ISCAN_STATE_SCANING) {
- WL_TRACE(("%s ISCAN already in progress \n", __FUNCTION__));
- return 0;
+ WL_SCAN(("%s ISCAN already in progress \n", __FUNCTION__));
+ goto set_scan_end;
}
}
}
#endif
+#if defined(CONFIG_FIRST_SCAN) && !defined(CSCAN)
+ if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
+ if (++g_first_counter_scans == MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN) {
+
+ WL_ERROR(("%s Clean up First scan flag which is %d\n", \
+ __FUNCTION__, g_first_broadcast_scan));
+ g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
+ }
+ else {
+ WL_ERROR(("%s Ignoring Broadcast Scan:First Scan is not done yet %d\n", \
+ __FUNCTION__, g_first_counter_scans));
+ ret = -EBUSY;
+ goto set_scan_end;
+ }
+ }
+#endif
+
wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
- return 0;
+set_scan_end:
+ net_os_wake_unlock(dev);
+ return ret;
}
#endif
static bool
ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
{
-
-
uint8 *ie = *wpaie;
-
if ((ie[1] >= 6) &&
!bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x01"), 4)) {
return TRUE;
}
-
ie += ie[1] + 2;
*tlvs_len -= (int)(ie - *tlvs);
static bool
ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
{
-
-
uint8 *ie = *wpsie;
-
if ((ie[1] >= 4) &&
!bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x04"), 4)) {
return TRUE;
}
-
ie += ie[1] + 2;
*tlvs_len -= (int)(ie - *tlvs);
return 0;
}
+#ifndef CSCAN
static uint
wl_iw_get_scan_prep(
wl_scan_results_t *list,
wl_bss_info_t *bi = NULL;
char *event = extra, *end = extra + max_size - WE_ADD_EVENT_FIX, *value;
int ret = 0;
+ int channel;
- ASSERT(list);
-
-
+ if (!list) {
+ WL_ERROR(("%s: Null list pointer",__FUNCTION__));
+ return ret;
+ }
for (i = 0; i < list->count && i < IW_MAX_AP; i++)
{
WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
__FUNCTION__, list->version));
return ret;
- }
+ }
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
WL_TRACE(("%s : %s\n", __FUNCTION__, bi->SSID));
-
iwe.cmd = SIOCGIWAP;
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
iwe.u.data.flags = 1;
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
iwe.cmd = SIOCGIWMODE;
if (dtoh16(bi->capability) & DOT11_CAP_ESS)
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
}
-
iwe.cmd = SIOCGIWFREQ;
- iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
- CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
+ channel = (bi->ctl_ch == 0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
+ iwe.u.freq.m = wf_channel2mhz(channel,
+ channel <= CH_MAX_2G_CHANNEL ?
WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
iwe.u.freq.e = 6;
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
iwe.cmd = IWEVQUAL;
iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
iwe.u.qual.noise = 0x100 + bi->phy_noise;
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
- wl_iw_handle_scanresults_ies(&event, end, info, bi);
+ wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
iwe.cmd = SIOCGIWENCODE;
if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
iwe.u.data.length = 0;
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
if (bi->rateset.count) {
if (((event -extra) + IW_EV_LCP_LEN) <= (uintptr)end) {
value = event + IW_EV_LCP_LEN;
iwe.cmd = SIOCGIWRATE;
-
+
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
- iwe.u.bitrate.value =
- (bi->rateset.rates[j] & 0x7f) * 500000;
+ iwe.u.bitrate.value = (bi->rateset.rates[j] & 0x7f) * 500000;
value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
IW_EV_PARAM_LEN);
}
uint buflen_from_user = dwrq->length;
uint len = G_SCAN_RESULTS;
__u16 len_ret = 0;
-#if !defined(CSCAN)
+#if !defined(CSCAN)
__u16 merged_len = 0;
#endif
#if defined(WL_IW_USE_ISCAN)
iscan_buf_t * p_buf;
#if !defined(CSCAN)
uint32 counter = 0;
-#endif
-#endif
-
+#endif
+#endif
WL_TRACE(("%s: buflen_from_user %d: \n", dev->name, buflen_from_user));
if (!extra) {
return -EINVAL;
}
-
if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
return error;
ci.scan_channel = dtoh32(ci.scan_channel);
if (ci.scan_channel)
return -EAGAIN;
-#if !defined(CSCAN)
+#if !defined(CSCAN)
if (g_ss_cache_ctrl.m_timer_expired) {
wl_iw_free_ss_cache();
g_ss_cache_ctrl.m_timer_expired ^= 1;
else {
g_ss_cache_ctrl.m_cons_br_scan_cnt++;
}
-#endif
-
+#endif
-
if (g_scan_specified_ssid) {
list = kmalloc(len, GFP_KERNEL);
memset(list, 0, len);
list->buflen = htod32(len);
if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len))) {
- WL_TRACE(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, len));
+ WL_ERROR(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, error));
dwrq->length = len;
- if (g_scan_specified_ssid)
+ if (g_scan_specified_ssid) {
+ g_scan_specified_ssid = 0;
kfree(list);
+ }
return 0;
}
list->buflen = dtoh32(list->buflen);
list->version = dtoh32(list->version);
list->count = dtoh32(list->count);
-
if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
+ WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n",
+ __FUNCTION__, list->version));
if (g_scan_specified_ssid) {
g_scan_specified_ssid = 0;
kfree(list);
return -EINVAL;
}
-#if !defined(CSCAN)
+#if !defined(CSCAN)
if (g_scan_specified_ssid) {
wl_iw_add_bss_to_ss_cache(list);
kfree(list);
}
-#endif
-#if !defined(CSCAN)
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
#if defined(WL_IW_USE_ISCAN)
if (g_scan_specified_ssid)
WL_TRACE(("%s: Specified scan APs from scan=%d\n", __FUNCTION__, list->count));
counter += list_merge->count;
if (list_merge->count > 0)
len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
- extra+len_ret, buflen_from_user -len_ret);
+ extra+len_ret, buflen_from_user -len_ret);
p_buf = p_buf->next;
}
WL_TRACE(("%s merged with total Bcast APs=%d\n", __FUNCTION__, counter));
#else
list_merge = (wl_scan_results_t *) g_scan;
len_ret = (__u16) wl_iw_get_scan_prep(list_merge, info, extra, buflen_from_user);
-#endif
- MUTEX_UNLOCK_WL_SCAN_SET();
+#endif
+ mutex_unlock(&wl_cache_lock);
if (g_ss_cache_ctrl.m_link_down) {
-
wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
}
-
+
wl_iw_merge_scan_cache(info, extra+len_ret, buflen_from_user-len_ret, &merged_len);
len_ret += merged_len;
wl_iw_run_ss_cache_timer(0);
wl_iw_run_ss_cache_timer(1);
-#else
+#else
-
if (g_scan_specified_ssid) {
WL_TRACE(("%s: Specified scan APs in the list =%d\n", __FUNCTION__, list->count));
len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
if (list_merge->count > 0)
len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info, extra+len_ret,
buflen_from_user -len_ret);
-#endif
+#endif
}
else {
list = (wl_scan_results_t *) g_scan;
len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
}
-#endif
+#endif
#if defined(WL_IW_USE_ISCAN)
WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, list->count));
return 0;
}
+#endif
#if defined(WL_IW_USE_ISCAN)
static int
iscan_info_t *iscan = g_iscan;
iscan_buf_t * p_buf;
uint32 counter = 0;
+ uint8 channel;
#if !defined(CSCAN)
__u16 merged_len = 0;
uint buflen_from_user = dwrq->length;
#endif
- WL_TRACE(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
+ WL_SCAN(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
#if defined(SOFTAP)
if (ap_cfg_running) {
return -EINVAL;
}
-#if !defined(CSCAN)
+#if defined(CONFIG_FIRST_SCAN)
if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_READY) {
WL_TRACE(("%s %s: first ISCAN results are NOT ready yet \n", \
dev->name, __FUNCTION__));
return -EAGAIN;
}
-#endif
-
+#endif
+
if ((!iscan) || (iscan->sysioc_pid < 0)) {
- WL_TRACE(("%ssysioc_pid\n", __FUNCTION__));
- return wl_iw_get_scan(dev, info, dwrq, extra);
+ WL_ERROR(("%ssysioc_pid\n", __FUNCTION__));
+ return -EAGAIN;
}
#if !defined(CSCAN)
}
else {
if (g_ss_cache_ctrl.m_link_down) {
-
wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
}
if (g_ss_cache_ctrl.m_prev_scan_mode || g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-
+
wl_iw_reset_ss_cache();
}
g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
g_ss_cache_ctrl.m_cons_br_scan_cnt++;
}
-#endif
+#endif
WL_TRACE(("%s: SIOCGIWSCAN GET broadcast results\n", dev->name));
apcnt = 0;
while (p_buf != iscan->list_cur) {
list = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
- counter += list->count;
+ counter += list->count;
if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
+ WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n",
__FUNCTION__, list->version));
return -EINVAL;
}
bi = NULL;
for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) {
bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- WLC_IW_ISCAN_MAXLEN));
-
+ if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+ (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+ WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+ return -E2BIG;
+ }
+
if (event + ETHER_ADDR_LEN + bi->SSID_len + IW_EV_UINT_LEN + IW_EV_FREQ_LEN +
IW_EV_QUAL_LEN >= end)
return -E2BIG;
-
+
iwe.cmd = SIOCGIWAP;
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
-
iwe.u.data.length = dtoh32(bi->SSID_len);
iwe.cmd = SIOCGIWESSID;
iwe.u.data.flags = 1;
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
iwe.cmd = SIOCGIWMODE;
if (dtoh16(bi->capability) & DOT11_CAP_ESS)
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
}
-
iwe.cmd = SIOCGIWFREQ;
- iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
- CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
+ channel = (bi->ctl_ch == 0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
+ iwe.u.freq.m = wf_channel2mhz(channel,
+ channel <= CH_MAX_2G_CHANNEL ?
WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
iwe.u.freq.e = 6;
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
iwe.cmd = IWEVQUAL;
iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
iwe.u.qual.noise = 0x100 + bi->phy_noise;
event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
iwe.cmd = SIOCGIWENCODE;
if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
iwe.u.data.length = 0;
event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
if (bi->rateset.count) {
if (event + IW_MAX_BITRATES*IW_EV_PARAM_LEN >= end)
return -E2BIG;
dwrq->flags = 0;
#if !defined(CSCAN)
-
wl_iw_merge_scan_cache(info, event, buflen_from_user - dwrq->length, &merged_len);
dwrq->length += merged_len;
wl_iw_run_ss_cache_timer(0);
wl_iw_run_ss_cache_timer(1);
-
+#endif /* CSCAN */
+#if defined(CONFIG_FIRST_SCAN)
g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
#endif
WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, counter));
-
- if (!dwrq->length)
- return -EAGAIN;
-
return 0;
}
#endif
)
{
int error;
+ wl_join_params_t join_params;
+ int join_params_size;
WL_TRACE(("%s: SIOCSIWESSID\n", dev->name));
-
memset(&g_ssid, 0, sizeof(g_ssid));
g_ssid.SSID_len = 0;
}
g_ssid.SSID_len = htod32(g_ssid.SSID_len);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &g_ssid, sizeof(g_ssid))))
+
+ memset(&join_params, 0, sizeof(join_params));
+ join_params_size = sizeof(join_params.ssid);
+
+ memcpy(&join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
+ join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
+ memcpy(&join_params.params.bssid, ðer_bcast, ETHER_ADDR_LEN);
+
+ wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params, &join_params_size);
+
+ if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size))) {
+ WL_ERROR(("Invalid ioctl data=%d\n", error));
return error;
+ }
if (g_ssid.SSID_len) {
- WL_TRACE(("%s: join SSID=%s\n", __FUNCTION__, g_ssid.SSID));
+ WL_TRACE(("%s: join SSID=%s ch=%d\n", __FUNCTION__, \
+ g_ssid.SSID, g_wl_iw_params.target_channel));
}
return 0;
}
ssid.SSID_len = dtoh32(ssid.SSID_len);
-
memcpy(extra, ssid.SSID, ssid.SSID_len);
dwrq->length = ssid.SSID_len;
if (!extra)
return -EINVAL;
-
if (dwrq->length > sizeof(iw->nickname))
return -E2BIG;
int error;
struct iw_encode_ext *iwe;
- WL_TRACE(("%s: SIOCSIWENCODEEXT\n", dev->name));
+ WL_WSEC(("%s: SIOCSIWENCODEEXT\n", dev->name));
CHECK_EXTRA_FOR_NULL(extra);
char eabuf[ETHER_ADDR_STR_LEN];
WL_WSEC(("%s: SIOCSIWPMKSA\n", dev->name));
-
CHECK_EXTRA_FOR_NULL(extra);
iwpmksa = (struct iw_pmksa *)extra;
uint j;
pmkidptr = &pmkid;
- bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, \
- ETHER_ADDR_LEN);
+ bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, ETHER_ADDR_LEN);
bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID, WPA2_PMKID_LEN);
WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_REMOVE - PMKID: %s = ",
}
else
ret = -EINVAL;
+
{
uint j;
uint k;
WL_WSEC(("\n"));
}
}
- WL_WSEC(("PRINTING pmkid LIST - No of elements %d\n", pmkid_list.pmkids.npmkid));
+ WL_WSEC(("PRINTING pmkid LIST - No of elements %d, ret = %d\n", pmkid_list.pmkids.npmkid, ret));
for (i = 0; i < pmkid_list.pmkids.npmkid; i++) {
uint j;
WL_WSEC(("PMKID[%d]: %s = ", i,
WL_WSEC(("\n"));
if (!ret)
- ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, \
- sizeof(pmkid_list));
+ ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, sizeof(pmkid_list));
return ret;
}
#endif
char *extra
)
{
- WL_TRACE(("%s: SIOCGIWENCODEEXT\n", dev->name));
+ WL_WSEC(("%s: SIOCGIWENCODEEXT\n", dev->name));
return 0;
}
int val = 0;
wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
- WL_TRACE(("%s: SIOCSIWAUTH\n", dev->name));
+ WL_WSEC(("%s: SIOCSIWAUTH\n", dev->name));
#if defined(SOFTAP)
if (ap_cfg_running) {
paramid = vwrq->flags & IW_AUTH_INDEX;
paramval = vwrq->value;
- WL_TRACE(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
+ WL_WSEC(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
dev->name, paramid, paramval));
switch (paramid) {
#endif
else if (paramval & IW_AUTH_WAPI_VERSION_1)
val = WPA_AUTH_WAPI;
- WL_INFORM(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
+ WL_WSEC(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
return error;
break;
if (iw->privacy_invoked && !val) {
WL_WSEC(("%s: %s: 'Privacy invoked' TRUE but clearing wsec, assuming "
- "we're a WPS enrollee\n", dev->name, __FUNCTION__));
+ "we're a WPS enrollee\n", dev->name, __FUNCTION__));
if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
- WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
+ WL_ERROR(("Failed to set iovar is_WPS_enrollee\n"));
return error;
}
} else if (val) {
if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
- WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
+ WL_ERROR(("Failed to clear iovar is_WPS_enrollee\n"));
return error;
}
}
- if ((error = dev_wlc_intvar_set(dev, "wsec", val)))
+ if ((error = dev_wlc_intvar_set(dev, "wsec", val))) {
+ WL_ERROR(("Failed to set 'wsec'iovar\n"));
return error;
+ }
break;
case IW_AUTH_KEY_MGMT:
- if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
+ if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val))) {
+ WL_ERROR(("Failed to get 'wpa_auth'iovar\n"));
return error;
+ }
if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
if (paramval & IW_AUTH_KEY_MGMT_PSK)
#endif
if (paramval & (IW_AUTH_KEY_MGMT_WAPI_PSK | IW_AUTH_KEY_MGMT_WAPI_CERT))
val = WPA_AUTH_WAPI;
- WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
- if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
+ WL_WSEC(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
+ if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val))) {
+ WL_ERROR(("Failed to set 'wpa_auth'iovar\n"));
return error;
+ }
break;
case IW_AUTH_TKIP_COUNTERMEASURES:
- dev_wlc_bufvar_set(dev, "tkip_countermeasures", (char *)¶mval, 1);
+ if ((error = dev_wlc_bufvar_set(dev, "tkip_countermeasures", \
+ (char *)¶mval, sizeof(paramval))))
+ WL_WSEC(("%s: tkip_countermeasures failed %d\n", __FUNCTION__, error));
break;
case IW_AUTH_80211_AUTH_ALG:
- WL_INFORM(("Setting the D11auth %d\n", paramval));
+ WL_WSEC(("Setting the D11auth %d\n", paramval));
if (paramval == IW_AUTH_ALG_OPEN_SYSTEM)
val = 0;
else if (paramval == IW_AUTH_ALG_SHARED_KEY)
if (paramval == 0) {
iw->pwsec = 0;
iw->gwsec = 0;
- if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
+ if ((error = dev_wlc_intvar_get(dev, "wsec", &val))) {
+ WL_ERROR(("Failed to get 'wsec'iovar\n"));
return error;
+ }
if (val & (TKIP_ENABLED | AES_ENABLED)) {
val &= ~(TKIP_ENABLED | AES_ENABLED);
dev_wlc_intvar_set(dev, "wsec", val);
}
val = 0;
- WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
- dev_wlc_intvar_set(dev, "wpa_auth", 0);
+
+ WL_INFORM(("%s: %d: setting wpa_auth to %d\n",
+ __FUNCTION__, __LINE__, val));
+ error = dev_wlc_intvar_set(dev, "wpa_auth", 0);
+ if (error)
+ WL_ERROR(("Failed to set 'wpa_auth'iovar\n"));
return error;
}
break;
case IW_AUTH_DROP_UNENCRYPTED:
- dev_wlc_bufvar_set(dev, "wsec_restrict", (char *)¶mval, 1);
+ error = dev_wlc_bufvar_set(dev, "wsec_restrict", \
+ (char *)¶mval, sizeof(paramval));
+ if (error)
+ WL_ERROR(("%s: wsec_restrict %d\n", __FUNCTION__, error));
break;
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
+ error = dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", \
+ (char *)¶mval, sizeof(paramval));
+ if (error)
+ WL_WSEC(("%s: rx_unencrypted_eapol %d\n", __FUNCTION__, error));
break;
#if WIRELESS_EXT > 17
return error;
if (!(IW_WSEC_ENABLED(wsec))) {
-
if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
}
break;
}
-#endif
+#endif
case IW_AUTH_WAPI_ENABLED:
if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
return error;
break;
case IW_AUTH_TKIP_COUNTERMEASURES:
- dev_wlc_bufvar_get(dev, "tkip_countermeasures", (char *)¶mval, 1);
+ error = dev_wlc_bufvar_get(dev, "tkip_countermeasures", \
+ (char *)¶mval, sizeof(paramval));
+ if (error)
+ WL_ERROR(("%s get tkip_countermeasures %d\n", __FUNCTION__, error));
break;
case IW_AUTH_DROP_UNENCRYPTED:
- dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)¶mval, 1);
+ error = dev_wlc_bufvar_get(dev, "wsec_restrict", \
+ (char *)¶mval, sizeof(paramval));
+ if (error)
+ WL_ERROR(("%s get wsec_restrict %d\n", __FUNCTION__, error));
break;
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
+ error = dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", \
+ (char *)¶mval, sizeof(paramval));
+ if (error)
+ WL_ERROR(("%s get rx_unencrypted_eapol %d\n", __FUNCTION__, error));
break;
case IW_AUTH_80211_AUTH_ALG:
case IW_AUTH_PRIVACY_INVOKED:
paramval = iw->privacy_invoked;
break;
-
#endif
}
vwrq->value = paramval;
return 0;
}
-#endif
+#endif
#ifdef SOFTAP
case 28:
case 34:
case 66:
-
if (!strnicmp(keystr, "0x", 2))
keystr += 2;
else
return -1;
-
case 10:
case 26:
case 32:
key->algo = CRYPTO_ALGO_WEP128;
break;
case 16:
-
key->algo = CRYPTO_ALGO_AES_CCM;
break;
case 32:
return -1;
}
-
key->flags |= WL_PRIMARY_KEY;
return 0;
#ifdef EXT_WPA_CRYPTO
#define SHA1HashSize 20
-extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
- int iterations, u8 *buf, size_t buflen);
+extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len,
+ int iterations, u8 *buf, size_t buflen);
#else
#define SHA1HashSize 20
-int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
- int iterations, u8 *buf, size_t buflen)
+int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len,
+ int iterations, u8 *buf, size_t buflen)
{
WL_ERROR(("WARNING: %s is not implemented !!!\n", __FUNCTION__));
return -1;
}
-
#ifndef AP_ONLY
static int wl_bssiovar_mkbuf(
const char *iovar,
int *perr)
{
const char *prefix = "bsscfg:";
- int8* p;
+ int8 *p;
uint prefixlen;
uint namelen;
uint iolen;
- prefixlen = strlen(prefix);
- namelen = strlen(iovar) + 1;
+ prefixlen = strlen(prefix);
+ namelen = strlen(iovar) + 1;
iolen = prefixlen + namelen + sizeof(int) + paramlen;
-
if (buflen < 0 || iolen > (uint)buflen) {
*perr = BCME_BUFTOOSHORT;
return 0;
}
- p = (int8*)bufptr;
+ p = (int8 *)bufptr;
-
memcpy(p, prefix, prefixlen);
p += prefixlen;
-
memcpy(p, iovar, namelen);
p += namelen;
-
bssidx = htod32(bssidx);
memcpy(p, &bssidx, sizeof(int32));
p += sizeof(int32);
-
if (paramlen)
memcpy(p, param, paramlen);
#endif
-
-
int get_user_params(char *user_params, struct iw_point *dwrq)
{
int ret = 0;
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
-#endif /* SOFTAP */
-
-
#if defined(CSCAN)
static int
int i;
iscan_info_t *iscan = g_iscan;
- WL_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
+ WL_SCAN(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
if ((!dev) && (!g_iscan) && (!iscan->iscan_ex_params_p)) {
WL_ERROR(("%s error exit\n", __FUNCTION__));
err = -1;
+ goto exit;
}
+#ifdef PNO_SUPPORT
+ if (dhd_dev_get_pno_status(dev)) {
+ WL_ERROR(("%s: Scan called when PNO is active\n", __FUNCTION__));
+ }
+#endif
+
params_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
-
if (nssid > 0) {
i = OFFSETOF(wl_scan_params_t, channel_list) + nchan * sizeof(uint16);
i = ROUNDUP(i, sizeof(uint32));
p = (char*)iscan->iscan_ex_params_p->params.channel_list + nchan * sizeof(uint16);
}
-
iscan->iscan_ex_params_p->params.channel_num = \
htod32((nssid << WL_SCAN_PARAMS_NSSID_SHIFT) | \
(nchan & WL_SCAN_PARAMS_COUNT_MASK));
(uint)((iscan->iscan_ex_params_p->params.channel_num >> WL_SCAN_PARAMS_NSSID_SHIFT) & \
WL_SCAN_PARAMS_COUNT_MASK);
-
params_size = (int) (p - (char*)iscan->iscan_ex_params_p + nssid * sizeof(wlc_ssid_t));
iscan->iscan_ex_param_size = params_size;
if ((err = dev_iw_iovar_setbuf(dev, "iscan", iscan->iscan_ex_params_p, \
iscan->iscan_ex_param_size, \
iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
- WL_TRACE(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
+ WL_ERROR(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
err = -1;
}
str_ptr = extra;
-
if (strncmp(str_ptr, GET_SSID, strlen(GET_SSID))) {
WL_ERROR(("%s Error: extracting SSID='' string\n", __FUNCTION__));
goto exit_proc;
return -1;
}
+ if (iscan->iscan_ex_param_size > WLC_IOCTL_MAXLEN) {
+ WL_ERROR(("%s wrong ex_param_size %d", \
+ __FUNCTION__, iscan->iscan_ex_param_size));
+ return -1;
+ }
memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
- ASSERT(iscan->iscan_ex_param_size < WLC_IOCTL_MAXLEN);
wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
get_parmeter_from_string(&str_ptr, GET_SCAN_TYPE, PTYPE_INTDEC, \
&iscan->iscan_ex_params_p->params.scan_type, 1);
-
res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
} else {
-
WL_ERROR(("IWPRIV argument len = 0 \n"));
return -1;
}
__FUNCTION__, info->cmd, info->flags,
wrqu->data.pointer, wrqu->data.length));
+ net_os_wake_lock(dev);
+
if (g_onoff == G_WLAN_SET_OFF) {
WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
- return -1;
+ goto exit_proc;
}
+
if (wrqu->data.length < (strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t))) {
WL_ERROR(("%s aggument=%d less %d\n", __FUNCTION__, \
wrqu->data.length, strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t)));
- return -1;
+ goto exit_proc;
}
#ifdef TLV_DEBUG
goto exit_proc;
}
-
+#if defined(CONFIG_FIRST_SCAN)
+ if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
+ if (++g_first_counter_scans == MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN) {
+
+ WL_ERROR(("%s Clean up First scan flag which is %d\n", \
+ __FUNCTION__, g_first_broadcast_scan));
+ g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
+ }
+ else {
+ WL_ERROR(("%s Ignoring CSCAN : First Scan is not done yet %d\n", \
+ __FUNCTION__, g_first_counter_scans));
+ res = -EBUSY;
+ goto exit_proc;
+ }
+ }
+#endif
+
res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
exit_proc:
+ net_os_wake_unlock(dev);
return res;
}
#endif
-
-
#ifdef SOFTAP
-
#ifndef AP_ONLY
+
static int thr_wait_for_2nd_eth_dev(void *data)
{
+ struct net_device *dev = (struct net_device *)data;
+ wl_iw_t *iw;
int ret = 0;
+ unsigned long flags;
- printk("==========> WARNING!!! we are in thr_wait_for_2nd_eth_dev!!!\n");
+ net_os_wake_lock(dev);
DAEMONIZE("wl0_eth_wthread");
- WL_TRACE(("\n>%s threda started:, PID:%x\n", __FUNCTION__, current->pid));
+ WL_TRACE(("\n>%s thread started:, PID:%x\n", __FUNCTION__, current->pid));
+ iw = *(wl_iw_t **)netdev_priv(dev);
+ if (!iw) {
+ WL_ERROR(("%s: dev is null\n", __FUNCTION__));
+ ret = -1;
+ goto fail;
+ }
-/* if (down_timeout(&ap_eth_sema, msecs_to_jiffies(5000)) != 0) {
+#ifndef BCMSDIOH_STD
+ if (down_timeout(&ap_eth_sema, msecs_to_jiffies(5000)) != 0) {
WL_ERROR(("\n%s: sap_eth_sema timeout \n", __FUNCTION__));
ret = -1;
goto fail;
}
-*/
+#endif
+
+ flags = dhd_os_spin_lock(iw->pub);
if (!ap_net_dev) {
WL_ERROR((" ap_net_dev is null !!!"));
ret = -1;
+ dhd_os_spin_unlock(iw->pub, flags);
goto fail;
}
ap_cfg_running = TRUE;
- bcm_mdelay(500);
+ dhd_os_spin_unlock(iw->pub, flags);
+
+ bcm_mdelay(500);
-
wl_iw_send_priv_event(priv_dev, "AP_SET_CFG_OK");
fail:
-
WL_TRACE(("\n>%s, thread completed\n", __FUNCTION__));
+ net_os_wake_unlock(dev);
+
+ complete_and_exit(&ap_cfg_exited, 0);
return ret;
}
-#endif
-
+#endif
#ifndef AP_ONLY
static int last_auto_channel = 6;
#endif
fail :
return res;
-}
+}
static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
int bsscfg_index = 1;
char buf[WLC_IOCTL_SMLEN];
#endif
- wl_iw_t *iw;
if (!dev) {
WL_ERROR(("%s: dev is null\n", __FUNCTION__));
return -1;
}
+ net_os_wake_lock(dev);
+
WL_SOFTAP(("wl_iw: set ap profile:\n"));
WL_SOFTAP((" ssid = '%s'\n", ap->ssid));
WL_SOFTAP((" security = '%s'\n", ap->sec));
WL_SOFTAP((" channel = %d\n", ap->channel));
WL_SOFTAP((" max scb = %d\n", ap->max_scb));
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_SET, "SoftAP_SET");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-
#ifdef AP_ONLY
if (ap_cfg_running) {
- wl_iw_softap_deassoc_stations(dev);
+ wl_iw_softap_deassoc_stations(dev, NULL);
ap_cfg_running = FALSE;
}
-#endif
+#endif
-
if (ap_cfg_running == FALSE) {
#ifndef AP_ONLY
-
-
sema_init(&ap_eth_sema, 0);
mpc = 0;
}
#ifdef AP_ONLY
-
apsta_var = 0;
if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
WL_ERROR(("%s fail to set apsta_var 0\n", __FUNCTION__));
}
res = dev_wlc_ioctl(dev, WLC_GET_AP, &apsta_var, sizeof(apsta_var));
#else
-
apsta_var = 1;
iolen = wl_bssiovar_mkbuf("apsta",
bsscfg_index, &apsta_var, sizeof(apsta_var)+4,
buf, sizeof(buf), &mkvar_err);
- ASSERT(iolen);
+
+ if (iolen <= 0)
+ goto fail;
+
if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
goto fail;
}
WL_TRACE(("\n>in %s: apsta set result: %d \n", __FUNCTION__, res));
-#endif
+#endif
updown = 1;
if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown))) < 0) {
goto fail;
}
- res = wl_iw_softap_deassoc_stations(ap_net_dev);
+ res = wl_iw_softap_deassoc_stations(ap_net_dev, NULL);
if ((res = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
}
}
+ if (strlen(ap->country_code)) {
+ int error = 0;
+ if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
+ ap->country_code, sizeof(ap->country_code))) >= 0) {
+ WL_SOFTAP(("%s: set country %s OK\n",
+ __FUNCTION__, ap->country_code));
+ dhd_bus_country_set(dev, &ap->country_code[0]);
+ } else {
+ WL_ERROR(("%s: ERROR:%d setting country %s\n",
+ __FUNCTION__, error, ap->country_code));
+ }
+ } else {
+ WL_SOFTAP(("%s: Country code is not specified,"
+ " will use Radio's default\n",
+ __FUNCTION__));
+ }
+
+ iolen = wl_bssiovar_mkbuf("closednet",
+ bsscfg_index, &ap->closednet, sizeof(ap->closednet)+4,
+ buf, sizeof(buf), &mkvar_err);
+ ASSERT(iolen);
+ if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
+ WL_ERROR(("%s failed to set 'closednet'for apsta \n", __FUNCTION__));
+ goto fail;
+ }
+
if ((ap->channel == 0) && (get_softap_auto_channel(dev, ap) < 0)) {
ap->channel = 1;
WL_ERROR(("%s auto channel failed, pick up channel=%d\n", \
__FUNCTION__, ap->channel));
-
}
channel = ap->channel;
ap_ssid.SSID_len = strlen(ap->ssid);
strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
-
#ifdef AP_ONLY
if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
WL_ERROR(("ERROR:%d in:%s, wl_iw_set_ap_security is skipped\n", \
wl_iw_send_priv_event(dev, "ASCII_CMD=AP_BSS_START");
ap_cfg_running = TRUE;
#else
-
iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&ap_ssid),
ap_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
ASSERT(iolen);
goto fail;
}
if (ap_cfg_running == FALSE) {
-
- kernel_thread(thr_wait_for_2nd_eth_dev, 0, 0);
+ init_completion(&ap_cfg_exited);
+ ap_cfg_pid = kernel_thread(thr_wait_for_2nd_eth_dev, dev, 0);
} else {
-
-
+ ap_cfg_pid = -1;
if (ap_net_dev == NULL) {
WL_ERROR(("%s ERROR: ap_net_dev is NULL !!!\n", __FUNCTION__));
goto fail;
WL_ERROR(("%s: %s Configure security & restart AP bss \n", \
__FUNCTION__, ap_net_dev->name));
-
if ((res = wl_iw_set_ap_security(ap_net_dev, &my_ap)) < 0) {
WL_ERROR(("%s fail to set security : %d\n", __FUNCTION__, res));
goto fail;
}
-
if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0) {
WL_ERROR(("%s fail to set bss up\n", __FUNCTION__));
goto fail;
}
#endif
fail:
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_SET);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
WL_SOFTAP(("%s exit with %d\n", __FUNCTION__, res));
+
+ net_os_wake_unlock(dev);
+
return res;
}
WL_SOFTAP(("wl_iw: set ap profile:\n"));
WL_SOFTAP((" ssid = '%s'\n", ap->ssid));
WL_SOFTAP((" security = '%s'\n", ap->sec));
- if (ap->key[0] != '\0')
+ if (ap->key[0] != '\0') {
WL_SOFTAP((" key = '%s'\n", ap->key));
+ }
WL_SOFTAP((" channel = %d\n", ap->channel));
WL_SOFTAP((" max scb = %d\n", ap->max_scb));
-
if (strnicmp(ap->sec, "open", strlen("open")) == 0) {
-
-
wsec = 0;
res = dev_wlc_intvar_set(dev, "wsec", wsec);
wpa_auth = WPA_AUTH_DISABLED;
} else if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
-
memset(&key, 0, sizeof(key));
wsec = WEP_ENABLED;
WL_SOFTAP(("=====================\n"));
} else if (strnicmp(ap->sec, "wpa2-psk", strlen("wpa2-psk")) == 0) {
-
-
-
wsec_pmk_t psk;
size_t key_len;
return -1;
}
-
if (key_len < WSEC_MAX_PSK_LEN) {
unsigned char output[2*SHA1HashSize];
char key_str_buf[WSEC_MAX_PSK_LEN+1];
-
memset(output, 0, sizeof(output));
pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-
+
ptr = key_str_buf;
for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-
sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
(uint)output[i*4+1], (uint)output[i*4+2], \
(uint)output[i*4+3]);
} else if (strnicmp(ap->sec, "wpa-psk", strlen("wpa-psk")) == 0) {
-
wsec_pmk_t psk;
size_t key_len;
return -1;
}
-
if (key_len < WSEC_MAX_PSK_LEN) {
unsigned char output[2*SHA1HashSize];
char key_str_buf[WSEC_MAX_PSK_LEN+1];
+ bzero(output, 2*SHA1HashSize);
WL_SOFTAP(("%s: do passhash...\n", __FUNCTION__));
-
+
pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-
+
ptr = key_str_buf;
for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
- WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int*)&output[i*4])));
-
- sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
- (uint)output[i*4+1], (uint)output[i*4+2], \
- (uint)output[i*4+3]);
+ WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int *)&output[i*4])));
+
+ sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4],
+ (uint)output[i*4+1], (uint)output[i*4+2],
+ (uint)output[i*4+3]);
ptr += 8;
}
- printk("%s: passphase = %s\n", __FUNCTION__, key_str_buf);
+ WL_SOFTAP(("%s: passphase = %s\n", __FUNCTION__, key_str_buf));
psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
memcpy(psk.key, key_str_buf, psk.key_len);
}
-static int wl_iw_softap_deassoc_stations(struct net_device *dev)
+
+int get_parmeter_from_string(
+ char **str_ptr, const char *token,
+ int param_type, void *dst, int param_max_len)
+{
+ char int_str[7] = "0";
+ int parm_str_len;
+ char *param_str_begin;
+ char *param_str_end;
+
+ if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
+
+ strsep(str_ptr, "=,");
+ param_str_begin = *str_ptr;
+ strsep(str_ptr, "=,");
+
+ if (*str_ptr == NULL) {
+ parm_str_len = strlen(param_str_begin);
+ } else {
+ param_str_end = *str_ptr-1;
+ parm_str_len = param_str_end - param_str_begin;
+ }
+
+ WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
+
+ if (parm_str_len > param_max_len) {
+ WL_TRACE((" WARNING: extracted param len:%d is > MAX:%d\n",
+ parm_str_len, param_max_len));
+
+ parm_str_len = param_max_len;
+ }
+
+ switch (param_type) {
+
+ case PTYPE_INTDEC: {
+ int *pdst_int = dst;
+ char *eptr;
+
+ if (parm_str_len > sizeof(int_str))
+ parm_str_len = sizeof(int_str);
+
+ memcpy(int_str, param_str_begin, parm_str_len);
+
+ *pdst_int = simple_strtoul(int_str, &eptr, 10);
+
+ WL_TRACE((" written as integer:%d\n", *pdst_int));
+ }
+ break;
+ case PTYPE_STR_HEX: {
+ u8 *buf = dst;
+
+ param_max_len = param_max_len >> 1;
+ hstr_2_buf(param_str_begin, buf, param_max_len);
+ print_buf(buf, param_max_len, 0);
+ }
+ break;
+ default:
+ memcpy(dst, param_str_begin, parm_str_len);
+ *((char *)dst + parm_str_len) = 0;
+ WL_TRACE((" written as a string:%s\n", (char *)dst));
+ break;
+ }
+
+ return 0;
+ } else {
+ WL_ERROR(("\n %s: No token:%s in str:%s\n",
+ __FUNCTION__, token, *str_ptr));
+
+ return -1;
+ }
+}
+
+static int wl_iw_softap_deassoc_stations(struct net_device *dev, u8 *mac)
{
int i;
int res = 0;
-
char mac_buf[128] = {0};
+ char z_mac[6] = {0, 0, 0, 0, 0, 0};
+ char *sta_mac;
struct maclist *assoc_maclist = (struct maclist *) mac_buf;
+ bool deauth_all = false;
+
+ if (mac == NULL) {
+ deauth_all = true;
+ sta_mac = z_mac;
+ } else {
+ sta_mac = mac;
+ }
memset(assoc_maclist, 0, sizeof(mac_buf));
- assoc_maclist->count = 8;
+ assoc_maclist->count = 8;
res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 128);
if (res != 0) {
-
- WL_SOFTAP((" Error:%d in :%s, Couldn't get ASSOC List\n", res, __FUNCTION__));
+ WL_SOFTAP(("%s: Error:%d Couldn't get ASSOC List\n", __FUNCTION__, res));
return res;
}
- if (assoc_maclist->count)
- for (i = 0; i < assoc_maclist->count; i++) {
+ if (assoc_maclist->count) {
+ for (i = 0; i < assoc_maclist->count; i++) {
scb_val_t scbval;
+
scbval.val = htod32(1);
-
bcopy(&assoc_maclist->ea[i], &scbval.ea, ETHER_ADDR_LEN);
- WL_SOFTAP(("deauth STA:%d \n", i));
- res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
- &scbval, sizeof(scb_val_t));
-
- } else WL_SOFTAP((" STA ASSOC list is empty\n"));
-
+ if (deauth_all || (memcmp(&scbval.ea, sta_mac, ETHER_ADDR_LEN) == 0)) {
+ WL_SOFTAP(("%s, deauth STA:%d \n", __FUNCTION__, i));
+ res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
+ &scbval, sizeof(scb_val_t));
+ }
+ }
+ } else {
+ WL_SOFTAP((" STA ASSOC list is empty\n"));
+ }
- if (res != 0)
- WL_SOFTAP((" Error:%d in :%s\n", res, __FUNCTION__));
- else if (assoc_maclist->count) {
-
+ if (res != 0) {
+ WL_ERROR(("%s: Error:%d\n", __FUNCTION__, res));
+ } else if (assoc_maclist->count) {
bcm_mdelay(200);
}
return res;
}
-
static int iwpriv_softap_stop(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *ext)
{
int res = 0;
- wl_iw_t *iw;
- WL_SOFTAP(("got iwpriv AP_BSS_STOP \n"));
+ WL_SOFTAP(("got iwpriv AP_BSS_STOP\n"));
if ((!dev) && (!ap_net_dev)) {
WL_ERROR(("%s: dev is null\n", __FUNCTION__));
return res;
}
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_STOP, "SoftAP_STOP");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
+ net_os_wake_lock(dev);
- if ((ap_cfg_running == TRUE)) {
+ if ((ap_cfg_running == TRUE)) {
#ifdef AP_ONLY
- wl_iw_softap_deassoc_stations(dev);
+ wl_iw_softap_deassoc_stations(dev, NULL);
#else
- wl_iw_softap_deassoc_stations(ap_net_dev);
+ wl_iw_softap_deassoc_stations(ap_net_dev, NULL);
if ((res = dev_iw_write_cfg1_bss_var(dev, 2)) < 0)
WL_ERROR(("%s failed to del BSS err = %d", __FUNCTION__, res));
#endif
-
bcm_mdelay(100);
wrqu->data.length = 0;
else
WL_ERROR(("%s: was called when SoftAP is OFF : move on\n", __FUNCTION__));
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_STOP);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
WL_SOFTAP(("%s Done with %d\n", __FUNCTION__, res));
+
+ net_os_wake_unlock(dev);
+
return res;
}
-
static int iwpriv_fw_reload(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *ext)
{
-
int ret = -1;
char extra[256];
- char *fwstr = fw_path ;
+ char *fwstr = fw_path;
WL_SOFTAP(("current firmware_path[]=%s\n", fwstr));
info->cmd, info->flags,
wrqu->data.pointer, wrqu->data.length, fwstr, strlen(fwstr)));
-
if ((wrqu->data.length > 4) && (wrqu->data.length < sizeof(extra))) {
char *str_ptr;
goto exit_proc;
}
-
extra[wrqu->data.length] = 8;
str_ptr = extra;
goto exit_proc;
}
- if (strstr(fwstr, "apsta") != NULL) {
- WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
- ap_fw_loaded = TRUE;
+ if (strstr(fwstr, "apsta") != NULL) {
+ WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
+ ap_fw_loaded = TRUE;
} else {
WL_SOFTAP(("GOT STA FIRMWARE\n"));
ap_fw_loaded = FALSE;
exit_proc:
return ret;
}
-#ifdef SOFTAP
+#endif
+#ifdef SOFTAP
static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *ext)
{
int res = 0;
char *params = NULL;
if (!(params = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
return -ENOMEM;
-
if (copy_from_user(params, wrqu->data.pointer, wrqu->data.length)) {
kfree(params);
return -EFAULT;
return -EFAULT;
}
-
res = wl_iw_send_priv_event(dev, params);
kfree(params);
return res;
}
-#endif
+#endif
static int
- iwpriv_en_ap_bss(
+iwpriv_en_ap_bss(
struct net_device *dev,
struct iw_request_info *info,
void *wrqu,
char *extra)
{
int res = 0;
- wl_iw_t *iw;
if (!dev) {
WL_ERROR(("%s: dev is null\n", __FUNCTION__));
return -1;
}
- WL_TRACE(("%s: rcvd IWPRIV IOCTL: for dev:%s\n", __FUNCTION__, dev->name));
+ net_os_wake_lock(dev);
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_START, "SoftAP_START");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
+ WL_SOFTAP(("%s: rcvd IWPRIV IOCTL: for dev:%s\n", __FUNCTION__, dev->name));
-
#ifndef AP_ONLY
+ if (ap_cfg_pid >= 0) {
+ wait_for_completion(&ap_cfg_exited);
+ ap_cfg_pid = -1;
+ }
+
if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
WL_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
}
else {
-
if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0)
WL_ERROR(("%s fail to set bss up err=%d\n", __FUNCTION__, res));
else
-
bcm_mdelay(100);
}
#endif
-
WL_SOFTAP(("%s done with res %d \n", __FUNCTION__, res));
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_START);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
+
+ net_os_wake_unlock(dev);
+
return res;
}
static int
get_assoc_sta_list(struct net_device *dev, char *buf, int len)
{
-
- WL_TRACE(("calling dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
- dev, WLC_GET_ASSOCLIST, buf, len));
+ WL_TRACE(("%s: dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
+ __FUNCTION__, dev, WLC_GET_ASSOCLIST, buf, len));
- dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
+ return dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
- return 0;
}
+void check_error(int res, const char *msg, const char *func, int line)
+{
+ if (res != 0)
+ WL_ERROR(("%s, %d function:%s, line:%d\n", msg, res, func, line));
+}
+
static int
-set_ap_mac_list(struct net_device *dev, char *buf)
+set_ap_mac_list(struct net_device *dev, void *buf)
{
struct mac_list_set *mac_list_set = (struct mac_list_set *)buf;
- struct maclist *white_maclist = (struct maclist *)&mac_list_set->white_list;
- struct maclist *black_maclist = (struct maclist *)&mac_list_set->black_list;
- int mac_mode = mac_list_set->mode;
+ struct maclist *maclist = (struct maclist *)&mac_list_set->mac_list;
int length;
int i;
+ int mac_mode = mac_list_set->mode;
+ int ioc_res = 0;
+ ap_macmode = mac_list_set->mode;
+
+ bzero(&ap_black_list, sizeof(struct mflist));
- ap_macmode = mac_mode;
if (mac_mode == MACLIST_MODE_DISABLED) {
-
- bzero(&ap_black_list, sizeof(struct mflist));
-
- dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+ ioc_res = dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+ check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
+ WL_SOFTAP(("%s: MAC filtering disabled\n", __FUNCTION__));
} else {
+
scb_val_t scbval;
char mac_buf[256] = {0};
struct maclist *assoc_maclist = (struct maclist *) mac_buf;
- mac_mode = MACLIST_MODE_ALLOW;
-
- dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+ bcopy(maclist, &ap_black_list, sizeof(ap_black_list));
-
- length = sizeof(white_maclist->count)+white_maclist->count*ETHER_ADDR_LEN;
- dev_wlc_ioctl(dev, WLC_SET_MACLIST, white_maclist, length);
- WL_SOFTAP(("White List, length %d:\n", length));
- for (i = 0; i < white_maclist->count; i++)
- WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
- i, white_maclist->ea[i].octet[0], white_maclist->ea[i].octet[1], \
- white_maclist->ea[i].octet[2], \
- white_maclist->ea[i].octet[3], white_maclist->ea[i].octet[4], \
- white_maclist->ea[i].octet[5]));
+ ioc_res = dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+ check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
-
- bcopy(black_maclist, &ap_black_list, sizeof(ap_black_list));
+ length = sizeof(maclist->count) + maclist->count*ETHER_ADDR_LEN;
+ dev_wlc_ioctl(dev, WLC_SET_MACLIST, maclist, length);
- WL_SOFTAP(("Black List, size %d:\n", sizeof(ap_black_list)));
- for (i = 0; i < ap_black_list.count; i++)
+ WL_SOFTAP(("%s: applied MAC List, mode:%d, length %d:\n",
+ __FUNCTION__, mac_mode, length));
+ for (i = 0; i < maclist->count; i++)
WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
- i, ap_black_list.ea[i].octet[0], ap_black_list.ea[i].octet[1], \
- ap_black_list.ea[i].octet[2], \
- ap_black_list.ea[i].octet[3], \
- ap_black_list.ea[i].octet[4], ap_black_list.ea[i].octet[5]));
+ i, maclist->ea[i].octet[0], maclist->ea[i].octet[1], \
+ maclist->ea[i].octet[2], \
+ maclist->ea[i].octet[3], maclist->ea[i].octet[4], \
+ maclist->ea[i].octet[5]));
-
- dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
- if (assoc_maclist->count) {
- int j;
+ assoc_maclist->count = 8;
+ ioc_res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
+ check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
+ WL_SOFTAP((" Cur assoc clients:%d\n", assoc_maclist->count));
+
+ if (assoc_maclist->count)
for (i = 0; i < assoc_maclist->count; i++) {
- for (j = 0; j < white_maclist->count; j++) {
- if (!bcmp(&assoc_maclist->ea[i], &white_maclist->ea[j], \
+ int j;
+ bool assoc_mac_matched = false;
+
+ WL_SOFTAP(("\n Cheking assoc STA: "));
+ print_buf(&assoc_maclist->ea[i], 6, 7);
+ WL_SOFTAP(("with the b/w list:"));
+
+ for (j = 0; j < maclist->count; j++)
+ if (!bcmp(&assoc_maclist->ea[i], &maclist->ea[j],
ETHER_ADDR_LEN)) {
- WL_SOFTAP(("match allow, let it be\n"));
+
+ assoc_mac_matched = true;
break;
}
+
+ if (((mac_mode == MACLIST_MODE_ALLOW) && !assoc_mac_matched) ||
+ ((mac_mode == MACLIST_MODE_DENY) && assoc_mac_matched)) {
+
+ WL_SOFTAP(("b-match or w-mismatch,"
+ " do deauth/disassoc \n"));
+ scbval.val = htod32(1);
+ bcopy(&assoc_maclist->ea[i], &scbval.ea, \
+ ETHER_ADDR_LEN);
+ ioc_res = dev_wlc_ioctl(dev,
+ WLC_SCB_DEAUTHENTICATE_FOR_REASON,
+ &scbval, sizeof(scb_val_t));
+ check_error(ioc_res,
+ "ioctl ERROR:",
+ __FUNCTION__, __LINE__);
+
+ } else {
+ WL_SOFTAP((" no b/w list hits, let it be\n"));
}
- if (j == white_maclist->count) {
- WL_SOFTAP(("match black, deauth it\n"));
- scbval.val = htod32(1);
- bcopy(&assoc_maclist->ea[i], &scbval.ea, \
- ETHER_ADDR_LEN);
- dev_wlc_ioctl(dev, \
- WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
- sizeof(scb_val_t));
- }
- }
+ } else {
+ WL_SOFTAP(("No ASSOC CLIENTS\n"));
}
- }
- return 0;
+ }
+
+ WL_SOFTAP(("%s iocres:%d\n", __FUNCTION__, ioc_res));
+ return ioc_res;
}
-#endif /* SOFTAP */
+#endif
#ifdef SOFTAP
WL_SOFTAP((" AP_CFG \n"));
-
+
if (init_ap_profile_from_string(cmd_str+PROFILE_OFFSET, &my_ap) != 0) {
- WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
- ret = -1;
+ WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
+ ret = -1;
} else {
ret = set_ap_cfg(dev, &my_ap);
}
WL_SOFTAP(("\n SOFTAP - ENABLE BSS \n"));
-
WL_SOFTAP(("\n!!! got 'WL_AP_EN_BSS' from WPA supplicant, dev:%s\n", dev->name));
#ifndef AP_ONLY
if (ap_net_dev == NULL) {
- printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
+ printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
} else {
-
if ((ret = iwpriv_en_ap_bss(ap_net_dev, info, dwrq, cmd_str)) < 0)
WL_ERROR(("%s line %d fail to set bss up\n", \
__FUNCTION__, __LINE__));
__FUNCTION__, __LINE__));
#endif
} else if (strnicmp(sub_cmd, "ASSOC_LST", strlen("ASSOC_LST")) == 0) {
-
-
-
+ /* no code yet */
} else if (strnicmp(sub_cmd, "AP_BSS_STOP", strlen("AP_BSS_STOP")) == 0) {
-
WL_SOFTAP((" \n temp DOWN SOFTAP\n"));
#ifndef AP_ONLY
if ((ret = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
}
return ret;
+}
+#endif
+
+#define BCM4329_WAKELOCK_NAME "bcm4329_wifi_wakelock"
+static struct wake_lock bcm4329_suspend_lock;
+
+int bcm4329_wakelock_init = 0;
+
+void bcm4329_power_save_init(void)
+{
+ wake_lock_init(&bcm4329_suspend_lock, WAKE_LOCK_SUSPEND, BCM4329_WAKELOCK_NAME);
+ wake_lock(&bcm4329_suspend_lock);
+
+ bcm4329_wakelock_init = 2;
}
-#endif
+
+void bcm4329_power_save_exit(void)
+{
+ bcm4329_wakelock_init = 0;
+ msleep(100);
+
+ if (bcm4329_wakelock_init == 2)
+ wake_unlock(&bcm4329_suspend_lock);
+ wake_lock_destroy(&bcm4329_suspend_lock);
+}
+
static int wl_iw_set_priv(
struct net_device *dev,
struct iw_request_info *info,
int ret = 0;
char * extra;
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
if (!(extra = kmalloc(dwrq->length, GFP_KERNEL)))
return -ENOMEM;
return -EFAULT;
}
- WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d\n",
+ WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d",
dev->name, extra, info->cmd, info->flags, dwrq->length));
+ net_os_wake_lock(dev);
if (dwrq->length && extra) {
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_PRIV, "wl_iw_set_priv");
- WAKE_LOCK(iw->pub, WAKE_LOCK_PRIV);
+ if (strnicmp(extra, "START", strlen("START")) == 0) {
+ if (bcm4329_wakelock_init == 1)
+ {
+ wake_lock(&bcm4329_suspend_lock);
+ bcm4329_wakelock_init = 2;
+ }
+ wl_iw_control_wl_on(dev, info);
+ WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
+ }
if (g_onoff == G_WLAN_SET_OFF) {
- if (strnicmp(extra, "START", strlen("START")) != 0) {
- WL_ERROR(("%s First IOCTL after stop is NOT START \n", \
- __FUNCTION__));
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
- kfree(extra);
- return -EFAULT;
- } else {
- wl_iw_control_wl_on(dev, info);
- WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
- }
+ WL_TRACE(("%s, missing START, Fail\n", __FUNCTION__));
+ kfree(extra);
+ net_os_wake_unlock(dev);
+ return -EFAULT;
}
- if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
+ if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
WL_TRACE(("%s: active scan setting suppressed\n", dev->name));
#else
ret = wl_iw_set_active_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
- }
- else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
+#endif
+ } else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
WL_TRACE(("%s: passive scan setting suppressed\n", dev->name));
#else
ret = wl_iw_set_passive_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
- else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
+#endif
+ else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
ret = wl_iw_get_rssi(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
+ else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
ret = wl_iw_get_link_speed(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
+ else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
ret = wl_iw_get_macaddr(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
+ else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
ret = wl_iw_set_country(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "STOP", strlen("STOP")) == 0)
+ else if (strnicmp(extra, "SCAN-CHANNELS", strlen("SCAN-CHANNELS")) == 0)
+ ret = wl_iw_get_country(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, "STOP", strlen("STOP")) == 0){
ret = wl_iw_control_wl_off(dev, info);
- else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
+ if (bcm4329_wakelock_init == 2)
+ {
+ wake_unlock(&bcm4329_suspend_lock);
+ bcm4329_wakelock_init = 1;
+ }
+ }
+ else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
ret = wl_iw_get_band(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
+ else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
ret = wl_iw_set_band(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, DTIM_SKIP_GET_CMD, strlen(DTIM_SKIP_GET_CMD)) == 0)
+ ret = wl_iw_get_dtim_skip(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, DTIM_SKIP_SET_CMD, strlen(DTIM_SKIP_SET_CMD)) == 0)
+ ret = wl_iw_set_dtim_skip(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, SETSUSPEND_CMD, strlen(SETSUSPEND_CMD)) == 0)
+ ret = wl_iw_set_suspend(dev, info, (union iwreq_data *)dwrq, extra);
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+ else if (strnicmp(extra, SETDFSCHANNELS_CMD, strlen(SETDFSCHANNELS_CMD)) == 0)
+ ret = wl_iw_set_dfs_channels(dev, info, (union iwreq_data *)dwrq, extra);
+#endif
+#if defined(PNO_SUPPORT)
+ else if (strnicmp(extra, PNOSSIDCLR_SET_CMD, strlen(PNOSSIDCLR_SET_CMD)) == 0)
+ ret = wl_iw_set_pno_reset(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, PNOSETUP_SET_CMD, strlen(PNOSETUP_SET_CMD)) == 0)
+ ret = wl_iw_set_pno_set(dev, info, (union iwreq_data *)dwrq, extra);
+ else if (strnicmp(extra, PNOENABLE_SET_CMD, strlen(PNOENABLE_SET_CMD)) == 0)
+ ret = wl_iw_set_pno_enable(dev, info, (union iwreq_data *)dwrq, extra);
+#endif
#if defined(CSCAN)
-
else if (strnicmp(extra, CSCAN_COMMAND, strlen(CSCAN_COMMAND)) == 0)
ret = wl_iw_set_cscan(dev, info, (union iwreq_data *)dwrq, extra);
#endif
#ifdef CUSTOMER_HW2
- else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
+ else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
ret = wl_iw_set_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
+ else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
#else
- else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
+ else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
#endif
+ else if (strnicmp(extra, "GETPOWER", strlen("GETPOWER")) == 0)
+ ret = wl_iw_get_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
#ifdef SOFTAP
- else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
-
- wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
- }
- else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
+ else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
+ wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
+ } else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
WL_SOFTAP(("penguin, set AP_MAC_LIST_SET\n"));
set_ap_mac_list(dev, (extra + PROFILE_OFFSET));
- }
-#endif
- else {
- WL_TRACE(("Unkown PRIVATE command %s\n", extra));
+ }
+#endif
+ else {
+ WL_TRACE(("Unknown PRIVATE command: %s: ignored\n", extra));
snprintf(extra, MAX_WX_STRING, "OK");
dwrq->length = strlen("OK") + 1;
}
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
}
+ net_os_wake_unlock(dev);
+
if (extra) {
- if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
+ if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
kfree(extra);
return -EFAULT;
- }
+ }
- kfree(extra);
+ kfree(extra);
}
return ret;
(iw_handler) wl_iw_get_freq,
(iw_handler) wl_iw_set_mode,
(iw_handler) wl_iw_get_mode,
- (iw_handler) wl_iw_set_sens,
- (iw_handler) wl_iw_get_sens,
- (iw_handler) NULL,
- (iw_handler) wl_iw_get_range,
- (iw_handler) wl_iw_set_priv,
- (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) wl_iw_get_range,
+ (iw_handler) wl_iw_set_priv,
+ (iw_handler) NULL,
(iw_handler) NULL,
(iw_handler) NULL,
(iw_handler) wl_iw_set_spy,
#endif
(iw_handler) wl_iw_set_essid,
(iw_handler) wl_iw_get_essid,
- (iw_handler) wl_iw_set_nick,
+ (iw_handler) wl_iw_set_nick,
(iw_handler) wl_iw_get_nick,
(iw_handler) NULL,
(iw_handler) NULL,
(iw_handler)wl_iw_control_wl_off,
NULL,
(iw_handler)wl_iw_control_wl_on,
-#ifdef SOFTAP
-
-
+#ifdef SOFTAP
NULL,
(iw_handler)iwpriv_set_ap_config,
-
-
NULL,
(iw_handler)iwpriv_get_assoc_list,
-
NULL,
(iw_handler)iwpriv_set_mac_filters,
-
NULL,
(iw_handler)iwpriv_en_ap_bss,
-
NULL,
(iw_handler)iwpriv_wpasupp_loop_tst,
-
+
NULL,
(iw_handler)iwpriv_softap_stop,
-
+
NULL,
(iw_handler)iwpriv_fw_reload,
-#endif
+
+ NULL,
+ (iw_handler)iwpriv_set_ap_sta_disassoc,
+#endif
#if defined(CSCAN)
-
+
NULL,
(iw_handler)iwpriv_set_cscan
#endif
};
-static const struct iw_priv_args wl_iw_priv_args[] =
-{
- {
+static const struct iw_priv_args wl_iw_priv_args[] = {
+ {
WL_IW_SET_ACTIVE_SCAN,
0,
IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
},
#ifdef SOFTAP
-
-
{
WL_SET_AP_CFG,
- IW_PRIV_TYPE_CHAR | 256,
+ IW_PRIV_TYPE_CHAR | 256,
0,
"AP_SET_CFG"
},
{
WL_AP_STA_LIST,
- 0,
- IW_PRIV_TYPE_CHAR | 0,
+ IW_PRIV_TYPE_CHAR | 0,
+ IW_PRIV_TYPE_CHAR | 1024,
"AP_GET_STA_LIST"
},
{
WL_AP_MAC_FLTR,
- IW_PRIV_TYPE_CHAR | 256,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
+ IW_PRIV_TYPE_CHAR | 256,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
"AP_SET_MAC_FLTR"
},
- {
+ {
WL_AP_BSS_START,
0,
IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
{
AP_LPB_CMD,
- IW_PRIV_TYPE_CHAR | 256,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
+ IW_PRIV_TYPE_CHAR | 256,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
"AP_LPB_CMD"
},
- {
+ {
WL_AP_STOP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
"AP_BSS_STOP"
},
- {
+
+ {
WL_FW_RELOAD,
IW_PRIV_TYPE_CHAR | 256,
IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
"WL_FW_RELOAD"
},
-#endif
+
+ {
+ WL_AP_STA_DISASSOC,
+ IW_PRIV_TYPE_CHAR | 256,
+ IW_PRIV_TYPE_CHAR | 0,
+ "AP_STA_DISASSOC"
+ },
+#endif
#if defined(CSCAN)
- {
+ {
WL_COMBO_SCAN,
- IW_PRIV_TYPE_CHAR | 1024,
+ IW_PRIV_TYPE_CHAR | 1024,
0,
"CSCAN"
},
-#endif
- };
+#endif
+};
const struct iw_handler_def wl_iw_handler_def =
{
#if WIRELESS_EXT >= 19
get_wireless_stats: dhd_get_wireless_stats,
#endif
- };
+};
#endif
-
int wl_iw_ioctl(
struct net_device *dev,
struct ifreq *rq,
char *extra = NULL;
int token_size = 1, max_tokens = 0, ret = 0;
- WL_TRACE(("\n%s, cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
+ net_os_wake_lock(dev);
+
+ WL_TRACE(("%s: cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
if (cmd < SIOCIWFIRST ||
IW_IOCTL_IDX(cmd) >= ARRAYSIZE(wl_iw_handler) ||
!(handler = wl_iw_handler[IW_IOCTL_IDX(cmd)])) {
WL_ERROR(("%s: error in cmd=%x : not supported\n", __FUNCTION__, cmd));
+ net_os_wake_unlock(dev);
return -EOPNOTSUPP;
}
break;
case SIOCGIWRANGE:
-
max_tokens = sizeof(struct iw_range) + 500;
break;
if (wrq->u.data.length > max_tokens) {
WL_ERROR(("%s: error in cmd=%x wrq->u.data.length=%d > max_tokens=%d\n", \
__FUNCTION__, cmd, wrq->u.data.length, max_tokens));
- return -E2BIG;
+ ret = -E2BIG;
+ goto wl_iw_ioctl_done;
+ }
+ if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL))) {
+ ret = -ENOMEM;
+ goto wl_iw_ioctl_done;
}
- if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL)))
- return -ENOMEM;
if (copy_from_user(extra, wrq->u.data.pointer, wrq->u.data.length * token_size)) {
kfree(extra);
- return -EFAULT;
+ ret = -EFAULT;
+ goto wl_iw_ioctl_done;
}
}
if (extra) {
if (copy_to_user(wrq->u.data.pointer, extra, wrq->u.data.length * token_size)) {
kfree(extra);
- return -EFAULT;
+ ret = -EFAULT;
+ goto wl_iw_ioctl_done;
}
kfree(extra);
}
+wl_iw_ioctl_done:
+
+ net_os_wake_unlock(dev);
+
return ret;
}
else
return FALSE;
}
-#endif
+#endif
#ifndef IW_CUSTOM_MAX
#define IW_CUSTOM_MAX 256
-#endif
+#endif
void
wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
uint16 flags = ntoh16(e->flags);
uint32 datalen = ntoh32(e->datalen);
uint32 status = ntoh32(e->status);
- wl_iw_t *iw;
uint32 toto;
+ static uint32 roam_no_success = 0;
+ static bool roam_no_success_send = FALSE;
memset(&wrqu, 0, sizeof(wrqu));
memset(extra, 0, sizeof(extra));
- iw = 0;
if (!dev) {
WL_ERROR(("%s: dev is null\n", __FUNCTION__));
return;
}
- iw = *(wl_iw_t **)netdev_priv(dev);
+ net_os_wake_lock(dev);
- //WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
+ WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
-
switch (event_type) {
+
+ case WLC_E_RELOAD:
+ WL_ERROR(("%s: Firmware ERROR %d\n", __FUNCTION__, status));
+ net_os_send_hang_message(dev);
+ goto wl_iw_event_end;
+
#if defined(SOFTAP)
case WLC_E_PRUNE:
if (ap_cfg_running) {
macaddr[0], macaddr[1], macaddr[2], macaddr[3], \
macaddr[4], macaddr[5]));
-
- if (ap_macmode)
- {
+ if (ap_macmode) {
int i;
for (i = 0; i < ap_black_list.count; i++) {
if (!bcmp(macaddr, &ap_black_list.ea[i], \
}
if (i == ap_black_list.count) {
-
char mac_buf[32] = {0};
sprintf(mac_buf, "STA_BLOCK %02X:%02X:%02X:%02X:%02X:%02X",
macaddr[0], macaddr[1], macaddr[2],
}
}
break;
-#endif
+#endif
case WLC_E_TXFAIL:
cmd = IWEVTXDROP;
memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
WL_SOFTAP(("STA connect received %d\n", event_type));
if (ap_cfg_running) {
wl_iw_send_priv_event(priv_dev, "STA_JOIN");
- return;
+ goto wl_iw_event_end;
}
-#endif
+#endif
memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
wrqu.addr.sa_family = ARPHRD_ETHER;
cmd = IWEVREGISTERED;
break;
+ case WLC_E_ROAM:
+ if (status == WLC_E_STATUS_SUCCESS) {
+ memcpy(wrqu.addr.sa_data, &e->addr.octet, ETHER_ADDR_LEN);
+ wrqu.addr.sa_family = ARPHRD_ETHER;
+ cmd = SIOCGIWAP;
+ }
+ else if (status == WLC_E_STATUS_NO_NETWORKS) {
+ roam_no_success++;
+ if ((roam_no_success == 5) && (roam_no_success_send == FALSE)) {
+ roam_no_success_send = TRUE;
+ bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
+ bzero(&extra, ETHER_ADDR_LEN);
+ cmd = SIOCGIWAP;
+ WL_ERROR(("%s ROAMING did not succeeded , send Link Down\n", \
+ __FUNCTION__));
+ } else {
+ WL_TRACE(("##### ROAMING did not succeeded %d\n", roam_no_success));
+ goto wl_iw_event_end;
+ }
+ }
+ break;
case WLC_E_DEAUTH_IND:
case WLC_E_DISASSOC_IND:
#if defined(SOFTAP)
WL_SOFTAP(("STA disconnect received %d\n", event_type));
if (ap_cfg_running) {
wl_iw_send_priv_event(priv_dev, "STA_LEAVE");
- return;
+ goto wl_iw_event_end;
}
-#endif
+#endif
cmd = SIOCGIWAP;
bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
wrqu.addr.sa_family = ARPHRD_ETHER;
case WLC_E_NDIS_LINK:
cmd = SIOCGIWAP;
if (!(flags & WLC_EVENT_MSG_LINK)) {
-
-
#ifdef SOFTAP
#ifdef AP_ONLY
if (ap_cfg_running) {
#else
if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
#endif
-
- WL_SOFTAP(("AP DOWN %d\n", event_type));
- wl_iw_send_priv_event(priv_dev, "AP_DOWN");
- } else {
- WL_TRACE(("STA_Link Down\n"));
+ WL_SOFTAP(("AP DOWN %d\n", event_type));
+ wl_iw_send_priv_event(priv_dev, "AP_DOWN");
+ } else {
+ WL_TRACE(("STA_Link Down\n"));
+ g_ss_cache_ctrl.m_link_down = 1;
+ }
+#else
g_ss_cache_ctrl.m_link_down = 1;
- }
-#else
- g_ss_cache_ctrl.m_link_down = 1;
-#endif
+#endif
WL_TRACE(("Link Down\n"));
bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
bzero(&extra, ETHER_ADDR_LEN);
- WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT, 20 * HZ);
}
else {
-
memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
g_ss_cache_ctrl.m_link_down = 0;
-
+
memcpy(g_ss_cache_ctrl.m_active_bssid, &e->addr, ETHER_ADDR_LEN);
-#ifdef SOFTAP
+#ifdef SOFTAP
#ifdef AP_ONLY
if (ap_cfg_running) {
#else
if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
#endif
-
WL_SOFTAP(("AP UP %d\n", event_type));
wl_iw_send_priv_event(priv_dev, "AP_UP");
} else {
WL_TRACE(("STA_LINK_UP\n"));
+ roam_no_success_send = FALSE;
+ roam_no_success = 0;
}
-#else
-#endif
+#endif
WL_TRACE(("Link UP\n"));
}
+ net_os_wake_lock_timeout_enable(dev);
wrqu.addr.sa_family = ARPHRD_ETHER;
break;
case WLC_E_ACTION_FRAME:
count--;
}
}
- return;
+ goto wl_iw_event_end;
}
#endif
#endif
cmd = SIOCGIWSCAN;
wrqu.data.length = strlen(extra);
WL_TRACE(("Event WLC_E_SCAN_COMPLETE\n"));
-#endif
+#endif
+ break;
+
+ case WLC_E_PFN_NET_FOUND:
+ {
+ wlc_ssid_t * ssid;
+ ssid = (wlc_ssid_t *)data;
+ WL_TRACE(("%s Event WLC_E_PFN_NET_FOUND, send %s up : find %s len=%d\n", \
+ __FUNCTION__, PNO_EVENT_UP, ssid->SSID, ssid->SSID_len));
+ net_os_wake_lock_timeout_enable(dev);
+ cmd = IWEVCUSTOM;
+ memset(&wrqu, 0, sizeof(wrqu));
+ strcpy(extra, PNO_EVENT_UP);
+ wrqu.data.length = strlen(extra);
+ }
break;
default:
break;
}
#ifndef SANDGATE2G
- if (cmd) {
- if (cmd == SIOCGIWSCAN)
- wireless_send_event(dev, cmd, &wrqu, NULL);
- else
- wireless_send_event(dev, cmd, &wrqu, extra);
- }
+ if (cmd) {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
+ if (cmd == SIOCGIWSCAN)
+ wireless_send_event(dev, cmd, &wrqu, NULL);
+ else
+#endif
+ wireless_send_event(dev, cmd, &wrqu, extra);
+ }
#endif
#if WIRELESS_EXT > 14
wireless_send_event(dev, cmd, &wrqu, extra);
#endif
}
-#endif
-
-#endif
+#endif
+wl_iw_event_end:
+ net_os_wake_unlock(dev);
+#endif
}
int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
struct net_device *dev,
bool set)
{
+#if defined(BT_DHCP_USE_FLAGS)
char buf_flag7_dhcp_on[8] = { 7, 00, 00, 00, 0x1, 0x0, 0x00, 0x00 };
char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
+#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_lock();
#endif
+#if defined(BT_DHCP_eSCO_FIX)
+ set_btc_esco_params(dev, set);
+#endif
+
+#if defined(BT_DHCP_USE_FLAGS)
+ WL_TRACE_COEX(("WI-FI priority boost via bt flags, set:%d\n", set));
if (set == TRUE) {
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
+ dev_wlc_bufvar_set(dev, "btc_flags",
(char *)&buf_flag7_dhcp_on[0], sizeof(buf_flag7_dhcp_on));
}
else {
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
+ dev_wlc_bufvar_set(dev, "btc_flags",
(char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
}
+#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
rtnl_unlock();
bt_info_t *bt_local = (bt_info_t *)data;
bt_local->timer_on = 0;
WL_TRACE(("%s\n", __FUNCTION__));
-
+
up(&bt_local->bt_sem);
}
DAEMONIZE("dhcp_sysioc");
while (down_interruptible(&g_bt->bt_sem) == 0) {
+
+ net_os_wake_lock(g_bt->dev);
+
if (g_bt->timer_on) {
- del_timer(&g_bt->timer);
g_bt->timer_on = 0;
+ del_timer_sync(&g_bt->timer);
}
switch (g_bt->bt_state) {
case BT_DHCP_START:
-
+ WL_TRACE_COEX(("%s bt_dhcp stm: started \n", __FUNCTION__));
g_bt->bt_state = BT_DHCP_OPPORTUNITY_WINDOW;
- mod_timer(&g_bt->timer, jiffies + \
- BT_DHCP_OPPORTUNITY_WINDOW_TIEM*HZ/1000);
+ mod_timer(&g_bt->timer, jiffies + BT_DHCP_OPPORTUNITY_WINDOW_TIME*HZ/1000);
g_bt->timer_on = 1;
break;
+
case BT_DHCP_OPPORTUNITY_WINDOW:
-
- WL_TRACE(("%s waiting for %d msec expired, force bt flag\n", \
- __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIEM));
+ if (g_bt->dhcp_done) {
+ WL_TRACE_COEX(("%s DHCP Done before T1 expiration\n", \
+ __FUNCTION__));
+ g_bt->bt_state = BT_DHCP_IDLE;
+ g_bt->timer_on = 0;
+ break;
+ }
+
+ WL_TRACE_COEX(("%s DHCP T1:%d expired\n", \
+ __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIME));
if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, TRUE);
g_bt->bt_state = BT_DHCP_FLAG_FORCE_TIMEOUT;
mod_timer(&g_bt->timer, jiffies + BT_DHCP_FLAG_FORCE_TIME*HZ/1000);
g_bt->timer_on = 1;
break;
+
case BT_DHCP_FLAG_FORCE_TIMEOUT:
-
- WL_TRACE(("%s waiting for %d msec expired remove bt flag\n", \
+ if (g_bt->dhcp_done) {
+ WL_TRACE_COEX(("%s DHCP Done before T2 expiration\n", \
+ __FUNCTION__));
+ } else {
+ WL_TRACE_COEX(("%s DHCP wait interval T2:%d msec expired\n",
__FUNCTION__, BT_DHCP_FLAG_FORCE_TIME));
-
+ }
+
if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, FALSE);
g_bt->bt_state = BT_DHCP_IDLE;
g_bt->timer_on = 0;
break;
+
default:
WL_ERROR(("%s error g_status=%d !!!\n", __FUNCTION__, \
g_bt->bt_state));
g_bt->bt_state = BT_DHCP_IDLE;
g_bt->timer_on = 0;
break;
- }
+ }
+
+ net_os_wake_unlock(g_bt->dev);
}
if (g_bt->timer_on) {
- del_timer(&g_bt->timer);
g_bt->timer_on = 0;
+ del_timer_sync(&g_bt->timer);
}
+
complete_and_exit(&g_bt->bt_exited, 0);
}
return 0;
}
-int wl_iw_attach(struct net_device *dev, void * dhdp)
+int wl_iw_attach(struct net_device *dev, void *dhdp)
{
int params_size;
wl_iw_t *iw;
#if defined(WL_IW_USE_ISCAN)
iscan_info_t *iscan = NULL;
+#endif
+
+ mutex_init(&wl_cache_lock);
+#if defined(WL_IW_USE_ISCAN)
if (!dev)
return 0;
-
+ memset(&g_wl_iw_params, 0, sizeof(wl_iw_extra_params_t));
+
#ifdef CSCAN
params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params)) +
(WL_NUMCHANNELS * sizeof(uint16)) + WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params));
#endif
iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
-
if (!iscan)
return -ENOMEM;
memset(iscan, 0, sizeof(iscan_info_t));
-
iscan->iscan_ex_params_p = (wl_iscan_params_t*)kmalloc(params_size, GFP_KERNEL);
if (!iscan->iscan_ex_params_p)
g_iscan = iscan;
iscan->dev = dev;
iscan->iscan_state = ISCAN_STATE_IDLE;
-
+#if defined(CONFIG_FIRST_SCAN)
g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
+ g_first_counter_scans = 0;
g_iscan->scan_flag = 0;
+#endif
-
- iscan->timer_ms = 3000;
+ iscan->timer_ms = 8000;
init_timer(&iscan->timer);
iscan->timer.data = (ulong)iscan;
iscan->timer.function = wl_iw_timerfunc;
iscan->sysioc_pid = kernel_thread(_iscan_sysioc_thread, iscan, 0);
if (iscan->sysioc_pid < 0)
return -ENOMEM;
-#endif
+#endif
iw = *(wl_iw_t **)netdev_priv(dev);
iw->pub = (dhd_pub_t *)dhdp;
- MUTEX_LOCK_INIT(iw->pub);
- MUTEX_LOCK_WL_SCAN_SET_INIT();
#ifdef SOFTAP
priv_dev = dev;
- MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
#endif
g_scan = NULL;
-
g_scan = (void *)kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
if (!g_scan)
return -ENOMEM;
g_scan_specified_ssid = 0;
#if !defined(CSCAN)
-
wl_iw_init_ss_cache_ctrl();
-#endif
-
- wl_iw_bt_init(dev);
+#endif
+ wl_iw_bt_init(dev);
return 0;
}
KILL_PROC(iscan->sysioc_pid, SIGTERM);
wait_for_completion(&iscan->sysioc_exited);
}
- MUTEX_LOCK_WL_SCAN_SET();
+ mutex_lock(&wl_cache_lock);
while (iscan->list_hdr) {
buf = iscan->list_hdr->next;
kfree(iscan->list_hdr);
iscan->list_hdr = buf;
}
- MUTEX_UNLOCK_WL_SCAN_SET();
kfree(iscan->iscan_ex_params_p);
kfree(iscan);
g_iscan = NULL;
-#endif
+ mutex_unlock(&wl_cache_lock);
+#endif
if (g_scan)
kfree(g_scan);
g_scan = NULL;
#if !defined(CSCAN)
wl_iw_release_ss_cache_ctrl();
-#endif
+#endif
wl_iw_bt_release();
-
#ifdef SOFTAP
if (ap_cfg_running) {
WL_TRACE(("\n%s AP is going down\n", __FUNCTION__));
-
wl_iw_send_priv_event(priv_dev, "AP_DOWN");
}
#endif
-
}
* 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_iw.h,v 1.5.34.1.6.24 2010/07/27 20:46:02 Exp $
+ * $Id: wl_iw.h,v 1.5.34.1.6.36.4.15 2010/11/17 03:13:51 Exp $
*/
#define GET_HOME_DWELL "HOME="
#define GET_SCAN_TYPE "TYPE="
-#define BAND_GET_CMD "BANDGET"
-#define BAND_SET_CMD "BANDSET"
-
-
-#define WL_IW_RSSI_MINVAL -200
-#define WL_IW_RSSI_NO_SIGNAL -91
-#define WL_IW_RSSI_VERY_LOW -80
-#define WL_IW_RSSI_LOW -70
-#define WL_IW_RSSI_GOOD -68
-#define WL_IW_RSSI_VERY_GOOD -58
-#define WL_IW_RSSI_EXCELLENT -57
-#define WL_IW_RSSI_INVALID 0
-#define MAX_WX_STRING 80
-#define isprint(c) bcm_isprint(c)
+#define BAND_GET_CMD "GETBAND"
+#define BAND_SET_CMD "SETBAND"
+#define DTIM_SKIP_GET_CMD "DTIMSKIPGET"
+#define DTIM_SKIP_SET_CMD "DTIMSKIPSET"
+#define SETSUSPEND_CMD "SETSUSPENDOPT"
+#define PNOSSIDCLR_SET_CMD "PNOSSIDCLR"
+#define PNOSETUP_SET_CMD "PNOSETUP "
+#define PNOENABLE_SET_CMD "PNOFORCE"
+#define PNODEBUG_SET_CMD "PNODEBUG"
+#define SETDFSCHANNELS_CMD "SETDFSCHANNELS"
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+
+typedef struct wl_iw_extra_params {
+ int target_channel;
+} wl_iw_extra_params_t;
+
+#define WL_IW_RSSI_MINVAL -200
+#define WL_IW_RSSI_NO_SIGNAL -91
+#define WL_IW_RSSI_VERY_LOW -80
+#define WL_IW_RSSI_LOW -70
+#define WL_IW_RSSI_GOOD -68
+#define WL_IW_RSSI_VERY_GOOD -58
+#define WL_IW_RSSI_EXCELLENT -57
+#define WL_IW_RSSI_INVALID 0
+#define MAX_WX_STRING 80
+#define isprint(c) bcm_isprint(c)
#define WL_IW_SET_ACTIVE_SCAN (SIOCIWFIRSTPRIV+1)
-#define WL_IW_GET_RSSI (SIOCIWFIRSTPRIV+3)
+#define WL_IW_GET_RSSI (SIOCIWFIRSTPRIV+3)
#define WL_IW_SET_PASSIVE_SCAN (SIOCIWFIRSTPRIV+5)
#define WL_IW_GET_LINK_SPEED (SIOCIWFIRSTPRIV+7)
#define WL_IW_GET_CURR_MACADDR (SIOCIWFIRSTPRIV+9)
-#define WL_IW_SET_STOP (SIOCIWFIRSTPRIV+11)
-#define WL_IW_SET_START (SIOCIWFIRSTPRIV+13)
+#define WL_IW_SET_STOP (SIOCIWFIRSTPRIV+11)
+#define WL_IW_SET_START (SIOCIWFIRSTPRIV+13)
#define WL_SET_AP_CFG (SIOCIWFIRSTPRIV+15)
#define AP_LPB_CMD (SIOCIWFIRSTPRIV+23)
#define WL_AP_STOP (SIOCIWFIRSTPRIV+25)
#define WL_FW_RELOAD (SIOCIWFIRSTPRIV+27)
-#define WL_COMBO_SCAN (SIOCIWFIRSTPRIV+29)
-#define WL_AP_SPARE3 (SIOCIWFIRSTPRIV+31)
-#define G_SCAN_RESULTS 8*1024
-#define WE_ADD_EVENT_FIX 0x80
-#define G_WLAN_SET_ON 0
-#define G_WLAN_SET_OFF 1
+#define WL_AP_STA_DISASSOC (SIOCIWFIRSTPRIV+29)
+#define WL_COMBO_SCAN (SIOCIWFIRSTPRIV+31)
+
+#define G_SCAN_RESULTS (8*1024)
+#define WE_ADD_EVENT_FIX 0x80
+#define G_WLAN_SET_ON 0
+#define G_WLAN_SET_OFF 1
#define CHECK_EXTRA_FOR_NULL(extra) \
if (!extra) { \
struct iw_statistics wstats;
int spy_num;
- uint32 pwsec;
- uint32 gwsec;
- bool privacy_invoked;
+ uint32 pwsec;
+ uint32 gwsec;
+ bool privacy_invoked;
struct ether_addr spy_addr[IW_MAX_SPY];
struct iw_quality spy_qual[IW_MAX_SPY];
dhd_pub_t * pub;
} wl_iw_t;
-int wl_control_wl_start(struct net_device *dev);
-#define WLC_IW_SS_CACHE_MAXLEN 512
+#define WLC_IW_SS_CACHE_MAXLEN 2048
#define WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN 32
#define WLC_IW_BSS_INFO_MAXLEN \
(WLC_IW_SS_CACHE_MAXLEN - WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN)
typedef struct wl_iw_ss_cache {
struct wl_iw_ss_cache *next;
+ int dirty;
uint32 buflen;
uint32 version;
uint32 count;
- int dirty;
wl_bss_info_t bss_info[1];
} wl_iw_ss_cache_t;
uint m_cons_br_scan_cnt;
struct timer_list *m_timer;
} wl_iw_ss_cache_ctrl_t;
+
typedef enum broadcast_first_scan {
BROADCAST_SCAN_FIRST_IDLE = 0,
BROADCAST_SCAN_FIRST_STARTED,
uint8 ssid[SSID_LEN];
uint8 sec[SEC_LEN];
uint8 key[KEY_LEN];
- uint32 channel;
+ uint32 channel;
uint32 preamble;
- uint32 max_scb;
+ uint32 max_scb;
+ uint32 closednet;
+ char country_code[WLC_CNTRY_BUF_SZ];
};
#define MACLIST_MODE_DISABLED 0
-#define MACLIST_MODE_ENABLED 1
+#define MACLIST_MODE_DENY 1
#define MACLIST_MODE_ALLOW 2
struct mflist {
uint count;
struct ether_addr ea[16];
};
+
struct mac_list_set {
uint32 mode;
- struct mflist white_list;
- struct mflist black_list;
+ struct mflist mac_list;
};
-#endif
+#endif
#if WIRELESS_EXT > 12
#include <net/iw_handler.h>
extern const struct iw_handler_def wl_iw_handler_def;
-#endif
+#endif
extern int wl_iw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
extern void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data);
extern int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats);
int wl_iw_attach(struct net_device *dev, void * dhdp);
void wl_iw_detach(void);
+int wl_control_wl_start(struct net_device *dev);
+
+extern int net_os_wake_lock(struct net_device *dev);
+extern int net_os_wake_unlock(struct net_device *dev);
+extern int net_os_wake_lock_timeout(struct net_device *dev);
+extern int net_os_wake_lock_timeout_enable(struct net_device *dev);
+extern int net_os_set_suspend_disable(struct net_device *dev, int val);
+extern int net_os_set_suspend(struct net_device *dev, int val);
+extern int net_os_set_dtim_skip(struct net_device *dev, int val);
+extern int net_os_set_packet_filter(struct net_device *dev, int val);
+extern void dhd_bus_country_set(struct net_device *dev, char *country_code);
+extern char *dhd_bus_country_get(struct net_device *dev);
+extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
#define IWE_STREAM_ADD_EVENT(info, stream, ends, iwe, extra) \
iwe_stream_add_point(stream, ends, iwe, extra)
#endif
+extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
+extern int dhd_pno_clean(dhd_pub_t *dhd);
+extern int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid, ushort scan_fr);
+extern int dhd_pno_get_status(dhd_pub_t *dhd);
+extern int dhd_dev_pno_reset(struct net_device *dev);
+extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local, \
+ int nssid, ushort scan_fr);
+extern int dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled);
+extern int dhd_dev_get_pno_status(struct net_device *dev);
+
+#define PNO_TLV_PREFIX 'S'
+#define PNO_TLV_VERSION '1'
+#define PNO_TLV_SUBVERSION '2'
+#define PNO_TLV_RESERVED '0'
+#define PNO_TLV_TYPE_SSID_IE 'S'
+#define PNO_TLV_TYPE_TIME 'T'
+#define PNO_EVENT_UP "PNO_EVENT"
+#define PNO_SCAN_MAX_FW 508
+
+typedef struct cmd_tlv {
+ char prefix;
+ char version;
+ char subver;
+ char reserved;
+} cmd_tlv_t;
+
#if defined(CSCAN)
typedef struct cscan_tlv {
#define CSCAN_TLV_PREFIX 'S'
#define CSCAN_TLV_VERSION 1
#define CSCAN_TLV_SUBVERSION 0
-#define CSCAN_TLV_TYPE_SSID_IE 'S'
-#define CSCAN_TLV_TYPE_CHANNEL_IE 'C'
-#define CSCAN_TLV_TYPE_NPROBE_IE 'N'
-#define CSCAN_TLV_TYPE_ACTIVE_IE 'A'
-#define CSCAN_TLV_TYPE_PASSIVE_IE 'P'
-#define CSCAN_TLV_TYPE_HOME_IE 'H'
-#define CSCAN_TLV_TYPE_STYPE_IE 'T'
+#define CSCAN_TLV_TYPE_SSID_IE 'S'
+#define CSCAN_TLV_TYPE_CHANNEL_IE 'C'
+#define CSCAN_TLV_TYPE_NPROBE_IE 'N'
+#define CSCAN_TLV_TYPE_ACTIVE_IE 'A'
+#define CSCAN_TLV_TYPE_PASSIVE_IE 'P'
+#define CSCAN_TLV_TYPE_HOME_IE 'H'
+#define CSCAN_TLV_TYPE_STYPE_IE 'T'
extern int wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list, \
int channel_num, int *bytes_left);
+++ /dev/null
-/*
- * Linux Wireless Extensions support
- *
- * Copyright (C) 1999-2010, 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: wl_iw.c,v 1.51.4.9.2.6.4.124 2010/07/27 20:46:02 Exp $
- */
-
-#include <wlioctl.h>
-
-#include <typedefs.h>
-#include <linuxver.h>
-#include <osl.h>
-
-#include <bcmutils.h>
-#include <bcmendian.h>
-#include <proto/ethernet.h>
-
-#include <linux/if_arp.h>
-#include <asm/uaccess.h>
-
-#include <dngl_stats.h>
-#include <dhd.h>
-#include <dhdioctl.h>
-
-typedef void wlc_info_t;
-typedef void wl_info_t;
-typedef const struct si_pub si_t;
-#include <wlioctl.h>
-
-#include <proto/ethernet.h>
-#include <dngl_stats.h>
-#include <dhd.h>
-#include <dhd_dbg.h>
-#define WL_ERROR(x) DHD_ERROR(x)
-#define WL_TRACE(x) DHD_TRACE(x)
-#define WL_ASSOC(x) DHD_TRACE(x)
-#define WL_INFORM(x) DHD_TRACE(x)
-#define WL_WSEC(x) DHD_TRACE(x)
-#define WL_SCAN(x) DHD_TRACE(x)
-
-#include <wl_iw.h>
-
-#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
-
-
-#define IW_WSEC_ENABLED(wsec) ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
-
-#include <linux/rtnetlink.h>
-
-#define WL_IW_USE_ISCAN 1
-#define ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS 1
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
- struct mutex g_wl_ss_scan_lock;
-#endif
-
-#if defined(SOFTAP)
-#define WL_SOFTAP(x) DHD_TRACE(x)
-static struct net_device *priv_dev;
-static bool ap_cfg_running = FALSE;
-static bool ap_fw_loaded = FALSE;
-struct net_device *ap_net_dev = NULL;
-struct semaphore ap_eth_sema;
-static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap);
-static int wl_iw_softap_deassoc_stations(struct net_device *dev);
-#endif
-
-#define WL_IW_IOCTL_CALL(func_call) \
- do { \
- func_call; \
- } while (0)
-
-static int g_onoff = G_WLAN_SET_ON;
-
-extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
- uint32 reason, char* stringBuf, uint buflen);
-#include <bcmsdbus.h>
-extern void dhd_customer_gpio_wlan_ctrl(int onoff);
-extern uint dhd_dev_reset(struct net_device *dev, uint8 flag);
-extern void dhd_dev_init_ioctl(struct net_device *dev);
-int dev_iw_write_cfg1_bss_var(struct net_device *dev, int val);
-
-uint wl_msg_level = WL_ERROR_VAL;
-
-#define MAX_WLIW_IOCTL_LEN 1024
-
-#if defined(IL_BIGENDIAN)
-#include <bcmendian.h>
-#define htod32(i) (bcmswap32(i))
-#define htod16(i) (bcmswap16(i))
-#define dtoh32(i) (bcmswap32(i))
-#define dtoh16(i) (bcmswap16(i))
-#define htodchanspec(i) htod16(i)
-#define dtohchanspec(i) dtoh16(i)
-#else
-#define htod32(i) i
-#define htod16(i) i
-#define dtoh32(i) i
-#define dtoh16(i) i
-#define htodchanspec(i) i
-#define dtohchanspec(i) i
-#endif
-
-#ifdef CONFIG_WIRELESS_EXT
-
-extern struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev);
-extern int dhd_wait_pend8021x(struct net_device *dev);
-#endif
-
-#if WIRELESS_EXT < 19
-#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
-#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
-#endif
-
-static void *g_scan = NULL;
-static volatile uint g_scan_specified_ssid;
-static wlc_ssid_t g_specific_ssid;
-
-static wlc_ssid_t g_ssid;
-
-static wl_iw_ss_cache_ctrl_t g_ss_cache_ctrl;
-static volatile uint g_first_broadcast_scan;
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
-#define DAEMONIZE(a) daemonize(a); \
- allow_signal(SIGKILL); \
- allow_signal(SIGTERM);
-#else
-#define RAISE_RX_SOFTIRQ() \
- cpu_raise_softirq(smp_processor_id(), NET_RX_SOFTIRQ)
-#define DAEMONIZE(a) daemonize(); \
- do { if (a) \
- strncpy(current->comm, a, MIN(sizeof(current->comm), (strlen(a) + 1))); \
- } while (0);
-#endif
-
-#if defined(WL_IW_USE_ISCAN)
-#if !defined(CSCAN)
-static void wl_iw_free_ss_cache(void);
-static int wl_iw_run_ss_cache_timer(int kick_off);
-#endif
-int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
-static int dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len);
-#define ISCAN_STATE_IDLE 0
-#define ISCAN_STATE_SCANING 1
-
-#define WLC_IW_ISCAN_MAXLEN 2048
-typedef struct iscan_buf {
- struct iscan_buf * next;
- char iscan_buf[WLC_IW_ISCAN_MAXLEN];
-} iscan_buf_t;
-
-typedef struct iscan_info {
- struct net_device *dev;
- struct timer_list timer;
- uint32 timer_ms;
- uint32 timer_on;
- int iscan_state;
- iscan_buf_t * list_hdr;
- iscan_buf_t * list_cur;
-
- long sysioc_pid;
- struct semaphore sysioc_sem;
- struct completion sysioc_exited;
-
- uint32 scan_flag;
-#if defined CSCAN
- char ioctlbuf[WLC_IOCTL_MEDLEN];
-#else
- char ioctlbuf[WLC_IOCTL_SMLEN];
-#endif
-
- wl_iscan_params_t *iscan_ex_params_p;
- int iscan_ex_param_size;
-} iscan_info_t;
-#define COEX_DHCP 1
-static void wl_iw_bt_flag_set(struct net_device *dev, bool set);
-static void wl_iw_bt_release(void);
-
-typedef enum bt_coex_status {
- BT_DHCP_IDLE = 0,
- BT_DHCP_START,
- BT_DHCP_OPPORTUNITY_WINDOW,
- BT_DHCP_FLAG_FORCE_TIMEOUT
-} coex_status_t;
-#define BT_DHCP_OPPORTUNITY_WINDOW_TIEM 2500
-#define BT_DHCP_FLAG_FORCE_TIME 5500
-
-typedef struct bt_info {
- struct net_device *dev;
- struct timer_list timer;
- uint32 timer_ms;
- uint32 timer_on;
- int bt_state;
-
-
- long bt_pid;
- struct semaphore bt_sem;
- struct completion bt_exited;
-} bt_info_t;
-
-bt_info_t *g_bt = NULL;
-static void wl_iw_bt_timerfunc(ulong data);
-iscan_info_t *g_iscan = NULL;
-static void wl_iw_timerfunc(ulong data);
-static void wl_iw_set_event_mask(struct net_device *dev);
-static int
-wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, uint16 action);
-#endif
-static int
-wl_iw_set_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-);
-static int
-wl_iw_get_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-);
-
-static uint
-wl_iw_get_scan_prep(
- wl_scan_results_t *list,
- struct iw_request_info *info,
- char *extra,
- short max_size
-);
-
-
-static void swap_key_from_BE(
- wl_wsec_key_t *key
-)
-{
- key->index = htod32(key->index);
- key->len = htod32(key->len);
- key->algo = htod32(key->algo);
- key->flags = htod32(key->flags);
- key->rxiv.hi = htod32(key->rxiv.hi);
- key->rxiv.lo = htod16(key->rxiv.lo);
- key->iv_initialized = htod32(key->iv_initialized);
-}
-
-static void swap_key_to_BE(
- wl_wsec_key_t *key
-)
-{
- key->index = dtoh32(key->index);
- key->len = dtoh32(key->len);
- key->algo = dtoh32(key->algo);
- key->flags = dtoh32(key->flags);
- key->rxiv.hi = dtoh32(key->rxiv.hi);
- key->rxiv.lo = dtoh16(key->rxiv.lo);
- key->iv_initialized = dtoh32(key->iv_initialized);
-}
-
-
-static const char* cmd2nam(int cmd)
-{
- const char *n="";
-#if defined(DHD_DEBUG)
- int i=0;
- struct _WLCNVStruct {
- const char *n;
- int v;
- } wlcnv[] = {
- {"WLC_GET_MAGIC", 0},
- {"WLC_GET_VERSION", 1},
- {"WLC_UP", 2},
- {"WLC_DOWN", 3},
- {"WLC_GET_LOOP", 4},
- {"WLC_SET_LOOP", 5},
- {"WLC_DUMP", 6},
- {"WLC_GET_MSGLEVEL", 7},
- {"WLC_SET_MSGLEVEL", 8},
- {"WLC_GET_PROMISC", 9},
- {"WLC_SET_PROMISC", 10},
- {"WLC_GET_RATE", 12},
- {"WLC_GET_INSTANCE", 14},
- {"WLC_GET_INFRA", 19},
- {"WLC_SET_INFRA", 20},
- {"WLC_GET_AUTH", 21},
- {"WLC_SET_AUTH", 22},
- {"WLC_GET_BSSID", 23},
- {"WLC_SET_BSSID", 24},
- {"WLC_GET_SSID", 25},
- {"WLC_SET_SSID", 26},
- {"WLC_RESTART", 27},
- {"WLC_GET_CHANNEL", 29},
- {"WLC_SET_CHANNEL", 30},
- {"WLC_GET_SRL", 31},
- {"WLC_SET_SRL", 32},
- {"WLC_GET_LRL", 33},
- {"WLC_SET_LRL", 34},
- {"WLC_GET_PLCPHDR", 35},
- {"WLC_SET_PLCPHDR", 36},
- {"WLC_GET_RADIO", 37},
- {"WLC_SET_RADIO", 38},
- {"WLC_GET_PHYTYPE", 39},
- {"WLC_DUMP_RATE", 40},
- {"WLC_SET_RATE_PARAMS", 41},
- {"WLC_GET_KEY", 44},
- {"WLC_SET_KEY", 45},
- {"WLC_GET_REGULATORY", 46},
- {"WLC_SET_REGULATORY", 47},
- {"WLC_GET_PASSIVE_SCAN", 48},
- {"WLC_SET_PASSIVE_SCAN", 49},
- {"WLC_SCAN", 50},
- {"WLC_SCAN_RESULTS", 51},
- {"WLC_DISASSOC", 52},
- {"WLC_REASSOC", 53},
- {"WLC_GET_ROAM_TRIGGER", 54},
- {"WLC_SET_ROAM_TRIGGER", 55},
- {"WLC_GET_ROAM_DELTA", 56},
- {"WLC_SET_ROAM_DELTA", 57},
- {"WLC_GET_ROAM_SCAN_PERIOD", 58},
- {"WLC_SET_ROAM_SCAN_PERIOD", 59},
- {"WLC_EVM", 60},
- {"WLC_GET_TXANT", 61},
- {"WLC_SET_TXANT", 62},
- {"WLC_GET_ANTDIV", 63},
- {"WLC_SET_ANTDIV", 64},
- {"WLC_GET_CLOSED", 67},
- {"WLC_SET_CLOSED", 68},
- {"WLC_GET_MACLIST", 69},
- {"WLC_SET_MACLIST", 70},
- {"WLC_GET_RATESET", 71},
- {"WLC_SET_RATESET", 72},
- {"WLC_LONGTRAIN", 74},
- {"WLC_GET_BCNPRD", 75},
- {"WLC_SET_BCNPRD", 76},
- {"WLC_GET_DTIMPRD", 77},
- {"WLC_SET_DTIMPRD", 78},
- {"WLC_GET_SROM", 79},
- {"WLC_SET_SROM", 80},
- {"WLC_GET_WEP_RESTRICT", 81},
- {"WLC_SET_WEP_RESTRICT", 82},
- {"WLC_GET_COUNTRY", 83},
- {"WLC_SET_COUNTRY", 84},
- {"WLC_GET_PM", 85},
- {"WLC_SET_PM", 86},
- {"WLC_GET_WAKE", 87},
- {"WLC_SET_WAKE", 88},
- {"WLC_GET_FORCELINK", 90},
- {"WLC_SET_FORCELINK", 91},
- {"WLC_FREQ_ACCURACY", 92},
- {"WLC_CARRIER_SUPPRESS", 93},
- {"WLC_GET_PHYREG", 94},
- {"WLC_SET_PHYREG", 95},
- {"WLC_GET_RADIOREG", 96},
- {"WLC_SET_RADIOREG", 97},
- {"WLC_GET_REVINFO", 98},
- {"WLC_GET_UCANTDIV", 99},
- {"WLC_SET_UCANTDIV", 100},
- {"WLC_R_REG", 101},
- {"WLC_W_REG", 102},
- {"WLC_GET_MACMODE", 105},
- {"WLC_SET_MACMODE", 106},
- {"WLC_GET_MONITOR", 107},
- {"WLC_SET_MONITOR", 108},
- {"WLC_GET_GMODE", 109},
- {"WLC_SET_GMODE", 110},
- {"WLC_GET_LEGACY_ERP", 111},
- {"WLC_SET_LEGACY_ERP", 112},
- {"WLC_GET_RX_ANT", 113},
- {"WLC_GET_CURR_RATESET", 114},
- {"WLC_GET_SCANSUPPRESS", 115},
- {"WLC_SET_SCANSUPPRESS", 116},
- {"WLC_GET_AP", 117},
- {"WLC_SET_AP", 118},
- {"WLC_GET_EAP_RESTRICT", 119},
- {"WLC_SET_EAP_RESTRICT", 120},
- {"WLC_SCB_AUTHORIZE", 121},
- {"WLC_SCB_DEAUTHORIZE", 122},
- {"WLC_GET_WDSLIST", 123},
- {"WLC_SET_WDSLIST", 124},
- {"WLC_GET_ATIM", 125},
- {"WLC_SET_ATIM", 126},
- {"WLC_GET_RSSI", 127},
- {"WLC_GET_PHYANTDIV", 128},
- {"WLC_SET_PHYANTDIV", 129},
- {"WLC_AP_RX_ONLY", 130},
- {"WLC_GET_TX_PATH_PWR", 131},
- {"WLC_SET_TX_PATH_PWR", 132},
- {"WLC_GET_WSEC", 133},
- {"WLC_SET_WSEC", 134},
- {"WLC_GET_PHY_NOISE", 135},
- {"WLC_GET_BSS_INFO", 136},
- {"WLC_GET_PKTCNTS", 137},
- {"WLC_GET_LAZYWDS", 138},
- {"WLC_SET_LAZYWDS", 139},
- {"WLC_GET_BANDLIST", 140},
- {"WLC_GET_BAND", 141},
- {"WLC_SET_BAND", 142},
- {"WLC_SCB_DEAUTHENTICATE", 143},
- {"WLC_GET_SHORTSLOT", 144},
- {"WLC_GET_SHORTSLOT_OVERRIDE", 145},
- {"WLC_SET_SHORTSLOT_OVERRIDE", 146},
- {"WLC_GET_SHORTSLOT_RESTRICT", 147},
- {"WLC_SET_SHORTSLOT_RESTRICT", 148},
- {"WLC_GET_GMODE_PROTECTION", 149},
- {"WLC_GET_GMODE_PROTECTION_OVERRIDE", 150},
- {"WLC_SET_GMODE_PROTECTION_OVERRIDE", 151},
- {"WLC_UPGRADE", 152},
- {"WLC_GET_IGNORE_BCNS", 155},
- {"WLC_SET_IGNORE_BCNS", 156},
- {"WLC_GET_SCB_TIMEOUT", 157},
- {"WLC_SET_SCB_TIMEOUT", 158},
- {"WLC_GET_ASSOCLIST", 159},
- {"WLC_GET_CLK", 160},
- {"WLC_SET_CLK", 161},
- {"WLC_GET_UP", 162},
- {"WLC_OUT", 163},
- {"WLC_GET_WPA_AUTH", 164},
- {"WLC_SET_WPA_AUTH", 165},
- {"WLC_GET_UCFLAGS", 166},
- {"WLC_SET_UCFLAGS", 167},
- {"WLC_GET_PWRIDX", 168},
- {"WLC_SET_PWRIDX", 169},
- {"WLC_GET_TSSI", 170},
- {"WLC_GET_SUP_RATESET_OVERRIDE", 171},
- {"WLC_SET_SUP_RATESET_OVERRIDE", 172},
- {"WLC_GET_PROTECTION_CONTROL", 178},
- {"WLC_SET_PROTECTION_CONTROL", 179},
- {"WLC_GET_PHYLIST", 180},
- {"WLC_ENCRYPT_STRENGTH", 181},
- {"WLC_DECRYPT_STATUS", 182},
- {"WLC_GET_KEY_SEQ", 183},
- {"WLC_GET_SCAN_CHANNEL_TIME", 184},
- {"WLC_SET_SCAN_CHANNEL_TIME", 185},
- {"WLC_GET_SCAN_UNASSOC_TIME", 186},
- {"WLC_SET_SCAN_UNASSOC_TIME", 187},
- {"WLC_GET_SCAN_HOME_TIME", 188},
- {"WLC_SET_SCAN_HOME_TIME", 189},
- {"WLC_GET_SCAN_NPROBES", 190},
- {"WLC_SET_SCAN_NPROBES", 191},
- {"WLC_GET_PRB_RESP_TIMEOUT", 192},
- {"WLC_SET_PRB_RESP_TIMEOUT", 193},
- {"WLC_GET_ATTEN", 194},
- {"WLC_SET_ATTEN", 195},
- {"WLC_GET_SHMEM", 196},
- {"WLC_SET_SHMEM", 197},
- {"WLC_SET_WSEC_TEST", 200},
- {"WLC_SCB_DEAUTHENTICATE_FOR_REASON", 201},
- {"WLC_TKIP_COUNTERMEASURES", 202},
- {"WLC_GET_PIOMODE", 203},
- {"WLC_SET_PIOMODE", 204},
- {"WLC_SET_ASSOC_PREFER", 205},
- {"WLC_GET_ASSOC_PREFER", 206},
- {"WLC_SET_ROAM_PREFER", 207},
- {"WLC_GET_ROAM_PREFER", 208},
- {"WLC_SET_LED", 209},
- {"WLC_GET_LED", 210},
- {"WLC_GET_INTERFERENCE_MODE", 211},
- {"WLC_SET_INTERFERENCE_MODE", 212},
- {"WLC_GET_CHANNEL_QA", 213},
- {"WLC_START_CHANNEL_QA", 214},
- {"WLC_GET_CHANNEL_SEL", 215},
- {"WLC_START_CHANNEL_SEL", 216},
- {"WLC_GET_VALID_CHANNELS", 217},
- {"WLC_GET_FAKEFRAG", 218},
- {"WLC_SET_FAKEFRAG", 219},
- {"WLC_GET_PWROUT_PERCENTAGE", 220},
- {"WLC_SET_PWROUT_PERCENTAGE", 221},
- {"WLC_SET_BAD_FRAME_PREEMPT", 222},
- {"WLC_GET_BAD_FRAME_PREEMPT", 223},
- {"WLC_SET_LEAP_LIST", 224},
- {"WLC_GET_LEAP_LIST", 225},
- {"WLC_GET_CWMIN", 226},
- {"WLC_SET_CWMIN", 227},
- {"WLC_GET_CWMAX", 228},
- {"WLC_SET_CWMAX", 229},
- {"WLC_GET_WET", 230},
- {"WLC_SET_WET", 231},
- {"WLC_GET_PUB", 232},
- {"WLC_GET_KEY_PRIMARY", 235},
- {"WLC_SET_KEY_PRIMARY", 236},
- {"WLC_GET_ACI_ARGS", 238},
- {"WLC_SET_ACI_ARGS", 239},
- {"WLC_UNSET_CALLBACK", 240},
- {"WLC_SET_CALLBACK", 241},
- {"WLC_GET_RADAR", 242},
- {"WLC_SET_RADAR", 243},
- {"WLC_SET_SPECT_MANAGMENT", 244},
- {"WLC_GET_SPECT_MANAGMENT", 245},
- {"WLC_WDS_GET_REMOTE_HWADDR", 246},
- {"WLC_WDS_GET_WPA_SUP", 247},
- {"WLC_SET_CS_SCAN_TIMER", 248},
- {"WLC_GET_CS_SCAN_TIMER", 249},
- {"WLC_MEASURE_REQUEST", 250},
- {"WLC_INIT", 251},
- {"WLC_SEND_QUIET", 252},
- {"WLC_KEEPALIVE", 253},
- {"WLC_SEND_PWR_CONSTRAINT", 254},
- {"WLC_UPGRADE_STATUS", 255},
- {"WLC_CURRENT_PWR", 256},
- {"WLC_GET_SCAN_PASSIVE_TIME", 257},
- {"WLC_SET_SCAN_PASSIVE_TIME", 258},
- {"WLC_LEGACY_LINK_BEHAVIOR", 259},
- {"WLC_GET_CHANNELS_IN_COUNTRY", 260},
- {"WLC_GET_COUNTRY_LIST", 261},
- {"WLC_GET_VAR", 262},
- {"WLC_SET_VAR", 263},
- {"WLC_NVRAM_GET", 264},
- {"WLC_NVRAM_SET", 265},
- {"WLC_NVRAM_DUMP", 266},
- {"WLC_REBOOT", 267},
- {"WLC_SET_WSEC_PMK", 268},
- {"WLC_GET_AUTH_MODE", 269},
- {"WLC_SET_AUTH_MODE", 270},
- {"WLC_GET_WAKEENTRY", 271},
- {"WLC_SET_WAKEENTRY", 272},
- {"WLC_NDCONFIG_ITEM", 273},
- {"WLC_NVOTPW", 274},
- {"WLC_OTPW", 275},
- {"WLC_IOV_BLOCK_GET", 276},
- {"WLC_IOV_MODULES_GET", 277},
- {"WLC_SOFT_RESET", 278},
- {"WLC_GET_ALLOW_MODE", 279},
- {"WLC_SET_ALLOW_MODE", 280},
- {"WLC_GET_DESIRED_BSSID", 281},
- {"WLC_SET_DESIRED_BSSID", 282},
- {"WLC_DISASSOC_MYAP", 283},
- {"WLC_GET_NBANDS", 284},
- {"WLC_GET_BANDSTATES", 285},
- {"WLC_GET_WLC_BSS_INFO", 286},
- {"WLC_GET_ASSOC_INFO", 287},
- {"WLC_GET_OID_PHY", 288},
- {"WLC_SET_OID_PHY", 289},
- {"WLC_SET_ASSOC_TIME", 290},
- {"WLC_GET_DESIRED_SSID", 291},
- {"WLC_GET_CHANSPEC", 292},
- {"WLC_GET_ASSOC_STATE", 293},
- {"WLC_SET_PHY_STATE", 294},
- {"WLC_GET_SCAN_PENDING", 295},
- {"WLC_GET_SCANREQ_PENDING", 296},
- {"WLC_GET_PREV_ROAM_REASON", 297},
- {"WLC_SET_PREV_ROAM_REASON", 298},
- {"WLC_GET_BANDSTATES_PI", 299},
- {"WLC_GET_PHY_STATE", 300},
- {"WLC_GET_BSS_WPA_RSN", 301},
- {"WLC_GET_BSS_WPA2_RSN", 302},
- {"WLC_GET_BSS_BCN_TS", 303},
- {"WLC_GET_INT_DISASSOC", 304},
- {"WLC_SET_NUM_PEERS", 305},
- {"WLC_GET_NUM_BSS", 306},
- {"WLC_LAST", 307},
- };
-
- while (i < sizeof(wlcnv)/sizeof(wlcnv[0])) {
- if (wlcnv[i].v == cmd) {
- n = wlcnv[i].n;
- break;
- }
- ++i;
- }
-#endif /* DHD_DEBUG */
- return n;
-}
-
-static int dev_wlc_ioctl( struct net_device *dev,
- int cmd,
- void *arg,
- int len
-)
-{
- struct ifreq ifr;
- wl_ioctl_t ioc;
- mm_segment_t fs;
- int ret = -EINVAL;
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return ret;
- }
-
- WL_INFORM(("\n%s, PID:%x: send Local IOCTL -> dhd: cmd:%s(%d), buf:%p, len:%d ,\n",
- __FUNCTION__, current->pid, cmd2nam(cmd), cmd, arg, len));
-
- if (g_onoff == G_WLAN_SET_ON)
- {
- memset(&ioc, 0, sizeof(ioc));
- ioc.cmd = cmd;
- ioc.buf = arg;
- ioc.len = len;
-
- strcpy(ifr.ifr_name, dev->name);
- ifr.ifr_data = (caddr_t) &ioc;
-
-
- ret = dev_open(dev);
- if (ret) {
- WL_ERROR(("%s: Error dev_open: %d\n", __func__, ret));
- return ret;
- }
-
- fs = get_fs();
- set_fs(get_ds());
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- //printk("Calling dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE)\n");
- ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#else
- ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif
- set_fs(fs);
- }
- else {
- WL_TRACE(("%s: call after driver stop : ignored\n", __FUNCTION__));
- }
- return ret;
-}
-
-static int
-dev_wlc_intvar_get_reg(
- struct net_device *dev,
- char *name,
- uint reg,
- int *retval)
-{
- union {
- char buf[WLC_IOCTL_SMLEN];
- int val;
- } var;
- int error;
-
- uint len;
- len = bcm_mkiovar(name, (char *)(®), sizeof(reg), (char *)(&var), sizeof(var.buf));
- ASSERT(len);
- error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
-
- *retval = dtoh32(var.val);
- return (error);
-}
-
-
-static int
-dev_wlc_intvar_set_reg(
- struct net_device *dev,
- char *name,
- char *addr,
- char * val)
-{
- char reg_addr[8];
-
- memset(reg_addr, 0, sizeof(reg_addr));
- memcpy((char *)®_addr[0], (char *)addr, 4);
- memcpy((char *)®_addr[4], (char *)val, 4);
-
- return (dev_wlc_bufvar_set(dev, name, (char *)®_addr[0], sizeof(reg_addr)));
-}
-
-
-
-
-static int
-dev_wlc_intvar_set(
- struct net_device *dev,
- char *name,
- int val)
-{
- char buf[WLC_IOCTL_SMLEN];
- uint len;
-
- val = htod32(val);
- len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
- ASSERT(len);
-
- return (dev_wlc_ioctl(dev, WLC_SET_VAR, buf, len));
-}
-
-#if defined(WL_IW_USE_ISCAN)
-static int
-dev_iw_iovar_setbuf(
- struct net_device *dev,
- char *iovar,
- void *param,
- int paramlen,
- void *bufptr,
- int buflen)
-{
- int iolen;
-
- iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
- ASSERT(iolen);
-
- if (iolen == 0)
- return 0;
-
- return (dev_wlc_ioctl(dev, WLC_SET_VAR, bufptr, iolen));
-}
-
-static int
-dev_iw_iovar_getbuf(
- struct net_device *dev,
- char *iovar,
- void *param,
- int paramlen,
- void *bufptr,
- int buflen)
-{
- int iolen;
-
- iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
- ASSERT(iolen);
-
- return (dev_wlc_ioctl(dev, WLC_GET_VAR, bufptr, buflen));
-}
-#endif
-
-
-#if WIRELESS_EXT > 17
-static int
-dev_wlc_bufvar_set(
- struct net_device *dev,
- char *name,
- char *buf, int len)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
- static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif
- uint buflen;
-
- buflen = bcm_mkiovar(name, buf, len, ioctlbuf, sizeof(ioctlbuf));
- ASSERT(buflen);
-
- return (dev_wlc_ioctl(dev, WLC_SET_VAR, ioctlbuf, buflen));
-}
-#endif
-
-
-static int
-dev_wlc_bufvar_get(
- struct net_device *dev,
- char *name,
- char *buf, int buflen)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
- static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif
- int error;
- uint len;
-
- len = bcm_mkiovar(name, NULL, 0, ioctlbuf, sizeof(ioctlbuf));
- ASSERT(len);
- error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf, MAX_WLIW_IOCTL_LEN);
- if (!error)
- bcopy(ioctlbuf, buf, buflen);
-
- return (error);
-}
-
-
-
-static int
-dev_wlc_intvar_get(
- struct net_device *dev,
- char *name,
- int *retval)
-{
- union {
- char buf[WLC_IOCTL_SMLEN];
- int val;
- } var;
- int error;
-
- uint len;
- uint data_null;
-
- len = bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf));
- ASSERT(len);
- error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
-
- *retval = dtoh32(var.val);
-
- return (error);
-}
-
-
-#if WIRELESS_EXT > 12
-static int
-wl_iw_set_active_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int as = 0;
- int error = 0;
- char *p = extra;
-
-#if defined(WL_IW_USE_ISCAN)
- if (g_iscan->iscan_state == ISCAN_STATE_IDLE)
-#endif
- error = dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
-#if defined(WL_IW_USE_ISCAN)
- else
- g_iscan->scan_flag = as;
-#endif
- p += snprintf(p, MAX_WX_STRING, "OK");
-
- wrqu->data.length = p - extra + 1;
- return error;
-}
-
-static int
-wl_iw_set_passive_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int ps = 1;
- int error = 0;
- char *p = extra;
-
-#if defined(WL_IW_USE_ISCAN)
- if (g_iscan->iscan_state == ISCAN_STATE_IDLE) {
-#endif
-
-
- if (g_scan_specified_ssid == 0) {
- error = dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &ps, sizeof(ps));
- }
-#if defined(WL_IW_USE_ISCAN)
- }
- else
- g_iscan->scan_flag = ps;
-#endif
-
- p += snprintf(p, MAX_WX_STRING, "OK");
-
- wrqu->data.length = p - extra + 1;
- return error;
-}
-
-static int
-wl_iw_get_macaddr(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error;
- char buf[128];
- struct ether_addr *id;
- char *p = extra;
-
-
- strcpy(buf, "cur_etheraddr");
- error = dev_wlc_ioctl(dev, WLC_GET_VAR, buf, sizeof(buf));
- id = (struct ether_addr *) buf;
- p += snprintf(p, MAX_WX_STRING, "Macaddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
- id->octet[0], id->octet[1], id->octet[2],
- id->octet[3], id->octet[4], id->octet[5]);
- wrqu->data.length = p - extra + 1;
-
- return error;
-}
-
-
-
-static int
-wl_iw_set_country(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- char country_code[WLC_CNTRY_BUF_SZ];
- int error = 0;
- char *p = extra;
- int country_offset;
- int country_code_size;
-
- memset(country_code, 0, sizeof(country_code));
-
-
- country_offset = strcspn(extra, " ");
- country_code_size = strlen(extra) - country_offset;
-
-
- if (country_offset != 0) {
- strncpy(country_code, extra + country_offset +1,
- MIN(country_code_size, sizeof(country_code)));
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
- &country_code, sizeof(country_code))) >= 0) {
- p += snprintf(p, MAX_WX_STRING, "OK");
- WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
- goto exit;
- }
- }
-
- WL_ERROR(("%s: set country %s failed code %d\n", __FUNCTION__, country_code, error));
- p += snprintf(p, MAX_WX_STRING, "FAIL");
-
-exit:
- wrqu->data.length = p - extra + 1;
- return error;
-}
-
-#ifdef CUSTOMER_HW2
-static int
-wl_iw_set_power_mode(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error = 0;
- char *p = extra;
- static int pm = PM_FAST;
- int pm_local = PM_OFF;
- char powermode_val = 0;
-
- strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
-
- if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
-
- WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
-
- dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm));
- dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
- }
- else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
-
- WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-
- dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
- }
- else {
- WL_ERROR(("Unkwown yet power setting, ignored\n"));
- }
-
- p += snprintf(p, MAX_WX_STRING, "OK");
-
- wrqu->data.length = p - extra + 1;
-
- return error;
-}
-#endif
-static int
-wl_iw_set_btcoex_dhcp(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error = 0;
- char *p = extra;
-#ifndef CUSTOMER_HW2
- static int pm = PM_FAST;
- int pm_local = PM_OFF;
-#endif
- char powermode_val = 0;
- char buf_reg66va_dhcp_on[8] = { 66, 00, 00, 00, 0x10, 0x27, 0x00, 0x00 };
- char buf_reg41va_dhcp_on[8] = { 41, 00, 00, 00, 0x33, 0x00, 0x00, 0x00 };
- char buf_reg68va_dhcp_on[8] = { 68, 00, 00, 00, 0x90, 0x01, 0x00, 0x00 };
-
- uint32 regaddr;
- static uint32 saved_reg66;
- static uint32 saved_reg41;
- static uint32 saved_reg68;
- static bool saved_status = FALSE;
-
- char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-#ifndef CUSTOMER_HW2
- uint32 temp1, temp2;
-#endif
-
-
-#ifdef CUSTOMER_HW2
- strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") +1, 1);
-#else
- strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
-#endif
-
- if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
-
- WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
-
-
- if ((saved_status == FALSE) &&
-#ifndef CUSTOMER_HW2
- (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
-#endif
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 66, &saved_reg66)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 41, &saved_reg41)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 68, &saved_reg68))) {
- saved_status = TRUE;
- WL_TRACE(("Saved 0x%x 0x%x 0x%x\n", \
- saved_reg66, saved_reg41, saved_reg68));
-
-
-#ifndef CUSTOMER_HW2
- dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
-#endif
-
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg66va_dhcp_on[0], \
- sizeof(buf_reg66va_dhcp_on));
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg41va_dhcp_on[0], \
- sizeof(buf_reg41va_dhcp_on));
-
- dev_wlc_bufvar_set(dev, "btc_params", \
- (char *)&buf_reg68va_dhcp_on[0], \
- sizeof(buf_reg68va_dhcp_on));
-
-#ifndef CUSTOMER_HW2
- if ((!dev_wlc_intvar_get_reg(dev, "btc_params", 12, &temp1)) &&
- (!dev_wlc_intvar_get_reg(dev, "btc_params", 13, &temp2)))
- {
- if ((temp1 != 0) && (temp2 != 0)) {
-#endif
- g_bt->bt_state = BT_DHCP_START;
- g_bt->timer_on = 1;
- mod_timer(&g_bt->timer, g_bt->timer.expires);
- WL_TRACE(("%s enable BT DHCP Timer\n", \
- __FUNCTION__));
-#ifndef CUSTOMER_HW2
- }
- }
-#endif
- }
- else if (saved_status == TRUE) {
- WL_ERROR(("%s was called w/o DHCP OFF. Continue\n", __FUNCTION__));
- }
- }
-#ifdef CUSTOMER_HW2
- else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
-#else
- else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
-#endif
-
- WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-
-#ifndef CUSTOMER_HW2
- dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
-#endif
-
-
- WL_TRACE(("%s disable BT DHCP Timer\n", __FUNCTION__));
- if (g_bt->timer_on) {
- g_bt->timer_on = 0;
- del_timer_sync(&g_bt->timer);
- }
-
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
- (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
-
-
- if (saved_status) {
- regaddr = 66;
- dev_wlc_intvar_set_reg(dev, "btc_params", \
- (char *)®addr, (char *)&saved_reg66);
- regaddr = 41;
- dev_wlc_intvar_set_reg(dev, "btc_params", \
- (char *)®addr, (char *)&saved_reg41);
- regaddr = 68;
- dev_wlc_intvar_set_reg(dev, "btc_params", \
- (char *)®addr, (char *)&saved_reg68);
- }
- saved_status = FALSE;
-
- }
- else {
- WL_ERROR(("Unkwown yet power setting, ignored\n"));
- }
-
- p += snprintf(p, MAX_WX_STRING, "OK");
-
- wrqu->data.length = p - extra + 1;
-
- return error;
-}
-
-int
-wl_format_ssid(char* ssid_buf, uint8* ssid, int ssid_len)
-{
- int i, c;
- char *p = ssid_buf;
-
- if (ssid_len > 32) ssid_len = 32;
-
- for (i = 0; i < ssid_len; i++) {
- c = (int)ssid[i];
- if (c == '\\') {
- *p++ = '\\';
- *p++ = '\\';
- } else if (isprint((uchar)c)) {
- *p++ = (char)c;
- } else {
- p += sprintf(p, "\\x%02X", c);
- }
- }
- *p = '\0';
-
- return p - ssid_buf;
-}
-
-static int
-wl_iw_get_link_speed(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error = 0;
- char *p = extra;
- static int link_speed;
-
-
- if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_RATE, &link_speed, sizeof(link_speed));
- link_speed *= 500000;
- }
-
- p += snprintf(p, MAX_WX_STRING, "LinkSpeed %d", link_speed/1000000);
-
- wrqu->data.length = p - extra + 1;
-
- return error;
-}
-
-
-static int
-wl_iw_get_band(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error = -1;
- char *p = extra;
- static int band;
-
- if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
-
- p += snprintf(p, MAX_WX_STRING, "Band %d", band);
-
- wrqu->data.length = p - extra + 1;
- }
- return error;
-}
-
-
-static int
-wl_iw_set_band(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error = -1;
- char *p = extra;
- char band;
-
- if (g_onoff == G_WLAN_SET_ON) {
-
- band = *(extra + strlen(BAND_SET_CMD) + 1) - '0';
-
- if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
- &band, sizeof(band))) >= 0) {
- p += snprintf(p, MAX_WX_STRING, "OK");
- WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
- goto exit;
- }
- else WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
- band, error));
- }
- else WL_ERROR(("%s Incorrect band setting, ignored\n", __FUNCTION__));
- }
-
- p += snprintf(p, MAX_WX_STRING, "FAIL");
-
-exit:
- wrqu->data.length = p - extra + 1;
- return error;
-}
-
-
-static int
-wl_iw_get_rssi(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- static int rssi = 0;
- static wlc_ssid_t ssid = {0};
- int error = 0;
- char *p = extra;
- static char ssidbuf[SSID_FMT_BUF_LEN];
- scb_val_t scb_val;
-
- bzero(&scb_val, sizeof(scb_val_t));
-
- if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
- rssi = dtoh32(scb_val.val);
-
- error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
-
- ssid.SSID_len = dtoh32(ssid.SSID_len);
- }
-
- wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
- p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
- wrqu->data.length = p - extra + 1;
-
- return error;
-}
-
-int
-wl_iw_send_priv_event(
- struct net_device *dev,
- char *flag
-)
-{
- union iwreq_data wrqu;
- char extra[IW_CUSTOM_MAX + 1];
- int cmd;
-
- cmd = IWEVCUSTOM;
- memset(&wrqu, 0, sizeof(wrqu));
- if (strlen(flag) > sizeof(extra))
- return -1;
-
- strcpy(extra, flag);
- wrqu.data.length = strlen(extra);
- wireless_send_event(dev, cmd, &wrqu, extra);
- WL_TRACE(("Send IWEVCUSTOM Event as %s\n", extra));
-
- return 0;
-}
-
-
-int
-wl_control_wl_start(struct net_device *dev)
-{
- int ret = 0;
- wl_iw_t *iw;
-
- WL_TRACE(("Enter %s \n", __FUNCTION__));
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return -1;
- }
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK(iw->pub);
-
- if (g_onoff == G_WLAN_SET_OFF) {
- dhd_customer_gpio_wlan_ctrl(WLAN_RESET_ON);
-
-#if defined(BCMLXSDMMC)
- sdioh_start(NULL, 0);
-#endif
-
- dhd_dev_reset(dev, 0);
-
-#if defined(BCMLXSDMMC)
- sdioh_start(NULL, 1);
-#endif
-
- dhd_dev_init_ioctl(dev);
-
- g_onoff = G_WLAN_SET_ON;
- }
- WL_TRACE(("Exited %s \n", __FUNCTION__));
-
- MUTEX_UNLOCK(iw->pub);
- return ret;
-}
-static int
-wl_iw_control_wl_off(
- struct net_device *dev,
- struct iw_request_info *info
-)
-{
- int ret = 0;
- wl_iw_t *iw;
-
- WL_TRACE(("Enter %s\n", __FUNCTION__));
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return -1;
- }
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK(iw->pub);
-
-#ifdef SOFTAP
- ap_cfg_running = FALSE;
-#endif
-
- if (g_onoff == G_WLAN_SET_ON) {
- g_onoff = G_WLAN_SET_OFF;
-
-#if defined(WL_IW_USE_ISCAN)
- g_iscan->iscan_state = ISCAN_STATE_IDLE;
-#endif
-
- dhd_dev_reset(dev, 1);
-
-#if defined(WL_IW_USE_ISCAN)
-#if !defined(CSCAN)
-
- wl_iw_free_ss_cache();
- wl_iw_run_ss_cache_timer(0);
-
- g_ss_cache_ctrl.m_link_down = 1;
-#endif
- memset(g_scan, 0, G_SCAN_RESULTS);
- g_scan_specified_ssid = 0;
-
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
-#endif
-
-#if defined(BCMLXSDMMC)
- sdioh_stop(NULL);
-#endif
-
- dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
-
- wl_iw_send_priv_event(dev, "STOP");
-
- }
-
- MUTEX_UNLOCK(iw->pub);
-
- WL_TRACE(("Exited %s\n", __FUNCTION__));
-
- return ret;
-}
-
-static int
-wl_iw_control_wl_on(
- struct net_device *dev,
- struct iw_request_info *info
-)
-{
- int ret = 0;
-
- WL_TRACE(("Enter %s \n", __FUNCTION__));
-
- ret = wl_control_wl_start(dev);
-
- wl_iw_send_priv_event(dev, "START");
-
-#if !defined(CSCAN)
-#ifdef SOFTAP
- if (!ap_fw_loaded) {
- wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
- }
-#else
- wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
-#endif
-#endif
-
- WL_TRACE(("Exited %s \n", __FUNCTION__));
-
- return ret;
-}
-
-#ifdef SOFTAP
-static struct ap_profile my_ap;
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap);
-static int get_assoc_sta_list(struct net_device *dev, char *buf, int len);
-static int set_ap_mac_list(struct net_device *dev, char *buf);
-#endif /* SOFTAP */
-
-int hex2num(char c)
-{
- if (c >= '0' && c <= '9')
- return c - '0';
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- return -1;
-}
-
-int hex2byte(const char *hex)
-{
- int a, b;
- a = hex2num(*hex++);
- if (a < 0)
- return -1;
- b = hex2num(*hex++);
- if (b < 0)
- return -1;
- return (a << 4) | b;
-}
-
-
-
-int hstr_2_buf(const char *txt, u8 *buf, int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- int a, b;
-
- a = hex2num(*txt++);
- if (a < 0)
- return -1;
- b = hex2num(*txt++);
- if (b < 0)
- return -1;
- *buf++ = (a << 4) | b;
- }
-
- return 0;
-}
-
-
-
-#if defined(SOFTAP) || defined(CSCAN)
-
-/* parameter type */
-#define PTYPE_STRING 0
-#define PTYPE_INTDEC 1
-#define PTYPE_INTHEX 2
-#define PTYPE_STR_HEX 3
-
-int get_parmeter_from_string(
- char **str_ptr, const char *token,
- int param_type, void *dst, int param_max_len)
-{
- char int_str[7] = "0";
- int parm_str_len;
- char *param_str_begin;
- char *param_str_end;
- char *orig_str = *str_ptr;
-
- if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
-
- strsep(str_ptr, "=,");
- param_str_begin = *str_ptr;
- strsep(str_ptr, "=,");
-
- if (*str_ptr == NULL) {
-
- parm_str_len = strlen(param_str_begin);
- } else {
- param_str_end = *str_ptr-1;
- parm_str_len = param_str_end - param_str_begin;
- }
-
- WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
-
- if (parm_str_len > param_max_len) {
- WL_ERROR((" WARNING: extracted param len:%d is > MAX:%d\n",
- parm_str_len, param_max_len));
-
- parm_str_len = param_max_len;
- }
-
- switch (param_type) {
-
- case PTYPE_INTDEC: {
-
- int *pdst_int = dst;
- char *eptr;
- if (parm_str_len > sizeof(int_str))
- parm_str_len = sizeof(int_str);
-
- memcpy(int_str, param_str_begin, parm_str_len);
-
- *pdst_int = simple_strtoul(int_str, &eptr, 10);
-
- WL_TRACE((" written as integer:%d\n", *pdst_int));
- }
- break;
- case PTYPE_STR_HEX: {
- u8 *buf = dst;
-
- param_max_len = param_max_len >> 1;
- hstr_2_buf(param_str_begin, buf, param_max_len);
- print_buf(buf, param_max_len, 0);
- }
- break;
- default:
-
- memcpy(dst, param_str_begin, parm_str_len);
- *((char *)dst + parm_str_len) = 0;
- WL_ERROR((" written as a string:%s\n", (char *)dst));
- break;
-
- }
-
- return 0;
- } else {
- WL_ERROR(("\n %s: ERROR: can't find token:%s in str:%s \n",
- __FUNCTION__, token, orig_str));
-
- return -1;
- }
-}
-
-#endif
-
-
-#ifdef SOFTAP
-int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
-{
- char *str_ptr = param_str;
- char sub_cmd[16];
- int ret = 0;
-
- memset(sub_cmd, 0, sizeof(sub_cmd));
- memset(ap_cfg, 0, sizeof(struct ap_profile));
-
-
- if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=",
- PTYPE_STRING, sub_cmd, SSID_LEN) != 0) {
- return -1;
- }
- if (strncmp(sub_cmd, "AP_CFG", 6)) {
- WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
- return -1;
- }
-
-
-
- ret = get_parmeter_from_string(&str_ptr, "SSID=", PTYPE_STRING, ap_cfg->ssid, SSID_LEN);
-
- ret |= get_parmeter_from_string(&str_ptr, "SEC=", PTYPE_STRING, ap_cfg->sec, SEC_LEN);
-
- ret |= get_parmeter_from_string(&str_ptr, "KEY=", PTYPE_STRING, ap_cfg->key, KEY_LEN);
-
- ret |= get_parmeter_from_string(&str_ptr, "CHANNEL=", PTYPE_INTDEC, &ap_cfg->channel, 5);
-
- ret |= get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
-
- ret |= get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC, &ap_cfg->max_scb, 5);
-
- return ret;
-}
-#endif
-
-
-
-#ifdef SOFTAP
-static int iwpriv_set_ap_config(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
-{
- int res = 0;
- char *extra = NULL;
- struct ap_profile *ap_cfg = &my_ap;
-
- WL_TRACE(("> Got IWPRIV SET_AP IOCTL: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
- info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length));
-
-
- if (wrqu->data.length != 0) {
-
- char *str_ptr;
-
- if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
- return -ENOMEM;
-
- if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
- kfree(extra);
- return -EFAULT;
- }
-
- extra[wrqu->data.length] = 0;
- WL_SOFTAP((" Got str param in iw_point:\n %s\n", extra));
-
- memset(ap_cfg, 0, sizeof(struct ap_profile));
-
-
-
- str_ptr = extra;
-
- if ((res = init_ap_profile_from_string(extra, ap_cfg)) < 0) {
- WL_ERROR(("%s failed to parse %d\n", __FUNCTION__, res));
- kfree(extra);
- return -1;
- }
-
- } else {
-
- WL_ERROR(("IWPRIV argument len = 0 \n"));
- return -1;
- }
-
- if ((res = set_ap_cfg(dev, ap_cfg)) < 0)
- WL_ERROR(("%s failed to set_ap_cfg %d\n", __FUNCTION__, res));
-
- kfree(extra);
-
- return res;
-}
-#endif
-
-
-
-#ifdef SOFTAP
-static int iwpriv_get_assoc_list(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *p_iwrq,
- char *extra)
-{
- int i, ret = 0;
- char mac_buf[256];
- struct maclist *sta_maclist = (struct maclist *)mac_buf;
-
- char mac_lst[256];
- char *p_mac_str;
-
- WL_TRACE(("\n %s: IWPRIV IOCTL: cmd:%hx, flags:%hx, extra:%p, iwp.len:%d, \
- iwp.len:%p, iwp.flags:%x \n", __FUNCTION__, info->cmd, info->flags, \
- extra, p_iwrq->data.length, p_iwrq->data.pointer, p_iwrq->data.flags));
-
- WL_SOFTAP(("extra:%s\n", extra));
- print_buf((u8 *)p_iwrq, 16, 0);
-
- memset(sta_maclist, 0, sizeof(mac_buf));
-
- sta_maclist->count = 8;
-
- WL_TRACE((" net device:%s, buf_sz:%d\n", dev->name, sizeof(mac_buf)));
- get_assoc_sta_list(dev, mac_buf, 256);
- WL_TRACE((" got %d stations\n", sta_maclist->count));
-
-
- memset(mac_lst, 0, sizeof(mac_lst));
- p_mac_str = mac_lst;
-
- for (i = 0; i < 8; i++) {
- struct ether_addr * id = &sta_maclist->ea[i];
-
- WL_SOFTAP(("dhd_drv>> sta_mac[%d] :", i));
- print_buf((unsigned char *)&sta_maclist->ea[i], 6, 0);
-
-
- p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
- "Mac[%d]=%02X:%02X:%02X:%02X:%02X:%02X\n", i,
- id->octet[0], id->octet[1], id->octet[2],
- id->octet[3], id->octet[4], id->octet[5]);
-
- }
-
- p_iwrq->data.length = strlen(mac_lst);
-
- WL_TRACE(("u.pointer:%p\n", p_iwrq->data.pointer));
- WL_TRACE(("resulting str:\n%s \n len:%d\n\n", mac_lst, p_iwrq->data.length));
-
- if (p_iwrq->data.length) {
- if (copy_to_user(p_iwrq->data.pointer, mac_lst, p_iwrq->data.length)) {
- WL_ERROR(("%s: Can't copy to user\n", __FUNCTION__));
- return -EFAULT;
- }
- }
-
- WL_ERROR(("Exited %s \n", __FUNCTION__));
- return ret;
-}
-#endif
-
-
-#ifdef SOFTAP
-static int iwpriv_set_mac_filters(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
-{
-
- int i, ret = -1;
- char * extra = NULL;
- u8 macfilt[8][6];
- int mac_cnt = 0;
- char sub_cmd[16];
-
- WL_TRACE((">>> Got IWPRIV SET_MAC_FILTER IOCTL: info->cmd:%x, \
- info->flags:%x, u.data:%p, u.len:%d\n",
- info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length));
-
- if (wrqu->data.length != 0) {
-
- char *str_ptr;
-
- if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
- return -ENOMEM;
-
- if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
- kfree(extra);
- return -EFAULT;
- }
-
- extra[wrqu->data.length] = 0;
- WL_SOFTAP((" Got parameter string in iw_point:\n %s \n", extra));
-
- memset(macfilt, 0, sizeof(macfilt));
- memset(sub_cmd, 0, sizeof(sub_cmd));
-
-
- str_ptr = extra;
-
-
- if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=", PTYPE_STRING, sub_cmd, 15) != 0) {
- goto exit_proc;
- }
-
-#define MAC_FILT_MAX 8
-
- if (strncmp(sub_cmd, "MAC_FLT_W", strlen("MAC_FLT_W"))) {
- WL_ERROR(("ERROR: sub_cmd:%s != 'MAC_FLT_W'!\n", sub_cmd));
- goto exit_proc;
- }
-
- if (get_parmeter_from_string(&str_ptr, "MAC_CNT=",
- PTYPE_INTDEC, &mac_cnt, 4) != 0) {
- WL_ERROR(("ERROR: MAC_CNT param is missing \n"));
- goto exit_proc;
- }
-
- if (mac_cnt > MAC_FILT_MAX) {
- WL_ERROR(("ERROR: number of MAC filters > MAX\n"));
- goto exit_proc;
- }
-
- for (i=0; i< mac_cnt; i++)
- if (get_parmeter_from_string(&str_ptr, "MAC=",
- PTYPE_STR_HEX, macfilt[i], 12) != 0) {
- WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
- goto exit_proc;
- }
-
- for (i = 0; i < mac_cnt; i++) {
- WL_SOFTAP(("mac_filt[%d]:", i));
- print_buf(macfilt[i], 6, 0);
- }
-
-
- wrqu->data.pointer = NULL;
- wrqu->data.length = 0;
- ret = 0;
-
- } else {
-
- WL_ERROR(("IWPRIV argument len is 0\n"));
- return -1;
- }
-
- exit_proc:
- kfree(extra);
- return ret;
-}
-#endif
-
-#endif
-
-#if WIRELESS_EXT < 13
-struct iw_request_info
-{
- __u16 cmd;
- __u16 flags;
-};
-
-typedef int (*iw_handler)(struct net_device *dev,
- struct iw_request_info *info,
- void *wrqu,
- char *extra);
-#endif
-
-static int
-wl_iw_config_commit(
- struct net_device *dev,
- struct iw_request_info *info,
- void *zwrq,
- char *extra
-)
-{
- wlc_ssid_t ssid;
- int error;
- struct sockaddr bssid;
-
- WL_TRACE(("%s: SIOCSIWCOMMIT\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid))))
- return error;
-
- ssid.SSID_len = dtoh32(ssid.SSID_len);
-
- if (!ssid.SSID_len)
- return 0;
-
- bzero(&bssid, sizeof(struct sockaddr));
- if ((error = dev_wlc_ioctl(dev, WLC_REASSOC, &bssid, ETHER_ADDR_LEN))) {
- WL_ERROR(("%s: WLC_REASSOC to %s failed \n", __FUNCTION__, ssid.SSID));
- return error;
- }
-
- return 0;
-}
-
-static int
-wl_iw_get_name(
- struct net_device *dev,
- struct iw_request_info *info,
- char *cwrq,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCGIWNAME\n", dev->name));
-
- strcpy(cwrq, "IEEE 802.11-DS");
-
- return 0;
-}
-
-static int
-wl_iw_set_freq(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *fwrq,
- char *extra
-)
-{
- int error, chan;
- uint sf = 0;
-
- WL_TRACE(("%s %s: SIOCSIWFREQ : e=%d m=%d\n", __func__, dev->name, fwrq->e, fwrq->m));
-
-#if defined(SOFTAP)
- if (ap_cfg_running) {
- WL_TRACE(("%s:>> not executed, 'SOFT_AP is active' \n", __FUNCTION__));
- return 0;
- }
-#endif
-
-
- if (fwrq->e == 0 && fwrq->m < MAXCHANNEL)
- {
- chan = fwrq->m;
- }
- else
- {
- if (fwrq->e >= 6)
- {
- fwrq->e -= 6;
- while (fwrq->e--)
- fwrq->m *= 10;
- }
- else if (fwrq->e < 6)
- {
- while (fwrq->e++ < 6)
- fwrq->m /= 10;
- }
-
- if (fwrq->m > 4000 && fwrq->m < 5000)
- sf = WF_CHAN_FACTOR_4_G;
-
- chan = wf_mhz2channel(fwrq->m, sf);
- }
- chan = htod32(chan);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan))))
- return error;
-
-
- return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_freq(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *fwrq,
- char *extra
-)
-{
- channel_info_t ci;
- int error;
-
- WL_TRACE(("%s: SIOCGIWFREQ\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
- return error;
-
-
- fwrq->m = dtoh32(ci.hw_channel);
- fwrq->e = dtoh32(0);
- return 0;
-}
-
-static int
-wl_iw_set_mode(
- struct net_device *dev,
- struct iw_request_info *info,
- __u32 *uwrq,
- char *extra
-)
-{
- int infra = 0, ap = 0, error = 0;
-
- WL_TRACE(("%s: SIOCSIWMODE\n", dev->name));
-
- switch (*uwrq) {
- case IW_MODE_MASTER:
- infra = ap = 1;
- break;
- case IW_MODE_ADHOC:
- case IW_MODE_AUTO:
- break;
- case IW_MODE_INFRA:
- infra = 1;
- break;
- default:
- return -EINVAL;
- }
- infra = htod32(infra);
- ap = htod32(ap);
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra))) ||
- (error = dev_wlc_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap))))
- return error;
-
-
- return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_mode(
- struct net_device *dev,
- struct iw_request_info *info,
- __u32 *uwrq,
- char *extra
-)
-{
- int error, infra = 0, ap = 0;
-
- WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
- (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
- return error;
-
- infra = dtoh32(infra);
- ap = dtoh32(ap);
- *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
-
- return 0;
-}
-
-static int
-wl_iw_set_sens(
- struct net_device *dev,
- struct iw_request_info *info,
- __u32 *uwrq,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCSIWSENS\n", dev->name));
- return 0;
-}
-
-static int
-wl_iw_get_sens(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- static int rssi = 0;
- static wlc_ssid_t ssid = {0};
- int error = 0;
- static char ssidbuf[SSID_FMT_BUF_LEN];
- scb_val_t scb_val;
-
- WL_TRACE(("%s: SIOCGIWSENS\n", dev->name));
-
- bzero(&scb_val, sizeof(scb_val_t));
-
- if (g_onoff == G_WLAN_SET_ON) {
- error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
- if (error) {
- WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
- return error;
- }
- rssi = dtoh32(scb_val.val);
-
- error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
- if (!error) {
- ssid.SSID_len = dtoh32(ssid.SSID_len);
- wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
- }
- }
-
- wrqu->sens.value = -rssi;
-
- return error;
-}
-
-static int
-wl_iw_get_range(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- struct iw_range *range = (struct iw_range *) extra;
- wl_uint32_list_t *list;
- wl_rateset_t rateset;
- int8 *channels;
- int error, i, k;
- uint sf, ch;
-
- int phytype;
- int bw_cap = 0, sgi_tx = 0, nmode = 0;
- channel_info_t ci;
- uint8 nrate_list2copy = 0;
- uint16 nrate_list[4][8] = { {13, 26, 39, 52, 78, 104, 117, 130},
- {14, 29, 43, 58, 87, 116, 130, 144},
- {27, 54, 81, 108, 162, 216, 243, 270},
- {30, 60, 90, 120, 180, 240, 270, 300}};
-
- WL_TRACE(("%s: SIOCGIWRANGE\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- channels = kmalloc((MAXCHANNEL+1)*4, GFP_KERNEL);
- if (!channels) {
- WL_ERROR(("Could not alloc channels\n"));
- return -ENOMEM;
- }
- list = (wl_uint32_list_t *)channels;
-
- dwrq->length = sizeof(struct iw_range);
- memset(range, 0, sizeof(range));
-
-
- range->min_nwid = range->max_nwid = 0;
-
-
- list->count = htod32(MAXCHANNEL);
- if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, (MAXCHANNEL+1)*4))) {
- kfree(channels);
- return error;
- }
- for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
- range->freq[i].i = dtoh32(list->element[i]);
-
- ch = dtoh32(list->element[i]);
- if (ch <= CH_MAX_2G_CHANNEL)
- sf = WF_CHAN_FACTOR_2_4_G;
- else
- sf = WF_CHAN_FACTOR_5_G;
-
- range->freq[i].m = wf_channel2mhz(ch, sf);
- range->freq[i].e = 6;
- }
- range->num_frequency = range->num_channels = i;
-
-
- range->max_qual.qual = 5;
-
- range->max_qual.level = 0x100 - 200;
-
- range->max_qual.noise = 0x100 - 200;
-
- range->sensitivity = 65535;
-
-#if WIRELESS_EXT > 11
-
- range->avg_qual.qual = 3;
-
- range->avg_qual.level = 0x100 + WL_IW_RSSI_GOOD;
-
- range->avg_qual.noise = 0x100 - 75;
-#endif
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset)))) {
- kfree(channels);
- return error;
- }
- rateset.count = dtoh32(rateset.count);
- range->num_bitrates = rateset.count;
- for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
- range->bitrate[i] = (rateset.rates[i]& 0x7f) * 500000;
- dev_wlc_intvar_get(dev, "nmode", &nmode);
- dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &phytype, sizeof(phytype));
-
- if (nmode == 1 && phytype == WLC_PHY_TYPE_SSN) {
- dev_wlc_intvar_get(dev, "mimo_bw_cap", &bw_cap);
- dev_wlc_intvar_get(dev, "sgi_tx", &sgi_tx);
- dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(channel_info_t));
- ci.hw_channel = dtoh32(ci.hw_channel);
-
- if (bw_cap == 0 ||
- (bw_cap == 2 && ci.hw_channel <= 14)) {
- if (sgi_tx == 0)
- nrate_list2copy = 0;
- else
- nrate_list2copy = 1;
- }
- if (bw_cap == 1 ||
- (bw_cap == 2 && ci.hw_channel >= 36)) {
- if (sgi_tx == 0)
- nrate_list2copy = 2;
- else
- nrate_list2copy = 3;
- }
- range->num_bitrates += 8;
- for (k = 0; i < range->num_bitrates; k++, i++) {
-
- range->bitrate[i] = (nrate_list[nrate_list2copy][k]) * 500000;
- }
- }
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i)))) {
- kfree(channels);
- return error;
- }
- i = dtoh32(i);
- if (i == WLC_PHY_TYPE_A)
- range->throughput = 24000000;
- else
- range->throughput = 1500000;
-
-
- range->min_rts = 0;
- range->max_rts = 2347;
- range->min_frag = 256;
- range->max_frag = 2346;
-
- range->max_encoding_tokens = DOT11_MAX_DEFAULT_KEYS;
- range->num_encoding_sizes = 4;
- range->encoding_size[0] = WEP1_KEY_SIZE;
- range->encoding_size[1] = WEP128_KEY_SIZE;
-#if WIRELESS_EXT > 17
- range->encoding_size[2] = TKIP_KEY_SIZE;
-#else
- range->encoding_size[2] = 0;
-#endif
- range->encoding_size[3] = AES_KEY_SIZE;
-
-
- range->min_pmp = 0;
- range->max_pmp = 0;
- range->min_pmt = 0;
- range->max_pmt = 0;
- range->pmp_flags = 0;
- range->pm_capa = 0;
-
-
- range->num_txpower = 2;
- range->txpower[0] = 1;
- range->txpower[1] = 255;
- range->txpower_capa = IW_TXPOW_MWATT;
-
-#if WIRELESS_EXT > 10
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 19;
-
-
- range->retry_capa = IW_RETRY_LIMIT;
- range->retry_flags = IW_RETRY_LIMIT;
- range->r_time_flags = 0;
-
- range->min_retry = 1;
- range->max_retry = 255;
-
- range->min_r_time = 0;
- range->max_r_time = 0;
-#endif
-
-#if WIRELESS_EXT > 17
- range->enc_capa = IW_ENC_CAPA_WPA;
- range->enc_capa |= IW_ENC_CAPA_CIPHER_TKIP;
- range->enc_capa |= IW_ENC_CAPA_CIPHER_CCMP;
-#ifdef BCMWPA2
- range->enc_capa |= IW_ENC_CAPA_WPA2;
-#endif
-
-
- IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
-
- IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
- IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
- IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
- IW_EVENT_CAPA_SET(range->event_capa, IWEVMICHAELMICFAILURE);
-#ifdef BCMWPA2
- IW_EVENT_CAPA_SET(range->event_capa, IWEVPMKIDCAND);
-#endif
-#endif
-
- kfree(channels);
-
- return 0;
-}
-
-static int
-rssi_to_qual(int rssi)
-{
- if (rssi <= WL_IW_RSSI_NO_SIGNAL)
- return 0;
- else if (rssi <= WL_IW_RSSI_VERY_LOW)
- return 1;
- else if (rssi <= WL_IW_RSSI_LOW)
- return 2;
- else if (rssi <= WL_IW_RSSI_GOOD)
- return 3;
- else if (rssi <= WL_IW_RSSI_VERY_GOOD)
- return 4;
- else
- return 5;
-}
-
-static int
-wl_iw_set_spy(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
- struct sockaddr *addr = (struct sockaddr *) extra;
- int i;
-
- WL_TRACE(("%s: SIOCSIWSPY\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- iw->spy_num = MIN(ARRAYSIZE(iw->spy_addr), dwrq->length);
- for (i = 0; i < iw->spy_num; i++)
- memcpy(&iw->spy_addr[i], addr[i].sa_data, ETHER_ADDR_LEN);
- memset(iw->spy_qual, 0, sizeof(iw->spy_qual));
-
- return 0;
-}
-
-static int
-wl_iw_get_spy(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
- struct sockaddr *addr = (struct sockaddr *) extra;
- struct iw_quality *qual = (struct iw_quality *) &addr[iw->spy_num];
- int i;
-
- WL_TRACE(("%s: SIOCGIWSPY\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- dwrq->length = iw->spy_num;
- for (i = 0; i < iw->spy_num; i++) {
- memcpy(addr[i].sa_data, &iw->spy_addr[i], ETHER_ADDR_LEN);
- addr[i].sa_family = AF_UNIX;
- memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality));
- iw->spy_qual[i].updated = 0;
- }
-
- return 0;
-}
-
-static int
-wl_iw_set_wap(
- struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *awrq,
- char *extra
-)
-{
- int error = -EINVAL;
- wl_join_params_t join_params;
-
- WL_TRACE(("%s: SIOCSIWAP\n", dev->name));
-
- if (awrq->sa_family != ARPHRD_ETHER) {
- WL_ERROR(("Invalid Header...sa_family\n"));
- return -EINVAL;
- }
-
-
- if (ETHER_ISBCAST(awrq->sa_data) || ETHER_ISNULLADDR(awrq->sa_data)) {
- scb_val_t scbval;
-
- bzero(&scbval, sizeof(scb_val_t));
-
- (void) dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
- return 0;
- }
-
-
-
- memset(&join_params, 0, sizeof(join_params));
-
- memcpy(join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
- join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
- memcpy(&join_params.params.bssid, awrq->sa_data, ETHER_ADDR_LEN);
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, sizeof(join_params)))) {
- WL_ERROR(("Invalid ioctl data.\n"));
- return error;
- }
-
-
- memset(&g_ssid, 0, sizeof(g_ssid));
- return 0;
-}
-
-static int
-wl_iw_get_wap(
- struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *awrq,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCGIWAP\n", dev->name));
-
- awrq->sa_family = ARPHRD_ETHER;
- memset(awrq->sa_data, 0, ETHER_ADDR_LEN);
-
-
- (void) dev_wlc_ioctl(dev, WLC_GET_BSSID, awrq->sa_data, ETHER_ADDR_LEN);
-
- return 0;
-}
-
-#if WIRELESS_EXT > 17
-static int
-wl_iw_mlme(
- struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *awrq,
- char *extra
-)
-{
- struct iw_mlme *mlme;
- scb_val_t scbval;
- int error = -EINVAL;
-
- WL_TRACE(("%s: SIOCSIWMLME DISASSOC/DEAUTH\n", dev->name));
-
- mlme = (struct iw_mlme *)extra;
- if (mlme == NULL) {
- WL_ERROR(("Invalid ioctl data.\n"));
- return error;
- }
-
- scbval.val = mlme->reason_code;
- bcopy(&mlme->addr.sa_data, &scbval.ea, ETHER_ADDR_LEN);
-
- if (mlme->cmd == IW_MLME_DISASSOC) {
- scbval.val = htod32(scbval.val);
- error = dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
- }
- else if (mlme->cmd == IW_MLME_DEAUTH) {
- scbval.val = htod32(scbval.val);
- error = dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
- sizeof(scb_val_t));
- }
- else {
- WL_ERROR(("Invalid ioctl data.\n"));
- return error;
- }
-
- return error;
-}
-#endif
-
-static int
-wl_iw_get_aplist(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_scan_results_t *list;
- struct sockaddr *addr = (struct sockaddr *) extra;
- struct iw_quality qual[IW_MAX_AP];
- wl_bss_info_t *bi = NULL;
- int error, i;
- uint buflen = dwrq->length;
-
- WL_TRACE(("%s: SIOCGIWAPLIST\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
-
- list = kmalloc(buflen, GFP_KERNEL);
- if (!list)
- return -ENOMEM;
- memset(list, 0, buflen);
- list->buflen = htod32(buflen);
- if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen))) {
- WL_ERROR(("%d: Scan results error %d\n", __LINE__, error));
- kfree(list);
- return error;
- }
- list->buflen = dtoh32(list->buflen);
- list->version = dtoh32(list->version);
- list->count = dtoh32(list->count);
- if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
- kfree(list);
- return -EINVAL;
- }
-
- for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
- bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- buflen));
-
-
- if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
- continue;
-
-
- memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
- addr[dwrq->length].sa_family = ARPHRD_ETHER;
- qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
- qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
- qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
-
-#if WIRELESS_EXT > 18
- qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-#else
- qual[dwrq->length].updated = 7;
-#endif
-
- dwrq->length++;
- }
-
- kfree(list);
-
- if (dwrq->length) {
- memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
-
- dwrq->flags = 1;
- }
-
- return 0;
-}
-
-#ifdef WL_IW_USE_ISCAN
-static int
-wl_iw_iscan_get_aplist(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_scan_results_t *list;
- iscan_buf_t * buf;
- iscan_info_t *iscan = g_iscan;
-
- struct sockaddr *addr = (struct sockaddr *) extra;
- struct iw_quality qual[IW_MAX_AP];
- wl_bss_info_t *bi = NULL;
- int i;
-
- WL_TRACE(("%s: SIOCGIWAPLIST\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- if ((!iscan) || (iscan->sysioc_pid < 0)) {
- return wl_iw_get_aplist(dev, info, dwrq, extra);
- }
-
- buf = iscan->list_hdr;
-
- while (buf) {
- list = &((wl_iscan_results_t*)buf->iscan_buf)->results;
- if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
- return -EINVAL;
- }
-
- bi = NULL;
- for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
- bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length))
- : list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- WLC_IW_ISCAN_MAXLEN));
-
-
- if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
- continue;
-
-
- memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
- addr[dwrq->length].sa_family = ARPHRD_ETHER;
- qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
- qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
- qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
-
-#if WIRELESS_EXT > 18
- qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-#else
- qual[dwrq->length].updated = 7;
-#endif
-
- dwrq->length++;
- }
- buf = buf->next;
- }
- if (dwrq->length) {
- memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
-
- dwrq->flags = 1;
- }
-
- return 0;
-}
-
-static int
-wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid)
-{
- int err = 0;
-
- memcpy(¶ms->bssid, ðer_bcast, ETHER_ADDR_LEN);
- params->bss_type = DOT11_BSSTYPE_ANY;
- params->scan_type = 0;
- params->nprobes = -1;
- params->active_time = -1;
- params->passive_time = -1;
- params->home_time = -1;
- params->channel_num = 0;
-
- params->nprobes = htod32(params->nprobes);
- params->active_time = htod32(params->active_time);
- params->passive_time = htod32(params->passive_time);
- params->home_time = htod32(params->home_time);
- if (ssid && ssid->SSID_len)
- memcpy(¶ms->ssid, ssid, sizeof(wlc_ssid_t));
-
- return err;
-}
-
-static int
-wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, uint16 action)
-{
- int err = 0;
-
- iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
- iscan->iscan_ex_params_p->action = htod16(action);
- iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
- WL_SCAN(("%s : nprobes=%d\n", __FUNCTION__, iscan->iscan_ex_params_p->params.nprobes));
- WL_SCAN(("active_time=%d\n", iscan->iscan_ex_params_p->params.active_time));
- WL_SCAN(("passive_time=%d\n", iscan->iscan_ex_params_p->params.passive_time));
- WL_SCAN(("home_time=%d\n", iscan->iscan_ex_params_p->params.home_time));
- WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
- WL_SCAN(("bss_type=%d\n", iscan->iscan_ex_params_p->params.bss_type));
-
-
- (void) dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
- iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf));
-
- return err;
-}
-
-static void
-wl_iw_timerfunc(ulong data)
-{
- iscan_info_t *iscan = (iscan_info_t *)data;
- if (iscan) {
- iscan->timer_on = 0;
- if (iscan->iscan_state != ISCAN_STATE_IDLE) {
- WL_TRACE(("timer trigger\n"));
- up(&iscan->sysioc_sem);
- }
- }
-}
-static void wl_iw_set_event_mask(struct net_device *dev)
-{
- char eventmask[WL_EVENTING_MASK_LEN];
- char iovbuf[WL_EVENTING_MASK_LEN + 12];
-
- dev_iw_iovar_getbuf(dev, "event_msgs", "", 0, iovbuf, sizeof(iovbuf));
- bcopy(iovbuf, eventmask, WL_EVENTING_MASK_LEN);
- setbit(eventmask, WLC_E_SCAN_COMPLETE);
- dev_iw_iovar_setbuf(dev, "event_msgs", eventmask, WL_EVENTING_MASK_LEN,
- iovbuf, sizeof(iovbuf));
-}
-
-static uint32
-wl_iw_iscan_get(iscan_info_t *iscan)
-{
- iscan_buf_t * buf;
- iscan_buf_t * ptr;
- wl_iscan_results_t * list_buf;
- wl_iscan_results_t list;
- wl_scan_results_t *results;
- uint32 status;
-
-
- MUTEX_LOCK_WL_SCAN_SET();
- if (iscan->list_cur) {
- buf = iscan->list_cur;
- iscan->list_cur = buf->next;
- }
- else {
- buf = kmalloc(sizeof(iscan_buf_t), GFP_KERNEL);
- if (!buf) {
- WL_ERROR(("%s can't alloc iscan_buf_t : going to abort currect iscan\n", \
- __FUNCTION__));
- MUTEX_UNLOCK_WL_SCAN_SET();
- return WL_SCAN_RESULTS_NO_MEM;
- }
- buf->next = NULL;
- if (!iscan->list_hdr)
- iscan->list_hdr = buf;
- else {
- ptr = iscan->list_hdr;
- while (ptr->next) {
- ptr = ptr->next;
- }
- ptr->next = buf;
- }
- }
- memset(buf->iscan_buf, 0, WLC_IW_ISCAN_MAXLEN);
- list_buf = (wl_iscan_results_t*)buf->iscan_buf;
- results = &list_buf->results;
- results->buflen = WL_ISCAN_RESULTS_FIXED_SIZE;
- results->version = 0;
- results->count = 0;
-
- memset(&list, 0, sizeof(list));
- list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
- (void) dev_iw_iovar_getbuf(
- iscan->dev,
- "iscanresults",
- &list,
- WL_ISCAN_RESULTS_FIXED_SIZE,
- buf->iscan_buf,
- WLC_IW_ISCAN_MAXLEN);
- results->buflen = dtoh32(results->buflen);
- results->version = dtoh32(results->version);
- results->count = dtoh32(results->count);
- WL_TRACE(("%s: results->count = %d\n", __func__, results->count));
-
- //WL_TRACE(("results->buflen = %d\n", results->buflen));
- status = dtoh32(list_buf->status);
- MUTEX_UNLOCK_WL_SCAN_SET();
- return status;
-}
-
-static void wl_iw_force_specific_scan(iscan_info_t *iscan)
-{
- WL_TRACE(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_lock();
-#endif
-
- (void) dev_wlc_ioctl(iscan->dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid));
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_unlock();
-#endif
-}
-static void wl_iw_send_scan_complete(iscan_info_t *iscan)
-{
-#ifndef SANDGATE2G
- union iwreq_data wrqu;
-
-#if !defined(CSCAN)
- if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
-#endif
- memset(&wrqu, 0, sizeof(wrqu));
- wireless_send_event(iscan->dev, SIOCGIWSCAN, &wrqu, NULL);
- WL_TRACE(("Send Event ISCAN complete\n"));
-#endif
-}
-static int
-_iscan_sysioc_thread(void *data)
-{
- uint32 status;
- iscan_info_t *iscan = (iscan_info_t *)data;
- static bool iscan_pass_abort = FALSE;
- DAEMONIZE("iscan_sysioc");
-
- status = WL_SCAN_RESULTS_PARTIAL;
- while (down_interruptible(&iscan->sysioc_sem) == 0) {
-
-#if defined(SOFTAP)
- if (ap_cfg_running) {
- WL_TRACE(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
- continue;
- }
-#endif
- if (iscan->timer_on) {
- del_timer(&iscan->timer);
- iscan->timer_on = 0;
- }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_lock();
-#endif
- status = wl_iw_iscan_get(iscan);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_unlock();
-#endif
- if (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
- WL_TRACE(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
- wl_iw_send_scan_complete(iscan);
- iscan_pass_abort = FALSE;
- status = -1;
- }
-
- switch (status) {
- case WL_SCAN_RESULTS_PARTIAL:
- WL_TRACE(("iscanresults incomplete\n"));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_lock();
-#endif
-
- wl_iw_iscan(iscan, NULL, WL_SCAN_ACTION_CONTINUE);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_unlock();
-#endif
-
- mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
- iscan->timer_on = 1;
- break;
- case WL_SCAN_RESULTS_SUCCESS:
- WL_TRACE(("iscanresults complete\n"));
- iscan->iscan_state = ISCAN_STATE_IDLE;
- wl_iw_send_scan_complete(iscan);
- break;
- case WL_SCAN_RESULTS_PENDING:
- WL_TRACE(("iscanresults pending\n"));
-
- mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
- iscan->timer_on = 1;
- break;
- case WL_SCAN_RESULTS_ABORTED:
- WL_TRACE(("iscanresults aborted\n"));
- iscan->iscan_state = ISCAN_STATE_IDLE;
- if (g_scan_specified_ssid == 0)
- wl_iw_send_scan_complete(iscan);
- else {
- iscan_pass_abort = TRUE;
- wl_iw_force_specific_scan(iscan);
- }
- break;
- case WL_SCAN_RESULTS_NO_MEM:
- WL_TRACE(("iscanresults can't alloc memory: skip\n"));
- iscan->iscan_state = ISCAN_STATE_IDLE;
- break;
- default:
- WL_TRACE(("iscanresults returned unknown status %d\n", status));
- break;
- }
- }
-
- if (iscan->timer_on) {
- del_timer(&iscan->timer);
- iscan->timer_on = 0;
- }
- complete_and_exit(&iscan->sysioc_exited, 0);
-}
-#endif
-
-#if !defined(CSCAN)
-
-static void
-wl_iw_set_ss_cache_timer_flag(void)
-{
- g_ss_cache_ctrl.m_timer_expired = 1;
- //WL_TRACE(("%s called\n", __FUNCTION__));
-}
-
-static int
-wl_iw_init_ss_cache_ctrl(void)
-{
- WL_TRACE(("%s :\n", __FUNCTION__));
- g_ss_cache_ctrl.m_prev_scan_mode = 0;
- g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
- g_ss_cache_ctrl.m_cache_head = NULL;
- g_ss_cache_ctrl.m_link_down = 0;
- g_ss_cache_ctrl.m_timer_expired = 0;
- memset(g_ss_cache_ctrl.m_active_bssid, 0, ETHER_ADDR_LEN);
-
- g_ss_cache_ctrl.m_timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
- if (!g_ss_cache_ctrl.m_timer) {
- return -ENOMEM;
- }
- g_ss_cache_ctrl.m_timer->function = (void *)wl_iw_set_ss_cache_timer_flag;
- init_timer(g_ss_cache_ctrl.m_timer);
-
- return 0;
-}
-
-
-
-static void
-wl_iw_free_ss_cache(void)
-{
- wl_iw_ss_cache_t *node, *cur;
- wl_iw_ss_cache_t **spec_scan_head;
-
- WL_TRACE(("%s called\n", __FUNCTION__));
-
- MUTEX_LOCK_WL_SCAN_SET();
- spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
- node = *spec_scan_head;
-
- for (;node;) {
- WL_TRACE(("%s : SSID - %s\n", __FUNCTION__, node->bss_info->SSID));
- cur = node;
- node = cur->next;
- kfree(cur);
- }
- *spec_scan_head = NULL;
- MUTEX_UNLOCK_WL_SCAN_SET();
-}
-
-
-
-static int
-wl_iw_run_ss_cache_timer(int kick_off)
-{
- struct timer_list **timer;
-
- timer = &g_ss_cache_ctrl.m_timer;
-
- if (*timer) {
- if (kick_off) {
- (*timer)->expires = jiffies + 30000 * HZ / 1000;
- add_timer(*timer);
- //WL_TRACE(("%s : timer starts \n", __FUNCTION__));
- } else {
- del_timer_sync(*timer);
- //WL_TRACE(("%s : timer stops \n", __FUNCTION__));
- }
- }
-
- return 0;
-}
-
-
-void
-wl_iw_release_ss_cache_ctrl(void)
-{
- WL_TRACE(("%s :\n", __FUNCTION__));
- wl_iw_free_ss_cache();
- wl_iw_run_ss_cache_timer(0);
- if (g_ss_cache_ctrl.m_timer) {
- kfree(g_ss_cache_ctrl.m_timer);
- }
-}
-
-
-
-static void
-wl_iw_reset_ss_cache(void)
-{
- wl_iw_ss_cache_t *node, *prev, *cur;
- wl_iw_ss_cache_t **spec_scan_head;
-
- MUTEX_LOCK_WL_SCAN_SET();
- spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
- node = *spec_scan_head;
- prev = node;
-
- for (;node;) {
- WL_TRACE(("%s : node SSID %s \n", __FUNCTION__, node->bss_info->SSID));
- if (!node->dirty) {
- cur = node;
- if (cur == *spec_scan_head) {
- *spec_scan_head = cur->next;
- prev = *spec_scan_head;
- }
- else {
- prev->next = cur->next;
- }
- node = cur->next;
-
- WL_TRACE(("%s : Del node : SSID %s\n", __FUNCTION__, cur->bss_info->SSID));
- kfree(cur);
- continue;
- }
-
- node->dirty = 0;
- prev = node;
- node = node->next;
- }
- MUTEX_UNLOCK_WL_SCAN_SET();
-}
-
-
-static int
-wl_iw_add_bss_to_ss_cache(wl_scan_results_t *ss_list)
-{
-
- wl_iw_ss_cache_t *node, *prev, *leaf;
- wl_iw_ss_cache_t **spec_scan_head;
- wl_bss_info_t *bi = NULL;
- int i;
-
-
- if (!ss_list->count) {
- return 0;
- }
-
- MUTEX_LOCK_WL_SCAN_SET();
- spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
- for (i = 0; i < ss_list->count; i++) {
-
- node = *spec_scan_head;
- prev = node;
-
- bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
-
- WL_TRACE(("%s : find %d with specific SSID %s\n", __FUNCTION__, i, bi->SSID));
- for (;node;) {
- if (!memcmp(&node->bss_info->BSSID, &bi->BSSID, ETHER_ADDR_LEN)) {
-
- WL_TRACE(("dirty marked : SSID %s\n", bi->SSID));
- node->dirty = 1;
- break;
- }
- prev = node;
- node = node->next;
- }
-
- if (node) {
- continue;
- }
- leaf = kmalloc(bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN, GFP_KERNEL);
- if (!leaf) {
- MUTEX_UNLOCK_WL_SCAN_SET();
- return -ENOMEM;
- }
-
- memcpy(leaf->bss_info, bi, bi->length);
- leaf->next = NULL;
- leaf->dirty = 1;
- leaf->count = 1;
- leaf->version = ss_list->version;
-
- if (!prev) {
- *spec_scan_head = leaf;
- }
- else {
- prev->next = leaf;
- }
- }
- MUTEX_UNLOCK_WL_SCAN_SET();
- return 0;
-
-}
-
-
-static int
-wl_iw_merge_scan_cache(struct iw_request_info *info, char *extra, uint buflen_from_user,
-__u16 *merged_len)
-{
- wl_iw_ss_cache_t *node;
- wl_scan_results_t *list_merge;
-
- MUTEX_LOCK_WL_SCAN_SET();
- node = g_ss_cache_ctrl.m_cache_head;
- for (;node;) {
- list_merge = (wl_scan_results_t *)node;
- WL_TRACE(("%s: Cached Specific APs list=%d\n", __FUNCTION__, list_merge->count));
- if (buflen_from_user - *merged_len > 0) {
- *merged_len += (__u16) wl_iw_get_scan_prep(list_merge, info,
- extra + *merged_len, buflen_from_user - *merged_len);
- }
- else {
- WL_TRACE(("%s: exit with break\n", __FUNCTION__));
- break;
- }
- node = node->next;
- }
- MUTEX_UNLOCK_WL_SCAN_SET();
- return 0;
-}
-
-
-static int
-wl_iw_delete_bss_from_ss_cache(void *addr)
-{
-
- wl_iw_ss_cache_t *node, *prev;
- wl_iw_ss_cache_t **spec_scan_head;
-
- MUTEX_LOCK_WL_SCAN_SET();
- spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
- node = *spec_scan_head;
- prev = node;
- for (;node;) {
- if (!memcmp(&node->bss_info->BSSID, addr, ETHER_ADDR_LEN)) {
- if (node == *spec_scan_head) {
- *spec_scan_head = node->next;
- }
- else {
- prev->next = node->next;
- }
-
- WL_TRACE(("%s : Del node : %s\n", __FUNCTION__, node->bss_info->SSID));
- kfree(node);
- break;
- }
-
- prev = node;
- node = node->next;
- }
-
- memset(addr, 0, ETHER_ADDR_LEN);
- MUTEX_UNLOCK_WL_SCAN_SET();
- return 0;
-
-}
-
-#endif
-
-
-static int
-wl_iw_set_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int error;
- WL_TRACE(("\n:%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
-
-
-#if defined(CSCAN)
- WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
- return -EINVAL;
-#endif
-
-#if defined(SOFTAP)
-
- if (ap_cfg_running) {
- WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
- return 0;
- }
-#endif
-
-
- if (g_onoff == G_WLAN_SET_OFF)
- return 0;
-
-
- memset(&g_specific_ssid, 0, sizeof(g_specific_ssid));
-#ifndef WL_IW_USE_ISCAN
-
- g_scan_specified_ssid = 0;
-#endif
-
-#if WIRELESS_EXT > 17
-
- if (wrqu->data.length == sizeof(struct iw_scan_req)) {
- if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
- struct iw_scan_req *req = (struct iw_scan_req *)extra;
- if (g_first_broadcast_scan != BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-
- WL_TRACE(("%s Ignoring SC %s first BC is not done = %d\n", \
- __FUNCTION__, req->essid, \
- g_first_broadcast_scan));
- return -EBUSY;
- }
- if (g_scan_specified_ssid) {
- WL_TRACE(("%s Specific SCAN is not done ignore scan for = %s \n", \
- __FUNCTION__, req->essid));
-
- return -EBUSY;
- }
- else {
- g_specific_ssid.SSID_len = MIN(sizeof(g_specific_ssid.SSID), \
- req->essid_len);
- memcpy(g_specific_ssid.SSID, req->essid, g_specific_ssid.SSID_len);
- g_specific_ssid.SSID_len = htod32(g_specific_ssid.SSID_len);
- g_scan_specified_ssid = 1;
- WL_TRACE(("### Specific scan ssid=%s len=%d\n", \
- g_specific_ssid.SSID, g_specific_ssid.SSID_len));
- }
- }
- }
-#endif
-
- if ((error = dev_wlc_ioctl(dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid)))) {
- WL_TRACE(("#### Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
-
- g_scan_specified_ssid = 0;
- return -EBUSY;
- }
-
- return 0;
-}
-
-#ifdef WL_IW_USE_ISCAN
-int
-wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag)
-{
- wlc_ssid_t ssid;
- iscan_info_t *iscan = g_iscan;
-
-#if !defined(CSCAN)
-
- if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_IDLE) {
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_STARTED;
- WL_TRACE(("%s: First Brodcast scan was forced\n", __FUNCTION__));
- }
- else if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED) {
- WL_TRACE(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
- return 0;
- }
-#endif
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- if (flag)
- rtnl_lock();
-#endif
-
- dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &iscan->scan_flag, sizeof(iscan->scan_flag));
- wl_iw_set_event_mask(dev);
-
- WL_TRACE(("+++: Set Broadcast ISCAN\n"));
-
- memset(&ssid, 0, sizeof(ssid));
-
- iscan->list_cur = iscan->list_hdr;
- iscan->iscan_state = ISCAN_STATE_SCANING;
-
- memset(&iscan->iscan_ex_params_p->params, 0, iscan->iscan_ex_param_size);
- wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, &ssid);
- wl_iw_iscan(iscan, &ssid, WL_SCAN_ACTION_START);
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- if (flag)
- rtnl_unlock();
-#endif
-
- mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-
- iscan->timer_on = 1;
-
- return 0;
-}
-static int
-wl_iw_iscan_set_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- wlc_ssid_t ssid;
- iscan_info_t *iscan = g_iscan;
-
- WL_TRACE(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
-
-#if defined(CSCAN)
- WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
- return -EINVAL;
-#endif
-
-
-#if defined(SOFTAP)
- if (ap_cfg_running) {
- WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
- return 0;
- }
-#endif
-
- if (g_onoff == G_WLAN_SET_OFF) {
- WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
- return 0;
- }
-
-
- if ((!iscan) || (iscan->sysioc_pid < 0)) {
- WL_TRACE(("%s use backup if iscan thread is not successful\n", \
- __FUNCTION__));
- return wl_iw_set_scan(dev, info, wrqu, extra);
- }
-
- if (g_scan_specified_ssid) {
- WL_TRACE(("%s Specific SCAN already running ignoring BC scan\n", \
- __FUNCTION__));
- return EBUSY;
- }
-
-
- memset(&ssid, 0, sizeof(ssid));
-
-#if WIRELESS_EXT > 17
-
- if (wrqu->data.length == sizeof(struct iw_scan_req)) {
- if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
- int as = 0;
- struct iw_scan_req *req = (struct iw_scan_req *)extra;
-#if !defined(CSCAN)
- if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-
- WL_TRACE(("%s First ISCAN in progress : ignoring SC = %s\n", \
- __FUNCTION__, req->essid));
- return -EBUSY;
- }
-#endif
- ssid.SSID_len = MIN(sizeof(ssid.SSID), req->essid_len);
- memcpy(ssid.SSID, req->essid, ssid.SSID_len);
- ssid.SSID_len = htod32(ssid.SSID_len);
- dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
- wl_iw_set_event_mask(dev);
- return wl_iw_set_scan(dev, info, wrqu, extra);
- }
- else {
- g_scan_specified_ssid = 0;
-
- if (iscan->iscan_state == ISCAN_STATE_SCANING) {
- WL_TRACE(("%s ISCAN already in progress \n", __FUNCTION__));
- return 0;
- }
- }
- }
-#endif
-
- wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
-
- return 0;
-}
-#endif
-
-#if WIRELESS_EXT > 17
-static bool
-ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
-{
-
-
- uint8 *ie = *wpaie;
-
-
- if ((ie[1] >= 6) &&
- !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x01"), 4)) {
- return TRUE;
- }
-
-
- ie += ie[1] + 2;
-
- *tlvs_len -= (int)(ie - *tlvs);
-
- *tlvs = ie;
- return FALSE;
-}
-
-static bool
-ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
-{
-
-
- uint8 *ie = *wpsie;
-
-
- if ((ie[1] >= 4) &&
- !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x04"), 4)) {
- return TRUE;
- }
-
-
- ie += ie[1] + 2;
-
- *tlvs_len -= (int)(ie - *tlvs);
-
- *tlvs = ie;
- return FALSE;
-}
-#endif
-
-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;
-}
-
-
-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);
-}
-
-static int
-wl_iw_handle_scanresults_ies(char **event_p, char *end,
- struct iw_request_info *info, wl_bss_info_t *bi)
-{
-#if WIRELESS_EXT > 17
- struct iw_event iwe;
- char *event;
- char *buf;
- int custom_event_len;
-
- event = *event_p;
- if (bi->ie_length) {
-
- bcm_tlv_t *ie;
- uint8 *ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
- int ptr_len = bi->ie_length;
-
-#ifdef BCMWPA2
- if ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_RSN_ID))) {
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = ie->len + 2;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
- }
- ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-#endif
-
- while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
-
- if (ie_is_wps_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = ie->len + 2;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
- break;
- }
- }
-
- ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
- ptr_len = bi->ie_length;
- while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
- if (ie_is_wpa_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = ie->len + 2;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
- break;
- }
- }
-
- 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
- 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);
-#endif
- break;
- }
- *event_p = event;
- }
-#endif
-
- return 0;
-}
-
-static uint
-wl_iw_get_scan_prep(
- wl_scan_results_t *list,
- struct iw_request_info *info,
- char *extra,
- short max_size)
-{
- int i, j;
- struct iw_event iwe;
- wl_bss_info_t *bi = NULL;
- char *event = extra, *end = extra + max_size - WE_ADD_EVENT_FIX, *value;
- int ret = 0;
-
- ASSERT(list);
-
-
-
- for (i = 0; i < list->count && i < IW_MAX_AP; i++)
- {
- if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
- return ret;
- }
-
- bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-
- WL_TRACE(("%s : %s\n", __FUNCTION__, bi->SSID));
-
-
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
-
- iwe.u.data.length = dtoh32(bi->SSID_len);
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.flags = 1;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
-
- if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
- iwe.cmd = SIOCGIWMODE;
- if (dtoh16(bi->capability) & DOT11_CAP_ESS)
- iwe.u.mode = IW_MODE_INFRA;
- else
- iwe.u.mode = IW_MODE_ADHOC;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
- }
-
-
- iwe.cmd = SIOCGIWFREQ;
- iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
- CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
- WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
- iwe.u.freq.e = 6;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
-
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
- iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
- iwe.u.qual.noise = 0x100 + bi->phy_noise;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
-
- wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
-
- iwe.cmd = SIOCGIWENCODE;
- if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
- iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
- iwe.u.data.length = 0;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
-
- if (bi->rateset.count) {
- if (((event -extra) + IW_EV_LCP_LEN) <= (uintptr)end) {
- value = event + IW_EV_LCP_LEN;
- iwe.cmd = SIOCGIWRATE;
-
- iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
- for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
- iwe.u.bitrate.value =
- (bi->rateset.rates[j] & 0x7f) * 500000;
- value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
- IW_EV_PARAM_LEN);
- }
- event = value;
- }
- }
- }
-
- if ((ret = (event - extra)) < 0) {
- WL_ERROR(("==> Wrong size\n"));
- ret = 0;
- }
- WL_TRACE(("%s: size=%d bytes prepared \n", __FUNCTION__, (unsigned int)(event - extra)));
- return (uint)ret;
-}
-
-static int
-wl_iw_get_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- channel_info_t ci;
- wl_scan_results_t *list_merge;
- wl_scan_results_t *list = (wl_scan_results_t *) g_scan;
- int error;
- uint buflen_from_user = dwrq->length;
- uint len = G_SCAN_RESULTS;
- __u16 len_ret = 0;
-#if !defined(CSCAN)
- __u16 merged_len = 0;
-#endif
-#if defined(WL_IW_USE_ISCAN)
- iscan_info_t *iscan = g_iscan;
- iscan_buf_t * p_buf;
-#if !defined(CSCAN)
- uint32 counter = 0;
-#endif
-#endif
-
- WL_TRACE(("%s: buflen_from_user %d: \n", dev->name, buflen_from_user));
-
- if (!extra) {
- WL_TRACE(("%s: wl_iw_get_scan return -EINVAL\n", dev->name));
- return -EINVAL;
- }
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
- return error;
- ci.scan_channel = dtoh32(ci.scan_channel);
- if (ci.scan_channel)
- return -EAGAIN;
-
-#if !defined(CSCAN)
- if (g_ss_cache_ctrl.m_timer_expired) {
- wl_iw_free_ss_cache();
- g_ss_cache_ctrl.m_timer_expired ^= 1;
- }
- if ((!g_scan_specified_ssid && g_ss_cache_ctrl.m_prev_scan_mode) ||
- g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
- g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-
- wl_iw_reset_ss_cache();
- }
- g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
- if (g_scan_specified_ssid) {
- g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
- }
- else {
- g_ss_cache_ctrl.m_cons_br_scan_cnt++;
- }
-#endif
-
-
-
- if (g_scan_specified_ssid) {
-
- list = kmalloc(len, GFP_KERNEL);
- if (!list) {
- WL_TRACE(("%s: wl_iw_get_scan return -ENOMEM\n", dev->name));
- g_scan_specified_ssid = 0;
- return -ENOMEM;
- }
- }
-
- memset(list, 0, len);
- list->buflen = htod32(len);
- if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len))) {
- WL_TRACE(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, len));
- dwrq->length = len;
- if (g_scan_specified_ssid)
- kfree(list);
- return 0;
- }
- list->buflen = dtoh32(list->buflen);
- list->version = dtoh32(list->version);
- list->count = dtoh32(list->count);
-
-
- if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
- if (g_scan_specified_ssid) {
- g_scan_specified_ssid = 0;
- kfree(list);
- }
- return -EINVAL;
- }
-
-#if !defined(CSCAN)
- if (g_scan_specified_ssid) {
-
- wl_iw_add_bss_to_ss_cache(list);
- kfree(list);
- }
-#endif
-
-#if !defined(CSCAN)
- MUTEX_LOCK_WL_SCAN_SET();
-#if defined(WL_IW_USE_ISCAN)
- if (g_scan_specified_ssid)
- WL_TRACE(("%s: Specified scan APs from scan=%d\n", __FUNCTION__, list->count));
- p_buf = iscan->list_hdr;
-
- while (p_buf != iscan->list_cur) {
- list_merge = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
- WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
- counter += list_merge->count;
- if (list_merge->count > 0)
- len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
- extra+len_ret, buflen_from_user -len_ret);
- p_buf = p_buf->next;
- }
- WL_TRACE(("%s merged with total Bcast APs=%d\n", __FUNCTION__, counter));
-#else
- list_merge = (wl_scan_results_t *) g_scan;
- len_ret = (__u16) wl_iw_get_scan_prep(list_merge, info, extra, buflen_from_user);
-#endif
- MUTEX_UNLOCK_WL_SCAN_SET();
- if (g_ss_cache_ctrl.m_link_down) {
-
- wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
- }
-
- wl_iw_merge_scan_cache(info, extra+len_ret, buflen_from_user-len_ret, &merged_len);
- len_ret += merged_len;
- wl_iw_run_ss_cache_timer(0);
- wl_iw_run_ss_cache_timer(1);
-#else
-
-
- if (g_scan_specified_ssid) {
- WL_TRACE(("%s: Specified scan APs in the list =%d\n", __FUNCTION__, list->count));
- len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
- kfree(list);
-
-#if defined(WL_IW_USE_ISCAN)
- p_buf = iscan->list_hdr;
-
- while (p_buf != iscan->list_cur) {
- list_merge = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
- WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
- if (list_merge->count > 0)
- len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
- extra+len_ret, buflen_from_user -len_ret);
- p_buf = p_buf->next;
- }
-#else
- list_merge = (wl_scan_results_t *) g_scan;
- WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
- if (list_merge->count > 0)
- len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info, extra+len_ret,
- buflen_from_user -len_ret);
-#endif
- }
- else {
- list = (wl_scan_results_t *) g_scan;
- len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
- }
-#endif
-
-#if defined(WL_IW_USE_ISCAN)
-
- g_scan_specified_ssid = 0;
-#endif
-
- if ((len_ret + WE_ADD_EVENT_FIX) < buflen_from_user)
- len = len_ret;
-
- dwrq->length = len;
- dwrq->flags = 0;
-
- WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, list->count));
- return 0;
-}
-
-#if defined(WL_IW_USE_ISCAN)
-static int
-wl_iw_iscan_get_scan(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_scan_results_t *list;
- struct iw_event iwe;
- wl_bss_info_t *bi = NULL;
- int ii, j;
- int apcnt;
- char *event = extra, *end = extra + dwrq->length, *value;
- iscan_info_t *iscan = g_iscan;
- iscan_buf_t * p_buf;
- uint32 counter = 0;
-#if !defined(CSCAN)
- __u16 merged_len = 0;
- uint buflen_from_user = dwrq->length;
-#endif
-
- WL_TRACE(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
-
-#if defined(SOFTAP)
- if (ap_cfg_running) {
- WL_TRACE(("%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
- return -EINVAL;
- }
-#endif
-
- if (!extra) {
- WL_TRACE(("%s: INVALID SIOCGIWSCAN GET bad parameter\n", dev->name));
- return -EINVAL;
- }
-
-#if !defined(CSCAN)
- if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_READY) {
- WL_TRACE(("%s %s: first ISCAN results are NOT ready yet \n", \
- dev->name, __FUNCTION__));
- return -EAGAIN;
- }
-#endif
-
- if ((!iscan) || (iscan->sysioc_pid < 0)) {
- WL_TRACE(("%ssysioc_pid\n", __FUNCTION__));
- return wl_iw_get_scan(dev, info, dwrq, extra);
- }
-
-#if !defined(CSCAN)
- if (g_ss_cache_ctrl.m_timer_expired) {
- wl_iw_free_ss_cache();
- g_ss_cache_ctrl.m_timer_expired ^= 1;
- }
- if (g_scan_specified_ssid) {
- return wl_iw_get_scan(dev, info, dwrq, extra);
- }
- else {
- if (g_ss_cache_ctrl.m_link_down) {
-
- wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
- }
- if (g_ss_cache_ctrl.m_prev_scan_mode || g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
- g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-
- wl_iw_reset_ss_cache();
- }
- g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
- g_ss_cache_ctrl.m_cons_br_scan_cnt++;
- }
-#endif
-
- WL_TRACE(("%s: SIOCGIWSCAN GET broadcast results\n", dev->name));
- apcnt = 0;
- p_buf = iscan->list_hdr;
-
- while (p_buf != iscan->list_cur) {
- list = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
-
- counter += list->count;
-
- if (list->version != WL_BSS_INFO_VERSION) {
- WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
- __FUNCTION__, list->version));
- return -EINVAL;
- }
-
- bi = NULL;
- for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) {
- bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
- ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
- WLC_IW_ISCAN_MAXLEN));
-
-
- if (event + ETHER_ADDR_LEN + bi->SSID_len + IW_EV_UINT_LEN + IW_EV_FREQ_LEN +
- IW_EV_QUAL_LEN >= end)
- return -E2BIG;
-
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
-
-
- iwe.u.data.length = dtoh32(bi->SSID_len);
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.flags = 1;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
-
- if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
- iwe.cmd = SIOCGIWMODE;
- if (dtoh16(bi->capability) & DOT11_CAP_ESS)
- iwe.u.mode = IW_MODE_INFRA;
- else
- iwe.u.mode = IW_MODE_ADHOC;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
- }
-
-
- iwe.cmd = SIOCGIWFREQ;
- iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
- CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
- WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
- iwe.u.freq.e = 6;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
-
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
- iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
- iwe.u.qual.noise = 0x100 + bi->phy_noise;
- event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
-
- wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
-
- iwe.cmd = SIOCGIWENCODE;
- if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
- iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
- iwe.u.data.length = 0;
- event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
-
- if (bi->rateset.count) {
- if (event + IW_MAX_BITRATES*IW_EV_PARAM_LEN >= end)
- return -E2BIG;
-
- value = event + IW_EV_LCP_LEN;
- iwe.cmd = SIOCGIWRATE;
-
- iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
- for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
- iwe.u.bitrate.value = (bi->rateset.rates[j] & 0x7f) * 500000;
- value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
- IW_EV_PARAM_LEN);
- }
- event = value;
- }
- }
- p_buf = p_buf->next;
- }
-
- dwrq->length = event - extra;
- dwrq->flags = 0;
-
-#if !defined(CSCAN)
-
- wl_iw_merge_scan_cache(info, event, buflen_from_user - dwrq->length, &merged_len);
- dwrq->length += merged_len;
- wl_iw_run_ss_cache_timer(0);
- wl_iw_run_ss_cache_timer(1);
-
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
-#endif
-
- WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, counter));
-
-
- if (!dwrq->length)
- return -EAGAIN;
-
- return 0;
-}
-#endif
-
-static int
-wl_iw_set_essid(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- int error;
-
- WL_TRACE(("%s: SIOCSIWESSID\n", dev->name));
-
-
-
- memset(&g_ssid, 0, sizeof(g_ssid));
-
- CHECK_EXTRA_FOR_NULL(extra);
-
- if (dwrq->length && extra) {
-#if WIRELESS_EXT > 20
- g_ssid.SSID_len = MIN(sizeof(g_ssid.SSID), dwrq->length);
-#else
- g_ssid.SSID_len = MIN(sizeof(g_ssid.SSID), dwrq->length-1);
-#endif
- memcpy(g_ssid.SSID, extra, g_ssid.SSID_len);
- } else {
-
- g_ssid.SSID_len = 0;
- }
- g_ssid.SSID_len = htod32(g_ssid.SSID_len);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &g_ssid, sizeof(g_ssid))))
- return error;
-
- if (g_ssid.SSID_len) {
- WL_TRACE(("%s: join SSID=%s\n", __FUNCTION__, g_ssid.SSID));
- }
- return 0;
-}
-
-static int
-wl_iw_get_essid(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wlc_ssid_t ssid;
- int error;
-
- WL_TRACE(("%s: SIOCGIWESSID\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid)))) {
- WL_ERROR(("Error getting the SSID\n"));
- return error;
- }
-
- ssid.SSID_len = dtoh32(ssid.SSID_len);
-
-
- memcpy(extra, ssid.SSID, ssid.SSID_len);
-
- dwrq->length = ssid.SSID_len;
-
- dwrq->flags = 1;
-
- return 0;
-}
-
-static int
-wl_iw_set_nick(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
- WL_TRACE(("%s: SIOCSIWNICKN\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
-
- if (dwrq->length > sizeof(iw->nickname))
- return -E2BIG;
-
- memcpy(iw->nickname, extra, dwrq->length);
- iw->nickname[dwrq->length - 1] = '\0';
-
- return 0;
-}
-
-static int
-wl_iw_get_nick(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
- WL_TRACE(("%s: SIOCGIWNICKN\n", dev->name));
-
- if (!extra)
- return -EINVAL;
-
- strcpy(extra, iw->nickname);
- dwrq->length = strlen(extra) + 1;
-
- return 0;
-}
-
-static int wl_iw_set_rate(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- wl_rateset_t rateset;
- int error, rate, i, error_bg, error_a;
-
- WL_TRACE(("%s: SIOCSIWRATE\n", dev->name));
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
- return error;
-
- rateset.count = dtoh32(rateset.count);
-
- if (vwrq->value < 0) {
-
- rate = rateset.rates[rateset.count - 1] & 0x7f;
- } else if (vwrq->value < rateset.count) {
-
- rate = rateset.rates[vwrq->value] & 0x7f;
- } else {
-
- rate = vwrq->value / 500000;
- }
-
- if (vwrq->fixed) {
-
- error_bg = dev_wlc_intvar_set(dev, "bg_rate", rate);
- error_a = dev_wlc_intvar_set(dev, "a_rate", rate);
-
- if (error_bg && error_a)
- return (error_bg | error_a);
- } else {
-
-
- error_bg = dev_wlc_intvar_set(dev, "bg_rate", 0);
-
- error_a = dev_wlc_intvar_set(dev, "a_rate", 0);
-
- if (error_bg && error_a)
- return (error_bg | error_a);
-
-
- for (i = 0; i < rateset.count; i++)
- if ((rateset.rates[i] & 0x7f) > rate)
- break;
- rateset.count = htod32(i);
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_SET_RATESET, &rateset, sizeof(rateset))))
- return error;
- }
-
- return 0;
-}
-
-static int wl_iw_get_rate(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, rate;
-
- WL_TRACE(("%s: SIOCGIWRATE\n", dev->name));
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate))))
- return error;
- rate = dtoh32(rate);
- vwrq->value = rate * 500000;
-
- return 0;
-}
-
-static int
-wl_iw_set_rts(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, rts;
-
- WL_TRACE(("%s: SIOCSIWRTS\n", dev->name));
-
- if (vwrq->disabled)
- rts = DOT11_DEFAULT_RTS_LEN;
- else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_RTS_LEN)
- return -EINVAL;
- else
- rts = vwrq->value;
-
- if ((error = dev_wlc_intvar_set(dev, "rtsthresh", rts)))
- return error;
-
- return 0;
-}
-
-static int
-wl_iw_get_rts(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, rts;
-
- WL_TRACE(("%s: SIOCGIWRTS\n", dev->name));
-
- if ((error = dev_wlc_intvar_get(dev, "rtsthresh", &rts)))
- return error;
-
- vwrq->value = rts;
- vwrq->disabled = (rts >= DOT11_DEFAULT_RTS_LEN);
- vwrq->fixed = 1;
-
- return 0;
-}
-
-static int
-wl_iw_set_frag(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, frag;
-
- WL_TRACE(("%s: SIOCSIWFRAG\n", dev->name));
-
- if (vwrq->disabled)
- frag = DOT11_DEFAULT_FRAG_LEN;
- else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_FRAG_LEN)
- return -EINVAL;
- else
- frag = vwrq->value;
-
- if ((error = dev_wlc_intvar_set(dev, "fragthresh", frag)))
- return error;
-
- return 0;
-}
-
-static int
-wl_iw_get_frag(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, fragthreshold;
-
- WL_TRACE(("%s: SIOCGIWFRAG\n", dev->name));
-
- if ((error = dev_wlc_intvar_get(dev, "fragthresh", &fragthreshold)))
- return error;
-
- vwrq->value = fragthreshold;
- vwrq->disabled = (fragthreshold >= DOT11_DEFAULT_FRAG_LEN);
- vwrq->fixed = 1;
-
- return 0;
-}
-
-static int
-wl_iw_set_txpow(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, disable;
- uint16 txpwrmw;
- WL_TRACE(("%s: SIOCSIWTXPOW\n", dev->name));
-
-
- disable = vwrq->disabled ? WL_RADIO_SW_DISABLE : 0;
- disable += WL_RADIO_SW_DISABLE << 16;
-
- disable = htod32(disable);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_RADIO, &disable, sizeof(disable))))
- return error;
-
-
- if (disable & WL_RADIO_SW_DISABLE)
- return 0;
-
-
- if (!(vwrq->flags & IW_TXPOW_MWATT))
- return -EINVAL;
-
-
- if (vwrq->value < 0)
- return 0;
-
- if (vwrq->value > 0xffff) txpwrmw = 0xffff;
- else txpwrmw = (uint16)vwrq->value;
-
-
- error = dev_wlc_intvar_set(dev, "qtxpower", (int)(bcm_mw_to_qdbm(txpwrmw)));
- return error;
-}
-
-static int
-wl_iw_get_txpow(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, disable, txpwrdbm;
- uint8 result;
-
- WL_TRACE(("%s: SIOCGIWTXPOW\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_RADIO, &disable, sizeof(disable))) ||
- (error = dev_wlc_intvar_get(dev, "qtxpower", &txpwrdbm)))
- return error;
-
- disable = dtoh32(disable);
- result = (uint8)(txpwrdbm & ~WL_TXPWR_OVERRIDE);
- vwrq->value = (int32)bcm_qdbm_to_mw(result);
- vwrq->fixed = 0;
- vwrq->disabled = (disable & (WL_RADIO_SW_DISABLE | WL_RADIO_HW_DISABLE)) ? 1 : 0;
- vwrq->flags = IW_TXPOW_MWATT;
-
- return 0;
-}
-
-#if WIRELESS_EXT > 10
-static int
-wl_iw_set_retry(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, lrl, srl;
-
- WL_TRACE(("%s: SIOCSIWRETRY\n", dev->name));
-
-
- if (vwrq->disabled || (vwrq->flags & IW_RETRY_LIFETIME))
- return -EINVAL;
-
-
- if (vwrq->flags & IW_RETRY_LIMIT) {
-
-
-#if WIRELESS_EXT > 20
- if ((vwrq->flags & IW_RETRY_LONG) ||(vwrq->flags & IW_RETRY_MAX) ||
- !((vwrq->flags & IW_RETRY_SHORT) || (vwrq->flags & IW_RETRY_MIN))) {
-#else
- if ((vwrq->flags & IW_RETRY_MAX) || !(vwrq->flags & IW_RETRY_MIN)) {
-#endif
- lrl = htod32(vwrq->value);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_LRL, &lrl, sizeof(lrl))))
- return error;
- }
-
-
-#if WIRELESS_EXT > 20
- if ((vwrq->flags & IW_RETRY_SHORT) ||(vwrq->flags & IW_RETRY_MIN) ||
- !((vwrq->flags & IW_RETRY_LONG) || (vwrq->flags & IW_RETRY_MAX))) {
-#else
- if ((vwrq->flags & IW_RETRY_MIN) || !(vwrq->flags & IW_RETRY_MAX)) {
-#endif
- srl = htod32(vwrq->value);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_SRL, &srl, sizeof(srl))))
- return error;
- }
- }
- return 0;
-}
-
-static int
-wl_iw_get_retry(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, lrl, srl;
-
- WL_TRACE(("%s: SIOCGIWRETRY\n", dev->name));
-
- vwrq->disabled = 0;
-
-
- if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
- return -EINVAL;
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_LRL, &lrl, sizeof(lrl))) ||
- (error = dev_wlc_ioctl(dev, WLC_GET_SRL, &srl, sizeof(srl))))
- return error;
-
- lrl = dtoh32(lrl);
- srl = dtoh32(srl);
-
-
- if (vwrq->flags & IW_RETRY_MAX) {
- vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
- vwrq->value = lrl;
- } else {
- vwrq->flags = IW_RETRY_LIMIT;
- vwrq->value = srl;
- if (srl != lrl)
- vwrq->flags |= IW_RETRY_MIN;
- }
-
- return 0;
-}
-#endif
-
-static int
-wl_iw_set_encode(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_wsec_key_t key;
- int error, val, wsec;
-
- WL_TRACE(("%s: SIOCSIWENCODE\n", dev->name));
-
- memset(&key, 0, sizeof(key));
-
- if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
-
- for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
- val = htod32(key.index);
- if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
- return error;
- val = dtoh32(val);
- if (val)
- break;
- }
-
- if (key.index == DOT11_MAX_DEFAULT_KEYS)
- key.index = 0;
- } else {
- key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
- if (key.index >= DOT11_MAX_DEFAULT_KEYS)
- return -EINVAL;
- }
-
-
- if (!extra || !dwrq->length || (dwrq->flags & IW_ENCODE_NOKEY)) {
-
- val = htod32(key.index);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &val, sizeof(val))))
- return error;
- } else {
- key.len = dwrq->length;
-
- if (dwrq->length > sizeof(key.data))
- return -EINVAL;
-
- memcpy(key.data, extra, dwrq->length);
-
- key.flags = WL_PRIMARY_KEY;
- switch (key.len) {
- case WEP1_KEY_SIZE:
- key.algo = CRYPTO_ALGO_WEP1;
- break;
- case WEP128_KEY_SIZE:
- key.algo = CRYPTO_ALGO_WEP128;
- break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
- case TKIP_KEY_SIZE:
- key.algo = CRYPTO_ALGO_TKIP;
- break;
-#endif
- case AES_KEY_SIZE:
- key.algo = CRYPTO_ALGO_AES_CCM;
- break;
- default:
- return -EINVAL;
- }
-
-
- swap_key_from_BE(&key);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key))))
- return error;
- }
-
-
- val = (dwrq->flags & IW_ENCODE_DISABLED) ? 0 : WEP_ENABLED;
-
- if ((error = dev_wlc_intvar_get(dev, "wsec", &wsec)))
- return error;
-
- wsec &= ~(WEP_ENABLED);
- wsec |= val;
-
- if ((error = dev_wlc_intvar_set(dev, "wsec", wsec)))
- return error;
-
-
- val = (dwrq->flags & IW_ENCODE_RESTRICTED) ? 1 : 0;
- val = htod32(val);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val))))
- return error;
-
- return 0;
-}
-
-static int
-wl_iw_get_encode(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_wsec_key_t key;
- int error, val, wsec, auth;
-
- WL_TRACE(("%s: SIOCGIWENCODE\n", dev->name));
-
-
- bzero(&key, sizeof(wl_wsec_key_t));
-
- if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
-
- for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
- val = key.index;
- if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
- return error;
- val = dtoh32(val);
- if (val)
- break;
- }
- } else
- key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-
- if (key.index >= DOT11_MAX_DEFAULT_KEYS)
- key.index = 0;
-
-
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec))) ||
- (error = dev_wlc_ioctl(dev, WLC_GET_AUTH, &auth, sizeof(auth))))
- return error;
-
- swap_key_to_BE(&key);
-
- wsec = dtoh32(wsec);
- auth = dtoh32(auth);
-
- dwrq->length = MIN(DOT11_MAX_KEY_SIZE, key.len);
-
-
- dwrq->flags = key.index + 1;
- if (!(wsec & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))) {
-
- dwrq->flags |= IW_ENCODE_DISABLED;
- }
- if (auth) {
-
- dwrq->flags |= IW_ENCODE_RESTRICTED;
- }
-
-
- if (dwrq->length && extra)
- memcpy(extra, key.data, dwrq->length);
-
- return 0;
-}
-
-static int
-wl_iw_set_power(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, pm;
-
- WL_TRACE(("%s: SIOCSIWPOWER\n", dev->name));
-
- pm = vwrq->disabled ? PM_OFF : PM_MAX;
-
- pm = htod32(pm);
- if ((error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm))))
- return error;
-
- return 0;
-}
-
-static int
-wl_iw_get_power(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error, pm;
-
- WL_TRACE(("%s: SIOCGIWPOWER\n", dev->name));
-
- if ((error = dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))))
- return error;
-
- pm = dtoh32(pm);
- vwrq->disabled = pm ? 0 : 1;
- vwrq->flags = IW_POWER_ALL_R;
-
- return 0;
-}
-
-#if WIRELESS_EXT > 17
-static int
-wl_iw_set_wpaie(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *iwp,
- char *extra
-)
-{
- uchar buf[WLC_IOCTL_SMLEN] = {0};
- uchar *p = buf;
- int wapi_ie_size;
-
- WL_TRACE(("%s: SIOCSIWGENIE\n", dev->name));
-
- CHECK_EXTRA_FOR_NULL(extra);
-
- 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
- dev_wlc_bufvar_set(dev, "wpaie", extra, iwp->length);
-
- return 0;
-}
-
-static int
-wl_iw_get_wpaie(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *iwp,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCGIWGENIE\n", dev->name));
- iwp->length = 64;
- dev_wlc_bufvar_get(dev, "wpaie", extra, iwp->length);
- return 0;
-}
-
-static int
-wl_iw_set_encodeext(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *extra
-)
-{
- wl_wsec_key_t key;
- int error;
- struct iw_encode_ext *iwe;
-
- WL_TRACE(("%s: SIOCSIWENCODEEXT\n", dev->name));
-
- CHECK_EXTRA_FOR_NULL(extra);
-
- memset(&key, 0, sizeof(key));
- iwe = (struct iw_encode_ext *)extra;
-
-
- if (dwrq->flags & IW_ENCODE_DISABLED) {
-
- }
-
-
- key.index = 0;
- if (dwrq->flags & IW_ENCODE_INDEX)
- key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-
- key.len = iwe->key_len;
-
-
- if (!ETHER_ISMULTI(iwe->addr.sa_data))
- bcopy((void *)&iwe->addr.sa_data, (char *)&key.ea, ETHER_ADDR_LEN);
-
-
- if (key.len == 0) {
- if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
- WL_WSEC(("Changing the the primary Key to %d\n", key.index));
-
- key.index = htod32(key.index);
- error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY,
- &key.index, sizeof(key.index));
- if (error)
- return error;
- }
-
- else {
- swap_key_from_BE(&key);
- dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
- }
- }
- else {
- if (iwe->key_len > sizeof(key.data))
- return -EINVAL;
-
- WL_WSEC(("Setting the key index %d\n", key.index));
- if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
- WL_WSEC(("key is a Primary Key\n"));
- key.flags = WL_PRIMARY_KEY;
- }
-
- bcopy((void *)iwe->key, key.data, iwe->key_len);
-
- if (iwe->alg == IW_ENCODE_ALG_TKIP) {
- uint8 keybuf[8];
- bcopy(&key.data[24], keybuf, sizeof(keybuf));
- bcopy(&key.data[16], &key.data[24], sizeof(keybuf));
- bcopy(keybuf, &key.data[16], sizeof(keybuf));
- }
-
-
- if (iwe->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
- uchar *ivptr;
- ivptr = (uchar *)iwe->rx_seq;
- key.rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) |
- (ivptr[3] << 8) | ivptr[2];
- key.rxiv.lo = (ivptr[1] << 8) | ivptr[0];
- key.iv_initialized = TRUE;
- }
-
- switch (iwe->alg) {
- case IW_ENCODE_ALG_NONE:
- key.algo = CRYPTO_ALGO_OFF;
- break;
- case IW_ENCODE_ALG_WEP:
- if (iwe->key_len == WEP1_KEY_SIZE)
- key.algo = CRYPTO_ALGO_WEP1;
- else
- key.algo = CRYPTO_ALGO_WEP128;
- break;
- case IW_ENCODE_ALG_TKIP:
- key.algo = CRYPTO_ALGO_TKIP;
- break;
- case IW_ENCODE_ALG_CCMP:
- key.algo = CRYPTO_ALGO_AES_CCM;
- break;
- 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;
- default:
- break;
- }
- swap_key_from_BE(&key);
-
- dhd_wait_pend8021x(dev);
-
- error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
- if (error)
- return error;
- }
- return 0;
-}
-
-#if WIRELESS_EXT > 17
-#ifdef BCMWPA2
-struct {
- pmkid_list_t pmkids;
- pmkid_t foo[MAXPMKID-1];
-} pmkid_list;
-
-static int
-wl_iw_set_pmksa(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- struct iw_pmksa *iwpmksa;
- uint i;
- int ret = 0;
- char eabuf[ETHER_ADDR_STR_LEN];
-
- WL_WSEC(("%s: SIOCSIWPMKSA\n", dev->name));
-
- CHECK_EXTRA_FOR_NULL(extra);
-
- iwpmksa = (struct iw_pmksa *)extra;
- bzero((char *)eabuf, ETHER_ADDR_STR_LEN);
-
- if (iwpmksa->cmd == IW_PMKSA_FLUSH) {
- WL_WSEC(("wl_iw_set_pmksa - IW_PMKSA_FLUSH\n"));
- bzero((char *)&pmkid_list, sizeof(pmkid_list));
- }
-
- else if (iwpmksa->cmd == IW_PMKSA_REMOVE) {
- {
- pmkid_list_t pmkid, *pmkidptr;
- uint j;
- pmkidptr = &pmkid;
-
- bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, \
- ETHER_ADDR_LEN);
- bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID, WPA2_PMKID_LEN);
-
- WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_REMOVE - PMKID: %s = ",
- bcm_ether_ntoa(&pmkidptr->pmkid[0].BSSID,
- eabuf)));
- for (j = 0; j < WPA2_PMKID_LEN; j++)
- WL_WSEC(("%02x ", pmkidptr->pmkid[0].PMKID[j]));
- WL_WSEC(("\n"));
- }
-
- for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
- if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
- ETHER_ADDR_LEN))
- break;
-
- if ((pmkid_list.pmkids.npmkid > 0) && (i < pmkid_list.pmkids.npmkid)) {
- bzero(&pmkid_list.pmkids.pmkid[i], sizeof(pmkid_t));
- for (; i < (pmkid_list.pmkids.npmkid - 1); i++) {
- bcopy(&pmkid_list.pmkids.pmkid[i+1].BSSID,
- &pmkid_list.pmkids.pmkid[i].BSSID,
- ETHER_ADDR_LEN);
- bcopy(&pmkid_list.pmkids.pmkid[i+1].PMKID,
- &pmkid_list.pmkids.pmkid[i].PMKID,
- WPA2_PMKID_LEN);
- }
- pmkid_list.pmkids.npmkid--;
- }
- else
- ret = -EINVAL;
- }
-
- else if (iwpmksa->cmd == IW_PMKSA_ADD) {
- for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
- if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
- ETHER_ADDR_LEN))
- break;
- if (i < MAXPMKID) {
- bcopy(&iwpmksa->bssid.sa_data[0],
- &pmkid_list.pmkids.pmkid[i].BSSID,
- ETHER_ADDR_LEN);
- bcopy(&iwpmksa->pmkid[0], &pmkid_list.pmkids.pmkid[i].PMKID,
- WPA2_PMKID_LEN);
- if (i == pmkid_list.pmkids.npmkid)
- pmkid_list.pmkids.npmkid++;
- }
- else
- ret = -EINVAL;
- {
- uint j;
- uint k;
- k = pmkid_list.pmkids.npmkid;
- WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %s = ",
- bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[k].BSSID,
- eabuf)));
- for (j = 0; j < WPA2_PMKID_LEN; j++)
- WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[k].PMKID[j]));
- WL_WSEC(("\n"));
- }
- }
- WL_WSEC(("PRINTING pmkid LIST - No of elements %d\n", pmkid_list.pmkids.npmkid));
- for (i = 0; i < pmkid_list.pmkids.npmkid; i++) {
- uint j;
- WL_WSEC(("PMKID[%d]: %s = ", i,
- bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[i].BSSID,
- eabuf)));
- for (j = 0; j < WPA2_PMKID_LEN; j++)
- WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]));
- WL_WSEC(("\n"));
- }
- WL_WSEC(("\n"));
-
- if (!ret)
- ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, \
- sizeof(pmkid_list));
- return ret;
-}
-#endif
-#endif
-
-static int
-wl_iw_get_encodeext(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- WL_TRACE(("%s: SIOCGIWENCODEEXT\n", dev->name));
- return 0;
-}
-
-static int
-wl_iw_set_wpaauth(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error = 0;
- int paramid;
- int paramval;
- int val = 0;
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
- WL_TRACE(("%s: SIOCSIWAUTH\n", dev->name));
-
-#if defined(SOFTAP)
- if (ap_cfg_running) {
- WL_TRACE(("%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
- return 0;
- }
-#endif
-
- paramid = vwrq->flags & IW_AUTH_INDEX;
- paramval = vwrq->value;
-
- WL_TRACE(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
- dev->name, paramid, paramval));
-
- switch (paramid) {
- case IW_AUTH_WPA_VERSION:
-
- if (paramval & IW_AUTH_WPA_VERSION_DISABLED)
- val = WPA_AUTH_DISABLED;
- else if (paramval & (IW_AUTH_WPA_VERSION_WPA))
- val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED;
-#ifdef BCMWPA2
- else if (paramval & IW_AUTH_WPA_VERSION_WPA2)
- val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
-#endif
- else if (paramval & IW_AUTH_WAPI_VERSION_1)
- val = WPA_AUTH_WAPI;
- WL_INFORM(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
- if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
- return error;
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- case IW_AUTH_CIPHER_GROUP:
-
-
- if (paramval & (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
- val = WEP_ENABLED;
- if (paramval & IW_AUTH_CIPHER_TKIP)
- val = TKIP_ENABLED;
- if (paramval & IW_AUTH_CIPHER_CCMP)
- val = AES_ENABLED;
- if (paramval & IW_AUTH_CIPHER_SMS4)
- val = SMS4_ENABLED;
-
- if (paramid == IW_AUTH_CIPHER_PAIRWISE) {
- iw->pwsec = val;
- val |= iw->gwsec;
- }
- else {
- iw->gwsec = val;
- val |= iw->pwsec;
- }
-
- if (iw->privacy_invoked && !val) {
- WL_WSEC(("%s: %s: 'Privacy invoked' TRUE but clearing wsec, assuming "
- "we're a WPS enrollee\n", dev->name, __FUNCTION__));
- if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
- WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
- return error;
- }
- } else if (val) {
- if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
- WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
- return error;
- }
- }
-
- if ((error = dev_wlc_intvar_set(dev, "wsec", val)))
- return error;
-
- break;
-
- case IW_AUTH_KEY_MGMT:
- if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
- return error;
-
- if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
- if (paramval & IW_AUTH_KEY_MGMT_PSK)
- val = WPA_AUTH_PSK;
- else
- val = WPA_AUTH_UNSPECIFIED;
- }
-#ifdef BCMWPA2
- else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) {
- if (paramval & IW_AUTH_KEY_MGMT_PSK)
- val = WPA2_AUTH_PSK;
- else
- val = WPA2_AUTH_UNSPECIFIED;
- }
-#endif
- if (paramval & (IW_AUTH_KEY_MGMT_WAPI_PSK | IW_AUTH_KEY_MGMT_WAPI_CERT))
- val = WPA_AUTH_WAPI;
- WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
- if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
- return error;
-
- break;
- case IW_AUTH_TKIP_COUNTERMEASURES:
- dev_wlc_bufvar_set(dev, "tkip_countermeasures", (char *)¶mval, 1);
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
-
- WL_INFORM(("Setting the D11auth %d\n", paramval));
- if (paramval == IW_AUTH_ALG_OPEN_SYSTEM)
- val = 0;
- else if (paramval == IW_AUTH_ALG_SHARED_KEY)
- val = 1;
- else if (paramval == (IW_AUTH_ALG_OPEN_SYSTEM | IW_AUTH_ALG_SHARED_KEY))
- val = 2;
- else
- error = 1;
- if (!error && (error = dev_wlc_intvar_set(dev, "auth", val)))
- return error;
- break;
-
- case IW_AUTH_WPA_ENABLED:
- if (paramval == 0) {
- iw->pwsec = 0;
- iw->gwsec = 0;
- if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
- return error;
- if (val & (TKIP_ENABLED | AES_ENABLED)) {
- val &= ~(TKIP_ENABLED | AES_ENABLED);
- dev_wlc_intvar_set(dev, "wsec", val);
- }
- val = 0;
- WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
- dev_wlc_intvar_set(dev, "wpa_auth", 0);
- return error;
- }
-
-
- break;
-
- case IW_AUTH_DROP_UNENCRYPTED:
- dev_wlc_bufvar_set(dev, "wsec_restrict", (char *)¶mval, 1);
- break;
-
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
- break;
-
-#if WIRELESS_EXT > 17
- case IW_AUTH_ROAMING_CONTROL:
- WL_INFORM(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
-
- break;
- case IW_AUTH_PRIVACY_INVOKED: {
- int wsec;
-
- if (paramval == 0) {
- iw->privacy_invoked = FALSE;
- if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
- WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
- return error;
- }
- } else {
- iw->privacy_invoked = TRUE;
- if ((error = dev_wlc_intvar_get(dev, "wsec", &wsec)))
- return error;
-
- if (!(IW_WSEC_ENABLED(wsec))) {
-
-
- if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
- WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
- return error;
- }
- } else {
- if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
- WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
- return error;
- }
- }
- }
- break;
- }
-#endif
- 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", WPA_AUTH_WAPI))) {
- WL_ERROR(("%s: setting wpa_auth(WPA_AUTH_WAPI) returned %d\n",
- __FUNCTION__, error));
- return error;
- }
- }
-
- break;
- default:
- break;
- }
- return 0;
-}
-#ifdef BCMWPA2
-#define VAL_PSK(_val) (((_val) & WPA_AUTH_PSK) || ((_val) & WPA2_AUTH_PSK))
-#else
-#define VAL_PSK(_val) (((_val) & WPA_AUTH_PSK))
-#endif
-
-static int
-wl_iw_get_wpaauth(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *vwrq,
- char *extra
-)
-{
- int error;
- int paramid;
- int paramval = 0;
- int val;
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
- WL_TRACE(("%s: SIOCGIWAUTH\n", dev->name));
-
- paramid = vwrq->flags & IW_AUTH_INDEX;
-
- switch (paramid) {
- case IW_AUTH_WPA_VERSION:
-
- if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
- return error;
- if (val & (WPA_AUTH_NONE | WPA_AUTH_DISABLED))
- paramval = IW_AUTH_WPA_VERSION_DISABLED;
- else if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED))
- paramval = IW_AUTH_WPA_VERSION_WPA;
-#ifdef BCMWPA2
- else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED))
- paramval = IW_AUTH_WPA_VERSION_WPA2;
-#endif
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- case IW_AUTH_CIPHER_GROUP:
- if (paramid == IW_AUTH_CIPHER_PAIRWISE)
- val = iw->pwsec;
- else
- val = iw->gwsec;
-
- paramval = 0;
- if (val) {
- if (val & WEP_ENABLED)
- paramval |= (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104);
- if (val & TKIP_ENABLED)
- paramval |= (IW_AUTH_CIPHER_TKIP);
- if (val & AES_ENABLED)
- paramval |= (IW_AUTH_CIPHER_CCMP);
- }
- else
- paramval = IW_AUTH_CIPHER_NONE;
- break;
- case IW_AUTH_KEY_MGMT:
-
- if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
- return error;
- if (VAL_PSK(val))
- paramval = IW_AUTH_KEY_MGMT_PSK;
- else
- paramval = IW_AUTH_KEY_MGMT_802_1X;
-
- break;
- case IW_AUTH_TKIP_COUNTERMEASURES:
- dev_wlc_bufvar_get(dev, "tkip_countermeasures", (char *)¶mval, 1);
- break;
-
- case IW_AUTH_DROP_UNENCRYPTED:
- dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)¶mval, 1);
- break;
-
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)¶mval, 1);
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
-
- if ((error = dev_wlc_intvar_get(dev, "auth", &val)))
- return error;
- if (!val)
- paramval = IW_AUTH_ALG_OPEN_SYSTEM;
- else
- paramval = IW_AUTH_ALG_SHARED_KEY;
- break;
- case IW_AUTH_WPA_ENABLED:
- if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
- return error;
- if (val)
- paramval = TRUE;
- else
- paramval = FALSE;
- break;
-#if WIRELESS_EXT > 17
- case IW_AUTH_ROAMING_CONTROL:
- WL_ERROR(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
-
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- paramval = iw->privacy_invoked;
- break;
-
-#endif
- }
- vwrq->value = paramval;
- return 0;
-}
-#endif
-
-
-#ifdef SOFTAP
-
-static int ap_macmode = MACLIST_MODE_DISABLED;
-static struct mflist ap_black_list;
-static int
-wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
-{
- char hex[] = "XX";
- unsigned char *data = key->data;
-
- switch (strlen(keystr)) {
- case 5:
- case 13:
- case 16:
- key->len = strlen(keystr);
- memcpy(data, keystr, key->len + 1);
- break;
- case 12:
- case 28:
- case 34:
- case 66:
-
- if (!strnicmp(keystr, "0x", 2))
- keystr += 2;
- else
- return -1;
-
- case 10:
- case 26:
- case 32:
- case 64:
- key->len = strlen(keystr) / 2;
- while (*keystr) {
- strncpy(hex, keystr, 2);
- *data++ = (char) bcm_strtoul(hex, NULL, 16);
- keystr += 2;
- }
- break;
- default:
- return -1;
- }
-
- switch (key->len) {
- case 5:
- key->algo = CRYPTO_ALGO_WEP1;
- break;
- case 13:
- key->algo = CRYPTO_ALGO_WEP128;
- break;
- case 16:
-
- key->algo = CRYPTO_ALGO_AES_CCM;
- break;
- case 32:
- key->algo = CRYPTO_ALGO_TKIP;
- break;
- default:
- return -1;
- }
-
-
- key->flags |= WL_PRIMARY_KEY;
-
- return 0;
-}
-
-#ifdef EXT_WPA_CRYPTO
-#define SHA1HashSize 20
-extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
- int iterations, u8 *buf, size_t buflen);
-
-#else
-
-#define SHA1HashSize 20
-int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
- int iterations, u8 *buf, size_t buflen)
-{
- WL_ERROR(("WARNING: %s is not implemented !!!\n", __FUNCTION__));
- return -1;
-}
-
-#endif
-
-
-int dev_iw_write_cfg1_bss_var(struct net_device *dev, int val)
-{
- struct {
- int cfg;
- int val;
- } bss_setbuf;
-
- int bss_set_res;
- char smbuf[WLC_IOCTL_SMLEN];
- memset(smbuf, 0, sizeof(smbuf));
-
- bss_setbuf.cfg = 1;
- bss_setbuf.val = val;
-
- bss_set_res = dev_iw_iovar_setbuf(dev, "bss",
- &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf));
- WL_TRACE(("%s: bss_set_result:%d set with %d\n", __FUNCTION__, bss_set_res, val));
-
- return bss_set_res;
-}
-
-
-int dev_iw_read_cfg1_bss_var(struct net_device *dev, int *val)
-{
- int bsscfg_idx = 1;
- int bss_set_res;
- char smbuf[WLC_IOCTL_SMLEN];
- memset(smbuf, 0, sizeof(smbuf));
-
- bss_set_res = dev_iw_iovar_getbuf(dev, "bss", \
- &bsscfg_idx, sizeof(bsscfg_idx), smbuf, sizeof(smbuf));
- *val = *(int*)smbuf;
- *val = dtoh32(*val);
- WL_TRACE(("%s: status=%d bss_get_result=%d\n", __FUNCTION__, bss_set_res, *val));
- return bss_set_res;
-}
-
-
-
-#ifndef AP_ONLY
-static int wl_bssiovar_mkbuf(
- const char *iovar,
- int bssidx,
- void *param,
- int paramlen,
- void *bufptr,
- int buflen,
- int *perr)
-{
- const char *prefix = "bsscfg:";
- int8* p;
- uint prefixlen;
- uint namelen;
- uint iolen;
-
- prefixlen = strlen(prefix);
- namelen = strlen(iovar) + 1;
- iolen = prefixlen + namelen + sizeof(int) + paramlen;
-
-
- if (buflen < 0 || iolen > (uint)buflen) {
- *perr = BCME_BUFTOOSHORT;
- return 0;
- }
-
- p = (int8*)bufptr;
-
-
- memcpy(p, prefix, prefixlen);
- p += prefixlen;
-
-
- memcpy(p, iovar, namelen);
- p += namelen;
-
-
- bssidx = htod32(bssidx);
- memcpy(p, &bssidx, sizeof(int32));
- p += sizeof(int32);
-
-
- if (paramlen)
- memcpy(p, param, paramlen);
-
- *perr = 0;
- return iolen;
-}
-#endif
-
-
-
-
-int get_user_params(char *user_params, struct iw_point *dwrq)
-{
- int ret = 0;
-
- if (copy_from_user(user_params, dwrq->pointer, dwrq->length)) {
- WL_ERROR(("\n%s: no user params: uptr:%p, ulen:%d\n",
- __FUNCTION__, dwrq->pointer, dwrq->length));
- return -EFAULT;
- }
-
- WL_TRACE(("\n%s: iwpriv user params:%s\n", __FUNCTION__, user_params));
-
- return ret;
-}
-
-
-#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
-
-#endif /* SOFTAP */
-
-
-#if defined(CSCAN)
-
-static int
-wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nssid, int nchan)
-{
- int params_size = WL_SCAN_PARAMS_FIXED_SIZE + WL_NUMCHANNELS * sizeof(uint16);
- int err = 0;
- char *p;
- int i;
- iscan_info_t *iscan = g_iscan;
-
- WL_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
-
- if ((!dev) && (!g_iscan) && (!iscan->iscan_ex_params_p)) {
- WL_ERROR(("%s error exit\n", __FUNCTION__));
- err = -1;
- }
-
- params_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
-
-
- if (nssid > 0) {
- i = OFFSETOF(wl_scan_params_t, channel_list) + nchan * sizeof(uint16);
- i = ROUNDUP(i, sizeof(uint32));
- if (i + nssid * sizeof(wlc_ssid_t) > params_size) {
- printf("additional ssids exceed params_size\n");
- err = -1;
- goto exit;
- }
-
- p = ((char*)&iscan->iscan_ex_params_p->params) + i;
- memcpy(p, ssids_local, nssid * sizeof(wlc_ssid_t));
- p += nssid * sizeof(wlc_ssid_t);
- } else {
- p = (char*)iscan->iscan_ex_params_p->params.channel_list + nchan * sizeof(uint16);
- }
-
-
- iscan->iscan_ex_params_p->params.channel_num = \
- htod32((nssid << WL_SCAN_PARAMS_NSSID_SHIFT) | \
- (nchan & WL_SCAN_PARAMS_COUNT_MASK));
-
- nssid = \
- (uint)((iscan->iscan_ex_params_p->params.channel_num >> WL_SCAN_PARAMS_NSSID_SHIFT) & \
- WL_SCAN_PARAMS_COUNT_MASK);
-
-
- params_size = (int) (p - (char*)iscan->iscan_ex_params_p + nssid * sizeof(wlc_ssid_t));
- iscan->iscan_ex_param_size = params_size;
-
- iscan->list_cur = iscan->list_hdr;
- iscan->iscan_state = ISCAN_STATE_SCANING;
- wl_iw_set_event_mask(dev);
- mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-
- iscan->timer_on = 1;
-
-#ifdef SCAN_DUMP
- {
- int i;
- WL_SCAN(("\n### List of SSIDs to scan ###\n"));
- for (i = 0; i < nssid; i++) {
- if (!ssids_local[i].SSID_len)
- WL_SCAN(("%d: Broadcast scan\n", i));
- else
- WL_SCAN(("%d: scan for %s size =%d\n", i, \
- ssids_local[i].SSID, ssids_local[i].SSID_len));
- }
- WL_SCAN(("### List of channels to scan ###\n"));
- for (i = 0; i < nchan; i++)
- {
- WL_SCAN(("%d ", iscan->iscan_ex_params_p->params.channel_list[i]));
- }
- WL_SCAN(("\nnprobes=%d\n", iscan->iscan_ex_params_p->params.nprobes));
- WL_SCAN(("active_time=%d\n", iscan->iscan_ex_params_p->params.active_time));
- WL_SCAN(("passive_time=%d\n", iscan->iscan_ex_params_p->params.passive_time));
- WL_SCAN(("home_time=%d\n", iscan->iscan_ex_params_p->params.home_time));
- WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
- WL_SCAN(("\n###################\n"));
- }
-#endif
-
- if (params_size > WLC_IOCTL_MEDLEN) {
- WL_ERROR(("Set ISCAN for %s due to params_size=%d \n", \
- __FUNCTION__, params_size));
- err = -1;
- }
-
- if ((err = dev_iw_iovar_setbuf(dev, "iscan", iscan->iscan_ex_params_p, \
- iscan->iscan_ex_param_size, \
- iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
- WL_TRACE(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
- err = -1;
- }
-
-exit:
-
- return err;
-}
-
-
-static int iwpriv_set_cscan(struct net_device *dev, struct iw_request_info *info, \
- union iwreq_data *wrqu, char *ext)
-{
- int res = 0;
- char *extra = NULL;
- iscan_info_t *iscan = g_iscan;
- wlc_ssid_t ssids_local[WL_SCAN_PARAMS_SSID_MAX];
- int nssid = 0;
- int nchan = 0;
-
- WL_TRACE(("\%s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
- __FUNCTION__, info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length));
-
- if (g_onoff == G_WLAN_SET_OFF) {
- WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
- return -1;
- }
-
- if (wrqu->data.length != 0) {
-
- char *str_ptr;
-
- if (!iscan->iscan_ex_params_p) {
- return -EFAULT;
- }
-
- if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
- return -ENOMEM;
-
- if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
- kfree(extra);
- return -EFAULT;
- }
-
- extra[wrqu->data.length] = 0;
- WL_ERROR(("Got str param in iw_point:\n %s\n", extra));
-
- str_ptr = extra;
-
-
- if (strncmp(str_ptr, GET_SSID, strlen(GET_SSID))) {
- WL_ERROR(("%s Error: extracting SSID='' string\n", __FUNCTION__));
- goto exit_proc;
- }
- str_ptr += strlen(GET_SSID);
- nssid = wl_iw_parse_ssid_list(&str_ptr, ssids_local, nssid, \
- WL_SCAN_PARAMS_SSID_MAX);
- if (nssid == -1) {
- WL_ERROR(("%s wrong ssid list", __FUNCTION__));
- return -1;
- }
-
- memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
- ASSERT(iscan->iscan_ex_param_size < WLC_IOCTL_MAXLEN);
-
-
- wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
- iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
- iscan->iscan_ex_params_p->action = htod16(WL_SCAN_ACTION_START);
- iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
-
- if ((nchan = wl_iw_parse_channel_list(&str_ptr, \
- &iscan->iscan_ex_params_p->params.channel_list[0], \
- WL_NUMCHANNELS)) == -1) {
- WL_ERROR(("%s missing channel list\n", __FUNCTION__));
- return -1;
- }
-
-
- get_parmeter_from_string(&str_ptr, \
- GET_NPROBE, PTYPE_INTDEC, \
- &iscan->iscan_ex_params_p->params.nprobes, 2);
-
- get_parmeter_from_string(&str_ptr, GET_ACTIVE_ASSOC_DWELL, PTYPE_INTDEC, \
- &iscan->iscan_ex_params_p->params.active_time, 4);
-
- get_parmeter_from_string(&str_ptr, GET_PASSIVE_ASSOC_DWELL, PTYPE_INTDEC, \
- &iscan->iscan_ex_params_p->params.passive_time, 4);
-
- get_parmeter_from_string(&str_ptr, GET_HOME_DWELL, PTYPE_INTDEC, \
- &iscan->iscan_ex_params_p->params.home_time, 4);
-
- get_parmeter_from_string(&str_ptr, GET_SCAN_TYPE, PTYPE_INTDEC, \
- &iscan->iscan_ex_params_p->params.scan_type, 1);
-
-
- res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
-
- } else {
-
- WL_ERROR(("IWPRIV argument len = 0 \n"));
- return -1;
- }
-
-exit_proc:
-
- kfree(extra);
-
- return res;
-}
-
-
-static int
-wl_iw_set_cscan(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra
-)
-{
- int res = -1;
- iscan_info_t *iscan = g_iscan;
- wlc_ssid_t ssids_local[WL_SCAN_PARAMS_SSID_MAX];
- int nssid = 0;
- int nchan = 0;
- cscan_tlv_t *cscan_tlv_temp;
- char type;
- char *str_ptr;
- int tlv_size_left;
-#ifdef TLV_DEBUG
- int i;
- char tlv_in_example[] = { 'C', 'S', 'C', 'A', 'N', ' ', \
- 0x53, 0x01, 0x00, 0x00,
- 'S',
- 0x00,
- 'S',
- 0x04,
- 'B', 'R', 'C', 'M',
- 'C',
- 0x06,
- 'P',
- 0x94,
- 0x11,
- 'T',
- 0x01
- };
-#endif
-
- WL_TRACE(("\n### %s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
- __FUNCTION__, info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length));
-
- if (g_onoff == G_WLAN_SET_OFF) {
- WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
- return -1;
- }
-
- if (wrqu->data.length < (strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t))) {
- WL_ERROR(("%s aggument=%d less %d\n", __FUNCTION__, \
- wrqu->data.length, strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t)));
- return -1;
- }
-
-#ifdef TLV_DEBUG
- memcpy(extra, tlv_in_example, sizeof(tlv_in_example));
- wrqu->data.length = sizeof(tlv_in_example);
- for (i = 0; i < wrqu->data.length; i++)
- printf("%02X ", extra[i]);
- printf("\n");
-#endif
-
- str_ptr = extra;
- str_ptr += strlen(CSCAN_COMMAND);
- tlv_size_left = wrqu->data.length - strlen(CSCAN_COMMAND);
-
- cscan_tlv_temp = (cscan_tlv_t *)str_ptr;
- memset(ssids_local, 0, sizeof(ssids_local));
-
- if ((cscan_tlv_temp->prefix == CSCAN_TLV_PREFIX) && \
- (cscan_tlv_temp->version == CSCAN_TLV_VERSION) && \
- (cscan_tlv_temp->subver == CSCAN_TLV_SUBVERSION))
- {
- str_ptr += sizeof(cscan_tlv_t);
- tlv_size_left -= sizeof(cscan_tlv_t);
-
-
- if ((nssid = wl_iw_parse_ssid_list_tlv(&str_ptr, ssids_local, \
- WL_SCAN_PARAMS_SSID_MAX, &tlv_size_left)) <= 0) {
- WL_ERROR(("SSID is not presented or corrupted ret=%d\n", nssid));
- goto exit_proc;
- }
- else {
-
- memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
-
-
- wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
- iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
- iscan->iscan_ex_params_p->action = htod16(WL_SCAN_ACTION_START);
- iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
-
- while (tlv_size_left > 0)
- {
- type = str_ptr[0];
- switch (type) {
- case CSCAN_TLV_TYPE_CHANNEL_IE:
-
- if ((nchan = wl_iw_parse_channel_list_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.channel_list[0], \
- WL_NUMCHANNELS, &tlv_size_left)) == -1) {
- WL_ERROR(("%s missing channel list\n", \
- __FUNCTION__));
- goto exit_proc;
- }
- break;
- case CSCAN_TLV_TYPE_NPROBE_IE:
- if ((res = wl_iw_parse_data_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.nprobes, \
- sizeof(iscan->iscan_ex_params_p->params.nprobes), \
- type, sizeof(char), &tlv_size_left)) == -1) {
- WL_ERROR(("%s return %d\n", \
- __FUNCTION__, res));
- goto exit_proc;
- }
- break;
- case CSCAN_TLV_TYPE_ACTIVE_IE:
- if ((res = wl_iw_parse_data_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.active_time, \
- sizeof(iscan->iscan_ex_params_p->params.active_time), \
- type, sizeof(short), &tlv_size_left)) == -1) {
- WL_ERROR(("%s return %d\n", \
- __FUNCTION__, res));
- goto exit_proc;
- }
- break;
- case CSCAN_TLV_TYPE_PASSIVE_IE:
- if ((res = wl_iw_parse_data_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.passive_time, \
- sizeof(iscan->iscan_ex_params_p->params.passive_time), \
- type, sizeof(short), &tlv_size_left)) == -1) {
- WL_ERROR(("%s return %d\n", \
- __FUNCTION__, res));
- goto exit_proc;
- }
- break;
- case CSCAN_TLV_TYPE_HOME_IE:
- if ((res = wl_iw_parse_data_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.home_time, \
- sizeof(iscan->iscan_ex_params_p->params.home_time), \
- type, sizeof(short), &tlv_size_left)) == -1) {
- WL_ERROR(("%s return %d\n", \
- __FUNCTION__, res));
- goto exit_proc;
- }
- break;
- case CSCAN_TLV_TYPE_STYPE_IE:
- if ((res = wl_iw_parse_data_tlv(&str_ptr, \
- &iscan->iscan_ex_params_p->params.scan_type, \
- sizeof(iscan->iscan_ex_params_p->params.scan_type), \
- type, sizeof(char), &tlv_size_left)) == -1) {
- WL_ERROR(("%s return %d\n", \
- __FUNCTION__, res));
- goto exit_proc;
- }
- break;
-
- default :
- WL_ERROR(("%s get unkwown type %X\n", \
- __FUNCTION__, type));
- goto exit_proc;
- break;
- }
- }
- }
- }
- else {
- WL_ERROR(("%s get wrong TLV command\n", __FUNCTION__));
- goto exit_proc;
- }
-
-
- res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
-
-exit_proc:
- return res;
-}
-
-#endif
-
-
-
-#ifdef SOFTAP
-
-#ifndef AP_ONLY
-static int thr_wait_for_2nd_eth_dev(void *data)
-{
- int ret = 0;
-
- printk("==========> WARNING!!! we are in thr_wait_for_2nd_eth_dev!!!\n");
-
- DAEMONIZE("wl0_eth_wthread");
-
- WL_TRACE(("\n>%s threda started:, PID:%x\n", __FUNCTION__, current->pid));
-
-/* if (down_timeout(&ap_eth_sema, msecs_to_jiffies(5000)) != 0) {
- WL_ERROR(("\n%s: sap_eth_sema timeout \n", __FUNCTION__));
- ret = -1;
- goto fail;
- }
-*/
- if (!ap_net_dev) {
- WL_ERROR((" ap_net_dev is null !!!"));
- ret = -1;
- goto fail;
- }
-
- WL_TRACE(("\n>%s: Thread:'softap ethdev IF:%s is detected !!!'\n\n",
- __FUNCTION__, ap_net_dev->name));
-
- ap_cfg_running = TRUE;
-
- bcm_mdelay(500);
-
-
- wl_iw_send_priv_event(priv_dev, "AP_SET_CFG_OK");
-
-fail:
-
- WL_TRACE(("\n>%s, thread completed\n", __FUNCTION__));
-
- return ret;
-}
-#endif
-
-#ifndef AP_ONLY
-static int last_auto_channel = 6;
-#endif
-static int get_softap_auto_channel(struct net_device *dev, struct ap_profile *ap)
-{
- int chosen = 0;
- wl_uint32_list_t request;
- int rescan = 0;
- int retry = 0;
- int updown = 0;
- int ret = 0;
- wlc_ssid_t null_ssid;
- int res = 0;
-#ifndef AP_ONLY
- int iolen = 0;
- int mkvar_err = 0;
- int bsscfg_index = 1;
- char buf[WLC_IOCTL_SMLEN];
-#endif
- WL_SOFTAP(("Enter %s\n", __FUNCTION__));
-
-#ifndef AP_ONLY
- if (ap_cfg_running) {
- ap->channel = last_auto_channel;
- return res;
- }
-#endif
- memset(&null_ssid, 0, sizeof(wlc_ssid_t));
- res |= dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown));
-#ifdef AP_ONLY
- res |= dev_wlc_ioctl(dev, WLC_SET_SSID, &null_ssid, sizeof(null_ssid));
-#else
- iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&null_ssid), \
- null_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
- ASSERT(iolen);
- res |= dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen);
-#endif
- auto_channel_retry:
- request.count = htod32(0);
- ret = dev_wlc_ioctl(dev, WLC_START_CHANNEL_SEL, &request, sizeof(request));
- if (ret < 0) {
- WL_ERROR(("can't start auto channel scan\n"));
- goto fail;
- }
-
- get_channel_retry:
- bcm_mdelay(500);
-
- ret = dev_wlc_ioctl(dev, WLC_GET_CHANNEL_SEL, &chosen, sizeof(chosen));
- if (ret < 0 || dtoh32(chosen) == 0) {
- if (retry++ < 3)
- goto get_channel_retry;
- else {
- WL_ERROR(("can't get auto channel sel, err = %d, \
- chosen = %d\n", ret, chosen));
- goto fail;
- }
- }
- if ((chosen == 1) && (!rescan++))
- goto auto_channel_retry;
- WL_SOFTAP(("Set auto channel = %d\n", chosen));
- ap->channel = chosen;
- if ((res = dev_wlc_ioctl(dev, WLC_DOWN, &updown, sizeof(updown))) < 0) {
- WL_ERROR(("%s fail to set up err =%d\n", __FUNCTION__, res));
- goto fail;
- }
-#ifndef AP_ONLY
- if (!res)
- last_auto_channel = ap->channel;
-#endif
-
-fail :
- return res;
-}
-
-
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
-{
- int updown = 0;
- int channel = 0;
-
- wlc_ssid_t ap_ssid;
- int max_assoc = 8;
-
- int res = 0;
- int apsta_var = 0;
-#ifndef AP_ONLY
- int mpc = 0;
- int iolen = 0;
- int mkvar_err = 0;
- int bsscfg_index = 1;
- char buf[WLC_IOCTL_SMLEN];
-#endif
- wl_iw_t *iw;
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return -1;
- }
-
- WL_SOFTAP(("wl_iw: set ap profile:\n"));
- WL_SOFTAP((" ssid = '%s'\n", ap->ssid));
- WL_SOFTAP((" security = '%s'\n", ap->sec));
- if (ap->key[0] != '\0')
- WL_SOFTAP((" key = '%s'\n", ap->key));
- WL_SOFTAP((" channel = %d\n", ap->channel));
- WL_SOFTAP((" max scb = %d\n", ap->max_scb));
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_SET, "SoftAP_SET");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-
-#ifdef AP_ONLY
- if (ap_cfg_running) {
- wl_iw_softap_deassoc_stations(dev);
- ap_cfg_running = FALSE;
- }
-#endif
-
-
- if (ap_cfg_running == FALSE) {
-
-#ifndef AP_ONLY
-
-
- sema_init(&ap_eth_sema, 0);
-
- mpc = 0;
- if ((res = dev_wlc_intvar_set(dev, "mpc", mpc))) {
- WL_ERROR(("%s fail to set mpc\n", __FUNCTION__));
- goto fail;
- }
-#endif
-
- updown = 0;
- if ((res = dev_wlc_ioctl(dev, WLC_DOWN, &updown, sizeof(updown)))) {
- WL_ERROR(("%s fail to set updown\n", __FUNCTION__));
- goto fail;
- }
-
-#ifdef AP_ONLY
-
- apsta_var = 0;
- if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
- WL_ERROR(("%s fail to set apsta_var 0\n", __FUNCTION__));
- goto fail;
- }
- apsta_var = 1;
- if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
- WL_ERROR(("%s fail to set apsta_var 1\n", __FUNCTION__));
- goto fail;
- }
- res = dev_wlc_ioctl(dev, WLC_GET_AP, &apsta_var, sizeof(apsta_var));
-#else
-
- apsta_var = 1;
- iolen = wl_bssiovar_mkbuf("apsta",
- bsscfg_index, &apsta_var, sizeof(apsta_var)+4,
- buf, sizeof(buf), &mkvar_err);
- ASSERT(iolen);
- if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
- WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
- goto fail;
- }
- WL_TRACE(("\n>in %s: apsta set result: %d \n", __FUNCTION__, res));
-#endif
-
- updown = 1;
- if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown))) < 0) {
- WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
- goto fail;
- }
-
- } else {
-
- if (!ap_net_dev) {
- WL_ERROR(("%s: ap_net_dev is null\n", __FUNCTION__));
- goto fail;
- }
-
- res = wl_iw_softap_deassoc_stations(ap_net_dev);
-
-
- if ((res = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
- WL_ERROR(("%s fail to set bss down\n", __FUNCTION__));
- goto fail;
- }
- }
-
-
- if ((ap->channel == 0) && (get_softap_auto_channel(dev, ap) < 0)) {
- ap->channel = 1;
- WL_ERROR(("%s auto channel failed, pick up channel=%d\n", \
- __FUNCTION__, ap->channel));
-
- }
-
- channel = ap->channel;
- if ((res = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &channel, sizeof(channel)))) {
- WL_ERROR(("%s fail to set channel\n", __FUNCTION__));
- goto fail;
- }
-
- if (ap_cfg_running == FALSE) {
- updown = 0;
- if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown)))) {
- WL_ERROR(("%s fail to set up\n", __FUNCTION__));
- goto fail;
- }
- }
-
- max_assoc = ap->max_scb;
- if ((res = dev_wlc_intvar_set(dev, "maxassoc", max_assoc))) {
- WL_ERROR(("%s fail to set maxassoc\n", __FUNCTION__));
- goto fail;
- }
-
- ap_ssid.SSID_len = strlen(ap->ssid);
- strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
-
-
-#ifdef AP_ONLY
- if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
- WL_ERROR(("ERROR:%d in:%s, wl_iw_set_ap_security is skipped\n", \
- res, __FUNCTION__));
- goto fail;
- }
- wl_iw_send_priv_event(dev, "ASCII_CMD=AP_BSS_START");
- ap_cfg_running = TRUE;
-#else
-
- iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&ap_ssid),
- ap_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
- ASSERT(iolen);
- if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) != 0) {
- WL_ERROR(("ERROR:%d in:%s, Security & BSS reconfiguration is skipped\n", \
- res, __FUNCTION__));
- goto fail;
- }
- if (ap_cfg_running == FALSE) {
-
- kernel_thread(thr_wait_for_2nd_eth_dev, 0, 0);
- } else {
-
-
- if (ap_net_dev == NULL) {
- WL_ERROR(("%s ERROR: ap_net_dev is NULL !!!\n", __FUNCTION__));
- goto fail;
- }
-
- WL_ERROR(("%s: %s Configure security & restart AP bss \n", \
- __FUNCTION__, ap_net_dev->name));
-
-
- if ((res = wl_iw_set_ap_security(ap_net_dev, &my_ap)) < 0) {
- WL_ERROR(("%s fail to set security : %d\n", __FUNCTION__, res));
- goto fail;
- }
-
-
- if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0) {
- WL_ERROR(("%s fail to set bss up\n", __FUNCTION__));
- goto fail;
- }
- }
-#endif
-fail:
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_SET);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
- WL_SOFTAP(("%s exit with %d\n", __FUNCTION__, res));
- return res;
-}
-
-
-static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
-{
- int wsec = 0;
- int wpa_auth = 0;
- int res = 0;
- int i;
- char *ptr;
-#ifdef AP_ONLY
- int mpc = 0;
- wlc_ssid_t ap_ssid;
-#endif
- wl_wsec_key_t key;
-
- WL_SOFTAP(("\nsetting SOFTAP security mode:\n"));
- WL_SOFTAP(("wl_iw: set ap profile:\n"));
- WL_SOFTAP((" ssid = '%s'\n", ap->ssid));
- WL_SOFTAP((" security = '%s'\n", ap->sec));
- if (ap->key[0] != '\0')
- WL_SOFTAP((" key = '%s'\n", ap->key));
- WL_SOFTAP((" channel = %d\n", ap->channel));
- WL_SOFTAP((" max scb = %d\n", ap->max_scb));
-
-
- if (strnicmp(ap->sec, "open", strlen("open")) == 0) {
-
-
- wsec = 0;
- res = dev_wlc_intvar_set(dev, "wsec", wsec);
- wpa_auth = WPA_AUTH_DISABLED;
- res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
- WL_SOFTAP(("=====================\n"));
- WL_SOFTAP((" wsec & wpa_auth set 'OPEN', result:&d %d\n", res));
- WL_SOFTAP(("=====================\n"));
-
- } else if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
-
-
- memset(&key, 0, sizeof(key));
-
- wsec = WEP_ENABLED;
- res = dev_wlc_intvar_set(dev, "wsec", wsec);
-
- key.index = 0;
- if (wl_iw_parse_wep(ap->key, &key)) {
- WL_SOFTAP(("wep key parse err!\n"));
- return -1;
- }
-
- key.index = htod32(key.index);
- key.len = htod32(key.len);
- key.algo = htod32(key.algo);
- key.flags = htod32(key.flags);
-
- res |= dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
-
- wpa_auth = WPA_AUTH_DISABLED;
- res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
- WL_SOFTAP(("=====================\n"));
- WL_SOFTAP((" wsec & auth set 'WEP', result:&d %d\n", res));
- WL_SOFTAP(("=====================\n"));
-
- } else if (strnicmp(ap->sec, "wpa2-psk", strlen("wpa2-psk")) == 0) {
-
-
-
- wsec_pmk_t psk;
- size_t key_len;
-
- wsec = AES_ENABLED;
- dev_wlc_intvar_set(dev, "wsec", wsec);
-
- key_len = strlen(ap->key);
- if (key_len < WSEC_MIN_PSK_LEN || key_len > WSEC_MAX_PSK_LEN) {
- WL_SOFTAP(("passphrase must be between %d and %d characters long\n",
- WSEC_MIN_PSK_LEN, WSEC_MAX_PSK_LEN));
- return -1;
- }
-
-
- if (key_len < WSEC_MAX_PSK_LEN) {
- unsigned char output[2*SHA1HashSize];
- char key_str_buf[WSEC_MAX_PSK_LEN+1];
-
-
- memset(output, 0, sizeof(output));
- pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-
- ptr = key_str_buf;
- for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-
- sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
- (uint)output[i*4+1], (uint)output[i*4+2], \
- (uint)output[i*4+3]);
- ptr += 8;
- }
- WL_SOFTAP(("%s: passphase = %s\n", __FUNCTION__, key_str_buf));
-
- psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
- memcpy(psk.key, key_str_buf, psk.key_len);
- } else {
- psk.key_len = htod16((ushort) key_len);
- memcpy(psk.key, ap->key, key_len);
- }
- psk.flags = htod16(WSEC_PASSPHRASE);
- dev_wlc_ioctl(dev, WLC_SET_WSEC_PMK, &psk, sizeof(psk));
-
- wpa_auth = WPA2_AUTH_PSK;
- dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
- } else if (strnicmp(ap->sec, "wpa-psk", strlen("wpa-psk")) == 0) {
-
-
- wsec_pmk_t psk;
- size_t key_len;
-
- wsec = TKIP_ENABLED;
- res = dev_wlc_intvar_set(dev, "wsec", wsec);
-
- key_len = strlen(ap->key);
- if (key_len < WSEC_MIN_PSK_LEN || key_len > WSEC_MAX_PSK_LEN) {
- WL_SOFTAP(("passphrase must be between %d and %d characters long\n",
- WSEC_MIN_PSK_LEN, WSEC_MAX_PSK_LEN));
- return -1;
- }
-
-
- if (key_len < WSEC_MAX_PSK_LEN) {
- unsigned char output[2*SHA1HashSize];
- char key_str_buf[WSEC_MAX_PSK_LEN+1];
-
- WL_SOFTAP(("%s: do passhash...\n", __FUNCTION__));
-
- pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-
- ptr = key_str_buf;
- for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
- WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int*)&output[i*4])));
-
- sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
- (uint)output[i*4+1], (uint)output[i*4+2], \
- (uint)output[i*4+3]);
- ptr += 8;
- }
- printk("%s: passphase = %s\n", __FUNCTION__, key_str_buf);
-
- psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
- memcpy(psk.key, key_str_buf, psk.key_len);
- } else {
- psk.key_len = htod16((ushort) key_len);
- memcpy(psk.key, ap->key, key_len);
- }
-
- psk.flags = htod16(WSEC_PASSPHRASE);
- res |= dev_wlc_ioctl(dev, WLC_SET_WSEC_PMK, &psk, sizeof(psk));
-
- wpa_auth = WPA_AUTH_PSK;
- res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
- WL_SOFTAP((" wsec & auth set 'wpa-psk' (TKIP), result:&d %d\n", res));
- }
-
-#ifdef AP_ONLY
- ap_ssid.SSID_len = strlen(ap->ssid);
- strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
- res |= dev_wlc_ioctl(dev, WLC_SET_SSID, &ap_ssid, sizeof(ap_ssid));
- mpc = 0;
- res |= dev_wlc_intvar_set(dev, "mpc", mpc);
- if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
- res |= dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
- }
-#endif
- return res;
-}
-
-
-static int wl_iw_softap_deassoc_stations(struct net_device *dev)
-{
- int i;
- int res = 0;
-
- char mac_buf[128] = {0};
- struct maclist *assoc_maclist = (struct maclist *) mac_buf;
-
- memset(assoc_maclist, 0, sizeof(mac_buf));
- assoc_maclist->count = 8;
-
- res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 128);
- if (res != 0) {
-
- WL_SOFTAP((" Error:%d in :%s, Couldn't get ASSOC List\n", res, __FUNCTION__));
- return res;
- }
-
- if (assoc_maclist->count)
- for (i = 0; i < assoc_maclist->count; i++) {
- scb_val_t scbval;
- scbval.val = htod32(1);
-
- bcopy(&assoc_maclist->ea[i], &scbval.ea, ETHER_ADDR_LEN);
-
- WL_SOFTAP(("deauth STA:%d \n", i));
- res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
- &scbval, sizeof(scb_val_t));
-
- } else WL_SOFTAP((" STA ASSOC list is empty\n"));
-
-
- if (res != 0)
- WL_SOFTAP((" Error:%d in :%s\n", res, __FUNCTION__));
- else if (assoc_maclist->count) {
-
- bcm_mdelay(200);
- }
- return res;
-}
-
-
-
-static int iwpriv_softap_stop(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
-{
- int res = 0;
- wl_iw_t *iw;
-
- WL_SOFTAP(("got iwpriv AP_BSS_STOP \n"));
-
- if ((!dev) && (!ap_net_dev)) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return res;
- }
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_STOP, "SoftAP_STOP");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-
- if ((ap_cfg_running == TRUE)) {
-#ifdef AP_ONLY
- wl_iw_softap_deassoc_stations(dev);
-#else
- wl_iw_softap_deassoc_stations(ap_net_dev);
-
- if ((res = dev_iw_write_cfg1_bss_var(dev, 2)) < 0)
- WL_ERROR(("%s failed to del BSS err = %d", __FUNCTION__, res));
-#endif
-
-
- bcm_mdelay(100);
-
- wrqu->data.length = 0;
- ap_cfg_running = FALSE;
- }
- else
- WL_ERROR(("%s: was called when SoftAP is OFF : move on\n", __FUNCTION__));
-
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_STOP);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
- WL_SOFTAP(("%s Done with %d\n", __FUNCTION__, res));
- return res;
-}
-
-
-
-static int iwpriv_fw_reload(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
-{
-
- int ret = -1;
- char extra[256];
- char *fwstr = fw_path ;
-
- WL_SOFTAP(("current firmware_path[]=%s\n", fwstr));
-
- WL_TRACE((">Got FW_RELOAD cmd:"
- "info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d, \
- fw_path:%p, len:%d \n",
- info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length, fwstr, strlen(fwstr)));
-
-
- if ((wrqu->data.length > 4) && (wrqu->data.length < sizeof(extra))) {
-
- char *str_ptr;
-
- if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
- ret = -EFAULT;
- goto exit_proc;
- }
-
-
- extra[wrqu->data.length] = 8;
- str_ptr = extra;
-
- if (get_parmeter_from_string(&str_ptr, "FW_PATH=", PTYPE_STRING, fwstr, 255) != 0) {
- WL_ERROR(("Error: extracting FW_PATH='' string\n"));
- goto exit_proc;
- }
-
- if (strstr(fwstr, "apsta") != NULL) {
- WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
- ap_fw_loaded = TRUE;
- } else {
- WL_SOFTAP(("GOT STA FIRMWARE\n"));
- ap_fw_loaded = FALSE;
- }
-
- WL_SOFTAP(("SET firmware_path[]=%s , str_p:%p\n", fwstr, fwstr));
- ret = 0;
- } else {
- WL_ERROR(("Error: ivalid param len:%d\n", wrqu->data.length));
- }
-
-exit_proc:
- return ret;
-}
-#ifdef SOFTAP
-
-static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *ext)
-{
- int res = 0;
- char *params = NULL;
-
- WL_TRACE((">Got IWPRIV wp_supp loopback cmd test:"
- "info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
- info->cmd, info->flags,
- wrqu->data.pointer, wrqu->data.length));
-
- if (wrqu->data.length != 0) {
-
- if (!(params = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
- return -ENOMEM;
-
-
- if (copy_from_user(params, wrqu->data.pointer, wrqu->data.length)) {
- kfree(params);
- return -EFAULT;
- }
-
- params[wrqu->data.length] = 0;
- WL_SOFTAP(("\n>> copied from user:\n %s\n", params));
- } else {
- WL_ERROR(("ERROR param length is 0\n"));
- return -EFAULT;
- }
-
-
- res = wl_iw_send_priv_event(dev, params);
- kfree(params);
-
- return res;
-}
-#endif
-
-
-static int
- iwpriv_en_ap_bss(
- struct net_device *dev,
- struct iw_request_info *info,
- void *wrqu,
- char *extra)
-{
- int res = 0;
- wl_iw_t *iw;
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return -1;
- }
-
- WL_TRACE(("%s: rcvd IWPRIV IOCTL: for dev:%s\n", __FUNCTION__, dev->name));
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- MUTEX_LOCK_SOFTAP_SET(iw->pub);
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_START, "SoftAP_START");
- WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
-
-
-#ifndef AP_ONLY
- if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
- WL_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
- }
- else {
-
- if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0)
- WL_ERROR(("%s fail to set bss up err=%d\n", __FUNCTION__, res));
- else
-
- bcm_mdelay(100);
- }
-
-#endif
-
- WL_SOFTAP(("%s done with res %d \n", __FUNCTION__, res));
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_START);
- MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
- return res;
-}
-
-static int
-get_assoc_sta_list(struct net_device *dev, char *buf, int len)
-{
-
- WL_TRACE(("calling dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
- dev, WLC_GET_ASSOCLIST, buf, len));
-
- dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
-
- return 0;
-}
-
-
-static int
-set_ap_mac_list(struct net_device *dev, char *buf)
-{
- struct mac_list_set *mac_list_set = (struct mac_list_set *)buf;
- struct maclist *white_maclist = (struct maclist *)&mac_list_set->white_list;
- struct maclist *black_maclist = (struct maclist *)&mac_list_set->black_list;
- int mac_mode = mac_list_set->mode;
- int length;
- int i;
-
- ap_macmode = mac_mode;
- if (mac_mode == MACLIST_MODE_DISABLED) {
-
- bzero(&ap_black_list, sizeof(struct mflist));
-
-
- dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
- } else {
- scb_val_t scbval;
- char mac_buf[256] = {0};
- struct maclist *assoc_maclist = (struct maclist *) mac_buf;
-
- mac_mode = MACLIST_MODE_ALLOW;
-
- dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
-
-
- length = sizeof(white_maclist->count)+white_maclist->count*ETHER_ADDR_LEN;
- dev_wlc_ioctl(dev, WLC_SET_MACLIST, white_maclist, length);
- WL_SOFTAP(("White List, length %d:\n", length));
- for (i = 0; i < white_maclist->count; i++)
- WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
- i, white_maclist->ea[i].octet[0], white_maclist->ea[i].octet[1], \
- white_maclist->ea[i].octet[2], \
- white_maclist->ea[i].octet[3], white_maclist->ea[i].octet[4], \
- white_maclist->ea[i].octet[5]));
-
-
- bcopy(black_maclist, &ap_black_list, sizeof(ap_black_list));
-
- WL_SOFTAP(("Black List, size %d:\n", sizeof(ap_black_list)));
- for (i = 0; i < ap_black_list.count; i++)
- WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
- i, ap_black_list.ea[i].octet[0], ap_black_list.ea[i].octet[1], \
- ap_black_list.ea[i].octet[2], \
- ap_black_list.ea[i].octet[3], \
- ap_black_list.ea[i].octet[4], ap_black_list.ea[i].octet[5]));
-
-
- dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
- if (assoc_maclist->count) {
- int j;
- for (i = 0; i < assoc_maclist->count; i++) {
- for (j = 0; j < white_maclist->count; j++) {
- if (!bcmp(&assoc_maclist->ea[i], &white_maclist->ea[j], \
- ETHER_ADDR_LEN)) {
- WL_SOFTAP(("match allow, let it be\n"));
- break;
- }
- }
- if (j == white_maclist->count) {
- WL_SOFTAP(("match black, deauth it\n"));
- scbval.val = htod32(1);
- bcopy(&assoc_maclist->ea[i], &scbval.ea, \
- ETHER_ADDR_LEN);
- dev_wlc_ioctl(dev, \
- WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
- sizeof(scb_val_t));
- }
- }
- }
- }
- return 0;
-}
-#endif /* SOFTAP */
-
-
-#ifdef SOFTAP
-int set_macfilt_from_string(struct mflist *pmflist, char **param_str)
-{
- return 0;
-}
-#endif
-
-
-#ifdef SOFTAP
-#define PARAM_OFFSET PROFILE_OFFSET
-
-int wl_iw_process_private_ascii_cmd(
- struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *dwrq,
- char *cmd_str)
-{
- int ret = 0;
- char *sub_cmd = cmd_str + PROFILE_OFFSET + strlen("ASCII_CMD=");
-
- WL_SOFTAP(("\n %s: ASCII_CMD: offs_0:%s, offset_32:\n'%s'\n",
- __FUNCTION__, cmd_str, cmd_str + PROFILE_OFFSET));
-
- if (strnicmp(sub_cmd, "AP_CFG", strlen("AP_CFG")) == 0) {
-
- WL_SOFTAP((" AP_CFG \n"));
-
-
- if (init_ap_profile_from_string(cmd_str+PROFILE_OFFSET, &my_ap) != 0) {
- WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
- ret = -1;
- } else {
- ret = set_ap_cfg(dev, &my_ap);
- }
-
- } else if (strnicmp(sub_cmd, "AP_BSS_START", strlen("AP_BSS_START")) == 0) {
-
- WL_SOFTAP(("\n SOFTAP - ENABLE BSS \n"));
-
-
- WL_SOFTAP(("\n!!! got 'WL_AP_EN_BSS' from WPA supplicant, dev:%s\n", dev->name));
-
-#ifndef AP_ONLY
- if (ap_net_dev == NULL) {
- printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
- } else {
-
- if ((ret = iwpriv_en_ap_bss(ap_net_dev, info, dwrq, cmd_str)) < 0)
- WL_ERROR(("%s line %d fail to set bss up\n", \
- __FUNCTION__, __LINE__));
- }
-#else
- if ((ret = iwpriv_en_ap_bss(dev, info, dwrq, cmd_str)) < 0)
- WL_ERROR(("%s line %d fail to set bss up\n", \
- __FUNCTION__, __LINE__));
-#endif
- } else if (strnicmp(sub_cmd, "ASSOC_LST", strlen("ASSOC_LST")) == 0) {
-
-
-
- } else if (strnicmp(sub_cmd, "AP_BSS_STOP", strlen("AP_BSS_STOP")) == 0) {
-
- WL_SOFTAP((" \n temp DOWN SOFTAP\n"));
-#ifndef AP_ONLY
- if ((ret = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
- WL_ERROR(("%s line %d fail to set bss down\n", \
- __FUNCTION__, __LINE__));
- }
-#endif
- }
-
- return ret;
-
-}
-#endif
-static int wl_iw_set_priv(
- struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *dwrq,
- char *ext
-)
-{
- int ret = 0;
- char * extra;
-
- wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
- if (!(extra = kmalloc(dwrq->length, GFP_KERNEL)))
- return -ENOMEM;
-
- if (copy_from_user(extra, dwrq->pointer, dwrq->length)) {
- kfree(extra);
- return -EFAULT;
- }
-
- WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d\n",
- dev->name, extra, info->cmd, info->flags, dwrq->length));
-
-
- if (dwrq->length && extra) {
- WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_PRIV, "wl_iw_set_priv");
- WAKE_LOCK(iw->pub, WAKE_LOCK_PRIV);
-
- if (g_onoff == G_WLAN_SET_OFF) {
- if (strnicmp(extra, "START", strlen("START")) != 0) {
- WL_ERROR(("%s First IOCTL after stop is NOT START \n", \
- __FUNCTION__));
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
- kfree(extra);
- return -EFAULT;
- } else {
- wl_iw_control_wl_on(dev, info);
- WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
- }
- }
-
- if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
-#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
- WL_TRACE(("%s: active scan setting suppressed\n", dev->name));
-#else
- ret = wl_iw_set_active_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
- }
- else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
-#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
- WL_TRACE(("%s: passive scan setting suppressed\n", dev->name));
-#else
- ret = wl_iw_set_passive_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
- else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
- ret = wl_iw_get_rssi(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
- ret = wl_iw_get_link_speed(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
- ret = wl_iw_get_macaddr(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
- ret = wl_iw_set_country(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "STOP", strlen("STOP")) == 0)
- ret = wl_iw_control_wl_off(dev, info);
- else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
- ret = wl_iw_get_band(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
- ret = wl_iw_set_band(dev, info, (union iwreq_data *)dwrq, extra);
-#if defined(CSCAN)
-
- else if (strnicmp(extra, CSCAN_COMMAND, strlen(CSCAN_COMMAND)) == 0)
- ret = wl_iw_set_cscan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
-#ifdef CUSTOMER_HW2
- else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
- ret = wl_iw_set_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
- else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
- ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
-#else
- else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
- ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
-#ifdef SOFTAP
- else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
-
- wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
- }
- else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
- WL_SOFTAP(("penguin, set AP_MAC_LIST_SET\n"));
- set_ap_mac_list(dev, (extra + PROFILE_OFFSET));
- }
-#endif
- else {
- WL_TRACE(("Unkown PRIVATE command %s\n", extra));
- snprintf(extra, MAX_WX_STRING, "OK");
- dwrq->length = strlen("OK") + 1;
- }
- WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
- WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
- }
-
- if (extra) {
- if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
- kfree(extra);
- return -EFAULT;
- }
-
- kfree(extra);
- }
-
- return ret;
-}
-
-static const iw_handler wl_iw_handler[] =
-{
- (iw_handler) wl_iw_config_commit,
- (iw_handler) wl_iw_get_name,
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) wl_iw_set_freq,
- (iw_handler) wl_iw_get_freq,
- (iw_handler) wl_iw_set_mode,
- (iw_handler) wl_iw_get_mode,
- (iw_handler) wl_iw_set_sens,
- (iw_handler) wl_iw_get_sens,
- (iw_handler) NULL,
- (iw_handler) wl_iw_get_range,
- (iw_handler) wl_iw_set_priv,
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) wl_iw_set_spy,
- (iw_handler) wl_iw_get_spy,
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) wl_iw_set_wap,
- (iw_handler) wl_iw_get_wap,
-#if WIRELESS_EXT > 17
- (iw_handler) wl_iw_mlme,
-#else
- (iw_handler) NULL,
-#endif
-#if defined(WL_IW_USE_ISCAN)
- (iw_handler) wl_iw_iscan_get_aplist,
-#else
- (iw_handler) wl_iw_get_aplist,
-#endif
-#if WIRELESS_EXT > 13
-#if defined(WL_IW_USE_ISCAN)
- (iw_handler) wl_iw_iscan_set_scan,
- (iw_handler) wl_iw_iscan_get_scan,
-#else
- (iw_handler) wl_iw_set_scan,
- (iw_handler) wl_iw_get_scan,
-#endif
-#else
- (iw_handler) NULL,
- (iw_handler) NULL,
-#endif
- (iw_handler) wl_iw_set_essid,
- (iw_handler) wl_iw_get_essid,
- (iw_handler) wl_iw_set_nick,
- (iw_handler) wl_iw_get_nick,
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) wl_iw_set_rate,
- (iw_handler) wl_iw_get_rate,
- (iw_handler) wl_iw_set_rts,
- (iw_handler) wl_iw_get_rts,
- (iw_handler) wl_iw_set_frag,
- (iw_handler) wl_iw_get_frag,
- (iw_handler) wl_iw_set_txpow,
- (iw_handler) wl_iw_get_txpow,
-#if WIRELESS_EXT > 10
- (iw_handler) wl_iw_set_retry,
- (iw_handler) wl_iw_get_retry,
-#endif
- (iw_handler) wl_iw_set_encode,
- (iw_handler) wl_iw_get_encode,
- (iw_handler) wl_iw_set_power,
- (iw_handler) wl_iw_get_power,
-#if WIRELESS_EXT > 17
- (iw_handler) NULL,
- (iw_handler) NULL,
- (iw_handler) wl_iw_set_wpaie,
- (iw_handler) wl_iw_get_wpaie,
- (iw_handler) wl_iw_set_wpaauth,
- (iw_handler) wl_iw_get_wpaauth,
- (iw_handler) wl_iw_set_encodeext,
- (iw_handler) wl_iw_get_encodeext,
-#ifdef BCMWPA2
- (iw_handler) wl_iw_set_pmksa,
-#endif
-#endif
-};
-
-#if WIRELESS_EXT > 12
-static const iw_handler wl_iw_priv_handler[] = {
- NULL,
- (iw_handler)wl_iw_set_active_scan,
- NULL,
- (iw_handler)wl_iw_get_rssi,
- NULL,
- (iw_handler)wl_iw_set_passive_scan,
- NULL,
- (iw_handler)wl_iw_get_link_speed,
- NULL,
- (iw_handler)wl_iw_get_macaddr,
- NULL,
- (iw_handler)wl_iw_control_wl_off,
- NULL,
- (iw_handler)wl_iw_control_wl_on,
-#ifdef SOFTAP
-
-
- NULL,
- (iw_handler)iwpriv_set_ap_config,
-
-
-
- NULL,
- (iw_handler)iwpriv_get_assoc_list,
-
-
- NULL,
- (iw_handler)iwpriv_set_mac_filters,
-
-
- NULL,
- (iw_handler)iwpriv_en_ap_bss,
-
-
- NULL,
- (iw_handler)iwpriv_wpasupp_loop_tst,
-
- NULL,
- (iw_handler)iwpriv_softap_stop,
-
- NULL,
- (iw_handler)iwpriv_fw_reload,
-#endif
-#if defined(CSCAN)
-
- NULL,
- (iw_handler)iwpriv_set_cscan
-#endif
-};
-
-static const struct iw_priv_args wl_iw_priv_args[] =
-{
- {
- WL_IW_SET_ACTIVE_SCAN,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "SCAN-ACTIVE"
- },
- {
- WL_IW_GET_RSSI,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "RSSI"
- },
- {
- WL_IW_SET_PASSIVE_SCAN,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "SCAN-PASSIVE"
- },
- {
- WL_IW_GET_LINK_SPEED,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "LINKSPEED"
- },
- {
- WL_IW_GET_CURR_MACADDR,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "Macaddr"
- },
- {
- WL_IW_SET_STOP,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "STOP"
- },
- {
- WL_IW_SET_START,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "START"
- },
-
-#ifdef SOFTAP
-
-
- {
- WL_SET_AP_CFG,
- IW_PRIV_TYPE_CHAR | 256,
- 0,
- "AP_SET_CFG"
- },
-
- {
- WL_AP_STA_LIST,
- 0,
- IW_PRIV_TYPE_CHAR | 0,
- "AP_GET_STA_LIST"
- },
-
- {
- WL_AP_MAC_FLTR,
- IW_PRIV_TYPE_CHAR | 256,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- "AP_SET_MAC_FLTR"
- },
-
- {
- WL_AP_BSS_START,
- 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
- "AP_BSS_START"
- },
-
- {
- AP_LPB_CMD,
- IW_PRIV_TYPE_CHAR | 256,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- "AP_LPB_CMD"
- },
-
- {
- WL_AP_STOP,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- "AP_BSS_STOP"
- },
- {
- WL_FW_RELOAD,
- IW_PRIV_TYPE_CHAR | 256,
- IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
- "WL_FW_RELOAD"
- },
-#endif
-#if defined(CSCAN)
- {
- WL_COMBO_SCAN,
- IW_PRIV_TYPE_CHAR | 1024,
- 0,
- "CSCAN"
- },
-#endif
- };
-
-const struct iw_handler_def wl_iw_handler_def =
-{
- .num_standard = ARRAYSIZE(wl_iw_handler),
- .standard = (iw_handler *) wl_iw_handler,
- .num_private = ARRAYSIZE(wl_iw_priv_handler),
- .num_private_args = ARRAY_SIZE(wl_iw_priv_args),
- .private = (iw_handler *)wl_iw_priv_handler,
- .private_args = (void *) wl_iw_priv_args,
-
-#if WIRELESS_EXT >= 19
- get_wireless_stats: dhd_get_wireless_stats,
-#endif
- };
-#endif
-
-
-
-int wl_iw_ioctl(
- struct net_device *dev,
- struct ifreq *rq,
- int cmd
-)
-{
- struct iwreq *wrq = (struct iwreq *) rq;
- struct iw_request_info info;
- iw_handler handler;
- char *extra = NULL;
- int token_size = 1, max_tokens = 0, ret = 0;
-
- WL_TRACE(("\n%s, cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
- if (cmd < SIOCIWFIRST ||
- IW_IOCTL_IDX(cmd) >= ARRAYSIZE(wl_iw_handler) ||
- !(handler = wl_iw_handler[IW_IOCTL_IDX(cmd)])) {
- WL_ERROR(("%s: error in cmd=%x : not supported\n", __FUNCTION__, cmd));
- return -EOPNOTSUPP;
- }
-
- switch (cmd) {
-
- case SIOCSIWESSID:
- case SIOCGIWESSID:
- case SIOCSIWNICKN:
- case SIOCGIWNICKN:
- max_tokens = IW_ESSID_MAX_SIZE + 1;
- break;
-
- case SIOCSIWENCODE:
- case SIOCGIWENCODE:
-#if WIRELESS_EXT > 17
- case SIOCSIWENCODEEXT:
- case SIOCGIWENCODEEXT:
-#endif
- max_tokens = wrq->u.data.length;
- break;
-
- case SIOCGIWRANGE:
-
- max_tokens = sizeof(struct iw_range) + 500;
- break;
-
- case SIOCGIWAPLIST:
- token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
- max_tokens = IW_MAX_AP;
- break;
-
-#if WIRELESS_EXT > 13
- case SIOCGIWSCAN:
-#if defined(WL_IW_USE_ISCAN)
- if (g_iscan)
- max_tokens = wrq->u.data.length;
- else
-#endif
- max_tokens = IW_SCAN_MAX_DATA;
- break;
-#endif
-
- case SIOCSIWSPY:
- token_size = sizeof(struct sockaddr);
- max_tokens = IW_MAX_SPY;
- break;
-
- case SIOCGIWSPY:
- token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
- max_tokens = IW_MAX_SPY;
- break;
-
-#if WIRELESS_EXT > 17
- case SIOCSIWPMKSA:
- case SIOCSIWGENIE:
-#endif
- case SIOCSIWPRIV:
- max_tokens = wrq->u.data.length;
- break;
- }
-
- if (max_tokens && wrq->u.data.pointer) {
- if (wrq->u.data.length > max_tokens) {
- WL_ERROR(("%s: error in cmd=%x wrq->u.data.length=%d > max_tokens=%d\n", \
- __FUNCTION__, cmd, wrq->u.data.length, max_tokens));
- return -E2BIG;
- }
- if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL)))
- return -ENOMEM;
-
- if (copy_from_user(extra, wrq->u.data.pointer, wrq->u.data.length * token_size)) {
- kfree(extra);
- return -EFAULT;
- }
- }
-
- info.cmd = cmd;
- info.flags = 0;
-
- ret = handler(dev, &info, &wrq->u, extra);
-
- if (extra) {
- if (copy_to_user(wrq->u.data.pointer, extra, wrq->u.data.length * token_size)) {
- kfree(extra);
- return -EFAULT;
- }
-
- kfree(extra);
- }
-
- return ret;
-}
-
-
-bool
-wl_iw_conn_status_str(uint32 event_type, uint32 status, uint32 reason,
- char* stringBuf, uint buflen)
-{
- typedef struct conn_fail_event_map_t {
- uint32 inEvent;
- uint32 inStatus;
- uint32 inReason;
- const char* outName;
- const char* outCause;
- } conn_fail_event_map_t;
-
-
-# define WL_IW_DONT_CARE 9999
- const conn_fail_event_map_t event_map [] = {
-
-
- {WLC_E_SET_SSID, WLC_E_STATUS_SUCCESS, WL_IW_DONT_CARE,
- "Conn", "Success"},
- {WLC_E_SET_SSID, WLC_E_STATUS_NO_NETWORKS, WL_IW_DONT_CARE,
- "Conn", "NoNetworks"},
- {WLC_E_SET_SSID, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
- "Conn", "ConfigMismatch"},
- {WLC_E_PRUNE, WL_IW_DONT_CARE, WLC_E_PRUNE_ENCR_MISMATCH,
- "Conn", "EncrypMismatch"},
- {WLC_E_PRUNE, WL_IW_DONT_CARE, WLC_E_RSN_MISMATCH,
- "Conn", "RsnMismatch"},
- {WLC_E_AUTH, WLC_E_STATUS_TIMEOUT, WL_IW_DONT_CARE,
- "Conn", "AuthTimeout"},
- {WLC_E_AUTH, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
- "Conn", "AuthFail"},
- {WLC_E_AUTH, WLC_E_STATUS_NO_ACK, WL_IW_DONT_CARE,
- "Conn", "AuthNoAck"},
- {WLC_E_REASSOC, WLC_E_STATUS_FAIL, WL_IW_DONT_CARE,
- "Conn", "ReassocFail"},
- {WLC_E_REASSOC, WLC_E_STATUS_TIMEOUT, WL_IW_DONT_CARE,
- "Conn", "ReassocTimeout"},
- {WLC_E_REASSOC, WLC_E_STATUS_ABORT, WL_IW_DONT_CARE,
- "Conn", "ReassocAbort"},
- {WLC_E_PSK_SUP, WLC_SUP_KEYED, WL_IW_DONT_CARE,
- "Sup", "ConnSuccess"},
- {WLC_E_PSK_SUP, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
- "Sup", "WpaHandshakeFail"},
- {WLC_E_DEAUTH_IND, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
- "Conn", "Deauth"},
- {WLC_E_DISASSOC_IND, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
- "Conn", "DisassocInd"},
- {WLC_E_DISASSOC, WL_IW_DONT_CARE, WL_IW_DONT_CARE,
- "Conn", "Disassoc"}
- };
-
- const char* name = "";
- const char* cause = NULL;
- int i;
-
-
- for (i = 0; i < sizeof(event_map)/sizeof(event_map[0]); i++) {
- const conn_fail_event_map_t* row = &event_map[i];
- if (row->inEvent == event_type &&
- (row->inStatus == status || row->inStatus == WL_IW_DONT_CARE) &&
- (row->inReason == reason || row->inReason == WL_IW_DONT_CARE)) {
- name = row->outName;
- cause = row->outCause;
- break;
- }
- }
-
-
- if (cause) {
- memset(stringBuf, 0, buflen);
- snprintf(stringBuf, buflen, "%s %s %02d %02d",
- name, cause, status, reason);
- WL_INFORM(("Connection status: %s\n", stringBuf));
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-#if WIRELESS_EXT > 14
-
-static bool
-wl_iw_check_conn_fail(wl_event_msg_t *e, char* stringBuf, uint buflen)
-{
- uint32 event = ntoh32(e->event_type);
- uint32 status = ntoh32(e->status);
- uint32 reason = ntoh32(e->reason);
-
- if (wl_iw_conn_status_str(event, status, reason, stringBuf, buflen)) {
- return TRUE;
- }
- else
- return FALSE;
-}
-#endif
-
-#ifndef IW_CUSTOM_MAX
-#define IW_CUSTOM_MAX 256
-#endif
-
-void
-wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
-{
-#if WIRELESS_EXT > 13
- union iwreq_data wrqu;
- char extra[IW_CUSTOM_MAX + 1];
- int cmd = 0;
- uint32 event_type = ntoh32(e->event_type);
- uint16 flags = ntoh16(e->flags);
- uint32 datalen = ntoh32(e->datalen);
- uint32 status = ntoh32(e->status);
- wl_iw_t *iw;
- uint32 toto;
-
- memset(&wrqu, 0, sizeof(wrqu));
- memset(extra, 0, sizeof(extra));
- iw = 0;
-
- if (!dev) {
- WL_ERROR(("%s: dev is null\n", __FUNCTION__));
- return;
- }
-
- iw = *(wl_iw_t **)netdev_priv(dev);
-
- //WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
-
-
- switch (event_type) {
-#if defined(SOFTAP)
- case WLC_E_PRUNE:
- if (ap_cfg_running) {
- char *macaddr = (char *)&e->addr;
- WL_SOFTAP(("PRUNE received, %02X:%02X:%02X:%02X:%02X:%02X!\n",
- macaddr[0], macaddr[1], macaddr[2], macaddr[3], \
- macaddr[4], macaddr[5]));
-
-
- if (ap_macmode)
- {
- int i;
- for (i = 0; i < ap_black_list.count; i++) {
- if (!bcmp(macaddr, &ap_black_list.ea[i], \
- sizeof(struct ether_addr))) {
- WL_SOFTAP(("mac in black list, ignore it\n"));
- break;
- }
- }
-
- if (i == ap_black_list.count) {
-
- char mac_buf[32] = {0};
- sprintf(mac_buf, "STA_BLOCK %02X:%02X:%02X:%02X:%02X:%02X",
- macaddr[0], macaddr[1], macaddr[2],
- macaddr[3], macaddr[4], macaddr[5]);
- wl_iw_send_priv_event(priv_dev, mac_buf);
- }
- }
- }
- break;
-#endif
- case WLC_E_TXFAIL:
- cmd = IWEVTXDROP;
- memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
- wrqu.addr.sa_family = ARPHRD_ETHER;
- break;
-#if WIRELESS_EXT > 14
- case WLC_E_JOIN:
- case WLC_E_ASSOC_IND:
- case WLC_E_REASSOC_IND:
-#if defined(SOFTAP)
- WL_SOFTAP(("STA connect received %d\n", event_type));
- if (ap_cfg_running) {
- wl_iw_send_priv_event(priv_dev, "STA_JOIN");
- return;
- }
-#endif
- memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
- wrqu.addr.sa_family = ARPHRD_ETHER;
- cmd = IWEVREGISTERED;
- break;
- case WLC_E_DEAUTH_IND:
- case WLC_E_DISASSOC_IND:
-#if defined(SOFTAP)
- WL_SOFTAP(("STA disconnect received %d\n", event_type));
- if (ap_cfg_running) {
- wl_iw_send_priv_event(priv_dev, "STA_LEAVE");
- return;
- }
-#endif
- cmd = SIOCGIWAP;
- bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
- wrqu.addr.sa_family = ARPHRD_ETHER;
- bzero(&extra, ETHER_ADDR_LEN);
- break;
- case WLC_E_LINK:
- case WLC_E_NDIS_LINK:
- cmd = SIOCGIWAP;
- if (!(flags & WLC_EVENT_MSG_LINK)) {
-
-
-#ifdef SOFTAP
-#ifdef AP_ONLY
- if (ap_cfg_running) {
-#else
- if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
-#endif
-
- WL_SOFTAP(("AP DOWN %d\n", event_type));
- wl_iw_send_priv_event(priv_dev, "AP_DOWN");
- } else {
- WL_TRACE(("STA_Link Down\n"));
- g_ss_cache_ctrl.m_link_down = 1;
- }
-#else
- g_ss_cache_ctrl.m_link_down = 1;
-#endif
- WL_TRACE(("Link Down\n"));
-
- bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
- bzero(&extra, ETHER_ADDR_LEN);
- WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT, 20 * HZ);
- }
- else {
-
- memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
- g_ss_cache_ctrl.m_link_down = 0;
-
- memcpy(g_ss_cache_ctrl.m_active_bssid, &e->addr, ETHER_ADDR_LEN);
-#ifdef SOFTAP
-
-#ifdef AP_ONLY
- if (ap_cfg_running) {
-#else
- if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
-#endif
-
- WL_SOFTAP(("AP UP %d\n", event_type));
- wl_iw_send_priv_event(priv_dev, "AP_UP");
- } else {
- WL_TRACE(("STA_LINK_UP\n"));
- }
-#else
-#endif
- WL_TRACE(("Link UP\n"));
-
- }
- wrqu.addr.sa_family = ARPHRD_ETHER;
- break;
- case WLC_E_ACTION_FRAME:
- cmd = IWEVCUSTOM;
- if (datalen + 1 <= sizeof(extra)) {
- wrqu.data.length = datalen + 1;
- extra[0] = WLC_E_ACTION_FRAME;
- memcpy(&extra[1], data, datalen);
- WL_TRACE(("WLC_E_ACTION_FRAME len %d \n", wrqu.data.length));
- }
- break;
-
- case WLC_E_ACTION_FRAME_COMPLETE:
- cmd = IWEVCUSTOM;
- memcpy(&toto, data, 4);
- if (sizeof(status) + 1 <= sizeof(extra)) {
- wrqu.data.length = sizeof(status) + 1;
- extra[0] = WLC_E_ACTION_FRAME_COMPLETE;
- memcpy(&extra[1], &status, sizeof(status));
- printf("wl_iw_event status %d PacketId %d \n", status, toto);
- printf("WLC_E_ACTION_FRAME_COMPLETE len %d \n", wrqu.data.length);
- }
- break;
-#endif
-#if WIRELESS_EXT > 17
- case WLC_E_MIC_ERROR: {
- struct iw_michaelmicfailure *micerrevt = (struct iw_michaelmicfailure *)&extra;
- cmd = IWEVMICHAELMICFAILURE;
- wrqu.data.length = sizeof(struct iw_michaelmicfailure);
- if (flags & WLC_EVENT_MSG_GROUP)
- micerrevt->flags |= IW_MICFAILURE_GROUP;
- else
- micerrevt->flags |= IW_MICFAILURE_PAIRWISE;
- memcpy(micerrevt->src_addr.sa_data, &e->addr, ETHER_ADDR_LEN);
- micerrevt->src_addr.sa_family = ARPHRD_ETHER;
-
- break;
- }
-#ifdef BCMWPA2
- case WLC_E_PMKID_CACHE: {
- if (data)
- {
- struct iw_pmkid_cand *iwpmkidcand = (struct iw_pmkid_cand *)&extra;
- pmkid_cand_list_t *pmkcandlist;
- pmkid_cand_t *pmkidcand;
- int count;
-
- cmd = IWEVPMKIDCAND;
- pmkcandlist = data;
- count = ntoh32_ua((uint8 *)&pmkcandlist->npmkid_cand);
- ASSERT(count >= 0);
- wrqu.data.length = sizeof(struct iw_pmkid_cand);
- pmkidcand = pmkcandlist->pmkid_cand;
- while (count) {
- bzero(iwpmkidcand, sizeof(struct iw_pmkid_cand));
- if (pmkidcand->preauth)
- iwpmkidcand->flags |= IW_PMKID_CAND_PREAUTH;
- bcopy(&pmkidcand->BSSID, &iwpmkidcand->bssid.sa_data,
- ETHER_ADDR_LEN);
-#ifndef SANDGATE2G
- wireless_send_event(dev, cmd, &wrqu, extra);
-#endif
- pmkidcand++;
- count--;
- }
- }
- return;
- }
-#endif
-#endif
-
- case WLC_E_SCAN_COMPLETE:
-#if defined(WL_IW_USE_ISCAN)
- if ((g_iscan) && (g_iscan->sysioc_pid >= 0) &&
- (g_iscan->iscan_state != ISCAN_STATE_IDLE))
- {
- up(&g_iscan->sysioc_sem);
- } else {
- cmd = SIOCGIWSCAN;
- wrqu.data.length = strlen(extra);
- WL_TRACE(("Event WLC_E_SCAN_COMPLETE from specific scan %d\n", \
- g_iscan->iscan_state));
- }
-#else
- cmd = SIOCGIWSCAN;
- wrqu.data.length = strlen(extra);
- WL_TRACE(("Event WLC_E_SCAN_COMPLETE\n"));
-#endif
- break;
-
- default:
-
- WL_TRACE(("Unknown Event %d: ignoring\n", event_type));
- break;
- }
-#ifndef SANDGATE2G
- if (cmd) {
- if (cmd == SIOCGIWSCAN)
- wireless_send_event(dev, cmd, &wrqu, NULL);
- else
- wireless_send_event(dev, cmd, &wrqu, extra);
- }
-#endif
-
-#if WIRELESS_EXT > 14
-
- memset(extra, 0, sizeof(extra));
- if (wl_iw_check_conn_fail(e, extra, sizeof(extra))) {
- cmd = IWEVCUSTOM;
- wrqu.data.length = strlen(extra);
-#ifndef SANDGATE2G
- wireless_send_event(dev, cmd, &wrqu, extra);
-#endif
- }
-#endif
-
-#endif
-}
-
-int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
-{
- int res = 0;
- wl_cnt_t cnt;
- int phy_noise;
- int rssi;
- scb_val_t scb_val;
-
- phy_noise = 0;
- if ((res = dev_wlc_ioctl(dev, WLC_GET_PHY_NOISE, &phy_noise, sizeof(phy_noise))))
- goto done;
-
- phy_noise = dtoh32(phy_noise);
- WL_TRACE(("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise));
-
- bzero(&scb_val, sizeof(scb_val_t));
- if ((res = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t))))
- goto done;
-
- rssi = dtoh32(scb_val.val);
- WL_TRACE(("wl_iw_get_wireless_stats rssi=%d\n", rssi));
- if (rssi <= WL_IW_RSSI_NO_SIGNAL)
- wstats->qual.qual = 0;
- else if (rssi <= WL_IW_RSSI_VERY_LOW)
- wstats->qual.qual = 1;
- else if (rssi <= WL_IW_RSSI_LOW)
- wstats->qual.qual = 2;
- else if (rssi <= WL_IW_RSSI_GOOD)
- wstats->qual.qual = 3;
- else if (rssi <= WL_IW_RSSI_VERY_GOOD)
- wstats->qual.qual = 4;
- else
- wstats->qual.qual = 5;
-
-
- wstats->qual.level = 0x100 + rssi;
- wstats->qual.noise = 0x100 + phy_noise;
-#if WIRELESS_EXT > 18
- wstats->qual.updated |= (IW_QUAL_ALL_UPDATED | IW_QUAL_DBM);
-#else
- wstats->qual.updated |= 7;
-#endif
-
-#if WIRELESS_EXT > 11
- WL_TRACE(("wl_iw_get_wireless_stats counters=%d\n", (int)sizeof(wl_cnt_t)));
-
- memset(&cnt, 0, sizeof(wl_cnt_t));
- res = dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, sizeof(wl_cnt_t));
- if (res)
- {
- WL_ERROR(("wl_iw_get_wireless_stats counters failed error=%d\n", res));
- goto done;
- }
-
- cnt.version = dtoh16(cnt.version);
- if (cnt.version != WL_CNT_T_VERSION) {
- WL_TRACE(("\tIncorrect version of counters struct: expected %d; got %d\n",
- WL_CNT_T_VERSION, cnt.version));
- goto done;
- }
-
- wstats->discard.nwid = 0;
- wstats->discard.code = dtoh32(cnt.rxundec);
- wstats->discard.fragment = dtoh32(cnt.rxfragerr);
- wstats->discard.retries = dtoh32(cnt.txfail);
- wstats->discard.misc = dtoh32(cnt.rxrunt) + dtoh32(cnt.rxgiant);
- wstats->miss.beacon = 0;
-
- WL_TRACE(("wl_iw_get_wireless_stats counters txframe=%d txbyte=%d\n",
- dtoh32(cnt.txframe), dtoh32(cnt.txbyte)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n", dtoh32(cnt.rxfrmtoolong)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxbadplcp=%d\n", dtoh32(cnt.rxbadplcp)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxundec=%d\n", dtoh32(cnt.rxundec)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxfragerr=%d\n", dtoh32(cnt.rxfragerr)));
- WL_TRACE(("wl_iw_get_wireless_stats counters txfail=%d\n", dtoh32(cnt.txfail)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxrunt=%d\n", dtoh32(cnt.rxrunt)));
- WL_TRACE(("wl_iw_get_wireless_stats counters rxgiant=%d\n", dtoh32(cnt.rxgiant)));
-
-#endif
-
-done:
- return res;
-}
-static void
-wl_iw_bt_flag_set(
- struct net_device *dev,
- bool set)
-{
- char buf_flag7_dhcp_on[8] = { 7, 00, 00, 00, 0x1, 0x0, 0x00, 0x00 };
- char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_lock();
-#endif
-
- if (set == TRUE) {
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
- (char *)&buf_flag7_dhcp_on[0], sizeof(buf_flag7_dhcp_on));
- }
- else {
-
- dev_wlc_bufvar_set(dev, "btc_flags", \
- (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
- }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
- rtnl_unlock();
-#endif
-}
-
-static void
-wl_iw_bt_timerfunc(ulong data)
-{
- bt_info_t *bt_local = (bt_info_t *)data;
- bt_local->timer_on = 0;
- WL_TRACE(("%s\n", __FUNCTION__));
-
- up(&bt_local->bt_sem);
-}
-
-static int
-_bt_dhcp_sysioc_thread(void *data)
-{
- DAEMONIZE("dhcp_sysioc");
-
- while (down_interruptible(&g_bt->bt_sem) == 0) {
- if (g_bt->timer_on) {
- del_timer(&g_bt->timer);
- g_bt->timer_on = 0;
- }
-
- switch (g_bt->bt_state) {
- case BT_DHCP_START:
-
- g_bt->bt_state = BT_DHCP_OPPORTUNITY_WINDOW;
- mod_timer(&g_bt->timer, jiffies + \
- BT_DHCP_OPPORTUNITY_WINDOW_TIEM*HZ/1000);
- g_bt->timer_on = 1;
- break;
- case BT_DHCP_OPPORTUNITY_WINDOW:
-
- WL_TRACE(("%s waiting for %d msec expired, force bt flag\n", \
- __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIEM));
- if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, TRUE);
- g_bt->bt_state = BT_DHCP_FLAG_FORCE_TIMEOUT;
- mod_timer(&g_bt->timer, jiffies + BT_DHCP_FLAG_FORCE_TIME*HZ/1000);
- g_bt->timer_on = 1;
- break;
- case BT_DHCP_FLAG_FORCE_TIMEOUT:
-
- WL_TRACE(("%s waiting for %d msec expired remove bt flag\n", \
- __FUNCTION__, BT_DHCP_FLAG_FORCE_TIME));
-
- if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, FALSE);
- g_bt->bt_state = BT_DHCP_IDLE;
- g_bt->timer_on = 0;
- break;
- default:
- WL_ERROR(("%s error g_status=%d !!!\n", __FUNCTION__, \
- g_bt->bt_state));
- if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, FALSE);
- g_bt->bt_state = BT_DHCP_IDLE;
- g_bt->timer_on = 0;
- break;
- }
- }
-
- if (g_bt->timer_on) {
- del_timer(&g_bt->timer);
- g_bt->timer_on = 0;
- }
- complete_and_exit(&g_bt->bt_exited, 0);
-}
-
-static void
-wl_iw_bt_release(void)
-{
- bt_info_t *bt_local = g_bt;
-
- if (!bt_local) {
- return;
- }
-
- if (bt_local->bt_pid >= 0) {
- KILL_PROC(bt_local->bt_pid, SIGTERM);
- wait_for_completion(&bt_local->bt_exited);
- }
- kfree(bt_local);
- g_bt = NULL;
-}
-
-static int
-wl_iw_bt_init(struct net_device *dev)
-{
- bt_info_t *bt_dhcp = NULL;
-
- bt_dhcp = kmalloc(sizeof(bt_info_t), GFP_KERNEL);
- if (!bt_dhcp)
- return -ENOMEM;
-
- memset(bt_dhcp, 0, sizeof(bt_info_t));
- bt_dhcp->bt_pid = -1;
- g_bt = bt_dhcp;
- bt_dhcp->dev = dev;
- bt_dhcp->bt_state = BT_DHCP_IDLE;
-
-
- bt_dhcp->timer_ms = 10;
- init_timer(&bt_dhcp->timer);
- bt_dhcp->timer.data = (ulong)bt_dhcp;
- bt_dhcp->timer.function = wl_iw_bt_timerfunc;
-
- sema_init(&bt_dhcp->bt_sem, 0);
- init_completion(&bt_dhcp->bt_exited);
- bt_dhcp->bt_pid = kernel_thread(_bt_dhcp_sysioc_thread, bt_dhcp, 0);
- if (bt_dhcp->bt_pid < 0) {
- WL_ERROR(("Failed in %s\n", __FUNCTION__));
- return -ENOMEM;
- }
-
- return 0;
-}
-
-int wl_iw_attach(struct net_device *dev, void * dhdp)
-{
- int params_size;
- wl_iw_t *iw;
-#if defined(WL_IW_USE_ISCAN)
- iscan_info_t *iscan = NULL;
-
- if (!dev)
- return 0;
-
-
-#ifdef CSCAN
- params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params)) +
- (WL_NUMCHANNELS * sizeof(uint16)) + WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
-#else
- params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params));
-#endif
- iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
-
- if (!iscan)
- return -ENOMEM;
- memset(iscan, 0, sizeof(iscan_info_t));
-
-
- iscan->iscan_ex_params_p = (wl_iscan_params_t*)kmalloc(params_size, GFP_KERNEL);
- if (!iscan->iscan_ex_params_p)
- return -ENOMEM;
- iscan->iscan_ex_param_size = params_size;
- iscan->sysioc_pid = -1;
-
- g_iscan = iscan;
- iscan->dev = dev;
- iscan->iscan_state = ISCAN_STATE_IDLE;
-
- g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
- g_iscan->scan_flag = 0;
-
-
- iscan->timer_ms = 3000;
- init_timer(&iscan->timer);
- iscan->timer.data = (ulong)iscan;
- iscan->timer.function = wl_iw_timerfunc;
-
- sema_init(&iscan->sysioc_sem, 0);
- init_completion(&iscan->sysioc_exited);
- iscan->sysioc_pid = kernel_thread(_iscan_sysioc_thread, iscan, 0);
- if (iscan->sysioc_pid < 0)
- return -ENOMEM;
-#endif
-
- iw = *(wl_iw_t **)netdev_priv(dev);
- iw->pub = (dhd_pub_t *)dhdp;
- MUTEX_LOCK_INIT(iw->pub);
- MUTEX_LOCK_WL_SCAN_SET_INIT();
-#ifdef SOFTAP
- priv_dev = dev;
- MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
-#endif
- g_scan = NULL;
-
-
- g_scan = (void *)kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
- if (!g_scan)
- return -ENOMEM;
-
- memset(g_scan, 0, G_SCAN_RESULTS);
- g_scan_specified_ssid = 0;
-
-#if !defined(CSCAN)
-
- wl_iw_init_ss_cache_ctrl();
-#endif
-
- wl_iw_bt_init(dev);
-
-
- return 0;
-}
-
-void wl_iw_detach(void)
-{
-#if defined(WL_IW_USE_ISCAN)
- iscan_buf_t *buf;
- iscan_info_t *iscan = g_iscan;
-
- if (!iscan)
- return;
- if (iscan->sysioc_pid >= 0) {
- KILL_PROC(iscan->sysioc_pid, SIGTERM);
- wait_for_completion(&iscan->sysioc_exited);
- }
- MUTEX_LOCK_WL_SCAN_SET();
- while (iscan->list_hdr) {
- buf = iscan->list_hdr->next;
- kfree(iscan->list_hdr);
- iscan->list_hdr = buf;
- }
- MUTEX_UNLOCK_WL_SCAN_SET();
- kfree(iscan->iscan_ex_params_p);
- kfree(iscan);
- g_iscan = NULL;
-#endif
-
- if (g_scan)
- kfree(g_scan);
-
- g_scan = NULL;
-#if !defined(CSCAN)
- wl_iw_release_ss_cache_ctrl();
-#endif
- wl_iw_bt_release();
-
-#ifdef SOFTAP
- if (ap_cfg_running) {
- WL_TRACE(("\n%s AP is going down\n", __FUNCTION__));
-
- wl_iw_send_priv_event(priv_dev, "AP_DOWN");
- }
-#endif
-
-}