diff options
Diffstat (limited to 'drivers/staging/brcm80211')
129 files changed, 4521 insertions, 8178 deletions
diff --git a/drivers/staging/brcm80211/Kconfig b/drivers/staging/brcm80211/Kconfig index 57d2d1b782f1..b6f86354b69f 100644 --- a/drivers/staging/brcm80211/Kconfig +++ b/drivers/staging/brcm80211/Kconfig @@ -2,13 +2,7 @@ menuconfig BRCM80211 tristate "Broadcom IEEE802.11n WLAN drivers" depends on WLAN -choice - prompt "Broadcom IEEE802.11n driver style" - depends on BRCM80211 - help - Select the appropriate driver style from the list below. - -config BRCM80211_PCI +config BRCMSMAC bool "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" depends on PCI depends on BRCM80211 && MAC80211 @@ -16,7 +10,7 @@ config BRCM80211_PCI ---help--- This module adds support for PCIe wireless adapters based on Broadcom IEEE802.11n SoftMAC chipsets. If you choose to build a module, it'll - be called brcm80211.ko. + be called brcmsmac.ko. config BRCMFMAC bool "Broadcom IEEE802.11n embedded FullMAC WLAN driver" @@ -30,4 +24,10 @@ config BRCMFMAC Broadcom IEEE802.11n FullMAC chipsets. This driver uses the kernel's wireless extensions subsystem. If you choose to build a module, it'll be called brcmfmac.ko. -endchoice + +config BRCMDBG + bool "Broadcom driver debug functions" + default n + depends on BRCM80211 + ---help--- + Selecting this enables additional code for debug purposes. diff --git a/drivers/staging/brcm80211/Makefile b/drivers/staging/brcm80211/Makefile index 1953ebe3d64b..c064cdf47f0d 100644 --- a/drivers/staging/brcm80211/Makefile +++ b/drivers/staging/brcm80211/Makefile @@ -15,62 +15,9 @@ # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -ccflags-y := \ - -DBCMDBG \ - -DWLC_HIGH \ - -DSTA \ - -DWME \ - -DWL11N \ - -DDBAND \ - -DBCMDMA32 \ - -DBCMNVRAMR \ - -Idrivers/staging/brcm80211/sys \ - -Idrivers/staging/brcm80211/phy \ - -Idrivers/staging/brcm80211/util \ - -Idrivers/staging/brcm80211/include +# common flags +subdir-ccflags-y := -DBCMDMA32 +subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG -DBCMDBG_ASSERT -PCI_CFLAGS := -DWLC_LOW - -BRCM80211_OFILES := \ - util/siutils.o \ - util/aiutils.o \ - util/bcmotp.o \ - util/bcmsrom.o \ - util/bcmutils.o \ - util/bcmwifi.o \ - util/hndpmu.o \ - util/linux_osl.o \ - sys/wlc_alloc.o \ - sys/wlc_antsel.o \ - sys/wlc_channel.o \ - sys/wlc_event.o \ - sys/wlc_mac80211.o \ - sys/wlc_rate.o \ - sys/wlc_stf.o \ - sys/wl_mac80211.o \ - sys/wlc_ampdu.o - -PCIFILES := \ - phy/wlc_phy_cmn.o \ - phy/wlc_phy_lcn.o \ - phy/wlc_phy_n.o \ - phy/wlc_phytbl_lcn.o \ - phy/wlc_phytbl_n.o \ - sys/wlc_bmac.o \ - sys/wlc_phy_shim.o \ - sys/wl_ucode_loader.o \ - util/hnddma.o \ - util/nicpci.o \ - util/nvram/nvram_ro.o \ - util/qmath.o - -MODULEPFX := brcm80211 - -# PCI driver -ifeq ($(CONFIG_BRCM80211_PCI),y) -obj-m += $(MODULEPFX).o -ccflags-y += $(PCI_CFLAGS) -$(MODULEPFX)-objs = $(BRCM80211_OFILES) $(PCIFILES) -endif - -obj-$(CONFIG_BRCMFMAC) += brcmfmac/ +obj-$(CONFIG_BRCMFMAC) += brcmfmac/ +obj-$(CONFIG_BRCMSMAC) += brcmsmac/ diff --git a/drivers/staging/brcm80211/brcmfmac/Kconfig b/drivers/staging/brcm80211/brcmfmac/Kconfig deleted file mode 100644 index e9f3037b0876..000000000000 --- a/drivers/staging/brcm80211/brcmfmac/Kconfig +++ /dev/null @@ -1,15 +0,0 @@ -menuconfig BRCMFMAC - tristate "Broadcom fullmac wireless cards support" - depends on MMC - depends on CFG80211 - select FW_LOADER - select WIRELESS_EXT - select WEXT_PRIV - ---help--- - This module adds support for wireless adapters based on - Broadcom fullmac chipsets. - This driver uses the kernel's wireless extensions subsystem. - If you choose to build a module, it'll be called brcmfmac.ko. Say M if - unsure. - - diff --git a/drivers/staging/brcm80211/brcmfmac/Makefile b/drivers/staging/brcm80211/brcmfmac/Makefile index 76f2d8b37e45..ac5a7d4ba806 100644 --- a/drivers/staging/brcm80211/brcmfmac/Makefile +++ b/drivers/staging/brcm80211/brcmfmac/Makefile @@ -17,13 +17,11 @@ ccflags-y := \ -DARP_OFFLOAD_SUPPORT \ - -DBCMDBG \ -DBCMLXSDMMC \ -DBCMPLATFORM_BUS \ -DBCMSDIO \ -DBDC \ -DBRCM_FULLMAC \ - -DDHD_DEBUG \ -DDHD_FIRSTREAD=64 \ -DDHD_SCHED \ -DDHD_SDALIGN=64 \ @@ -32,16 +30,34 @@ ccflags-y := \ -DMMC_SDIO_ABORT \ -DPKT_FILTER_SUPPORT \ -DSHOW_EVENTS \ - -DTOE \ - -Idrivers/staging/brcm80211/brcmfmac \ + -DTOE + +ccflags-$(CONFIG_BRCMDBG) += -DDHD_DEBUG + +ccflags-y += \ + -Idrivers/staging/brcm80211/brcmfmac \ -Idrivers/staging/brcm80211/include \ -Idrivers/staging/brcm80211/util -DHDOFILES = dhd_linux.o ../util/linux_osl.o ../util/bcmutils.o dhd_common.o dhd_custom_gpio.o \ - wl_iw.o wl_cfg80211.o ../util/siutils.o ../util/sbutils.o ../util/aiutils.o ../util/hndpmu.o ../util/bcmwifi.o dhd_sdio.o \ - dhd_linux_sched.o dhd_cdc.o bcmsdh_sdmmc.o bcmsdh.o bcmsdh_linux.o \ - bcmsdh_sdmmc_linux.o +DHDOFILES = \ + wl_cfg80211.o \ + wl_iw.o \ + dhd_cdc.o \ + dhd_common.o \ + dhd_custom_gpio.o \ + dhd_sdio.o \ + dhd_linux.o \ + dhd_linux_sched.o \ + bcmsdh.o \ + bcmsdh_linux.o \ + bcmsdh_sdmmc.o \ + bcmsdh_sdmmc_linux.o \ + aiutils.o \ + siutils.o \ + sbutils.o \ + bcmutils.o \ + bcmwifi.o \ + hndpmu.o obj-m += brcmfmac.o brcmfmac-objs += $(DHDOFILES) - diff --git a/drivers/staging/brcm80211/brcmfmac/aiutils.c b/drivers/staging/brcm80211/brcmfmac/aiutils.c new file mode 100644 index 000000000000..e64808648ce3 --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/aiutils.c @@ -0,0 +1 @@ +#include "../util/aiutils.c" diff --git a/drivers/staging/brcm80211/include/bcmcdc.h b/drivers/staging/brcm80211/brcmfmac/bcmcdc.h index 10c1ddcd5e5a..ed4c4a517eca 100644 --- a/drivers/staging/brcm80211/include/bcmcdc.h +++ b/drivers/staging/brcm80211/brcmfmac/bcmcdc.h @@ -13,7 +13,7 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <proto/ethernet.h> +#include <linux/if_ether.h> typedef struct cdc_ioctl { u32 cmd; /* ioctl command value */ @@ -24,7 +24,7 @@ typedef struct cdc_ioctl { } cdc_ioctl_t; /* Max valid buffer size that can be sent to the dongle */ -#define CDC_MAX_MSG_SIZE ETHER_MAX_LEN +#define CDC_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN) /* len field is divided into input and output buffer lengths */ #define CDCL_IOC_OUTLEN_MASK 0x0000FFFF /* maximum or expected diff --git a/drivers/staging/brcm80211/include/bcmsdbus.h b/drivers/staging/brcm80211/brcmfmac/bcmsdbus.h index 89059dd8088b..53c32915acc9 100644 --- a/drivers/staging/brcm80211/include/bcmsdbus.h +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdbus.h @@ -46,8 +46,8 @@ typedef void (*sdioh_cb_fn_t) (void *); * The handler shall be provided by all subsequent calls. No local cache * cfghdl points to the starting address of pci device mapped memory */ -extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *cfghdl, uint irq); -extern SDIOH_API_RC sdioh_detach(struct osl_info *osh, sdioh_info_t *si); +extern sdioh_info_t *sdioh_attach(void *cfghdl, uint irq); +extern SDIOH_API_RC sdioh_detach(sdioh_info_t *si); extern SDIOH_API_RC sdioh_interrupt_register(sdioh_info_t *si, sdioh_cb_fn_t fn, void *argh); extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *si); @@ -58,7 +58,7 @@ extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *si, bool *onoff); /* enable or disable SD interrupt */ extern SDIOH_API_RC sdioh_interrupt_set(sdioh_info_t *si, bool enable_disable); -#if defined(BCMDBG) +#if defined(DHD_DEBUG) extern bool sdioh_interrupt_pending(sdioh_info_t *si); #endif diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c index acf43a365081..473f57d9f00b 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh.c @@ -19,8 +19,6 @@ #include <linux/netdevice.h> #include <bcmdefs.h> #include <bcmdevs.h> -#include <bcmendian.h> -#include <osl.h> #include <bcmutils.h> #include <hndsoc.h> #include <siutils.h> @@ -39,7 +37,6 @@ struct bcmsdh_info { bool init_success; /* underlying driver successfully attached */ void *sdioh; /* handler for sdioh */ u32 vendevid; /* Target Vendor and Device ID on SD bus */ - struct osl_info *osh; bool regfail; /* Save status of last reg_read/reg_write call */ u32 sbwad; /* Save backplane window address */ @@ -56,8 +53,7 @@ void bcmsdh_enable_hw_oob_intr(bcmsdh_info_t *sdh, bool enable) } #endif -bcmsdh_info_t *bcmsdh_attach(struct osl_info *osh, void *cfghdl, - void **regsva, uint irq) +bcmsdh_info_t *bcmsdh_attach(void *cfghdl, void **regsva, uint irq) { bcmsdh_info_t *bcmsdh; @@ -70,13 +66,12 @@ bcmsdh_info_t *bcmsdh_attach(struct osl_info *osh, void *cfghdl, /* save the handler locally */ l_bcmsdh = bcmsdh; - bcmsdh->sdioh = sdioh_attach(osh, cfghdl, irq); + bcmsdh->sdioh = sdioh_attach(cfghdl, irq); if (!bcmsdh->sdioh) { - bcmsdh_detach(osh, bcmsdh); + bcmsdh_detach(bcmsdh); return NULL; } - bcmsdh->osh = osh; bcmsdh->init_success = true; *regsva = (u32 *) SI_ENUM_BASE; @@ -86,13 +81,13 @@ bcmsdh_info_t *bcmsdh_attach(struct osl_info *osh, void *cfghdl, return bcmsdh; } -int bcmsdh_detach(struct osl_info *osh, void *sdh) +int bcmsdh_detach(void *sdh) { bcmsdh_info_t *bcmsdh = (bcmsdh_info_t *) sdh; if (bcmsdh != NULL) { if (bcmsdh->sdioh) { - sdioh_detach(osh, bcmsdh->sdioh); + sdioh_detach(bcmsdh->sdioh); bcmsdh->sdioh = NULL; } kfree(bcmsdh); @@ -324,7 +319,7 @@ int bcmsdh_cis_read(void *sdh, uint func, u8 * cis, uint length) BCMSDH_ERROR(("%s: out of memory\n", __func__)); return BCME_NOMEM; } - bcopy(cis, tmp_buf, length); + memcpy(tmp_buf, cis, length); for (tmp_ptr = tmp_buf, ptr = cis; ptr < (cis + length - 4); tmp_ptr++) { ptr += sprintf((char *)ptr, "%.2x ", *tmp_ptr & 0xff); diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c index d24b5e7d753c..e3556ff43bb9 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c @@ -24,15 +24,14 @@ #include <linux/pci.h> #include <linux/completion.h> -#include <osl.h> #include <pcicfg.h> #include <bcmdefs.h> #include <bcmdevs.h> +#include <bcmutils.h> #if defined(OOB_INTR_ONLY) #include <linux/irq.h> extern void dhdsdio_isr(void *args); -#include <bcmutils.h> #include <dngl_stats.h> #include <dhd.h> #endif /* defined(OOB_INTR_ONLY) */ @@ -56,7 +55,6 @@ struct bcmsdh_hc { #else struct pci_dev *dev; /* pci device handle */ #endif /* BCMPLATFORM_BUS */ - struct osl_info *osh; void *regs; /* SDIO Host Controller address */ bcmsdh_info_t *sdh; /* SDIO Host Controller handle */ void *ch; @@ -114,7 +112,7 @@ bool bcmsdh_chipmatch(u16 vendor, u16 device) #ifdef BCMSDIOH_SPI /* This is the PciSpiHost. */ if (device == SPIH_FPGA_ID && vendor == VENDOR_BROADCOM) { - printf("Found PCI SPI Host Controller\n"); + WL_NONE("Found PCI SPI Host Controller\n"); return true; } #endif /* BCMSDIOH_SPI */ @@ -142,7 +140,6 @@ static #endif /* BCMLXSDMMC */ int bcmsdh_probe(struct device *dev) { - struct osl_info *osh = NULL; bcmsdh_hc_t *sdhc = NULL; unsigned long regs = 0; bcmsdh_info_t *sdh = NULL; @@ -177,28 +174,21 @@ int bcmsdh_probe(struct device *dev) } #endif /* defined(OOB_INTR_ONLY) */ /* allocate SDIO Host Controller state info */ - osh = osl_attach(dev, PCI_BUS); - if (!osh) { - SDLX_MSG(("%s: osl_attach failed\n", __func__)); - goto err; - } sdhc = kzalloc(sizeof(bcmsdh_hc_t), GFP_ATOMIC); if (!sdhc) { SDLX_MSG(("%s: out of memory\n", __func__)); goto err; } - sdhc->osh = osh; - sdhc->dev = (void *)dev; #ifdef BCMLXSDMMC - sdh = bcmsdh_attach(osh, (void *)0, (void **)®s, irq); + sdh = bcmsdh_attach((void *)0, (void **)®s, irq); if (!sdh) { SDLX_MSG(("%s: bcmsdh_attach failed\n", __func__)); goto err; } #else - sdh = bcmsdh_attach(osh, (void *)r->start, (void **)®s, irq); + sdh = bcmsdh_attach((void *)r->start, (void **)®s, irq); if (!sdh) { SDLX_MSG(("%s: bcmsdh_attach failed\n", __func__)); goto err; @@ -220,7 +210,7 @@ int bcmsdh_probe(struct device *dev) /* try to attach to the target device */ sdhc->ch = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), - 0, 0, 0, 0, (void *)regs, NULL, sdh); + 0, 0, 0, 0, (void *)regs, sdh); if (!sdhc->ch) { SDLX_MSG(("%s: device attach failed\n", __func__)); goto err; @@ -232,11 +222,10 @@ int bcmsdh_probe(struct device *dev) err: if (sdhc) { if (sdhc->sdh) - bcmsdh_detach(sdhc->osh, sdhc->sdh); + bcmsdh_detach(sdhc->sdh); kfree(sdhc); } - if (osh) - osl_detach(osh); + return -ENODEV; } @@ -246,11 +235,10 @@ static int bcmsdh_remove(struct device *dev) { bcmsdh_hc_t *sdhc, *prev; - struct osl_info *osh; sdhc = sdhcinfo; drvinfo.detach(sdhc->ch); - bcmsdh_detach(sdhc->osh, sdhc->sdh); + bcmsdh_detach(sdhc->sdh); /* find the SDIO Host Controller state for this pdev and take it out from the list */ for (sdhc = sdhcinfo, prev = NULL; sdhc; sdhc = sdhc->next) { @@ -269,9 +257,7 @@ int bcmsdh_remove(struct device *dev) } /* release SDIO Host Controller info */ - osh = sdhc->osh; kfree(sdhc); - osl_detach(osh); #if !defined(BCMLXSDMMC) dev_set_drvdata(dev, NULL); @@ -328,8 +314,6 @@ static irqreturn_t wlan_oob_irq(int irq, void *dev_id) return IRQ_HANDLED; } - WAKE_LOCK_TIMEOUT(dhdp, WAKE_LOCK_TMOUT, 25); - dhdsdio_isr((void *)dhdp->bus); return IRQ_HANDLED; diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c index d399b5c76f94..65313fa0cf4a 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -17,8 +17,6 @@ #include <linux/netdevice.h> #include <bcmdefs.h> #include <bcmdevs.h> -#include <bcmendian.h> -#include <osl.h> #include <bcmutils.h> #include <sdio.h> /* SDIO Device and Protocol Specs */ #include <sdioh.h> /* SDIO Host Controller Specification */ @@ -112,7 +110,7 @@ static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd) /* * Public entry points & extern's */ -extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *bar0, uint irq) +sdioh_info_t *sdioh_attach(void *bar0, uint irq) { sdioh_info_t *sd; int err_ret; @@ -129,7 +127,6 @@ extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *bar0, uint irq) sd_err(("sdioh_attach: out of memory\n")); return NULL; } - sd->osh = osh; if (sdioh_sdmmc_osinit(sd) != 0) { sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__)); kfree(sd); @@ -175,7 +172,7 @@ extern sdioh_info_t *sdioh_attach(struct osl_info *osh, void *bar0, uint irq) return sd; } -extern SDIOH_API_RC sdioh_detach(struct osl_info *osh, sdioh_info_t *sd) +extern SDIOH_API_RC sdioh_detach(sdioh_info_t *sd) { sd_trace(("%s\n", __func__)); @@ -441,7 +438,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, val_size = sizeof(int); if (plen >= (int)sizeof(int_val)) - bcopy(params, &int_val, sizeof(int_val)); + memcpy(&int_val, params, sizeof(int_val)); bool_val = (int_val != 0) ? true : false; @@ -449,7 +446,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, switch (actionid) { case IOV_GVAL(IOV_MSGLEVEL): int_val = (s32) sd_msglevel; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_MSGLEVEL): @@ -458,7 +455,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_BLOCKMODE): int_val = (s32) si->sd_blockmode; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_BLOCKMODE): @@ -472,7 +469,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, break; } int_val = (s32) si->client_block_size[int_val]; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_BLOCKSIZE): @@ -514,12 +511,12 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_RXCHAIN): int_val = false; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_DMA): int_val = (s32) si->sd_use_dma; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_DMA): @@ -528,7 +525,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_USEINTS): int_val = (s32) si->use_client_ints; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_USEINTS): @@ -542,7 +539,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_DIVISOR): int_val = (u32) sd_divisor; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_DIVISOR): @@ -551,7 +548,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_POWER): int_val = (u32) sd_power; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_POWER): @@ -560,7 +557,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_CLOCK): int_val = (u32) sd_clock; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_CLOCK): @@ -569,7 +566,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_SDMODE): int_val = (u32) sd_sdmode; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_SDMODE): @@ -578,7 +575,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_HISPEED): int_val = (u32) sd_hiok; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_HISPEED): @@ -587,12 +584,12 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, case IOV_GVAL(IOV_NUMINTS): int_val = (s32) si->intrcount; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_NUMLOCALINTS): int_val = (s32) 0; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_HOSTREG): @@ -621,7 +618,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, int_val = 32; /* sdioh_sdmmc_rreg(si, sd_ptr->offset); */ - bcopy(&int_val, arg, sizeof(int_val)); + memcpy(arg, &int_val, sizeof(int_val)); break; } @@ -657,7 +654,7 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name, } int_val = (int)data; - bcopy(&int_val, arg, sizeof(int_val)); + memcpy(arg, &int_val, sizeof(int_val)); break; } @@ -735,7 +732,7 @@ static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, u32 regaddr) } /* Only the lower 17-bits are valid */ - scratch = ltoh32(scratch); + scratch = le32_to_cpu(scratch); scratch &= 0x0001FFFF; return scratch; } @@ -1039,7 +1036,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, if (pkt == NULL) { sd_data(("%s: Creating new %s Packet, len=%d\n", __func__, write ? "TX" : "RX", buflen_u)); - mypkt = pkt_buf_get_skb(sd->osh, buflen_u); + mypkt = pkt_buf_get_skb(buflen_u); if (!mypkt) { sd_err(("%s: pkt_buf_get_skb failed: len %d\n", __func__, buflen_u)); @@ -1048,16 +1045,16 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, /* For a write, copy the buffer data into the packet. */ if (write) - bcopy(buffer, mypkt->data, buflen_u); + memcpy(mypkt->data, buffer, buflen_u); Status = sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt); /* For a read, copy the packet data back to the buffer. */ if (!write) - bcopy(mypkt->data, buffer, buflen_u); + memcpy(buffer, mypkt->data, buflen_u); - pkt_buf_free_skb(sd->osh, mypkt, write ? true : false); + pkt_buf_free_skb(mypkt); } else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) { /* Case 2: We have a packet, but it is unaligned. */ @@ -1066,7 +1063,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, sd_data(("%s: Creating aligned %s Packet, len=%d\n", __func__, write ? "TX" : "RX", pkt->len)); - mypkt = pkt_buf_get_skb(sd->osh, pkt->len); + mypkt = pkt_buf_get_skb(pkt->len); if (!mypkt) { sd_err(("%s: pkt_buf_get_skb failed: len %d\n", __func__, pkt->len)); @@ -1075,16 +1072,16 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, /* For a write, copy the buffer data into the packet. */ if (write) - bcopy(pkt->data, mypkt->data, pkt->len); + memcpy(mypkt->data, pkt->data, pkt->len); Status = sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt); /* For a read, copy the packet data back to the buffer. */ if (!write) - bcopy(mypkt->data, pkt->data, mypkt->len); + memcpy(pkt->data, mypkt->data, mypkt->len); - pkt_buf_free_skb(sd->osh, mypkt, write ? true : false); + pkt_buf_free_skb(mypkt); } else { /* case 3: We have a packet and it is aligned. */ sd_data(("%s: Aligned %s Packet, direct DMA\n", diff --git a/drivers/staging/brcm80211/include/bcmsdh_sdmmc.h b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.h index 4d671ddb3af1..3ef42b318493 100644 --- a/drivers/staging/brcm80211/include/bcmsdh_sdmmc.h +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.h @@ -18,12 +18,36 @@ #define __BCMSDH_SDMMC_H__ #ifdef BCMDBG -#define sd_err(x) do { if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) printf x; } while (0) -#define sd_trace(x) do { if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) printf x; } while (0) -#define sd_info(x) do { if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) printf x; } while (0) -#define sd_debug(x) do { if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) printf x; } while (0) -#define sd_data(x) do { if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) printf x; } while (0) -#define sd_ctrl(x) do { if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) printf x; } while (0) +#define sd_err(x) \ + do { \ + if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define sd_trace(x) \ + do { \ + if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define sd_info(x) \ + do { \ + if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define sd_debug(x) \ + do { \ + if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define sd_data(x) \ + do { \ + if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define sd_ctrl(x) \ + do { \ + if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) #else #define sd_err(x) #define sd_trace(x) @@ -94,8 +118,8 @@ extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); */ /* Register mapping routines */ -extern u32 *sdioh_sdmmc_reg_map(struct osl_info *osh, s32 addr, int size); -extern void sdioh_sdmmc_reg_unmap(struct osl_info *osh, s32 addr, int size); +extern u32 *sdioh_sdmmc_reg_map(s32 addr, int size); +extern void sdioh_sdmmc_reg_unmap(s32 addr, int size); /* Interrupt (de)registration routines */ extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); diff --git a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c index ceaa47490680..d738d4da5443 100644 --- a/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c @@ -17,7 +17,6 @@ #include <linux/sched.h> /* request_irq() */ #include <linux/netdevice.h> #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <sdio.h> /* SDIO Specs */ #include <bcmsdbus.h> /* bcmsdh to/from specific controller APIs */ diff --git a/drivers/staging/brcm80211/brcmfmac/bcmutils.c b/drivers/staging/brcm80211/brcmfmac/bcmutils.c new file mode 100644 index 000000000000..8e1296a0009e --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/bcmutils.c @@ -0,0 +1 @@ +#include "../util/bcmutils.c" diff --git a/drivers/staging/brcm80211/brcmfmac/bcmwifi.c b/drivers/staging/brcm80211/brcmfmac/bcmwifi.c new file mode 100644 index 000000000000..9fe988c1b940 --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/bcmwifi.c @@ -0,0 +1 @@ +#include "../util/bcmwifi.c" diff --git a/drivers/staging/brcm80211/brcmfmac/dhd.h b/drivers/staging/brcm80211/brcmfmac/dhd.h index 69c6a0272812..60cf78213a07 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd.h @@ -33,9 +33,6 @@ #include <linux/ethtool.h> #include <asm/uaccess.h> #include <asm/unaligned.h> -#if defined(CONFIG_HAS_WAKELOCK) -#include <linux/wakelock.h> -#endif /* defined (CONFIG_HAS_WAKELOCK) */ /* The kernel threading is sdio-specific */ #include <wlioctl.h> @@ -52,32 +49,9 @@ enum dhd_bus_state { DHD_BUS_DATA /* Ready for frame transfers */ }; -enum dhd_bus_wake_state { - WAKE_LOCK_OFF, - WAKE_LOCK_PRIV, - WAKE_LOCK_DPC, - WAKE_LOCK_IOCTL, - WAKE_LOCK_DOWNLOAD, - 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_MAX -}; -enum dhd_prealloc_index { - DHD_PREALLOC_PROT = 0, - DHD_PREALLOC_RXBUF, - DHD_PREALLOC_DATABUF, - DHD_PREALLOC_OSL_BUF -}; - /* Common structure for module and instance linkage */ typedef struct dhd_pub { /* Linkage ponters */ - struct osl_info *osh; /* OSL handle */ struct dhd_bus *bus; /* Bus module handle */ struct dhd_prot *prot; /* Protocol module handle */ struct dhd_info *info; /* Info module handle */ @@ -95,8 +69,8 @@ typedef struct dhd_pub { /* Dongle media info */ bool iswl; /* Dongle-resident driver is wl */ unsigned long drv_version; /* Version of dongle-resident driver */ - struct ether_addr mac; /* MAC address obtained from dongle */ - dngl_stats_t dstats; /* Stats for dongle-based data */ + u8 mac[ETH_ALEN]; /* MAC address obtained from dongle */ + dngl_stats_t dstats; /* Stats for dongle-based data */ /* Additional stats for the bus level */ unsigned long tx_packets; /* Data packets sent to dongle */ @@ -145,9 +119,6 @@ typedef struct dhd_pub { u8 country_code[WLC_CNTRY_BUF_SZ]; char eventmask[WL_EVENTING_MASK_LEN]; -#if defined(CONFIG_HAS_WAKELOCK) - struct wake_lock wakelock[WAKE_LOCK_MAX]; -#endif /* defined (CONFIG_HAS_WAKELOCK) */ } dhd_pub_t; #if defined(CONFIG_PM_SLEEP) @@ -230,41 +201,6 @@ static inline void MUTEX_UNLOCK_WL_SCAN_SET(void) { } -static inline void WAKE_LOCK_INIT(dhd_pub_t *dhdp, int index, char *y) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_init(&dhdp->wakelock[index], WAKE_LOCK_SUSPEND, y); -#endif /* defined (CONFIG_HAS_WAKELOCK) */ -} - -static inline void WAKE_LOCK(dhd_pub_t *dhdp, int index) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock(&dhdp->wakelock[index]); -#endif /* defined (CONFIG_HAS_WAKELOCK) */ -} - -static inline void WAKE_UNLOCK(dhd_pub_t *dhdp, int index) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_unlock(&dhdp->wakelock[index]); -#endif /* defined (CONFIG_HAS_WAKELOCK) */ -} - -static inline void WAKE_LOCK_TIMEOUT(dhd_pub_t *dhdp, int index, long time) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_timeout(&dhdp->wakelock[index], time); -#endif /* defined (CONFIG_HAS_WAKELOCK) */ -} - -static inline void WAKE_LOCK_DESTROY(dhd_pub_t *dhdp, int index) -{ -#if defined(CONFIG_HAS_WAKELOCK) - wake_lock_destroy(&dhdp->wakelock[index]); -#endif /* defined (CONFIG_HAS_WAKELOCK) */ -} - typedef struct dhd_if_event { u8 ifidx; u8 action; @@ -276,16 +212,12 @@ typedef struct dhd_if_event { * Exported from dhd OS modules (dhd_linux/dhd_ndis) */ -/* To allow osl_attach/detach calls from os-independent modules */ -struct osl_info *dhd_osl_attach(void *pdev, uint bustype); -void dhd_osl_detach(struct osl_info *osh); - /* Indication from bus module regarding presence/insertion of dongle. * Return dhd_pub_t pointer, used as handle to OS module in later calls. * Returned structure should have bus and prot pointers filled in. * bus_hdrlen specifies required headroom for bus module header. */ -extern dhd_pub_t *dhd_attach(struct osl_info *osh, struct dhd_bus *bus, +extern dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen); extern int dhd_net_attach(dhd_pub_t *dhdp, int idx); @@ -364,7 +296,6 @@ extern int dhd_ifname2idx(struct dhd_info *dhd, char *name); extern u8 *dhd_bssidx2bssid(dhd_pub_t *dhd, int idx); extern int wl_host_event(struct dhd_info *dhd, int *idx, void *pktdata, wl_event_msg_t *, void **data_ptr); -extern void wl_event_to_host_order(wl_event_msg_t *evt); extern void dhd_common_init(void); @@ -389,14 +320,12 @@ extern int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag); extern uint dhd_bus_status(dhd_pub_t *dhdp); extern int dhd_bus_start(dhd_pub_t *dhdp); -extern void print_buf(void *pbuf, int len, int bytes_per_line); - -typedef enum cust_gpio_modes { +enum cust_gpio_modes { WLAN_RESET_ON, WLAN_RESET_OFF, WLAN_POWER_ON, WLAN_POWER_OFF -} cust_gpio_modes_t; +}; /* * Insmod parameters for debug/test */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h index cd0d5400bf07..065f1aeb6ca9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_bus.h @@ -27,7 +27,7 @@ extern void dhd_bus_unregister(void); /* Download firmware image and nvram image */ extern bool dhd_bus_download_firmware(struct dhd_bus *bus, - struct osl_info *osh, char *fw_path, char *nv_path); + char *fw_path, char *nv_path); /* Stop bus module: clear pending frames, disable data flow */ extern void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index b7b527f5024c..39a4d001fbd0 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -17,11 +17,9 @@ #include <linux/types.h> #include <linux/netdevice.h> #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <bcmcdc.h> -#include <bcmendian.h> #include <dngl_stats.h> #include <dhd.h> @@ -65,7 +63,7 @@ typedef struct dhd_prot { static int dhdcdc_msg(dhd_pub_t *dhd) { dhd_prot_t *prot = dhd->prot; - int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t); + int len = le32_to_cpu(prot->msg.len) + sizeof(cdc_ioctl_t); DHD_TRACE(("%s: Enter\n", __func__)); @@ -93,7 +91,7 @@ static int dhdcdc_cmplt(dhd_pub_t *dhd, u32 id, u32 len) len + sizeof(cdc_ioctl_t)); if (ret < 0) break; - } while (CDC_IOC_ID(ltoh32(prot->msg.flags)) != id); + } while (CDC_IOC_ID(le32_to_cpu(prot->msg.flags)) != id); return ret; } @@ -124,11 +122,11 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) memset(msg, 0, sizeof(cdc_ioctl_t)); - msg->cmd = htol32(cmd); - msg->len = htol32(len); + msg->cmd = cpu_to_le32(cmd); + msg->len = cpu_to_le32(len); msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT); CDC_SET_IF_IDX(msg, ifidx); - msg->flags = htol32(msg->flags); + msg->flags = cpu_to_le32(msg->flags); if (buf) memcpy(prot->buf, buf, len); @@ -146,7 +144,7 @@ retry: if (ret < 0) goto done; - flags = ltoh32(msg->flags); + flags = le32_to_cpu(msg->flags); id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; if ((id < prot->reqid) && (++retries < RETRIES)) @@ -170,7 +168,7 @@ retry: /* Check the ERROR flag */ if (flags & CDCF_IOC_ERROR) { - ret = ltoh32(msg->status); + ret = le32_to_cpu(msg->status); /* Cache error from dongle */ dhd->dongle_error = ret; } @@ -191,11 +189,11 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) memset(msg, 0, sizeof(cdc_ioctl_t)); - msg->cmd = htol32(cmd); - msg->len = htol32(len); + msg->cmd = cpu_to_le32(cmd); + msg->len = cpu_to_le32(len); msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT) | CDCF_IOC_SET; CDC_SET_IF_IDX(msg, ifidx); - msg->flags = htol32(msg->flags); + msg->flags = cpu_to_le32(msg->flags); if (buf) memcpy(prot->buf, buf, len); @@ -208,7 +206,7 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) if (ret < 0) goto done; - flags = ltoh32(msg->flags); + flags = le32_to_cpu(msg->flags); id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT; if (id != prot->reqid) { @@ -220,7 +218,7 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len) /* Check the ERROR flag */ if (flags & CDCF_IOC_ERROR) { - ret = ltoh32(msg->status); + ret = le32_to_cpu(msg->status); /* Cache error from dongle */ dhd->dongle_error = ret; } @@ -276,8 +274,8 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len) ret = 0; else { cdc_ioctl_t *msg = &prot->msg; - ioc->needed = ltoh32(msg->len); /* len == needed when set/query - fails from dongle */ + /* len == needed when set/query fails from dongle */ + ioc->needed = le32_to_cpu(msg->len); } /* Intercept the wme_dp ioctl here */ @@ -286,8 +284,8 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len) slen = strlen("wme_dp") + 1; if (len >= (int)(slen + sizeof(int))) - bcopy(((char *)buf + slen), &val, sizeof(int)); - dhd->wme_dp = (u8) ltoh32(val); + memcpy(&val, (char *)buf + slen, sizeof(int)); + dhd->wme_dp = (u8) le32_to_cpu(val); } prot->pending = false; @@ -345,26 +343,6 @@ void dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, struct sk_buff *pktbuf) BDC_SET_IF_IDX(h, ifidx); } -bool dhd_proto_fcinfo(dhd_pub_t *dhd, struct sk_buff *pktbuf, u8 * fcbits) -{ -#ifdef BDC - struct bdc_header *h; - - if (pktbuf->len < BDC_HEADER_LEN) { - DHD_ERROR(("%s: rx data too short (%d < %d)\n", - __func__, pktbuf->len, BDC_HEADER_LEN)); - return BCME_ERROR; - } - - h = (struct bdc_header *)(pktbuf->data); - - *fcbits = h->priority >> BDC_PRIORITY_FC_SHIFT; - if ((h->flags2 & BDC_FLAG2_FC_FLAG) == BDC_FLAG2_FC_FLAG) - return true; -#endif - return false; -} - int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, struct sk_buff *pktbuf) { #ifdef BDC @@ -437,8 +415,7 @@ int dhd_prot_attach(dhd_pub_t *dhd) return 0; fail: - if (cdc != NULL) - kfree(cdc); + kfree(cdc); return BCME_NOMEM; } @@ -477,7 +454,7 @@ int dhd_prot_init(dhd_pub_t *dhd) dhd_os_proto_unblock(dhd); return ret; } - memcpy(dhd->mac.octet, buf, ETH_ALEN); + memcpy(dhd->mac, buf, ETH_ALEN); dhd_os_proto_unblock(dhd); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 3dbf72eebd4a..aa171f6181e9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -17,9 +17,7 @@ #include <linux/string.h> #include <bcmdefs.h> #include <linux/netdevice.h> -#include <osl.h> #include <bcmutils.h> -#include <bcmendian.h> #include <dngl_stats.h> #include <dhd.h> #include <dhd_bus.h> @@ -37,11 +35,6 @@ u32 dhd_conn_event; u32 dhd_conn_status; u32 dhd_conn_reason; -#define htod32(i) i -#define htod16(i) i -#define dtoh32(i) i -#define dtoh16(i) i - extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len); extern void dhd_ind_scan_confirm(void *h, bool status); @@ -57,8 +50,8 @@ void dhd_iscan_unlock(void); #error DHD_SDALIGN is not a power of 2! #endif -#ifdef DHD_DEBUG #define EPI_VERSION_STR "4.218.248.5" +#ifdef DHD_DEBUG const char dhd_version[] = "Dongle Host Driver, version " EPI_VERSION_STR "\nCompiled on " __DATE__ " at " __TIME__; @@ -214,7 +207,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, goto exit; if (plen >= (int)sizeof(int_val)) - bcopy(params, &int_val, sizeof(int_val)); + memcpy(&int_val, params, sizeof(int_val)); switch (actionid) { case IOV_GVAL(IOV_VERSION): @@ -224,7 +217,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_MSGLEVEL): int_val = (s32) dhd_msg_level; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_MSGLEVEL): @@ -239,12 +232,12 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_BCMERROR): int_val = (s32) dhd_pub->bcmerror; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_WDTICK): int_val = (s32) dhd_watchdog_ms; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_WDTICK): @@ -262,7 +255,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, #ifdef DHD_DEBUG case IOV_GVAL(IOV_DCONSOLE_POLL): int_val = (s32) dhd_console_ms; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_DCONSOLE_POLL): @@ -290,7 +283,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_IOCTLTIMEOUT):{ int_val = (s32) dhd_os_get_ioctl_resp_timeout(); - bcopy(&int_val, arg, sizeof(int_val)); + memcpy(arg, &int_val, sizeof(int_val)); break; } @@ -312,21 +305,6 @@ exit: return bcmerror; } -/* Store the status of a connection attempt for later retrieval by an iovar */ -void dhd_store_conn_status(u32 event, u32 status, u32 reason) -{ - /* Do not overwrite a WLC_E_PRUNE with a WLC_E_SET_SSID - * because an encryption/rsn mismatch results in both events, and - * the important information is in the WLC_E_PRUNE. - */ - if (!(event == WLC_E_SET_SSID && status == WLC_E_STATUS_FAIL && - dhd_conn_event == WLC_E_PRUNE)) { - dhd_conn_event = event; - dhd_conn_status = status; - dhd_conn_reason = reason; - } -} - bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt, int prec) { @@ -368,7 +346,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt, ASSERT(p); } - pkt_buf_free_skb(dhdp->osh, p, true); + pkt_buf_free_skb(p); } /* Enqueue */ @@ -592,14 +570,14 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) WLC_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"} }; uint event_type, flags, auth_type, datalen; - event_type = ntoh32(event->event_type); - flags = ntoh16(event->flags); - status = ntoh32(event->status); - reason = ntoh32(event->reason); - auth_type = ntoh32(event->auth_type); - datalen = ntoh32(event->datalen); + event_type = be32_to_cpu(event->event_type); + flags = be16_to_cpu(event->flags); + status = be32_to_cpu(event->status); + reason = be32_to_cpu(event->reason); + auth_type = be32_to_cpu(event->auth_type); + datalen = be32_to_cpu(event->datalen); /* debug dump of event messages */ - sprintf(eabuf, "%pM", event->addr.octet); + sprintf(eabuf, "%pM", event->addr); event_name = "UNKNOWN"; for (i = 0; i < ARRAY_SIZE(event_names); i++) { @@ -653,9 +631,9 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) case WLC_E_AUTH: case WLC_E_AUTH_IND: - if (auth_type == DOT11_OPEN_SYSTEM) + if (auth_type == WLAN_AUTH_OPEN) auth_str = "Open System"; - else if (auth_type == DOT11_SHARED_KEY) + else if (auth_type == WLAN_AUTH_SHARED_KEY) auth_str = "Shared Key"; else { sprintf(err_msg, "AUTH unknown: %d", (int)auth_type); @@ -754,34 +732,35 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) memcpy(&hdr, buf, MSGTRACE_HDRLEN); if (hdr.version != MSGTRACE_VERSION) { - printf + DHD_ERROR( ("\nMACEVENT: %s [unsupported version --> " "dhd version:%d dongle version:%d]\n", - event_name, MSGTRACE_VERSION, hdr.version); + event_name, MSGTRACE_VERSION, hdr.version) + ); /* Reset datalen to avoid display below */ datalen = 0; break; } /* There are 2 bytes available at the end of data */ - buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0'; + buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0'; - if (ntoh32(hdr.discarded_bytes) - || ntoh32(hdr.discarded_printf)) { - printf + if (be32_to_cpu(hdr.discarded_bytes) + || be32_to_cpu(hdr.discarded_printf)) { + DHD_ERROR( ("\nWLC_E_TRACE: [Discarded traces in dongle -->" "discarded_bytes %d discarded_printf %d]\n", - ntoh32(hdr.discarded_bytes), - ntoh32(hdr.discarded_printf)); + be32_to_cpu(hdr.discarded_bytes), + be32_to_cpu(hdr.discarded_printf))); } - nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1; + nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; if (nblost > 0) { - printf + DHD_ERROR( ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n", - ntoh32(hdr.seqnum), nblost); + be32_to_cpu(hdr.seqnum), nblost)); } - seqnum_prev = ntoh32(hdr.seqnum); + seqnum_prev = be32_to_cpu(hdr.seqnum); /* Display the trace buffer. Advance from \n to \n to * avoid display big @@ -790,10 +769,10 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) p = (char *)&buf[MSGTRACE_HDRLEN]; while ((s = strstr(p, "\n")) != NULL) { *s = '\0'; - printf("%s\n", p); + printk(KERN_DEBUG"%s\n", p); p = s + 1; } - printf("%s\n", p); + printk(KERN_DEBUG "%s\n", p); /* Reset datalen to avoid display below */ datalen = 0; @@ -802,7 +781,7 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) case WLC_E_RSSI: DHD_EVENT(("MACEVENT: %s %d\n", event_name, - ntoh32(*((int *)event_data)))); + be32_to_cpu(*((int *)event_data)))); break; default: @@ -840,7 +819,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, } /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */ - if (ntoh16_ua((void *)&pvt_data->bcm_hdr.usr_subtype) != + if (get_unaligned_be16(&pvt_data->bcm_hdr.usr_subtype) != BCMILCP_BCM_SUBTYPE_EVENT) { DHD_ERROR(("%s: mismatched subtype, bailing\n", __func__)); return BCME_ERROR; @@ -852,10 +831,10 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, /* memcpy since BRCM event pkt may be unaligned. */ memcpy(event, &pvt_data->event, sizeof(wl_event_msg_t)); - type = ntoh32_ua((void *)&event->event_type); - flags = ntoh16_ua((void *)&event->flags); - status = ntoh32_ua((void *)&event->status); - evlen = ntoh32_ua((void *)&event->datalen) + sizeof(bcm_event_t); + type = get_unaligned_be32(&event->event_type); + flags = get_unaligned_be16(&event->flags); + status = get_unaligned_be32(&event->status); + evlen = get_unaligned_be32(&event->datalen) + sizeof(bcm_event_t); switch (type) { case WLC_E_IF: @@ -868,7 +847,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, if (ifevent->action == WLC_E_IF_ADD) dhd_add_if(dhd, ifevent->ifidx, NULL, event->ifname, - pvt_data->eth.ether_dhost, + pvt_data->eth.h_dest, ifevent->flags, ifevent->bssidx); else @@ -909,10 +888,10 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, if (type == WLC_E_NDIS_LINK) { u32 temp; - temp = ntoh32_ua((void *)&event->event_type); + temp = get_unaligned_be32(&event->event_type); DHD_TRACE(("Converted to WLC_E_LINK type %d\n", temp)); - temp = ntoh32(WLC_E_NDIS_LINK); + temp = be32_to_cpu(WLC_E_NDIS_LINK); memcpy((void *)(&pvt_data->event.event_type), &temp, sizeof(pvt_data->event.event_type)); } @@ -926,42 +905,6 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, return BCME_OK; } -void wl_event_to_host_order(wl_event_msg_t *evt) -{ - /* Event struct members passed from dongle to host are stored - * in network - * byte order. Convert all members to host-order. - */ - evt->event_type = ntoh32(evt->event_type); - evt->flags = ntoh16(evt->flags); - evt->status = ntoh32(evt->status); - evt->reason = ntoh32(evt->reason); - evt->auth_type = ntoh32(evt->auth_type); - evt->datalen = ntoh32(evt->datalen); - evt->version = ntoh16(evt->version); -} - -void print_buf(void *pbuf, int len, int bytes_per_line) -{ - int i, j = 0; - unsigned char *buf = pbuf; - - if (bytes_per_line == 0) - bytes_per_line = len; - - for (i = 0; i < len; i++) { - printf("%2.2x", *buf++); - j++; - if (j == bytes_per_line) { - printf("\n"); - j = 0; - } else { - printf(":"); - } - } - printf("\n"); -} - /* Convert user's input in hex pattern to byte-size mask */ static int wl_pattern_atoh(char *src, char *dst) { @@ -1025,10 +968,10 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable, pkt_filterp = (wl_pkt_filter_enable_t *) (buf + str_len + 1); /* Parse packet filter id. */ - enable_parm.id = htod32(simple_strtoul(argv[i], NULL, 0)); + enable_parm.id = simple_strtoul(argv[i], NULL, 0); /* Parse enable/disable value. */ - enable_parm.enable = htod32(enable); + enable_parm.enable = enable; buf_len += sizeof(enable_parm); memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm)); @@ -1053,8 +996,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable, __func__, arg, rc)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); } void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) @@ -1113,7 +1055,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) pkt_filterp = (wl_pkt_filter_t *) (buf + str_len + 1); /* Parse packet filter id. */ - pkt_filter.id = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.id = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Polarity not provided\n")); @@ -1121,7 +1063,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse filter polarity. */ - pkt_filter.negate_match = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Filter type not provided\n")); @@ -1129,7 +1071,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse filter type. */ - pkt_filter.type = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.type = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Offset not provided\n")); @@ -1137,7 +1079,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse pattern filter offset. */ - pkt_filter.u.pattern.offset = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Bitmask not provided\n")); @@ -1146,8 +1088,8 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) /* Parse pattern filter mask. */ mask_size = - htod32(wl_pattern_atoh - (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern)); + wl_pattern_atoh + (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern); if (NULL == argv[++i]) { DHD_ERROR(("Pattern not provided\n")); @@ -1156,9 +1098,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) /* Parse pattern filter pattern. */ pattern_size = - htod32(wl_pattern_atoh(argv[i], + wl_pattern_atoh(argv[i], (char *)&pkt_filterp->u.pattern. - mask_and_pattern[mask_size])); + mask_and_pattern[mask_size]); if (mask_size != pattern_size) { DHD_ERROR(("Mask and pattern not the same size\n")); @@ -1189,11 +1131,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) __func__, arg)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); - if (buf) - kfree(buf); + kfree(buf); } void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode) @@ -1242,7 +1182,7 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd) int scan_unassoc_time = 40; #ifdef GET_CUSTOM_MAC_ENABLE int ret = 0; - struct ether_addr ea_addr; + u8 ea_addr[ETH_ALEN]; #endif /* GET_CUSTOM_MAC_ENABLE */ dhd_os_proto_block(dhd); @@ -1254,9 +1194,9 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd) ** firmware but unique per board mac address maybe provided by ** customer code */ - ret = dhd_custom_get_mac_address(ea_addr.octet); + ret = dhd_custom_get_mac_address(ea_addr); if (!ret) { - bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETH_ALEN, + bcm_mkiovar("cur_etheraddr", (void *)ea_addr, ETH_ALEN, buf, sizeof(buf)); ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf)); if (ret < 0) { @@ -1478,8 +1418,7 @@ int dhd_iscan_print_cache(iscan_buf_t *iscan_skip) bi->BSSID.octet[2], bi->BSSID.octet[3], bi->BSSID.octet[4], bi->BSSID.octet[5])); - bi = (wl_bss_info_t *)((unsigned long)bi + - dtoh32(bi->length)); + bi = (wl_bss_info_t *)((unsigned long)bi + bi->length); } iscan_cur = iscan_cur->next; l++; @@ -1543,18 +1482,16 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip) bi->BSSID.octet[5])); bi_new = bi; - bi = (wl_bss_info_t *)((unsigned long)bi + - dtoh32 - (bi->length)); + bi = (wl_bss_info_t *)((unsigned long) + bi + bi->length); /* if(bi && bi_new) { - bcopy(bi, bi_new, results->buflen - - dtoh32(bi_new->length)); - results->buflen -= dtoh32(bi_new->length); + memcpy(bi_new, bi, results->buflen - + bi_new->length); + results->buflen -= bi_new->length; } */ - results->buflen -= - dtoh32(bi_new->length); + results->buflen -= bi_new->length; results->count--; for (j = i; j < results->count; j++) { @@ -1570,16 +1507,13 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip) bi_next = (wl_bss_info_t *)((unsigned long)bi + - dtoh32 - (bi->length)); - bcopy(bi, bi_new, - dtoh32 - (bi->length)); + bi->length); + memcpy(bi_new, bi, + bi->length); bi_new = (wl_bss_info_t *)((unsigned long)bi_new + - dtoh32 - (bi_new-> - length)); + bi_new-> + length); bi = bi_next; } } @@ -1594,7 +1528,7 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip) break; } bi = (wl_bss_info_t *)((unsigned long)bi + - dtoh32(bi->length)); + bi->length); } } iscan_cur = iscan_cur->next; @@ -1648,7 +1582,7 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur) dhd_iscan_delete_bss(dhdp, bi->BSSID.octet, iscan_cur); - bi = (wl_bss_info_t *)((unsigned long)bi + dtoh32(bi->length)); + bi = (wl_bss_info_t *)((unsigned long)bi + bi->length); } done: @@ -1677,15 +1611,15 @@ int dhd_iscan_request(void *dhdp, u16 action) params.params.bss_type = DOT11_BSSTYPE_ANY; params.params.scan_type = DOT11_SCANTYPE_ACTIVE; - params.params.nprobes = htod32(-1); - params.params.active_time = htod32(-1); - params.params.passive_time = htod32(-1); - params.params.home_time = htod32(-1); - params.params.channel_num = htod32(0); + params.params.nprobes = -1; + params.params.active_time = -1; + params.params.passive_time = -1; + params.params.home_time = -1; + params.params.channel_num = 0; - params.version = htod32(ISCAN_REQ_VERSION); - params.action = htod16(action); - params.scan_duration = htod16(0); + params.version = ISCAN_REQ_VERSION; + params.action = action; + params.scan_duration = 0; bcm_mkiovar("iscan", (char *)¶ms, sizeof(wl_iscan_params_t), buf, WLC_IOCTL_SMLEN); @@ -1722,16 +1656,16 @@ static int dhd_iscan_get_partial_result(void *dhdp, uint *scan_count) results->count = 0; memset(&list, 0, sizeof(list)); - list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN); + list.results.buflen = WLC_IW_ISCAN_MAXLEN; bcm_mkiovar("iscanresults", (char *)&list, WL_ISCAN_RESULTS_FIXED_SIZE, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN); rc = dhd_wl_ioctl(dhdp, WLC_GET_VAR, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN); - results->buflen = dtoh32(results->buflen); - results->version = dtoh32(results->version); - *scan_count = results->count = dtoh32(results->count); - status = dtoh32(list_buf->status); + results->buflen = results->buflen; + results->version = results->version; + *scan_count = results->count = results->count; + status = list_buf->status; dhd_iscan_unlock(); @@ -1854,12 +1788,12 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc 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)); + pfn_param.version = PFN_VERSION; + pfn_param.flags = (PFN_LIST_ORDER << SORT_CRITERIA_BIT); /* set up pno scan fr */ if (scan_fr != 0) - pfn_param.scan_freq = htod32(scan_fr); + pfn_param.scan_freq = scan_fr; bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf, sizeof(iovbuf)); @@ -1868,11 +1802,11 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc /* 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); + pfn_element.bss_type = DOT11_BSSTYPE_INFRASTRUCTURE; + pfn_element.auth = WLAN_AUTH_OPEN; + pfn_element.wpa_auth = WPA_AUTH_PFN_ANY; + pfn_element.wsec = 0; + pfn_element.infra = 1; memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID, ssids_local[i].SSID_len); diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_custom_gpio.c b/drivers/staging/brcm80211/brcmfmac/dhd_custom_gpio.c index c3f18bb3b27c..cbfa1c1b7059 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_custom_gpio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_custom_gpio.c @@ -15,7 +15,6 @@ */ #include <linux/netdevice.h> -#include <osl.h> #include <bcmutils.h> #include <dngl_stats.h> @@ -149,9 +148,8 @@ int dhd_custom_get_mac_address(unsigned char *buf) #ifdef EXAMPLE_GET_MAC /* EXAMPLE code */ { - struct ether_addr ea_example = { - {0x00, 0x11, 0x22, 0x33, 0x44, 0xFF} }; - bcopy((char *)&ea_example, buf, sizeof(struct ether_addr)); + u8 ea_example[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}; + memcpy(buf, ea_example, ETH_ALEN); } #endif /* EXAMPLE_GET_MAC */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h index cd2578ad3552..0817f1348e09 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h @@ -21,31 +21,31 @@ #define DHD_ERROR(args) \ do {if ((dhd_msg_level & DHD_ERROR_VAL) && (net_ratelimit())) \ - printf args; } while (0) + printk args; } while (0) #define DHD_TRACE(args) do {if (dhd_msg_level & DHD_TRACE_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_INFO(args) do {if (dhd_msg_level & DHD_INFO_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_DATA(args) do {if (dhd_msg_level & DHD_DATA_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_CTL(args) do {if (dhd_msg_level & DHD_CTL_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_TIMER(args) do {if (dhd_msg_level & DHD_TIMER_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_HDRS(args) do {if (dhd_msg_level & DHD_HDRS_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_BYTES(args) do {if (dhd_msg_level & DHD_BYTES_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_INTR(args) do {if (dhd_msg_level & DHD_INTR_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_GLOM(args) do {if (dhd_msg_level & DHD_GLOM_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_EVENT(args) do {if (dhd_msg_level & DHD_EVENT_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_BTA(args) do {if (dhd_msg_level & DHD_BTA_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_ISCAN(args) do {if (dhd_msg_level & DHD_ISCAN_VAL) \ - printf args; } while (0) + printk args; } while (0) #define DHD_ERROR_ON() (dhd_msg_level & DHD_ERROR_VAL) #define DHD_TRACE_ON() (dhd_msg_level & DHD_TRACE_VAL) @@ -63,7 +63,7 @@ #else /* (defined BCMDBG) || (defined DHD_DEBUG) */ -#define DHD_ERROR(args) do {if (net_ratelimit()) printf args; } while (0) +#define DHD_ERROR(args) do {if (net_ratelimit()) printk args; } while (0) #define DHD_TRACE(args) #define DHD_INFO(args) #define DHD_DATA(args) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index db4508378775..02c6d446934c 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -32,11 +32,8 @@ #include <linux/fs.h> #include <linux/uaccess.h> #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> -#include <bcmendian.h> -#include <proto/ethernet.h> #include <dngl_stats.h> #include <dhd.h> #include <dhd_bus.h> @@ -45,7 +42,8 @@ #include <wl_cfg80211.h> -#define EPI_VERSION_STR "4.218.248.5" +#define EPI_VERSION_STR "4.218.248.5" +#define ETH_P_BRCM 0x886c #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) #include <linux/wifi_tiwlan.h> @@ -149,7 +147,7 @@ static struct platform_driver wifi_device = { .suspend = wifi_suspend, .resume = wifi_resume, .driver = { - .name = "bcm4329_wlan", + .name = KBUILD_MODNAME, } }; @@ -247,7 +245,7 @@ typedef struct dhd_info { struct semaphore sysioc_sem; bool set_multicast; bool set_macaddress; - struct ether_addr macvalue; + u8 macvalue[ETH_ALEN]; wait_queue_head_t ctrl_wait; atomic_t pend_8021x_cnt; @@ -387,12 +385,6 @@ module_param(dhd_pktgen_len, uint, 0); #define DHD_COMPILED #endif -static char dhd_version[] = "Dongle Host Driver, version " EPI_VERSION_STR -#ifdef DHD_DEBUG -"\nCompiled in " " on " __DATE__ " at " __TIME__ -#endif -; - #if defined(CONFIG_WIRELESS_EXT) struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev); #endif /* defined(CONFIG_WIRELESS_EXT) */ @@ -719,7 +711,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx) strcpy(bufp, "mcast_list"); bufp += strlen("mcast_list") + 1; - cnt = htol32(cnt); + cnt = cpu_to_le32(cnt); memcpy(bufp, &cnt, sizeof(cnt)); bufp += sizeof(cnt); @@ -758,7 +750,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx) dhd_ifname(&dhd->pub, ifidx))); return; } - allmulti = htol32(allmulti); + allmulti = cpu_to_le32(allmulti); if (!bcm_mkiovar ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) { @@ -778,7 +770,8 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx) ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { DHD_ERROR(("%s: set allmulti %d failed\n", - dhd_ifname(&dhd->pub, ifidx), ltoh32(allmulti))); + dhd_ifname(&dhd->pub, ifidx), + le32_to_cpu(allmulti))); } kfree(buf); @@ -787,7 +780,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx) driver does */ allmulti = (dev->flags & IFF_PROMISC) ? true : false; - allmulti = htol32(allmulti); + allmulti = cpu_to_le32(allmulti); memset(&ioc, 0, sizeof(ioc)); ioc.cmd = WLC_SET_PROMISC; @@ -798,12 +791,13 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx) ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len); if (ret < 0) { DHD_ERROR(("%s: set promisc %d failed\n", - dhd_ifname(&dhd->pub, ifidx), ltoh32(allmulti))); + dhd_ifname(&dhd->pub, ifidx), + le32_to_cpu(allmulti))); } } static int -_dhd_set_mac_address(dhd_info_t *dhd, int ifidx, struct ether_addr *addr) +_dhd_set_mac_address(dhd_info_t *dhd, int ifidx, u8 *addr) { char buf[32]; wl_ioctl_t ioc; @@ -976,7 +970,7 @@ static int _dhd_sysioc_thread(void *data) if (dhd->set_macaddress) { dhd->set_macaddress = false; _dhd_set_mac_address(dhd, i, - &dhd->macvalue); + dhd->macvalue); } } } @@ -1030,11 +1024,11 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf) /* Update multicast statistic */ if (pktbuf->len >= ETH_ALEN) { u8 *pktdata = (u8 *) (pktbuf->data); - struct ether_header *eh = (struct ether_header *)pktdata; + struct ethhdr *eh = (struct ethhdr *)pktdata; - if (is_multicast_ether_addr(eh->ether_dhost)) + if (is_multicast_ether_addr(eh->h_dest)) dhdp->tx_multicast++; - if (ntoh16(eh->ether_type) == ETH_P_PAE) + if (ntohs(eh->h_proto) == ETH_P_PAE) atomic_inc(&dhd->pend_8021x_cnt); } @@ -1045,7 +1039,6 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf) #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 */ @@ -1053,30 +1046,20 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf) } static inline void * -osl_pkt_frmnative(struct osl_info *osh, struct sk_buff *skb) +osl_pkt_frmnative(struct sk_buff *skb) { - struct sk_buff *nskb; - - for (nskb = skb; nskb; nskb = nskb->next) - osh->pktalloced++; - return (void *)skb; } #define PKTFRMNATIVE(osh, skb) \ - osl_pkt_frmnative((osh), (struct sk_buff *)(skb)) + osl_pkt_frmnative((struct sk_buff *)(skb)) static inline struct sk_buff * -osl_pkt_tonative(struct osl_info *osh, void *pkt) +osl_pkt_tonative(void *pkt) { - struct sk_buff *nskb; - - for (nskb = (struct sk_buff *)pkt; nskb; nskb = nskb->next) - osh->pktalloced--; - return (struct sk_buff *)pkt; } #define PKTTONATIVE(osh, pkt) \ - osl_pkt_tonative((osh), (pkt)) + osl_pkt_tonative((pkt)) static int dhd_start_xmit(struct sk_buff *skb, struct net_device *net) { @@ -1215,7 +1198,7 @@ void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf, skb_pull(skb, ETH_HLEN); /* Process special event packets and then discard them */ - if (ntoh16(skb->protocol) == ETHER_TYPE_BRCM) + if (ntohs(skb->protocol) == ETH_P_BRCM) dhd_wl_host_event(dhd, &ifidx, skb_mac_header(skb), &event, &data); @@ -1254,13 +1237,13 @@ void dhd_txcomplete(dhd_pub_t *dhdp, struct sk_buff *txp, bool success) { uint ifidx; dhd_info_t *dhd = (dhd_info_t *) (dhdp->info); - struct ether_header *eh; + struct ethhdr *eh; u16 type; dhd_prot_hdrpull(dhdp, &ifidx, txp); - eh = (struct ether_header *)(txp->data); - type = ntoh16(eh->ether_type); + eh = (struct ethhdr *)(txp->data); + type = ntohs(eh->h_proto); if (type == ETH_P_PAE) atomic_dec(&dhd->pend_8021x_cnt); @@ -1304,7 +1287,6 @@ static struct net_device_stats *dhd_get_stats(struct net_device *net) static int 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 @@ -1325,18 +1307,14 @@ static int dhd_watchdog_thread(void *data) break; if (down_interruptible(&dhd->watchdog_sem) == 0) { if (dhd->pub.dongle_reset == false) { - WAKE_LOCK(&dhd->pub, WAKE_LOCK_WATCHDOG); /* 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++; } else break; } - - WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_WATCHDOG); return 0; } @@ -1370,7 +1348,6 @@ static int dhd_dpc_thread(void *data) { 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 */ @@ -1393,21 +1370,15 @@ static int dhd_dpc_thread(void *data) /* 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_bus_stop(dhd->pub.bus, true); } } else break; } - - WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_DPC); return 0; } @@ -1797,22 +1768,16 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd) 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); done: if (!bcmerror && buf && ioc.buf) { if (copy_to_user(ioc.buf, buf, buflen)) bcmerror = -EFAULT; } - if (buf) - kfree(buf); + kfree(buf); if (bcmerror > 0) bcmerror = 0; @@ -1866,7 +1831,7 @@ static int dhd_open(struct net_device *net) } atomic_set(&dhd->pend_8021x_cnt, 0); - memcpy(net->dev_addr, dhd->pub.mac.octet, ETH_ALEN); + memcpy(net->dev_addr, dhd->pub.mac, ETH_ALEN); #ifdef TOE /* Get current TOE mode from dongle */ @@ -1891,16 +1856,6 @@ static int dhd_open(struct net_device *net) return ret; } -struct osl_info *dhd_osl_attach(void *pdev, uint bustype) -{ - return osl_attach(pdev, bustype); -} - -void dhd_osl_detach(struct osl_info *osh) -{ - osl_detach(osh); -} - int dhd_add_if(dhd_info_t *dhd, int ifidx, void *handle, char *name, u8 *mac_addr, u32 flags, u8 bssidx) @@ -1954,8 +1909,7 @@ void dhd_del_if(dhd_info_t *dhd, int ifidx) up(&dhd->sysioc_sem); } -dhd_pub_t *dhd_attach(struct osl_info *osh, struct dhd_bus *bus, - uint bus_hdrlen) +dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen) { dhd_info_t *dhd = NULL; struct net_device *net; @@ -1976,19 +1930,16 @@ dhd_pub_t *dhd_attach(struct osl_info *osh, struct dhd_bus *bus, } /* Allocate primary dhd_info */ - dhd = kmalloc(sizeof(dhd_info_t), GFP_ATOMIC); + dhd = kzalloc(sizeof(dhd_info_t), GFP_ATOMIC); if (!dhd) { DHD_ERROR(("%s: OOM - alloc dhd_info\n", __func__)); goto fail; } - memset(dhd, 0, sizeof(dhd_info_t)); - /* * Save the dhd_info into the priv */ memcpy(netdev_priv(net), &dhd, sizeof(dhd)); - dhd->pub.osh = osh; /* Set network interface name if it was provided as module parameter */ if (iface_name[0]) { @@ -2115,11 +2066,6 @@ dhd_pub_t *dhd_attach(struct osl_info *osh, struct dhd_bus *bus, #endif /* 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"); - WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_PNO_FIND_TMOUT, - "dhd_wake_lock_link_pno_find_event"); #ifdef CONFIG_HAS_EARLYSUSPEND dhd->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 20; dhd->early_suspend.suspend = dhd_early_suspend; @@ -2153,20 +2099,13 @@ int dhd_bus_start(dhd_pub_t *dhdp) /* 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, + if (!(dhd_bus_download_firmware(dhd->pub.bus, fw_path, nv_path))) { DHD_ERROR(("%s: dhdsdio_probe_download failed. " "firmware = %s nvram = %s\n", __func__, 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 */ @@ -2203,7 +2142,7 @@ int dhd_bus_start(dhd_pub_t *dhdp) bcm_mkiovar("event_msgs", dhdp->eventmask, WL_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); dhdcdc_query_ioctl(dhdp, 0, WLC_GET_VAR, iovbuf, sizeof(iovbuf)); - bcopy(iovbuf, dhdp->eventmask, WL_EVENTING_MASK_LEN); + memcpy(dhdp->eventmask, iovbuf, WL_EVENTING_MASK_LEN); setbit(dhdp->eventmask, WLC_E_SET_SSID); setbit(dhdp->eventmask, WLC_E_PRUNE); @@ -2299,7 +2238,7 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx) */ if (ifidx != 0) { /* for virtual interfaces use the primary MAC */ - memcpy(temp_addr, dhd->pub.mac.octet, ETH_ALEN); + memcpy(temp_addr, dhd->pub.mac, ETH_ALEN); } @@ -2335,7 +2274,7 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx) goto fail; } - printf("%s: Broadcom Dongle Host Driver\n", net->name); + DHD_INFO(("%s: Broadcom Dongle Host Driver\n", net->name)); return 0; @@ -2432,9 +2371,6 @@ void dhd_detach(dhd_pub_t *dhdp) unregister_pm_notifier(&dhd_sleep_pm_notifier); #endif /* defined(CONFIG_PM_SLEEP) */ /* && defined(DHD_GPL) */ - WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_TMOUT); - WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_LINK_DOWN_TMOUT); - WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_PNO_FIND_TMOUT); free_netdev(ifp->net); kfree(ifp); kfree(dhd); @@ -2483,7 +2419,7 @@ static int __init dhd_module_init(void) error = wifi_add_dev(); if (error) { DHD_ERROR(("%s: platform_driver_register failed\n", __func__)); - goto faild; + goto failed; } /* Waiting callback after platform_driver_register is done or @@ -2493,21 +2429,19 @@ static int __init dhd_module_init(void) __func__); /* remove device */ wifi_del_dev(); - goto faild; + goto failed; } #endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */ error = dhd_bus_register(); - if (!error) - printf("\n%s\n", dhd_version); - else { + if (error) { DHD_ERROR(("%s: sdio_register_driver failed\n", __func__)); - goto faild; + goto failed; } return error; -faild: +failed: /* turn off power and exit */ dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF); return -EINVAL; @@ -2790,7 +2724,7 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata, /* send up locally generated event */ void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data) { - switch (ntoh32(event->event_type)) { + switch (be32_to_cpu(event->event_type)) { default: break; } @@ -2975,7 +2909,7 @@ int write_to_file(dhd_pub_t *dhd, u8 *buf, int size) /* open file to write */ fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640); if (!fp) { - printf("%s: open file error\n", __func__); + DHD_ERROR(("%s: open file error\n", __func__)); ret = -1; goto exit; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h index a5309e27b65b..030d5ffb0e83 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_proto.h +++ b/drivers/staging/brcm80211/brcmfmac/dhd_proto.h @@ -46,9 +46,6 @@ extern int dhd_prot_init(dhd_pub_t *dhdp); /* Stop protocol: sync w/dongle state. */ extern void dhd_prot_stop(dhd_pub_t *dhdp); -extern bool dhd_proto_fcinfo(dhd_pub_t *dhd, struct sk_buff *pktbuf, - u8 *fcbits); - /* Add any protocol-specific data header. * Caller must reserve prot_hdrlen prepend space. */ diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index 3edce44978a1..106627040db0 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -17,7 +17,6 @@ #include <linux/types.h> #include <bcmdefs.h> #include <linux/netdevice.h> -#include <osl.h> #include <bcmsdh.h> #ifdef BCMEMBEDIMAGE @@ -26,7 +25,6 @@ #include <bcmdefs.h> #include <bcmutils.h> -#include <bcmendian.h> #include <bcmdevs.h> #include <siutils.h> @@ -44,8 +42,6 @@ #include <sbsdpcmdev.h> #include <bcmsdpcm.h> -#include <proto/ethernet.h> -#include <proto/802.1d.h> #include <proto/802.11.h> #include <dngl_stats.h> @@ -61,9 +57,9 @@ #define DHDSDIO_MEM_DUMP_FNAME "mem_dump" #endif -#define QLEN 256 /* bulk rx and tx queue lengths */ -#define FCHI (QLEN - 10) -#define FCLOW (FCHI / 2) +#define TXQLEN 2048 /* bulk tx queue length */ +#define TXHI (TXQLEN - 256) /* turn on flow control above TXHI */ +#define TXLOW (TXHI - 256) /* turn off flow control below TXLOW */ #define PRIOMASK 7 #define TXRETRIES 2 /* # of retries for tx frames */ @@ -144,7 +140,15 @@ * bufpool was present for gspi bus. */ #define PKTFREE2() if ((bus->bus != SPI_BUS) || bus->usebufpool) \ - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); + +/* + * Conversion of 802.1D priority to precedence level + */ +#define PRIO2PREC(prio) \ + (((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? \ + ((prio^2)) : (prio)) + DHD_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep); extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len); @@ -329,7 +333,6 @@ uint dhd_txminmax; #define DONGLE_MIN_MEMSIZE (128 * 1024) int dhd_dongle_memsize; -static bool dhd_doflow; static bool dhd_alignctl; static bool sd1idle; @@ -357,7 +360,7 @@ extern void bcmsdh_enable_hw_oob_intr(void *sdh, bool enable); #if defined(OOB_INTR_ONLY) && defined(SDIO_ISR_THREAD) #error OOB_INTR_ONLY is NOT working with SDIO_ISR_THREAD #endif /* defined(OOB_INTR_ONLY) && defined(SDIO_ISR_THREAD) */ -#define PKTALIGN(_osh, _p, _len, _align) \ +#define PKTALIGN(_p, _len, _align) \ do { \ uint datalign; \ datalign = (unsigned long)((_p)->data); \ @@ -386,7 +389,7 @@ static bool dhd_readahead; do { \ retryvar = 0; \ do { \ - regvar = R_REG(bus->dhd->osh, regaddr); \ + regvar = R_REG(regaddr); \ } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \ if (retryvar) { \ bus->regfails += (retryvar-1); \ @@ -402,7 +405,7 @@ do { \ do { \ retryvar = 0; \ do { \ - W_REG(bus->dhd->osh, regaddr, regval); \ + W_REG(regaddr, regval); \ } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \ if (retryvar) { \ bus->regfails += (retryvar-1); \ @@ -431,16 +434,15 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus); #endif /* DHD_DEBUG */ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter); -static void dhdsdio_release(dhd_bus_t *bus, struct osl_info *osh); -static void dhdsdio_release_malloc(dhd_bus_t *bus, struct osl_info *osh); +static void dhdsdio_release(dhd_bus_t *bus); +static void dhdsdio_release_malloc(dhd_bus_t *bus); static void dhdsdio_disconnect(void *ptr); static bool dhdsdio_chipmatch(u16 chipid); -static bool dhdsdio_probe_attach(dhd_bus_t *bus, struct osl_info *osh, - void *sdh, void *regsva, u16 devid); -static bool dhdsdio_probe_malloc(dhd_bus_t *bus, struct osl_info *osh, - void *sdh); -static bool dhdsdio_probe_init(dhd_bus_t *bus, struct osl_info *osh, void *sdh); -static void dhdsdio_release_dongle(dhd_bus_t *bus, struct osl_info * osh); +static bool dhdsdio_probe_attach(dhd_bus_t *bus, void *sdh, + void *regsva, u16 devid); +static bool dhdsdio_probe_malloc(dhd_bus_t *bus, void *sdh); +static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh); +static void dhdsdio_release_dongle(dhd_bus_t *bus); static uint process_nvram_vars(char *varbuf, uint len); @@ -454,8 +456,7 @@ static int dhd_bcmsdh_send_buf(dhd_bus_t *bus, u32 addr, uint fn, struct sk_buff *pkt, bcmsdh_cmplt_fn_t complete, void *handle); -static bool dhdsdio_download_firmware(struct dhd_bus *bus, struct osl_info *osh, - void *sdh); +static bool dhdsdio_download_firmware(struct dhd_bus *bus, void *sdh); static int _dhdsdio_download_firmware(struct dhd_bus *bus); static int dhdsdio_download_code_file(struct dhd_bus *bus, char *image_path); @@ -908,7 +909,6 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, bool free_pkt) { int ret; - struct osl_info *osh; u8 *frame; u16 len, pad = 0; u32 swheader; @@ -920,7 +920,6 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, DHD_TRACE(("%s: Enter\n", __func__)); sdh = bus->sdh; - osh = bus->dhd->osh; if (bus->dhd->dongle_reset) { ret = BCME_NOTREADY; @@ -936,7 +935,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, DHD_INFO(("%s: insufficient headroom %d for %d pad\n", __func__, skb_headroom(pkt), pad)); bus->dhd->tx_realloc++; - new = pkt_buf_get_skb(osh, (pkt->len + DHD_SDALIGN)); + new = pkt_buf_get_skb(pkt->len + DHD_SDALIGN); if (!new) { DHD_ERROR(("%s: couldn't allocate new %d-byte " "packet\n", @@ -945,10 +944,10 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, goto done; } - PKTALIGN(osh, new, pkt->len, DHD_SDALIGN); - bcopy(pkt->data, new->data, pkt->len); + PKTALIGN(new, pkt->len, DHD_SDALIGN); + memcpy(new->data, pkt->data, pkt->len); if (free_pkt) - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); /* free the pkt if canned one is not used */ free_pkt = true; pkt = new; @@ -967,16 +966,17 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ len = (u16) (pkt->len); - *(u16 *) frame = htol16(len); - *(((u16 *) frame) + 1) = htol16(~len); + *(u16 *) frame = cpu_to_le16(len); + *(((u16 *) frame) + 1) = cpu_to_le16(~len); /* Software tag: channel, sequence number, data offset */ swheader = ((chan << SDPCM_CHANNEL_SHIFT) & SDPCM_CHANNEL_MASK) | bus->tx_seq | (((pad + SDPCM_HDRLEN) << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); - htol32_ua_store(swheader, frame + SDPCM_FRAMETAG_LEN); - htol32_ua_store(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); + + put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); + put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); #ifdef DHD_DEBUG tx_packets[pkt->priority]++; @@ -1061,7 +1061,7 @@ done: dhd_os_sdlock(bus->dhd); if (free_pkt) - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); return ret; } @@ -1069,12 +1069,10 @@ done: int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt) { int ret = BCME_ERROR; - struct osl_info *osh; uint datalen, prec; DHD_TRACE(("%s: Enter\n", __func__)); - osh = bus->dhd->osh; datalen = pkt->len; #ifdef SDTEST @@ -1112,7 +1110,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt) if (dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec) == false) { skb_pull(pkt, SDPCM_HDRLEN); dhd_txcomplete(bus->dhd, pkt, false); - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt); DHD_ERROR(("%s: out of bus->txq !!!\n", __func__)); ret = BCME_NORESOURCE; } else { @@ -1120,7 +1118,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt) } dhd_os_sdunlock_txq(bus->dhd); - if ((pktq_len(&bus->txq) >= FCHI) && dhd_doflow) + if (pktq_len(&bus->txq) >= TXHI) dhd_txflowcontrol(bus->dhd, 0, ON); #ifdef DHD_DEBUG @@ -1218,8 +1216,8 @@ static uint dhdsdio_sendfromq(dhd_bus_t *bus, uint maxframes) } /* Deflow-control stack if needed */ - if (dhd_doflow && dhd->up && (dhd->busstate == DHD_BUS_DATA) && - dhd->txoff && (pktq_len(&bus->txq) < FCLOW)) + if (dhd->up && (dhd->busstate == DHD_BUS_DATA) && + dhd->txoff && (pktq_len(&bus->txq) < TXLOW)) dhd_txflowcontrol(dhd, 0, OFF); return cnt; @@ -1282,8 +1280,8 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) dhdsdio_clkctl(bus, CLK_AVAIL, false); /* Hardware tag: 2 byte len followed by 2 byte ~len check (all LE) */ - *(u16 *) frame = htol16((u16) msglen); - *(((u16 *) frame) + 1) = htol16(~msglen); + *(u16 *) frame = cpu_to_le16((u16) msglen); + *(((u16 *) frame) + 1) = cpu_to_le16(~msglen); /* Software tag: channel, sequence number, data offset */ swheader = @@ -1291,8 +1289,8 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) SDPCM_CHANNEL_MASK) | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); - htol32_ua_store(swheader, frame + SDPCM_FRAMETAG_LEN); - htol32_ua_store(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); + put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); + put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); if (!DATAOK(bus)) { DHD_INFO(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d\n", @@ -1396,7 +1394,7 @@ int dhd_bus_rxctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) dhd_os_sdlock(bus->dhd); rxlen = bus->rxlen; - bcopy(bus->rxctl, msg, min(msglen, rxlen)); + memcpy(msg, bus->rxctl, min(msglen, rxlen)); bus->rxlen = 0; dhd_os_sdunlock(bus->dhd); @@ -1659,7 +1657,7 @@ static int dhdsdio_pktgen_get(dhd_bus_t *bus, u8 *arg) pktgen.mode = bus->pktgen_mode; pktgen.stop = bus->pktgen_stop; - bcopy(&pktgen, arg, sizeof(pktgen)); + memcpy(arg, &pktgen, sizeof(pktgen)); return 0; } @@ -1669,7 +1667,7 @@ static int dhdsdio_pktgen_set(dhd_bus_t *bus, u8 *arg) dhd_pktgen_t pktgen; uint oldcnt, oldmode; - bcopy(arg, &pktgen, sizeof(pktgen)); + memcpy(&pktgen, arg, sizeof(pktgen)); if (pktgen.version != DHD_PKTGEN_VERSION) return BCME_BADARG; @@ -1769,7 +1767,7 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh) if (rv < 0) return rv; - addr = ltoh32(addr); + addr = le32_to_cpu(addr); DHD_INFO(("sdpcm_shared address 0x%08X\n", addr)); @@ -1790,13 +1788,13 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh) return rv; /* Endianness */ - sh->flags = ltoh32(sh->flags); - sh->trap_addr = ltoh32(sh->trap_addr); - sh->assert_exp_addr = ltoh32(sh->assert_exp_addr); - sh->assert_file_addr = ltoh32(sh->assert_file_addr); - sh->assert_line = ltoh32(sh->assert_line); - sh->console_addr = ltoh32(sh->console_addr); - sh->msgtrace_addr = ltoh32(sh->msgtrace_addr); + sh->flags = le32_to_cpu(sh->flags); + sh->trap_addr = le32_to_cpu(sh->trap_addr); + sh->assert_exp_addr = le32_to_cpu(sh->assert_exp_addr); + sh->assert_file_addr = le32_to_cpu(sh->assert_file_addr); + sh->assert_line = le32_to_cpu(sh->assert_line); + sh->console_addr = le32_to_cpu(sh->console_addr); + sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr); if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) { DHD_ERROR(("%s: sdpcm_shared version %d in dhd " @@ -1932,10 +1930,8 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size) #endif /* DHD_DEBUG */ done: - if (mbuffer) - kfree(mbuffer); - if (str) - kfree(str); + kfree(mbuffer); + kfree(str); return bcmerror; } @@ -1952,34 +1948,33 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus) size = bus->ramsize; buf = kmalloc(size, GFP_ATOMIC); if (!buf) { - printf("%s: Out of memory (%d bytes)\n", __func__, size); + DHD_ERROR(("%s: Out of memory (%d bytes)\n", __func__, size)); return -1; } /* Read mem content */ - printf("Dump dongle memory"); + printk(KERN_DEBUG "Dump dongle memory"); databuf = buf; while (size) { read_size = min(MEMBLOCK, size); ret = dhdsdio_membytes(bus, false, start, databuf, read_size); if (ret) { - printf("%s: Error membytes %d\n", __func__, ret); - if (buf) - kfree(buf); + DHD_ERROR(("%s: Error membytes %d\n", __func__, ret)); + kfree(buf); return -1; } - printf("."); + printk("."); /* Decrement size and increment start address */ size -= read_size; start += read_size; databuf += read_size; } - printf("Done\n"); + printk(KERN_DEBUG "Done\n"); /* free buf before return !!! */ if (write_to_file(bus->dhd, buf, bus->ramsize)) { - printf("%s: Error writing to files\n", __func__); + DHD_ERROR(("%s: Error writing to files\n", __func__)); return -1; } @@ -2009,13 +2004,13 @@ static int dhdsdio_readconsole(dhd_bus_t *bus) /* Allocate console buffer (one time only) */ if (c->buf == NULL) { - c->bufsize = ltoh32(c->log.buf_size); + c->bufsize = le32_to_cpu(c->log.buf_size); c->buf = kmalloc(c->bufsize, GFP_ATOMIC); if (c->buf == NULL) return BCME_NOMEM; } - idx = ltoh32(c->log.idx); + idx = le32_to_cpu(c->log.idx); /* Protect against corrupt value */ if (idx > c->bufsize) @@ -2027,7 +2022,7 @@ static int dhdsdio_readconsole(dhd_bus_t *bus) return BCME_OK; /* Read the console buffer */ - addr = ltoh32(c->log.buf); + addr = le32_to_cpu(c->log.buf); rv = dhdsdio_membytes(bus, false, addr, c->buf, c->bufsize); if (rv < 0) return rv; @@ -2057,7 +2052,7 @@ static int dhdsdio_readconsole(dhd_bus_t *bus) if (line[n - 1] == '\r') n--; line[n] = 0; - printf("CONSOLE: %s\n", line); + printk(KERN_DEBUG "CONSOLE: %s\n", line); } } break2: @@ -2083,8 +2078,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len) } /* Free the old ones and replace with passed variables */ - if (bus->vars) - kfree(bus->vars); + kfree(bus->vars); bus->vars = kmalloc(len, GFP_ATOMIC); bus->varsz = bus->vars ? len : 0; @@ -2095,7 +2089,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len) /* Copy the passed variables, which should include the terminating double-null */ - bcopy(arg, bus->vars, bus->varsz); + memcpy(bus->vars, arg, bus->varsz); err: return bcmerror; } @@ -2118,7 +2112,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, goto exit; if (plen >= (int)sizeof(int_val)) - bcopy(params, &int_val, sizeof(int_val)); + memcpy(&int_val, params, sizeof(int_val)); bool_val = (int_val != 0) ? true : false; @@ -2138,7 +2132,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, bcmerror = dhdsdio_bussleep(bus, bool_val); } else { int_val = (s32) bus->sleeping; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); } goto exit; } @@ -2152,7 +2146,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, switch (actionid) { case IOV_GVAL(IOV_INTR): int_val = (s32) bus->intr; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_INTR): @@ -2173,7 +2167,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_POLLRATE): int_val = (s32) bus->pollrate; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_POLLRATE): @@ -2183,7 +2177,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_IDLETIME): int_val = bus->idletime; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_IDLETIME): @@ -2195,7 +2189,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_IDLECLOCK): int_val = (s32) bus->idleclock; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_IDLECLOCK): @@ -2204,7 +2198,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_SD1IDLE): int_val = (s32) sd1idle; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_SD1IDLE): @@ -2223,8 +2217,8 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, ASSERT(plen >= 2 * sizeof(int)); address = (u32) int_val; - bcopy((char *)params + sizeof(int_val), &int_val, - sizeof(int_val)); + memcpy(&int_val, (char *)params + sizeof(int_val), + sizeof(int_val)); size = (uint) int_val; /* Do some validation */ @@ -2267,17 +2261,17 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_MEMSIZE): int_val = (s32) bus->ramsize; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_SDIOD_DRIVE): int_val = (s32) dhd_sdiod_drive_strength; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_SDIOD_DRIVE): dhd_sdiod_drive_strength = int_val; - si_sdiod_drive_strength_init(bus->sih, bus->dhd->osh, + si_sdiod_drive_strength_init(bus->sih, dhd_sdiod_drive_strength); break; @@ -2291,7 +2285,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_READAHEAD): int_val = (s32) dhd_readahead; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_READAHEAD): @@ -2302,7 +2296,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_SDRXCHAIN): int_val = (s32) bus->use_rxchain; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_SDRXCHAIN): @@ -2313,7 +2307,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, break; case IOV_GVAL(IOV_ALIGNCTL): int_val = (s32) dhd_alignctl; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_ALIGNCTL): @@ -2322,13 +2316,13 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_SDALIGN): int_val = DHD_SDALIGN; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; #ifdef DHD_DEBUG case IOV_GVAL(IOV_VARS): if (bus->varsz < (uint) len) - bcopy(bus->vars, arg, bus->varsz); + memcpy(arg, bus->vars, bus->varsz); else bcmerror = BCME_BUFTOOSHORT; break; @@ -2347,7 +2341,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, int_val = (s32) bcmsdh_reg_read(bus->sdh, addr, size); if (bcmsdh_regfail(bus->sdh)) bcmerror = BCME_SDIO_ERROR; - bcopy(&int_val, arg, sizeof(s32)); + memcpy(arg, &int_val, sizeof(s32)); break; } @@ -2373,14 +2367,14 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, sdreg_t sdreg; u32 addr, size; - bcopy(params, &sdreg, sizeof(sdreg)); + memcpy(&sdreg, params, sizeof(sdreg)); addr = SI_ENUM_BASE + sdreg.offset; size = sdreg.func; int_val = (s32) bcmsdh_reg_read(bus->sdh, addr, size); if (bcmsdh_regfail(bus->sdh)) bcmerror = BCME_SDIO_ERROR; - bcopy(&int_val, arg, sizeof(s32)); + memcpy(arg, &int_val, sizeof(s32)); break; } @@ -2389,7 +2383,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, sdreg_t sdreg; u32 addr, size; - bcopy(params, &sdreg, sizeof(sdreg)); + memcpy(&sdreg, params, sizeof(sdreg)); addr = SI_ENUM_BASE + sdreg.offset; size = sdreg.func; @@ -2420,7 +2414,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_FORCEEVEN): int_val = (s32) forcealign; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_FORCEEVEN): @@ -2429,7 +2423,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_TXBOUND): int_val = (s32) dhd_txbound; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_TXBOUND): @@ -2438,7 +2432,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_RXBOUND): int_val = (s32) dhd_rxbound; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_RXBOUND): @@ -2447,7 +2441,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_TXMINMAX): int_val = (s32) dhd_txminmax; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_TXMINMAX): @@ -2458,7 +2452,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, #ifdef SDTEST case IOV_GVAL(IOV_EXTLOOP): int_val = (s32) bus->ext_loop; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_EXTLOOP): @@ -2480,9 +2474,6 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, __func__, bool_val, bus->dhd->dongle_reset, bus->dhd->busstate)); - ASSERT(bus->dhd->osh); - /* ASSERT(bus->cl_devid); */ - dhd_bus_devreset(bus->dhd, (u8) bool_val); break; @@ -2492,7 +2483,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid, /* Get its status */ int_val = (bool) bus->dhd->dongle_reset; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; @@ -2532,12 +2523,11 @@ static int dhdsdio_write_vars(dhd_bus_t *bus) varaddr = (bus->ramsize - 4) - varsize; if (bus->vars) { - vbuffer = kmalloc(varsize, GFP_ATOMIC); + vbuffer = kzalloc(varsize, GFP_ATOMIC); if (!vbuffer) return BCME_NOMEM; - memset(vbuffer, 0, varsize); - bcopy(bus->vars, vbuffer, bus->varsz); + memcpy(vbuffer, bus->vars, bus->varsz); /* Write the vars list */ bcmerror = @@ -2590,7 +2580,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus) } else { varsizew = varsize / 4; varsizew = (~varsizew << 16) | (varsizew & 0x0000FFFF); - varsizew = htol32(varsizew); + varsizew = cpu_to_le32(varsizew); } DHD_INFO(("New varsize is %d, length token=0x%08x\n", varsize, @@ -2828,7 +2818,6 @@ exit: void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex) { - struct osl_info *osh = bus->dhd->osh; u32 local_hostintmask; u8 saveclk; uint retries; @@ -2878,14 +2867,14 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex) dhdsdio_clkctl(bus, CLK_SDONLY, false); /* Clear the data packet queues */ - pktq_flush(osh, &bus->txq, true); + pktq_flush(&bus->txq, true); /* Clear any held glomming stuff */ if (bus->glomd) - pkt_buf_free_skb(osh, bus->glomd, false); + pkt_buf_free_skb(bus->glomd); if (bus->glom) - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); bus->glom = bus->glomd = NULL; @@ -3100,13 +3089,13 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff) ASSERT(bus->rxctl >= bus->rxbuf); /* Copy the already-read portion over */ - bcopy(hdr, bus->rxctl, firstread); + memcpy(bus->rxctl, hdr, firstread); if (len <= firstread) goto gotpkt; /* Copy the full data pkt in gSPI case and process ioctl. */ if (bus->bus == SPI_BUS) { - bcopy(hdr, bus->rxctl, len); + memcpy(bus->rxctl, hdr, len); goto gotpkt; } @@ -3184,7 +3173,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) u16 sublen, check; struct sk_buff *pfirst, *plast, *pnext, *save_pfirst; - struct osl_info *osh = bus->dhd->osh; int errcode; u8 chan, seq, doff, sfdoff; @@ -3214,7 +3202,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) for (totlen = num = 0; dlen; num++) { /* Get (and move past) next length */ - sublen = ltoh16_ua(dptr); + sublen = get_unaligned_le16(dptr); dlen -= sizeof(u16); dptr += sizeof(u16); if ((sublen < SDPCM_HDRLEN) || @@ -3240,7 +3228,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) } /* Allocate/chain packet for next subframe */ - pnext = pkt_buf_get_skb(osh, sublen + DHD_SDALIGN); + pnext = pkt_buf_get_skb(sublen + DHD_SDALIGN); if (pnext == NULL) { DHD_ERROR(("%s: pkt_buf_get_skb failed, num %d len %d\n", __func__, num, sublen)); @@ -3257,7 +3245,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) } /* Adhere to start alignment requirements */ - PKTALIGN(osh, pnext, sublen, DHD_SDALIGN); + PKTALIGN(pnext, sublen, DHD_SDALIGN); } /* If all allocations succeeded, save packet chain @@ -3276,13 +3264,13 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) pfirst = pnext = NULL; } else { if (pfirst) - pkt_buf_free_skb(osh, pfirst, false); + pkt_buf_free_skb(pfirst); bus->glom = NULL; num = 0; } /* Done with descriptor packet */ - pkt_buf_free_skb(osh, bus->glomd, false); + pkt_buf_free_skb(bus->glomd); bus->glomd = NULL; bus->nextlen = 0; @@ -3303,7 +3291,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) } pfirst = bus->glom; - dlen = (u16) pkttotlen(osh, pfirst); + dlen = (u16) pkttotlen(pfirst); /* Do an SDIO read for the superframe. Configurable iovar to * read directly into the chained packet, or allocate a large @@ -3323,7 +3311,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) F2SYNC, bus->dataptr, dlen, NULL, NULL, NULL); sublen = - (u16) pktfrombuf(osh, pfirst, 0, dlen, + (u16) pktfrombuf(pfirst, 0, dlen, bus->dataptr); if (sublen != dlen) { DHD_ERROR(("%s: FAILED TO COPY, dlen %d sublen %d\n", @@ -3351,7 +3339,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) bus->glomerr = 0; dhdsdio_rxfail(bus, true, false); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); dhd_os_sdunlock_rxq(bus->dhd); bus->rxglomfail++; bus->glom = NULL; @@ -3367,8 +3355,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) /* Validate the superframe header */ dptr = (u8 *) (pfirst->data); - sublen = ltoh16_ua(dptr); - check = ltoh16_ua(dptr + sizeof(u16)); + sublen = get_unaligned_le16(dptr); + check = get_unaligned_le16(dptr + sizeof(u16)); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); @@ -3437,8 +3425,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) num++, pnext = pnext->next) { dptr = (u8 *) (pnext->data); dlen = (u16) (pnext->len); - sublen = ltoh16_ua(dptr); - check = ltoh16_ua(dptr + sizeof(u16)); + sublen = get_unaligned_le16(dptr); + check = get_unaligned_le16(dptr + sizeof(u16)); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); #ifdef DHD_DEBUG @@ -3480,7 +3468,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) bus->glomerr = 0; dhdsdio_rxfail(bus, true, false); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(osh, bus->glom, false); + pkt_buf_free_skb(bus->glom); dhd_os_sdunlock_rxq(bus->dhd); bus->rxglomfail++; bus->glom = NULL; @@ -3500,7 +3488,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) pfirst->next = NULL; dptr = (u8 *) (pfirst->data); - sublen = ltoh16_ua(dptr); + sublen = get_unaligned_le16(dptr); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); @@ -3528,7 +3516,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) skb_pull(pfirst, doff); if (pfirst->len == 0) { - pkt_buf_free_skb(bus->dhd->osh, pfirst, false); + pkt_buf_free_skb(pfirst); if (plast) { plast->next = pnext; } else { @@ -3541,7 +3529,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) DHD_ERROR(("%s: rx protocol error\n", __func__)); bus->dhd->rx_errors++; - pkt_buf_free_skb(osh, pfirst, false); + pkt_buf_free_skb(pfirst); if (plast) { plast->next = pnext; } else { @@ -3585,7 +3573,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq) /* Return true if there may be more frames to read */ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) { - struct osl_info *osh = bus->dhd->osh; bcmsdh_info_t *sdh = bus->sdh; u16 len, check; /* Extracted hardware header fields */ @@ -3680,7 +3667,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) */ /* Allocate a packet buffer */ dhd_os_sdlock_rxq(bus->dhd); - pkt = pkt_buf_get_skb(osh, rdlen + DHD_SDALIGN); + pkt = pkt_buf_get_skb(rdlen + DHD_SDALIGN); if (!pkt) { if (bus->bus == SPI_BUS) { bus->usebufpool = false; @@ -3738,7 +3725,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) bus->usebufpool = true; ASSERT(!(pkt->prev)); - PKTALIGN(osh, pkt, rdlen, DHD_SDALIGN); + PKTALIGN(pkt, rdlen, DHD_SDALIGN); rxbuf = (u8 *) (pkt->data); /* Read the entire frame */ sdret = @@ -3753,7 +3740,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) if (sdret < 0) { DHD_ERROR(("%s (nextlen): read %d bytes failed: %d\n", __func__, rdlen, sdret)); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); bus->dhd->rx_errors++; dhd_os_sdunlock_rxq(bus->dhd); /* Force retry w/normal header read. @@ -3770,11 +3757,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) dhd_os_sdunlock_rxq(bus->dhd); /* Now check the header */ - bcopy(rxbuf, bus->rxhdr, SDPCM_HDRLEN); + memcpy(bus->rxhdr, rxbuf, SDPCM_HDRLEN); /* Extract hardware header fields */ - len = ltoh16_ua(bus->rxhdr); - check = ltoh16_ua(bus->rxhdr + sizeof(u16)); + len = get_unaligned_le16(bus->rxhdr); + check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); /* All zeros means readahead info was bad */ if (!(len | check)) { @@ -3901,8 +3888,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) doff); if (bus->usebufpool) { dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, - false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); } continue; @@ -3965,8 +3951,8 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) #endif /* Extract hardware header fields */ - len = ltoh16_ua(bus->rxhdr); - check = ltoh16_ua(bus->rxhdr + sizeof(u16)); + len = get_unaligned_le16(bus->rxhdr); + check = get_unaligned_le16(bus->rxhdr + sizeof(u16)); /* All zeros means no more frames */ if (!(len | check)) { @@ -4091,7 +4077,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) } dhd_os_sdlock_rxq(bus->dhd); - pkt = pkt_buf_get_skb(osh, (rdlen + firstread + DHD_SDALIGN)); + pkt = pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN); if (!pkt) { /* Give up on data, request rtx of events */ DHD_ERROR(("%s: pkt_buf_get_skb failed: rdlen %d chan %d\n", @@ -4108,7 +4094,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) /* Leave room for what we already read, and align remainder */ ASSERT(firstread < pkt->len); skb_pull(pkt, firstread); - PKTALIGN(osh, pkt, rdlen, DHD_SDALIGN); + PKTALIGN(pkt, rdlen, DHD_SDALIGN); /* Read the remaining frame data */ sdret = @@ -4127,7 +4113,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ? "data" : "test")), sdret)); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); bus->dhd->rx_errors++; dhdsdio_rxfail(bus, true, RETRYCHAN(chan)); @@ -4136,7 +4122,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) /* Copy the already-read portion */ skb_push(pkt, firstread); - bcopy(bus->rxhdr, pkt->data, firstread); + memcpy(pkt->data, bus->rxhdr, firstread); #ifdef DHD_DEBUG if (DHD_BYTES_ON() && DHD_DATA_ON()) @@ -4180,13 +4166,13 @@ deliver: if (pkt->len == 0) { dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); continue; } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt) != 0) { DHD_ERROR(("%s: rx protocol error\n", __func__)); dhd_os_sdlock_rxq(bus->dhd); - pkt_buf_free_skb(bus->dhd->osh, pkt, false); + pkt_buf_free_skb(pkt); dhd_os_sdunlock_rxq(bus->dhd); bus->dhd->rx_errors++; continue; @@ -4501,7 +4487,7 @@ clkwait: if (ret == 0) bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; - printf("Return_dpc value is : %d\n", ret); + DHD_INFO(("Return_dpc value is : %d\n", ret)); bus->ctrl_frame_stat = false; dhd_wait_event_wakeup(bus->dhd); } @@ -4635,13 +4621,12 @@ static void dhdsdio_pktgen(dhd_bus_t *bus) u8 *data; uint pktcount; uint fillbyte; - struct osl_info *osh = bus->dhd->osh; u16 len; /* Display current count if appropriate */ if (bus->pktgen_print && (++bus->pktgen_ptick >= bus->pktgen_print)) { bus->pktgen_ptick = 0; - printf("%s: send attempts %d rcvd %d\n", + printk(KERN_DEBUG "%s: send attempts %d rcvd %d\n", __func__, bus->pktgen_sent, bus->pktgen_rcvd); } @@ -4663,14 +4648,14 @@ static void dhdsdio_pktgen(dhd_bus_t *bus) /* Allocate an appropriate-sized packet */ len = bus->pktgen_len; - pkt = pkt_buf_get_skb(osh, + pkt = pkt_buf_get_skb( (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN), true); if (!pkt) { DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__)); break; } - PKTALIGN(osh, pkt, (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), + PKTALIGN(pkt, (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), DHD_SDALIGN); data = (u8 *) (pkt->data) + SDPCM_HDRLEN; @@ -4694,7 +4679,7 @@ static void dhdsdio_pktgen(dhd_bus_t *bus) default: DHD_ERROR(("Unrecognized pktgen mode %d\n", bus->pktgen_mode)); - pkt_buf_free_skb(osh, pkt, true); + pkt_buf_free_skb(pkt, true); bus->pktgen_count = 0; return; } @@ -4740,16 +4725,15 @@ static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start) { struct sk_buff *pkt; u8 *data; - struct osl_info *osh = bus->dhd->osh; /* Allocate the packet */ - pkt = pkt_buf_get_skb(osh, SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN, + pkt = pkt_buf_get_skb(SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN, true); if (!pkt) { DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__)); return; } - PKTALIGN(osh, pkt, (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), DHD_SDALIGN); + PKTALIGN(pkt, (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), DHD_SDALIGN); data = (u8 *) (pkt->data) + SDPCM_HDRLEN; /* Fill in the test header */ @@ -4765,7 +4749,6 @@ static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start) static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) { - struct osl_info *osh = bus->dhd->osh; u8 *data; uint pktlen; @@ -4779,7 +4762,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) if (pktlen < SDPCM_TEST_HDRLEN) { DHD_ERROR(("dhdsdio_restrcv: toss runt frame, pktlen %d\n", pktlen)); - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); return; } @@ -4797,7 +4780,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) DHD_ERROR(("dhdsdio_testrcv: frame length mismatch, " "pktlen %d seq %d" " cmd %d extra %d len %d\n", pktlen, seq, cmd, extra, len)); - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); return; } } @@ -4812,14 +4795,14 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) bus->pktgen_sent++; } else { bus->pktgen_fail++; - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); } bus->pktgen_rcvd++; break; case SDPCM_TEST_ECHORSP: if (bus->ext_loop) { - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); bus->pktgen_rcvd++; break; } @@ -4832,12 +4815,12 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) break; } } - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); bus->pktgen_rcvd++; break; case SDPCM_TEST_DISCARD: - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); bus->pktgen_rcvd++; break; @@ -4847,7 +4830,7 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq) DHD_INFO(("dhdsdio_testrcv: unsupported or unknown command, " "pktlen %d seq %d" " cmd %d extra %d len %d\n", pktlen, seq, cmd, extra, len)); - pkt_buf_free_skb(osh, pkt, false); + pkt_buf_free_skb(pkt, false); break; } @@ -4987,7 +4970,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen) /* Zero cbuf_index */ addr = bus->console_addr + offsetof(hndrte_cons_t, cbuf_idx); - val = htol32(0); + val = cpu_to_le32(0); rv = dhdsdio_membytes(bus, true, addr, (u8 *)&val, sizeof(val)); if (rv < 0) goto done; @@ -5000,7 +4983,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen) /* Write length into vcons_in */ addr = bus->console_addr + offsetof(hndrte_cons_t, vcons_in); - val = htol32(msglen); + val = cpu_to_le32(msglen); rv = dhdsdio_membytes(bus, true, addr, (u8 *)&val, sizeof(val)); if (rv < 0) goto done; @@ -5008,7 +4991,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen) /* Bump dongle by sending an empty event pkt. * sdpcm_sendup (RX) checks for virtual console input. */ - pkt = pkt_buf_get_skb(bus->dhd->osh, 4 + SDPCM_RESERVE); + pkt = pkt_buf_get_skb(4 + SDPCM_RESERVE); if ((pkt != NULL) && bus->clkstate == CLK_AVAIL) dhdsdio_txpkt(bus, pkt, SDPCM_EVENT_CHANNEL, true); @@ -5066,7 +5049,7 @@ static bool dhdsdio_chipmatch(u16 chipid) static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no, u16 slot, u16 func, uint bustype, void *regsva, - struct osl_info *osh, void *sdh) + void *sdh) { int ret; dhd_bus_t *bus; @@ -5085,7 +5068,6 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no, sd1idle = true; dhd_readahead = true; retrydata = false; - dhd_doflow = false; dhd_dongle_memsize = 0; dhd_txminmax = DHD_TXMINMAX; @@ -5143,15 +5125,6 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no, return NULL; } - if (osh == NULL) { - /* Ask the OS interface part for an OSL handle */ - osh = dhd_osl_attach(sdh, DHD_BUS); - if (!osh) { - DHD_ERROR(("%s: osl_attach failed!\n", __func__)); - return NULL; - } - } - /* Allocate private bus interface state */ bus = kzalloc(sizeof(dhd_bus_t), GFP_ATOMIC); if (!bus) { @@ -5166,25 +5139,25 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no, else use locally malloced rxbuf */ /* attempt to attach to the dongle */ - if (!(dhdsdio_probe_attach(bus, osh, sdh, regsva, devid))) { + if (!(dhdsdio_probe_attach(bus, sdh, regsva, devid))) { DHD_ERROR(("%s: dhdsdio_probe_attach failed\n", __func__)); goto fail; } /* Attach to the dhd/OS/network interface */ - bus->dhd = dhd_attach(osh, bus, SDPCM_RESERVE); + bus->dhd = dhd_attach(bus, SDPCM_RESERVE); if (!bus->dhd) { DHD_ERROR(("%s: dhd_attach failed\n", __func__)); goto fail; } /* Allocate buffers */ - if (!(dhdsdio_probe_malloc(bus, osh, sdh))) { + if (!(dhdsdio_probe_malloc(bus, sdh))) { DHD_ERROR(("%s: dhdsdio_probe_malloc failed\n", __func__)); goto fail; } - if (!(dhdsdio_probe_init(bus, osh, sdh))) { + if (!(dhdsdio_probe_init(bus, sdh))) { DHD_ERROR(("%s: dhdsdio_probe_init failed\n", __func__)); goto fail; } @@ -5220,13 +5193,12 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no, return bus; fail: - dhdsdio_release(bus, osh); + dhdsdio_release(bus); return NULL; } static bool -dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, - void *regsva, u16 devid) +dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid) { u8 clkctl = 0; int err = 0; @@ -5238,7 +5210,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, DHD_ERROR(("%s: FAILED to return to SI_ENUM_BASE\n", __func__)); #ifdef DHD_DEBUG - printf("F1 signature read @0x18000000=0x%4x\n", + printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", bcmsdh_reg_read(bus->sdh, SI_ENUM_BASE, 4)); #endif /* DHD_DEBUG */ @@ -5279,13 +5251,12 @@ dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, udelay(65); for (fn = 0; fn <= numfn; fn++) { - cis[fn] = kmalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC); + cis[fn] = kzalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC); if (!cis[fn]) { DHD_INFO(("dhdsdio_probe: fn %d cis malloc " "failed\n", fn)); break; } - memset(cis[fn], 0, SBSDIO_CIS_SIZE_LIMIT); err = bcmsdh_cis_read(sdh, fn, cis[fn], SBSDIO_CIS_SIZE_LIMIT); @@ -5311,7 +5282,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, #endif /* DHD_DEBUG */ /* si_attach() will provide an SI handle and scan the backplane */ - bus->sih = si_attach((uint) devid, osh, regsva, DHD_BUS, sdh, + bus->sih = si_attach((uint) devid, regsva, DHD_BUS, sdh, &bus->vars, &bus->varsz); if (!(bus->sih)) { DHD_ERROR(("%s: si_attach failed!\n", __func__)); @@ -5326,7 +5297,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, goto fail; } - si_sdiod_drive_strength_init(bus->sih, osh, dhd_sdiod_drive_strength); + si_sdiod_drive_strength_init(bus->sih, dhd_sdiod_drive_strength); /* Get info on the ARM and SOCRAM cores... */ if (!DHD_NOPMU(bus)) { @@ -5364,9 +5335,9 @@ dhdsdio_probe_attach(struct dhd_bus *bus, struct osl_info *osh, void *sdh, bus->sdpcmrev = si_corerev(bus->sih); /* Set core control so an SDIO reset does a backplane reset */ - OR_REG(osh, &bus->regs->corecontrol, CC_BPRESEN); + OR_REG(&bus->regs->corecontrol, CC_BPRESEN); - pktq_init(&bus->txq, (PRIOMASK + 1), QLEN); + pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); /* Locate an appropriately-aligned portion of hdrbuf */ bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], DHD_SDALIGN); @@ -5383,8 +5354,7 @@ fail: return false; } -static bool dhdsdio_probe_malloc(dhd_bus_t *bus, struct osl_info *osh, - void *sdh) +static bool dhdsdio_probe_malloc(dhd_bus_t *bus, void *sdh) { DHD_TRACE(("%s: Enter\n", __func__)); @@ -5425,7 +5395,7 @@ fail: return false; } -static bool dhdsdio_probe_init(dhd_bus_t *bus, struct osl_info *osh, void *sdh) +static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh) { s32 fnum; @@ -5502,20 +5472,19 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, struct osl_info *osh, void *sdh) } bool -dhd_bus_download_firmware(struct dhd_bus *bus, struct osl_info *osh, - char *fw_path, char *nv_path) +dhd_bus_download_firmware(struct dhd_bus *bus, char *fw_path, char *nv_path) { bool ret; bus->fw_path = fw_path; bus->nv_path = nv_path; - ret = dhdsdio_download_firmware(bus, osh, bus->sdh); + ret = dhdsdio_download_firmware(bus, bus->sdh); return ret; } static bool -dhdsdio_download_firmware(struct dhd_bus *bus, struct osl_info *osh, void *sdh) +dhdsdio_download_firmware(struct dhd_bus *bus, void *sdh) { bool ret; @@ -5530,37 +5499,32 @@ dhdsdio_download_firmware(struct dhd_bus *bus, struct osl_info *osh, void *sdh) } /* Detach and free everything */ -static void dhdsdio_release(dhd_bus_t *bus, struct osl_info *osh) +static void dhdsdio_release(dhd_bus_t *bus) { DHD_TRACE(("%s: Enter\n", __func__)); if (bus) { - ASSERT(osh); - /* De-register interrupt handler */ bcmsdh_intr_disable(bus->sdh); bcmsdh_intr_dereg(bus->sdh); if (bus->dhd) { - dhdsdio_release_dongle(bus, osh); + dhdsdio_release_dongle(bus); dhd_detach(bus->dhd); bus->dhd = NULL; } - dhdsdio_release_malloc(bus, osh); + dhdsdio_release_malloc(bus); kfree(bus); } - if (osh) - dhd_osl_detach(osh); - DHD_TRACE(("%s: Disconnected\n", __func__)); } -static void dhdsdio_release_malloc(dhd_bus_t *bus, struct osl_info *osh) +static void dhdsdio_release_malloc(dhd_bus_t *bus) { DHD_TRACE(("%s: Enter\n", __func__)); @@ -5573,13 +5537,11 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus, struct osl_info *osh) bus->rxlen = 0; } - if (bus->databuf) { - kfree(bus->databuf); - bus->databuf = NULL; - } + kfree(bus->databuf); + bus->databuf = NULL; } -static void dhdsdio_release_dongle(dhd_bus_t *bus, struct osl_info *osh) +static void dhdsdio_release_dongle(dhd_bus_t *bus) { DHD_TRACE(("%s: Enter\n", __func__)); @@ -5609,7 +5571,7 @@ static void dhdsdio_disconnect(void *ptr) if (bus) { ASSERT(bus->dhd); - dhdsdio_release(bus, bus->dhd->osh); + dhdsdio_release(bus); } DHD_TRACE(("%s: Disconnected\n", __func__)); @@ -5679,6 +5641,10 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus) unsigned char *ularray; ularray = kmalloc(bus->ramsize, GFP_ATOMIC); + if (!ularray) { + bcmerror = BCME_NOMEM; + goto err; + } /* Upload image to verify downloaded contents. */ offset = 0; memset(ularray, 0xaa, bus->ramsize); @@ -5690,7 +5656,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus) DHD_ERROR(("%s: error %d on reading %d membytes" " at 0x%08x\n", __func__, bcmerror, MEMBLOCK, offset)); - goto err; + goto free; } offset += MEMBLOCK; @@ -5704,7 +5670,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus) DHD_ERROR(("%s: error %d on reading %d membytes at 0x%08x\n", __func__, bcmerror, sizeof(dlarray) - offset, offset)); - goto err; + goto free; } } @@ -5712,11 +5678,11 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus) DHD_ERROR(("%s: Downloaded image is corrupted.\n", __func__)); ASSERT(0); - goto err; + goto free; } else DHD_ERROR(("%s: Download/Upload/Compare succeeded.\n", __func__)); - +free: kfree(ularray); } #endif /* DHD_DEBUG */ @@ -5764,8 +5730,7 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path) } err: - if (memblock) - kfree(memblock); + kfree(memblock); if (image) dhd_os_close_image(image); @@ -5904,8 +5869,7 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus) } err: - if (memblock) - kfree(memblock); + kfree(memblock); if (image) dhd_os_close_image(image); @@ -6051,7 +6015,7 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag) /* Clean tx/rx buffer pointers, detach from the dongle */ - dhdsdio_release_dongle(bus, bus->dhd->osh); + dhdsdio_release_dongle(bus); bus->dhd->dongle_reset = true; bus->dhd->up = false; @@ -6071,14 +6035,13 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag) bcmsdh_reset(bus->sdh); /* Attempt to re-attach & download */ - if (dhdsdio_probe_attach(bus, bus->dhd->osh, bus->sdh, + if (dhdsdio_probe_attach(bus, bus->sdh, (u32 *) SI_ENUM_BASE, bus->cl_devid)) { /* Attempt to download binary to the dongle */ if (dhdsdio_probe_init - (bus, bus->dhd->osh, bus->sdh) + (bus, bus->sdh) && dhdsdio_download_firmware(bus, - bus->dhd->osh, bus->sdh)) { /* Re-init bus, enable F2 transfer */ diff --git a/drivers/staging/brcm80211/include/dhdioctl.h b/drivers/staging/brcm80211/brcmfmac/dhdioctl.h index 4d06e506f154..f0ba53558ccd 100644 --- a/drivers/staging/brcm80211/include/dhdioctl.h +++ b/drivers/staging/brcm80211/brcmfmac/dhdioctl.h @@ -17,10 +17,6 @@ #ifndef _dhdioctl_h_ #define _dhdioctl_h_ -/* require default structure packing */ -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - /* Linux network driver ioctl encoding */ typedef struct dhd_ioctl { uint cmd; /* common ioctl definition */ @@ -101,7 +97,4 @@ typedef struct dhd_pktgen { #define DHD_IDLE_STOP (-1) /* Request SD clock be stopped (and use SD1 mode) */ -/* require default structure packing */ -#include <packed_section_end.h> - #endif /* _dhdioctl_h_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/hndpmu.c b/drivers/staging/brcm80211/brcmfmac/hndpmu.c new file mode 100644 index 000000000000..e841da6fb03d --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/hndpmu.c @@ -0,0 +1 @@ +#include "../util/hndpmu.c" diff --git a/drivers/staging/brcm80211/include/hndrte_armtrap.h b/drivers/staging/brcm80211/brcmfmac/hndrte_armtrap.h index 28f092c9e027..28f092c9e027 100644 --- a/drivers/staging/brcm80211/include/hndrte_armtrap.h +++ b/drivers/staging/brcm80211/brcmfmac/hndrte_armtrap.h diff --git a/drivers/staging/brcm80211/include/hndrte_cons.h b/drivers/staging/brcm80211/brcmfmac/hndrte_cons.h index 5caa53fb6552..4df3eecaa83b 100644 --- a/drivers/staging/brcm80211/include/hndrte_cons.h +++ b/drivers/staging/brcm80211/brcmfmac/hndrte_cons.h @@ -13,6 +13,8 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _hndrte_cons_h +#define _hndrte_cons_h #define CBUF_LEN (128) @@ -55,3 +57,6 @@ typedef struct { uint cbuf_idx; char cbuf[CBUF_LEN]; } hndrte_cons_t; + +#endif /* _hndrte_cons_h */ + diff --git a/drivers/staging/brcm80211/include/msgtrace.h b/drivers/staging/brcm80211/brcmfmac/msgtrace.h index 9d9e53da088a..d654671a5a30 100644 --- a/drivers/staging/brcm80211/include/msgtrace.h +++ b/drivers/staging/brcm80211/brcmfmac/msgtrace.h @@ -17,13 +17,10 @@ #ifndef _MSGTRACE_H #define _MSGTRACE_H -/* This marks the start of a packed structure section. */ -#include <packed_section_start.h> - #define MSGTRACE_VERSION 1 /* Message trace header */ -typedef BWL_PRE_PACKED_STRUCT struct msgtrace_hdr { +typedef struct msgtrace_hdr { u8 version; u8 spare; u16 len; /* Len of the trace */ @@ -36,7 +33,7 @@ typedef BWL_PRE_PACKED_STRUCT struct msgtrace_hdr { trace overflow */ u32 discarded_printf; /* Number of discarded printf because of trace overflow */ -} BWL_POST_PACKED_STRUCT msgtrace_hdr_t; +} __attribute__((packed)) msgtrace_hdr_t; #define MSGTRACE_HDRLEN sizeof(msgtrace_hdr_t) @@ -61,7 +58,4 @@ extern void msgtrace_put(char *buf, int count); extern void msgtrace_init(void *hdl1, void *hdl2, msgtrace_func_send_t func_send); -/* This marks the end of a packed structure section. */ -#include <packed_section_end.h> - #endif /* _MSGTRACE_H */ diff --git a/drivers/staging/brcm80211/brcmfmac/sbutils.c b/drivers/staging/brcm80211/brcmfmac/sbutils.c new file mode 100644 index 000000000000..64496b8ca2cd --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/sbutils.c @@ -0,0 +1 @@ +#include "../util/sbutils.c" diff --git a/drivers/staging/brcm80211/include/sdioh.h b/drivers/staging/brcm80211/brcmfmac/sdioh.h index f96aaf9cec74..f96aaf9cec74 100644 --- a/drivers/staging/brcm80211/include/sdioh.h +++ b/drivers/staging/brcm80211/brcmfmac/sdioh.h diff --git a/drivers/staging/brcm80211/include/sdiovar.h b/drivers/staging/brcm80211/brcmfmac/sdiovar.h index 7686fde03960..d1cfa5f0a982 100644 --- a/drivers/staging/brcm80211/include/sdiovar.h +++ b/drivers/staging/brcm80211/brcmfmac/sdiovar.h @@ -17,10 +17,6 @@ #ifndef _sdiovar_h_ #define _sdiovar_h_ -/* require default structure packing */ -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - typedef struct sdreg { int func; int offset; @@ -39,6 +35,4 @@ typedef struct sdreg { #define NUM_PREV_TRANSACTIONS 16 -#include <packed_section_end.h> - #endif /* _sdiovar_h_ */ diff --git a/drivers/staging/brcm80211/brcmfmac/siutils.c b/drivers/staging/brcm80211/brcmfmac/siutils.c new file mode 100644 index 000000000000..f428e992a11f --- /dev/null +++ b/drivers/staging/brcm80211/brcmfmac/siutils.c @@ -0,0 +1 @@ +#include "../util/siutils.c" diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 991463f4a7f4..555b056b49b1 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -16,11 +16,8 @@ #include <linux/kernel.h> #include <linux/if_arp.h> -#include <osl.h> #include <bcmutils.h> -#include <bcmendian.h> -#include <proto/ethernet.h> #include <asm/uaccess.h> @@ -44,6 +41,7 @@ static struct sdio_func *cfg80211_sdio_func; static struct wl_dev *wl_cfg80211_dev; +static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO; @@ -87,8 +85,8 @@ static s32 wl_cfg80211_set_tx_power(struct wiphy *wiphy, s32 dbm); static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm); static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy, - struct net_device *dev, - u8 key_idx); + struct net_device *dev, u8 key_idx, + bool unicast, bool multicast); static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params); @@ -555,24 +553,24 @@ static const u32 __wl_cipher_suites[] = { static void swap_key_from_BE(struct wl_wsec_key *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); + key->index = cpu_to_le32(key->index); + key->len = cpu_to_le32(key->len); + key->algo = cpu_to_le32(key->algo); + key->flags = cpu_to_le32(key->flags); + key->rxiv.hi = cpu_to_le32(key->rxiv.hi); + key->rxiv.lo = cpu_to_le16(key->rxiv.lo); + key->iv_initialized = cpu_to_le32(key->iv_initialized); } static void swap_key_to_BE(struct wl_wsec_key *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); + key->index = le32_to_cpu(key->index); + key->len = le32_to_cpu(key->len); + key->algo = le32_to_cpu(key->algo); + key->flags = le32_to_cpu(key->flags); + key->rxiv.hi = le32_to_cpu(key->rxiv.hi); + key->rxiv.lo = le16_to_cpu(key->rxiv.lo); + key->iv_initialized = le32_to_cpu(key->iv_initialized); } static s32 @@ -626,8 +624,8 @@ wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, default: return -EINVAL; } - infra = htod32(infra); - ap = htod32(ap); + infra = cpu_to_le32(infra); + ap = cpu_to_le32(ap); wdev = ndev->ieee80211_ptr; wdev->iftype = type; WL_DBG("%s : ap (%d), infra (%d)\n", ndev->name, ap, infra); @@ -648,7 +646,7 @@ wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev, static void wl_iscan_prep(struct wl_scan_params *params, struct wlc_ssid *ssid) { - memcpy(¶ms->bssid, ðer_bcast, ETH_ALEN); + memcpy(params->bssid, ether_bcast, ETH_ALEN); params->bss_type = DOT11_BSSTYPE_ANY; params->scan_type = 0; params->nprobes = -1; @@ -657,10 +655,10 @@ static void wl_iscan_prep(struct wl_scan_params *params, struct wlc_ssid *ssid) 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); + params->nprobes = cpu_to_le32(params->nprobes); + params->active_time = cpu_to_le32(params->active_time); + params->passive_time = cpu_to_le32(params->passive_time); + params->home_time = cpu_to_le32(params->home_time); if (ssid && ssid->SSID_len) memcpy(¶ms->ssid, ssid, sizeof(wlc_ssid_t)); @@ -673,7 +671,7 @@ wl_dev_iovar_setbuf(struct net_device *dev, s8 * iovar, void *param, s32 iolen; iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen); - BUG_ON(unlikely(!iolen)); + BUG_ON(!iolen); return wl_dev_ioctl(dev, WLC_SET_VAR, bufptr, iolen); } @@ -685,7 +683,7 @@ wl_dev_iovar_getbuf(struct net_device *dev, s8 * iovar, void *param, s32 iolen; iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen); - BUG_ON(unlikely(!iolen)); + BUG_ON(!iolen); return wl_dev_ioctl(dev, WLC_GET_VAR, bufptr, buflen); } @@ -703,14 +701,13 @@ wl_run_iscan(struct wl_iscan_ctrl *iscan, struct wlc_ssid *ssid, u16 action) params = kzalloc(params_size, GFP_KERNEL); if (unlikely(!params)) return -ENOMEM; - memset(params, 0, params_size); - BUG_ON(unlikely(params_size >= WLC_IOCTL_SMLEN)); + BUG_ON(params_size >= WLC_IOCTL_SMLEN); wl_iscan_prep(¶ms->params, ssid); - params->version = htod32(ISCAN_REQ_VERSION); - params->action = htod16(action); - params->scan_duration = htod16(0); + params->version = cpu_to_le32(ISCAN_REQ_VERSION); + params->action = cpu_to_le16(action); + params->scan_duration = cpu_to_le16(0); /* params_size += offsetof(wl_iscan_params_t, params); */ err = wl_dev_iovar_setbuf(iscan->dev, "iscan", params, params_size, @@ -813,7 +810,7 @@ __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, min_t(u8, sizeof(sr->ssid.SSID), ssids->ssid_len); if (sr->ssid.SSID_len) { memcpy(sr->ssid.SSID, ssids->ssid, sr->ssid.SSID_len); - sr->ssid.SSID_len = htod32(sr->ssid.SSID_len); + sr->ssid.SSID_len = cpu_to_le32(sr->ssid.SSID_len); WL_DBG("Specific scan ssid=\"%s\" len=%d\n", sr->ssid.SSID, sr->ssid.SSID_len); spec_scan = true; @@ -873,9 +870,9 @@ static s32 wl_dev_intvar_set(struct net_device *dev, s8 *name, s32 val) u32 len; s32 err = 0; - val = htod32(val); + val = cpu_to_le32(val); len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf)); - BUG_ON(unlikely(!len)); + BUG_ON(!len); err = wl_dev_ioctl(dev, WLC_SET_VAR, buf, len); if (unlikely(err)) { @@ -899,12 +896,12 @@ wl_dev_intvar_get(struct net_device *dev, s8 *name, s32 *retval) len = bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf)); - BUG_ON(unlikely(!len)); + BUG_ON(!len); err = wl_dev_ioctl(dev, WLC_GET_VAR, &var, len); if (unlikely(err)) { WL_ERR("error (%d)\n", err); } - *retval = dtoh32(var.val); + *retval = le32_to_cpu(var.val); return err; } @@ -938,7 +935,7 @@ static s32 wl_set_retry(struct net_device *dev, u32 retry, bool l) s32 err = 0; u32 cmd = (l ? WLC_SET_LRL : WLC_SET_SRL); - retry = htod32(retry); + retry = cpu_to_le32(retry); err = wl_dev_ioctl(dev, cmd, &retry, sizeof(retry)); if (unlikely(err)) { WL_ERR("cmd (%d) , error (%d)\n", cmd, err); @@ -1041,7 +1038,7 @@ wl_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, memset(&join_params, 0, sizeof(join_params)); memcpy((void *)join_params.ssid.SSID, (void *)params->ssid, params->ssid_len); - join_params.ssid.SSID_len = htod32(params->ssid_len); + join_params.ssid.SSID_len = cpu_to_le32(params->ssid_len); if (params->bssid) memcpy(&join_params.params.bssid, params->bssid, ETH_ALEN); @@ -1371,12 +1368,12 @@ wl_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, join_params.ssid.SSID_len = min(sizeof(join_params.ssid.SSID), sme->ssid_len); memcpy(&join_params.ssid.SSID, sme->ssid, join_params.ssid.SSID_len); - join_params.ssid.SSID_len = htod32(join_params.ssid.SSID_len); + join_params.ssid.SSID_len = cpu_to_le32(join_params.ssid.SSID_len); wl_update_prof(wl, NULL, &join_params.ssid, WL_PROF_SSID); - memcpy(&join_params.params.bssid, ðer_bcast, ETH_ALEN); + memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); wl_ch_to_chanspec(wl->channel, &join_params, &join_params_size); - WL_DBG("join_param_size %d\n", join_params_size); + WL_DBG("join_param_size %zu\n", join_params_size); if (join_params.ssid.SSID_len < IEEE80211_MAX_SSID_LEN) { WL_DBG("ssid \"%s\", len (%d)\n", @@ -1407,7 +1404,7 @@ wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, if (likely(act)) { scbval.val = reason_code; memcpy(&scbval.ea, &wl->bssid, ETH_ALEN); - scbval.val = htod32(scbval.val); + scbval.val = cpu_to_le32(scbval.val); err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t)); if (unlikely(err)) { @@ -1449,7 +1446,7 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy, } /* Make sure radio is off or on as far as software is concerned */ disable = WL_RADIO_SW_DISABLE << 16; - disable = htod32(disable); + disable = cpu_to_le32(disable); err = wl_dev_ioctl(ndev, WLC_SET_RADIO, &disable, sizeof(disable)); if (unlikely(err)) { WL_ERR("WLC_SET_RADIO error (%d)\n", err); @@ -1493,7 +1490,7 @@ static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm) static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, - u8 key_idx) + u8 key_idx, bool unicast, bool multicast) { u32 index; s32 wsec; @@ -1507,11 +1504,11 @@ wl_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *dev, WL_ERR("WLC_GET_WSEC error (%d)\n", err); return err; } - wsec = dtoh32(wsec); + wsec = le32_to_cpu(wsec); if (wsec & WEP_ENABLED) { /* Just select a new current key */ index = (u32) key_idx; - index = htod32(index); + index = cpu_to_le32(index); err = wl_dev_ioctl(dev, WLC_SET_KEY_PRIMARY, &index, sizeof(index)); if (unlikely(err)) { @@ -1684,7 +1681,7 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev, } val = 1; /* assume shared key. otherwise 0 */ - val = htod32(val); + val = cpu_to_le32(val); err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val)); if (unlikely(err)) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); @@ -1740,7 +1737,7 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, } val = 0; /* assume open key. otherwise 1 */ - val = htod32(val); + val = cpu_to_le32(val); err = wl_dev_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val)); if (unlikely(err)) { WL_ERR("WLC_SET_AUTH error (%d)\n", err); @@ -1768,7 +1765,7 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, key.index = key_idx; swap_key_to_BE(&key); memset(¶ms, 0, sizeof(params)); - params.key_len = (u8) min_t(u8, DOT11_MAX_KEY_SIZE, key.len); + params.key_len = (u8) min_t(u8, WLAN_MAX_KEY_LEN, key.len); memcpy(params.key, key.data, params.key_len); err = wl_dev_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec)); @@ -1776,7 +1773,7 @@ wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev, WL_ERR("WLC_GET_WSEC error (%d)\n", err); return err; } - wsec = dtoh32(wsec); + wsec = le32_to_cpu(wsec); switch (wsec) { case WEP_ENABLED: sec = wl_read_prof(wl, WL_PROF_SEC); @@ -1836,7 +1833,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, if (err) { WL_ERR("Could not get rate (%d)\n", err); } else { - rate = dtoh32(rate); + rate = le32_to_cpu(rate); sinfo->filled |= STATION_INFO_TX_BITRATE; sinfo->txrate.legacy = rate * 5; WL_DBG("Rate %d Mbps\n", rate / 2); @@ -1850,7 +1847,7 @@ wl_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, WL_ERR("Could not get rssi (%d)\n", err); return err; } - rssi = dtoh32(scb_val.val); + rssi = le32_to_cpu(scb_val.val); sinfo->filled |= STATION_INFO_SIGNAL; sinfo->signal = rssi; WL_DBG("RSSI %d dBm\n", rssi); @@ -1868,7 +1865,7 @@ wl_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, CHECK_SYS_UP(); pm = enabled ? PM_FAST : PM_OFF; - pm = htod32(pm); + pm = cpu_to_le32(pm); WL_DBG("power save %s\n", (pm ? "enabled" : "disabled")); err = wl_dev_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm)); if (unlikely(err)) { @@ -1931,7 +1928,7 @@ wl_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev, return err; } - rateset.count = dtoh32(rateset.count); + rateset.count = le32_to_cpu(rateset.count); legacy = wl_find_msb(mask->control[IEEE80211_BAND_2GHZ].legacy); if (!legacy) @@ -1980,8 +1977,6 @@ static s32 wl_cfg80211_suspend(struct wiphy *wiphy) struct net_device *ndev = wl_to_ndev(wl); s32 err = 0; - CHECK_SYS_UP(); - set_bit(WL_STATUS_SCAN_ABORTING, &wl->status); wl_term_iscan(wl); if (wl->scan_request) { @@ -2005,8 +2000,8 @@ wl_update_pmklist(struct net_device *dev, struct wl_pmk_list *pmk_list, WL_DBG("No of elements %d\n", pmk_list->pmkids.npmkid); for (i = 0; i < pmk_list->pmkids.npmkid; i++) { WL_DBG("PMKID[%d]: %pM =\n", i, - &pmk_list->pmkids.pmkid[i].BSSID); - for (j = 0; j < WPA2_PMKID_LEN; j++) { + &pmk_list->pmkids.pmkid[i].BSSID); + for (j = 0; j < WLAN_PMKID_LEN; j++) { WL_DBG("%02x\n", pmk_list->pmkids.pmkid[i].PMKID[j]); } } @@ -2035,7 +2030,7 @@ wl_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, memcpy(&wl->pmk_list->pmkids.pmkid[i].BSSID, pmksa->bssid, ETH_ALEN); memcpy(&wl->pmk_list->pmkids.pmkid[i].PMKID, pmksa->pmkid, - WPA2_PMKID_LEN); + WLAN_PMKID_LEN); if (i == wl->pmk_list->pmkids.npmkid) wl->pmk_list->pmkids.npmkid++; } else { @@ -2043,7 +2038,7 @@ wl_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev, } WL_DBG("set_pmksa,IW_PMKSA_ADD - PMKID: %pM =\n", &wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid].BSSID); - for (i = 0; i < WPA2_PMKID_LEN; i++) { + for (i = 0; i < WLAN_PMKID_LEN; i++) { WL_DBG("%02x\n", wl->pmk_list->pmkids.pmkid[wl->pmk_list->pmkids.npmkid]. PMKID[i]); @@ -2065,11 +2060,11 @@ wl_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, CHECK_SYS_UP(); memcpy(&pmkid.pmkid[0].BSSID, pmksa->bssid, ETH_ALEN); - memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WPA2_PMKID_LEN); + memcpy(&pmkid.pmkid[0].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); WL_DBG("del_pmksa,IW_PMKSA_REMOVE - PMKID: %pM =\n", &pmkid.pmkid[0].BSSID); - for (i = 0; i < WPA2_PMKID_LEN; i++) { + for (i = 0; i < WLAN_PMKID_LEN; i++) { WL_DBG("%02x\n", pmkid.pmkid[0].PMKID[i]); } @@ -2088,7 +2083,7 @@ wl_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, ETH_ALEN); memcpy(&wl->pmk_list->pmkids.pmkid[i].PMKID, &wl->pmk_list->pmkids.pmkid[i + 1].PMKID, - WPA2_PMKID_LEN); + WLAN_PMKID_LEN); } wl->pmk_list->pmkids.npmkid--; } else { @@ -2264,7 +2259,7 @@ static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi) u32 freq; s32 err = 0; - if (unlikely(dtoh32(bi->length) > WL_BSS_INFO_MAX)) { + if (unlikely(le32_to_cpu(bi->length) > WL_BSS_INFO_MAX)) { WL_DBG("Beacon is larger than buffer. Discarding\n"); return err; } @@ -2313,7 +2308,9 @@ static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi) notif_bss_info->frame_len = offsetof(struct ieee80211_mgmt, u.beacon.variable) + wl_get_ielen(wl); - freq = ieee80211_channel_to_frequency(notif_bss_info->channel); + freq = ieee80211_channel_to_frequency(notif_bss_info->channel, + band->band); + channel = ieee80211_get_channel(wiphy, freq); WL_DBG("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n", @@ -2337,8 +2334,8 @@ static s32 wl_inform_single_bss(struct wl_priv *wl, struct wl_bss_info *bi) static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e) { - u32 event = ntoh32(e->event_type); - u16 flags = ntoh16(e->flags); + u32 event = be32_to_cpu(e->event_type); + u16 flags = be16_to_cpu(e->flags); if (event == WLC_E_LINK) { if (flags & WLC_EVENT_MSG_LINK) { @@ -2356,8 +2353,8 @@ static bool wl_is_linkup(struct wl_priv *wl, const wl_event_msg_t *e) static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e) { - u32 event = ntoh32(e->event_type); - u16 flags = ntoh16(e->flags); + u32 event = be32_to_cpu(e->event_type); + u16 flags = be16_to_cpu(e->flags); if (event == WLC_E_DEAUTH_IND || event == WLC_E_DISASSOC_IND) { return true; @@ -2371,8 +2368,8 @@ static bool wl_is_linkdown(struct wl_priv *wl, const wl_event_msg_t *e) static bool wl_is_nonetwork(struct wl_priv *wl, const wl_event_msg_t *e) { - u32 event = ntoh32(e->event_type); - u32 status = ntoh32(e->status); + u32 event = be32_to_cpu(e->event_type); + u32 status = be32_to_cpu(e->status); if (event == WLC_E_SET_SSID || event == WLC_E_LINK) { if (status == WLC_E_STATUS_NO_NETWORKS) @@ -2436,7 +2433,7 @@ wl_dev_bufvar_set(struct net_device *dev, s8 *name, s8 *buf, s32 len) u32 buflen; buflen = bcm_mkiovar(name, buf, len, wl->ioctl_buf, WL_IOCTL_LEN_MAX); - BUG_ON(unlikely(!buflen)); + BUG_ON(!buflen); return wl_dev_ioctl(dev, WLC_SET_VAR, wl->ioctl_buf, buflen); } @@ -2450,7 +2447,7 @@ wl_dev_bufvar_get(struct net_device *dev, s8 *name, s8 *buf, s32 err = 0; len = bcm_mkiovar(name, NULL, 0, wl->ioctl_buf, WL_IOCTL_LEN_MAX); - BUG_ON(unlikely(!len)); + BUG_ON(!len); err = wl_dev_ioctl(dev, WLC_GET_VAR, (void *)wl->ioctl_buf, WL_IOCTL_LEN_MAX); if (unlikely(err)) { @@ -2537,10 +2534,10 @@ static void wl_ch_to_chanspec(int ch, struct wl_join_params *join_params, 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]); + cpu_to_le16(join_params->params.chanspec_list[0]); join_params->params.chanspec_num = - htod32(join_params->params.chanspec_num); + cpu_to_le32(join_params->params.chanspec_num); WL_DBG("join_params->params.chanspec_list[0]= %#X, channel %d, chanspec %#X\n", join_params->params.chanspec_list[0], ch, chanspec); @@ -2571,7 +2568,7 @@ static s32 wl_update_bss_info(struct wl_priv *wl) rtnl_lock(); if (unlikely(!bss)) { WL_DBG("Could not find the AP\n"); - *(u32 *) wl->extra_buf = htod32(WL_EXTRA_BUF_MAX); + *(u32 *) wl->extra_buf = cpu_to_le32(WL_EXTRA_BUF_MAX); err = wl_dev_ioctl(wl_to_ndev(wl), WLC_GET_BSS_INFO, wl->extra_buf, WL_EXTRA_BUF_MAX); if (unlikely(err)) { @@ -2682,7 +2679,7 @@ static s32 wl_notify_mic_status(struct wl_priv *wl, struct net_device *ndev, const wl_event_msg_t *e, void *data) { - u16 flags = ntoh16(e->flags); + u16 flags = be16_to_cpu(e->flags); enum nl80211_key_type key_type; rtnl_lock(); @@ -2723,7 +2720,7 @@ wl_notify_scan_status(struct wl_priv *wl, struct net_device *ndev, WL_ERR("scan busy (%d)\n", err); goto scan_done_out; } - channel_inform.scan_channel = dtoh32(channel_inform.scan_channel); + channel_inform.scan_channel = le32_to_cpu(channel_inform.scan_channel); if (unlikely(channel_inform.scan_channel)) { WL_DBG("channel_inform.scan_channel (%d)\n", @@ -2732,16 +2729,16 @@ wl_notify_scan_status(struct wl_priv *wl, struct net_device *ndev, wl->bss_list = wl->scan_results; bss_list = wl->bss_list; memset(bss_list, 0, len); - bss_list->buflen = htod32(len); + bss_list->buflen = cpu_to_le32(len); err = wl_dev_ioctl(ndev, WLC_SCAN_RESULTS, bss_list, len); if (unlikely(err)) { WL_ERR("%s Scan_results error (%d)\n", ndev->name, err); err = -EINVAL; goto scan_done_out; } - bss_list->buflen = dtoh32(bss_list->buflen); - bss_list->version = dtoh32(bss_list->version); - bss_list->count = dtoh32(bss_list->count); + bss_list->buflen = le32_to_cpu(bss_list->buflen); + bss_list->version = le32_to_cpu(bss_list->version); + bss_list->count = le32_to_cpu(bss_list->count); err = wl_inform_bss(wl); if (err) @@ -2950,7 +2947,7 @@ wl_get_iscan_results(struct wl_iscan_ctrl *iscan, u32 *status, results->count = 0; memset(&list, 0, sizeof(list)); - list.results.buflen = htod32(WL_ISCAN_BUF_MAX); + list.results.buflen = cpu_to_le32(WL_ISCAN_BUF_MAX); err = wl_dev_iovar_getbuf(iscan->dev, "iscanresults", &list, WL_ISCAN_RESULTS_FIXED_SIZE, iscan->scan_buf, WL_ISCAN_BUF_MAX); @@ -2958,12 +2955,12 @@ wl_get_iscan_results(struct wl_iscan_ctrl *iscan, u32 *status, WL_ERR("error (%d)\n", err); return err; } - results->buflen = dtoh32(results->buflen); - results->version = dtoh32(results->version); - results->count = dtoh32(results->count); + results->buflen = le32_to_cpu(results->buflen); + results->version = le32_to_cpu(results->version); + results->count = le32_to_cpu(results->count); WL_DBG("results->count = %d\n", results->count); WL_DBG("results->buflen = %d\n", results->buflen); - *status = dtoh32(list_buf->status); + *status = le32_to_cpu(list_buf->status); *bss_list = results; return err; @@ -3274,7 +3271,7 @@ static s32 wl_event_handler(void *data) void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t * e, void *data) { - u32 event_type = ntoh32(e->event_type); + u32 event_type = be32_to_cpu(e->event_type); struct wl_priv *wl = ndev_to_wl(ndev); #if (WL_DBG_LEVEL > 0) s8 *estr = (event_type <= sizeof(wl_dbg_estr) / WL_DBG_ESTR_MAX - 1) ? @@ -3393,8 +3390,8 @@ static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype) WL_ERR("invalid type (%d)\n", iftype); return err; } - infra = htod32(infra); - ap = htod32(ap); + infra = cpu_to_le32(infra); + ap = cpu_to_le32(ap); WL_DBG("%s ap (%d), infra (%d)\n", ndev->name, ap, infra); err = wl_dev_ioctl(ndev, WLC_SET_INFRA, &infra, sizeof(infra)); if (unlikely(err)) { @@ -3656,26 +3653,28 @@ static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode) pkt_filterp = (struct wl_pkt_filter *)(buf + str_len + 1); /* Parse packet filter id. */ - pkt_filter.id = htod32(100); + pkt_filter.id = cpu_to_le32(100); /* Parse filter polarity. */ - pkt_filter.negate_match = htod32(0); + pkt_filter.negate_match = cpu_to_le32(0); /* Parse filter type. */ - pkt_filter.type = htod32(0); + pkt_filter.type = cpu_to_le32(0); /* Parse pattern filter offset. */ - pkt_filter.u.pattern.offset = htod32(0); + pkt_filter.u.pattern.offset = cpu_to_le32(0); /* Parse pattern filter mask. */ - mask_size = htod32(wl_pattern_atoh("0xff", - (char *)pkt_filterp->u.pattern. - mask_and_pattern)); + mask_size = cpu_to_le32(wl_pattern_atoh("0xff", + (char *)pkt_filterp->u.pattern. + mask_and_pattern)); /* Parse pattern filter pattern. */ - pattern_size = htod32(wl_pattern_atoh("0x00", - (char *)&pkt_filterp->u.pattern. - mask_and_pattern[mask_size])); + pattern_size = cpu_to_le32(wl_pattern_atoh("0x00", + (char *)&pkt_filterp->u. + pattern. + mask_and_pattern + [mask_size])); if (mask_size != pattern_size) { WL_ERR("Mask and pattern not the same size\n"); diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 482691be210a..5112160e0ae3 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -20,7 +20,6 @@ #include <linux/wireless.h> #include <linux/wireless.h> #include <net/cfg80211.h> -#include <proto/ethernet.h> #include <wlioctl.h> struct wl_conf; @@ -29,23 +28,6 @@ struct wl_priv; struct wl_security; struct wl_ibss; -#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 - #define WL_DBG_NONE 0 #define WL_DBG_DBG (1 << 2) #define WL_DBG_INFO (1 << 1) @@ -316,7 +298,7 @@ struct wl_priv { cfg80211 layer */ struct wl_ie ie; /* information element object for internal purpose */ - struct ether_addr bssid; /* bssid of currently engaged network */ + u8 bssid[ETH_ALEN]; /* bssid of currently engaged network */ struct semaphore event_sync; /* for synchronization of main event thread */ struct wl_profile *profile; /* holding dongle profile */ @@ -366,7 +348,8 @@ static inline struct wl_bss_info *next_bss(struct wl_scan_results *list, { return bss = bss ? (struct wl_bss_info *)((unsigned long)bss + - dtoh32(bss->length)) : list->bss_info; + le32_to_cpu(bss->length)) : + list->bss_info; } #define for_each_bss(list, bss, __i) \ diff --git a/drivers/staging/brcm80211/brcmfmac/wl_iw.c b/drivers/staging/brcm80211/brcmfmac/wl_iw.c index db6e68eab290..b49957fb7586 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_iw.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_iw.c @@ -18,12 +18,9 @@ #include <linux/semaphore.h> #include <bcmdefs.h> #include <linux/netdevice.h> -#include <osl.h> #include <wlioctl.h> #include <bcmutils.h> -#include <bcmendian.h> -#include <proto/ethernet.h> #include <linux/if_arp.h> #include <asm/uaccess.h> @@ -31,11 +28,10 @@ #include <dngl_stats.h> #include <dhd.h> #include <dhdioctl.h> - +#include <linux/ieee80211.h> typedef const struct si_pub si_t; #include <wlioctl.h> -#include <proto/ethernet.h> #include <dngl_stats.h> #include <dhd.h> @@ -72,23 +68,6 @@ 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); @@ -137,6 +116,9 @@ typedef struct iscan_info { int iscan_ex_param_size; } iscan_info_t; iscan_info_t *g_iscan; + +static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; + static void wl_iw_timerfunc(unsigned long 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, u16 action); @@ -158,24 +140,24 @@ wl_iw_get_scan_prep(wl_scan_results_t *list, 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); + key->index = cpu_to_le32(key->index); + key->len = cpu_to_le32(key->len); + key->algo = cpu_to_le32(key->algo); + key->flags = cpu_to_le32(key->flags); + key->rxiv.hi = cpu_to_le32(key->rxiv.hi); + key->rxiv.lo = cpu_to_le16(key->rxiv.lo); + key->iv_initialized = cpu_to_le32(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); + key->index = le32_to_cpu(key->index); + key->len = le32_to_cpu(key->len); + key->algo = le32_to_cpu(key->algo); + key->flags = le32_to_cpu(key->flags); + key->rxiv.hi = le32_to_cpu(key->rxiv.hi); + key->rxiv.lo = le16_to_cpu(key->rxiv.lo); + key->iv_initialized = le32_to_cpu(key->iv_initialized); } static int dev_wlc_ioctl(struct net_device *dev, int cmd, void *arg, int len) @@ -223,7 +205,7 @@ static int dev_wlc_intvar_set(struct net_device *dev, char *name, int val) char buf[WLC_IOCTL_SMLEN]; uint len; - val = htod32(val); + val = cpu_to_le32(val); len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf)); ASSERT(len); @@ -288,7 +270,7 @@ dev_wlc_bufvar_get(struct net_device *dev, char *name, char *buf, int buflen) dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf, MAX_WLIW_IOCTL_LEN); if (!error) - bcopy(ioctlbuf, buf, buflen); + memcpy(buf, ioctlbuf, buflen); return error; } @@ -310,7 +292,7 @@ static int dev_wlc_intvar_get(struct net_device *dev, char *name, int *retval) ASSERT(len); error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len); - *retval = dtoh32(var.val); + *retval = le32_to_cpu(var.val); return error; } @@ -340,7 +322,7 @@ wl_iw_config_commit(struct net_device *dev, if (error) return error; - ssid.SSID_len = dtoh32(ssid.SSID_len); + ssid.SSID_len = le32_to_cpu(ssid.SSID_len); if (!ssid.SSID_len) return 0; @@ -392,7 +374,7 @@ wl_iw_set_freq(struct net_device *dev, chan = wf_mhz2channel(fwrq->m, sf); } - chan = htod32(chan); + chan = cpu_to_le32(chan); error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan)); if (error) @@ -415,8 +397,8 @@ wl_iw_get_freq(struct net_device *dev, if (error) return error; - fwrq->m = dtoh32(ci.hw_channel); - fwrq->e = dtoh32(0); + fwrq->m = le32_to_cpu(ci.hw_channel); + fwrq->e = le32_to_cpu(0); return 0; } @@ -441,8 +423,8 @@ wl_iw_set_mode(struct net_device *dev, default: return -EINVAL; } - infra = htod32(infra); - ap = htod32(ap); + infra = cpu_to_le32(infra); + ap = cpu_to_le32(ap); error = dev_wlc_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra)); if (error) @@ -471,8 +453,8 @@ wl_iw_get_mode(struct net_device *dev, if (error) return error; - infra = dtoh32(infra); - ap = dtoh32(ap); + infra = le32_to_cpu(infra); + ap = le32_to_cpu(ap); *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC; return 0; @@ -488,7 +470,7 @@ wl_iw_get_range(struct net_device *dev, wl_rateset_t rateset; s8 *channels; int error, i, k; - uint sf, ch; + uint ch; int phytype; int bw_cap = 0, sgi_tx = 0, nmode = 0; @@ -517,23 +499,24 @@ wl_iw_get_range(struct net_device *dev, range->min_nwid = range->max_nwid = 0; - list->count = htod32(MAXCHANNEL); + list->count = cpu_to_le32(MAXCHANNEL); error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, (MAXCHANNEL + 1) * 4); if (error) { 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; + for (i = 0; i < le32_to_cpu(list->count) && i < IW_MAX_FREQUENCIES; + i++) { + range->freq[i].i = le32_to_cpu(list->element[i]); - range->freq[i].m = wf_channel2mhz(ch, sf); + ch = le32_to_cpu(list->element[i]); + if (ch <= CH_MAX_2G_CHANNEL) { + range->freq[i].m = ieee80211_dsss_chan_to_freq(ch); + } else { + range->freq[i].m = ieee80211_ofdm_chan_to_freq( + WF_CHAN_FACTOR_5_G/2, ch); + } range->freq[i].e = 6; } range->num_frequency = range->num_channels = i; @@ -555,7 +538,7 @@ wl_iw_get_range(struct net_device *dev, kfree(channels); return error; } - rateset.count = dtoh32(rateset.count); + rateset.count = le32_to_cpu(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; @@ -567,7 +550,7 @@ wl_iw_get_range(struct net_device *dev, 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); + ci.hw_channel = le32_to_cpu(ci.hw_channel); if (bw_cap == 0 || (bw_cap == 2 && ci.hw_channel <= 14)) { if (sgi_tx == 0) @@ -593,7 +576,7 @@ wl_iw_get_range(struct net_device *dev, kfree(channels); return error; } - i = dtoh32(i); + i = le32_to_cpu(i); if (i == WLC_PHY_TYPE_A) range->throughput = 24000000; else @@ -606,14 +589,14 @@ wl_iw_get_range(struct net_device *dev, 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; + range->encoding_size[0] = WLAN_KEY_LEN_WEP40; + range->encoding_size[1] = WLAN_KEY_LEN_WEP104; #if WIRELESS_EXT > 17 - range->encoding_size[2] = TKIP_KEY_SIZE; + range->encoding_size[2] = WLAN_KEY_LEN_TKIP; #else range->encoding_size[2] = 0; #endif - range->encoding_size[3] = AES_KEY_SIZE; + range->encoding_size[3] = WLAN_KEY_LEN_AES_CMAC; range->min_pmp = 0; range->max_pmp = 0; @@ -690,7 +673,7 @@ wl_iw_set_spy(struct net_device *dev, iw->spy_num = min_t(int, ARRAY_SIZE(iw->spy_addr), dwrq->length); for (i = 0; i < iw->spy_num; i++) - memcpy(&iw->spy_addr[i], addr[i].sa_data, ETH_ALEN); + memcpy(iw->spy_addr[i], addr[i].sa_data, ETH_ALEN); memset(iw->spy_qual, 0, sizeof(iw->spy_qual)); return 0; @@ -712,7 +695,7 @@ wl_iw_get_spy(struct net_device *dev, dwrq->length = iw->spy_num; for (i = 0; i < iw->spy_num; i++) { - memcpy(addr[i].sa_data, &iw->spy_addr[i], ETH_ALEN); + memcpy(addr[i].sa_data, iw->spy_addr[i], ETH_ALEN); addr[i].sa_family = AF_UNIX; memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality)); iw->spy_qual[i].updated = 0; @@ -745,10 +728,10 @@ wl_iw_ch_to_chanspec(int ch, wl_join_params_t *join_params, 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]); + cpu_to_le16(join_params->params.chanspec_list[0]); join_params->params.chanspec_num = - htod32(join_params->params.chanspec_num); + cpu_to_le32(join_params->params.chanspec_num); WL_TRACE("%s join_params->params.chanspec_list[0]= %X\n", __func__, join_params->params.chanspec_list[0]); @@ -784,7 +767,7 @@ wl_iw_set_wap(struct net_device *dev, 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); + join_params.ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len); memcpy(&join_params.params.bssid, awrq->sa_data, ETH_ALEN); WL_TRACE("%s target_channel=%d\n", @@ -840,15 +823,15 @@ wl_iw_mlme(struct net_device *dev, } scbval.val = mlme->reason_code; - bcopy(&mlme->addr.sa_data, &scbval.ea, ETH_ALEN); + memcpy(&scbval.ea, &mlme->addr.sa_data, ETH_ALEN); if (mlme->cmd == IW_MLME_DISASSOC) { - scbval.val = htod32(scbval.val); + scbval.val = cpu_to_le32(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); + scbval.val = cpu_to_le32(scbval.val); error = dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval, sizeof(scb_val_t)); @@ -879,20 +862,19 @@ wl_iw_get_aplist(struct net_device *dev, if (!extra) return -EINVAL; - list = kmalloc(buflen, GFP_KERNEL); + list = kzalloc(buflen, GFP_KERNEL); if (!list) return -ENOMEM; - memset(list, 0, buflen); - list->buflen = htod32(buflen); + list->buflen = cpu_to_le32(buflen); error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen); if (error) { 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); + list->buflen = le32_to_cpu(list->buflen); + list->version = le32_to_cpu(list->version); + list->count = le32_to_cpu(list->count); if (list->version != WL_BSS_INFO_VERSION) { WL_ERROR("%s : list->version %d != WL_BSS_INFO_VERSION\n", __func__, list->version); @@ -903,18 +885,18 @@ wl_iw_get_aplist(struct net_device *dev, for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) { bi = bi ? (wl_bss_info_t *) ((unsigned long)bi + - dtoh32(bi->length)) : list-> + le32_to_cpu(bi->length)) : list-> bss_info; - ASSERT(((unsigned long)bi + dtoh32(bi->length)) <= + ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <= ((unsigned long)list + buflen)); - if (!(dtoh16(bi->capability) & DOT11_CAP_ESS)) + if (!(le16_to_cpu(bi->capability) & WLAN_CAPABILITY_ESS)) continue; memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETH_ALEN); 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].qual = rssi_to_qual(le16_to_cpu(bi->RSSI)); + qual[dwrq->length].level = 0x100 + le16_to_cpu(bi->RSSI); qual[dwrq->length].noise = 0x100 + bi->phy_noise; #if WIRELESS_EXT > 18 @@ -975,20 +957,22 @@ wl_iw_iscan_get_aplist(struct net_device *dev, for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) { bi = bi ? (wl_bss_info_t *) ((unsigned long)bi + - dtoh32(bi->length)) : + le32_to_cpu(bi->length)) : list->bss_info; - ASSERT(((unsigned long)bi + dtoh32(bi->length)) <= + ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <= ((unsigned long)list + WLC_IW_ISCAN_MAXLEN)); - if (!(dtoh16(bi->capability) & DOT11_CAP_ESS)) + if (!(le16_to_cpu(bi->capability) & + WLAN_CAPABILITY_ESS)) continue; memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETH_ALEN); 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); + rssi_to_qual(le16_to_cpu(bi->RSSI)); + qual[dwrq->length].level = 0x100 + + le16_to_cpu(bi->RSSI); qual[dwrq->length].noise = 0x100 + bi->phy_noise; #if WIRELESS_EXT > 18 @@ -1015,7 +999,7 @@ static int wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid) { int err = 0; - memcpy(¶ms->bssid, ðer_bcast, ETH_ALEN); + memcpy(params->bssid, ether_bcast, ETH_ALEN); params->bss_type = DOT11_BSSTYPE_ANY; params->scan_type = 0; params->nprobes = -1; @@ -1024,10 +1008,10 @@ static int wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid) 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); + params->nprobes = cpu_to_le32(params->nprobes); + params->active_time = cpu_to_le32(params->active_time); + params->passive_time = cpu_to_le32(params->passive_time); + params->home_time = cpu_to_le32(params->home_time); if (ssid && ssid->SSID_len) memcpy(¶ms->ssid, ssid, sizeof(wlc_ssid_t)); @@ -1038,9 +1022,9 @@ static int wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, u16 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); + iscan->iscan_ex_params_p->version = cpu_to_le32(ISCAN_REQ_VERSION); + iscan->iscan_ex_params_p->action = cpu_to_le16(action); + iscan->iscan_ex_params_p->scan_duration = cpu_to_le16(0); WL_SCAN("%s : nprobes=%d\n", __func__, iscan->iscan_ex_params_p->params.nprobes); @@ -1077,7 +1061,7 @@ static void wl_iw_set_event_mask(struct net_device *dev) 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); + memcpy(eventmask, iovbuf, 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)); @@ -1124,19 +1108,19 @@ static u32 wl_iw_iscan_get(iscan_info_t *iscan) results->count = 0; memset(&list, 0, sizeof(list)); - list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN); + list.results.buflen = cpu_to_le32(WLC_IW_ISCAN_MAXLEN); res = dev_iw_iovar_getbuf(iscan->dev, "iscanresults", &list, WL_ISCAN_RESULTS_FIXED_SIZE, buf->iscan_buf, WLC_IW_ISCAN_MAXLEN); if (res == 0) { - results->buflen = dtoh32(results->buflen); - results->version = dtoh32(results->version); - results->count = dtoh32(results->count); + results->buflen = le32_to_cpu(results->buflen); + results->version = le32_to_cpu(results->version); + results->count = le32_to_cpu(results->count); WL_TRACE("results->count = %d\n", results->count); WL_TRACE("results->buflen = %d\n", results->buflen); - status = dtoh32(list_buf->status); + status = le32_to_cpu(list_buf->status); } else { WL_ERROR("%s returns error %d\n", __func__, res); status = WL_SCAN_RESULTS_NO_MEM; @@ -1283,7 +1267,7 @@ wl_iw_set_scan(struct net_device *dev, memcpy(g_specific_ssid.SSID, req->essid, g_specific_ssid.SSID_len); g_specific_ssid.SSID_len = - htod32(g_specific_ssid.SSID_len); + cpu_to_le32(g_specific_ssid.SSID_len); g_scan_specified_ssid = 1; WL_TRACE("### Specific scan ssid=%s len=%d\n", g_specific_ssid.SSID, @@ -1367,7 +1351,7 @@ wl_iw_iscan_set_scan(struct net_device *dev, if (g_scan_specified_ssid) { WL_TRACE("%s Specific SCAN already running ignoring BC scan\n", __func__); - return EBUSY; + return -EBUSY; } memset(&ssid, 0, sizeof(ssid)); @@ -1379,7 +1363,7 @@ wl_iw_iscan_set_scan(struct net_device *dev, ssid.SSID_len = min_t(size_t, sizeof(ssid.SSID), req->essid_len); memcpy(ssid.SSID, req->essid, ssid.SSID_len); - ssid.SSID_len = htod32(ssid.SSID_len); + ssid.SSID_len = cpu_to_le32(ssid.SSID_len); } else { g_scan_specified_ssid = 0; @@ -1505,7 +1489,7 @@ wl_iw_get_scan_prep(wl_scan_results_t *list, } bi = bi ? (wl_bss_info_t *)((unsigned long)bi + - dtoh32(bi->length)) : list-> + le32_to_cpu(bi->length)) : list-> bss_info; WL_TRACE("%s : %s\n", __func__, bi->SSID); @@ -1516,14 +1500,15 @@ wl_iw_get_scan_prep(wl_scan_results_t *list, event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN); - iwe.u.data.length = dtoh32(bi->SSID_len); + iwe.u.data.length = le32_to_cpu(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)) { + if (le16_to_cpu(bi->capability) & (WLAN_CAPABILITY_ESS | + WLAN_CAPABILITY_IBSS)) { iwe.cmd = SIOCGIWMODE; - if (dtoh16(bi->capability) & DOT11_CAP_ESS) + if (le16_to_cpu(bi->capability) & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_INFRA; else iwe.u.mode = IW_MODE_ADHOC; @@ -1533,19 +1518,23 @@ wl_iw_get_scan_prep(wl_scan_results_t *list, } 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); + + if (CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL) + iwe.u.freq.m = ieee80211_dsss_chan_to_freq( + CHSPEC_CHANNEL(bi->chanspec)); + else + iwe.u.freq.m = ieee80211_ofdm_chan_to_freq( + WF_CHAN_FACTOR_5_G/2, + CHSPEC_CHANNEL(bi->chanspec)); + 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.qual = rssi_to_qual(le16_to_cpu(bi->RSSI)); + iwe.u.qual.level = 0x100 + le16_to_cpu(bi->RSSI); iwe.u.qual.noise = 0x100 + bi->phy_noise; event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, @@ -1554,7 +1543,7 @@ wl_iw_get_scan_prep(wl_scan_results_t *list, wl_iw_handle_scanresults_ies(&event, end, info, bi); iwe.cmd = SIOCGIWENCODE; - if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY) + if (le16_to_cpu(bi->capability) & WLAN_CAPABILITY_PRIVACY) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else iwe.u.data.flags = IW_ENCODE_DISABLED; @@ -1621,7 +1610,7 @@ wl_iw_get_scan(struct net_device *dev, error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci)); if (error) return error; - ci.scan_channel = dtoh32(ci.scan_channel); + ci.scan_channel = le32_to_cpu(ci.scan_channel); if (ci.scan_channel) return -EAGAIN; @@ -1636,7 +1625,7 @@ wl_iw_get_scan(struct net_device *dev, } memset(list, 0, len); - list->buflen = htod32(len); + list->buflen = cpu_to_le32(len); error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len); if (error) { WL_ERROR("%s: %s : Scan_results ERROR %d\n", @@ -1648,9 +1637,9 @@ wl_iw_get_scan(struct net_device *dev, } return 0; } - list->buflen = dtoh32(list->buflen); - list->version = dtoh32(list->version); - list->count = dtoh32(list->count); + list->buflen = le32_to_cpu(list->buflen); + list->version = le32_to_cpu(list->version); + list->count = le32_to_cpu(list->count); if (list->version != WL_BSS_INFO_VERSION) { WL_ERROR("%s : list->version %d != WL_BSS_INFO_VERSION\n", @@ -1770,9 +1759,9 @@ wl_iw_iscan_get_scan(struct net_device *dev, for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) { bi = bi ? (wl_bss_info_t *)((unsigned long)bi + - dtoh32(bi->length)) : + le32_to_cpu(bi->length)) : list->bss_info; - ASSERT(((unsigned long)bi + dtoh32(bi->length)) <= + ASSERT(((unsigned long)bi + le32_to_cpu(bi->length)) <= ((unsigned long)list + WLC_IW_ISCAN_MAXLEN)); if (event + ETH_ALEN + bi->SSID_len + @@ -1787,17 +1776,18 @@ wl_iw_iscan_get_scan(struct net_device *dev, IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN); - iwe.u.data.length = dtoh32(bi->SSID_len); + iwe.u.data.length = le32_to_cpu(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)) { + if (le16_to_cpu(bi->capability) & + (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { iwe.cmd = SIOCGIWMODE; - if (dtoh16(bi->capability) & DOT11_CAP_ESS) + if (le16_to_cpu(bi->capability) & + WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_INFRA; else iwe.u.mode = IW_MODE_ADHOC; @@ -1810,20 +1800,23 @@ wl_iw_iscan_get_scan(struct net_device *dev, 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); + + if (channel <= CH_MAX_2G_CHANNEL) + iwe.u.freq.m = + ieee80211_dsss_chan_to_freq(channel); + else + iwe.u.freq.m = ieee80211_ofdm_chan_to_freq( + WF_CHAN_FACTOR_5_G/2, + channel); + 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.qual = rssi_to_qual(le16_to_cpu(bi->RSSI)); + iwe.u.qual.level = 0x100 + le16_to_cpu(bi->RSSI); iwe.u.qual.noise = 0x100 + bi->phy_noise; event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, @@ -1832,7 +1825,8 @@ wl_iw_iscan_get_scan(struct net_device *dev, wl_iw_handle_scanresults_ies(&event, end, info, bi); iwe.cmd = SIOCGIWENCODE; - if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY) + if (le16_to_cpu(bi->capability) & + WLAN_CAPABILITY_PRIVACY) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else @@ -1912,14 +1906,14 @@ wl_iw_set_essid(struct net_device *dev, } else { g_ssid.SSID_len = 0; } - g_ssid.SSID_len = htod32(g_ssid.SSID_len); + g_ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len); 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, ETH_ALEN); + join_params.ssid.SSID_len = cpu_to_le32(g_ssid.SSID_len); + memcpy(join_params.params.bssid, ether_bcast, ETH_ALEN); wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params, &join_params_size); @@ -1955,7 +1949,7 @@ wl_iw_get_essid(struct net_device *dev, return error; } - ssid.SSID_len = dtoh32(ssid.SSID_len); + ssid.SSID_len = le32_to_cpu(ssid.SSID_len); memcpy(extra, ssid.SSID, ssid.SSID_len); @@ -2017,7 +2011,7 @@ wl_iw_set_rate(struct net_device *dev, if (error) return error; - rateset.count = dtoh32(rateset.count); + rateset.count = le32_to_cpu(rateset.count); if (vwrq->value < 0) rate = rateset.rates[rateset.count - 1] & 0x7f; @@ -2042,7 +2036,7 @@ wl_iw_set_rate(struct net_device *dev, for (i = 0; i < rateset.count; i++) if ((rateset.rates[i] & 0x7f) > rate) break; - rateset.count = htod32(i); + rateset.count = cpu_to_le32(i); error = dev_wlc_ioctl(dev, WLC_SET_RATESET, &rateset, sizeof(rateset)); @@ -2064,7 +2058,7 @@ wl_iw_get_rate(struct net_device *dev, error = dev_wlc_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate)); if (error) return error; - rate = dtoh32(rate); + rate = le32_to_cpu(rate); vwrq->value = rate * 500000; return 0; @@ -2164,7 +2158,7 @@ wl_iw_set_txpow(struct net_device *dev, disable = vwrq->disabled ? WL_RADIO_SW_DISABLE : 0; disable += WL_RADIO_SW_DISABLE << 16; - disable = htod32(disable); + disable = cpu_to_le32(disable); error = dev_wlc_ioctl(dev, WLC_SET_RADIO, &disable, sizeof(disable)); if (error) return error; @@ -2206,7 +2200,7 @@ wl_iw_get_txpow(struct net_device *dev, if (error) return error; - disable = dtoh32(disable); + disable = le32_to_cpu(disable); result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE); vwrq->value = (s32) bcm_qdbm_to_mw(result); vwrq->fixed = 0; @@ -2241,7 +2235,7 @@ wl_iw_set_retry(struct net_device *dev, if ((vwrq->flags & IW_RETRY_MAX) || !(vwrq->flags & IW_RETRY_MIN)) { #endif - lrl = htod32(vwrq->value); + lrl = cpu_to_le32(vwrq->value); error = dev_wlc_ioctl(dev, WLC_SET_LRL, &lrl, sizeof(lrl)); if (error) @@ -2256,7 +2250,7 @@ wl_iw_set_retry(struct net_device *dev, if ((vwrq->flags & IW_RETRY_MIN) || !(vwrq->flags & IW_RETRY_MAX)) { #endif - srl = htod32(vwrq->value); + srl = cpu_to_le32(vwrq->value); error = dev_wlc_ioctl(dev, WLC_SET_SRL, &srl, sizeof(srl)); if (error) @@ -2288,8 +2282,8 @@ wl_iw_get_retry(struct net_device *dev, if (error) return error; - lrl = dtoh32(lrl); - srl = dtoh32(srl); + lrl = le32_to_cpu(lrl); + srl = le32_to_cpu(srl); if (vwrq->flags & IW_RETRY_MAX) { vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; @@ -2320,12 +2314,12 @@ wl_iw_set_encode(struct net_device *dev, if ((dwrq->flags & IW_ENCODE_INDEX) == 0) { for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) { - val = htod32(key.index); + val = cpu_to_le32(key.index); error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val)); if (error) return error; - val = dtoh32(val); + val = le32_to_cpu(val); if (val) break; } @@ -2338,7 +2332,7 @@ wl_iw_set_encode(struct net_device *dev, } if (!extra || !dwrq->length || (dwrq->flags & IW_ENCODE_NOKEY)) { - val = htod32(key.index); + val = cpu_to_le32(key.index); error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &val, sizeof(val)); if (error) @@ -2353,16 +2347,16 @@ wl_iw_set_encode(struct net_device *dev, key.flags = WL_PRIMARY_KEY; switch (key.len) { - case WEP1_KEY_SIZE: + case WLAN_KEY_LEN_WEP40: key.algo = CRYPTO_ALGO_WEP1; break; - case WEP128_KEY_SIZE: + case WLAN_KEY_LEN_WEP104: key.algo = CRYPTO_ALGO_WEP128; break; - case TKIP_KEY_SIZE: + case WLAN_KEY_LEN_TKIP: key.algo = CRYPTO_ALGO_TKIP; break; - case AES_KEY_SIZE: + case WLAN_KEY_LEN_AES_CMAC: key.algo = CRYPTO_ALGO_AES_CCM; break; default: @@ -2389,7 +2383,7 @@ wl_iw_set_encode(struct net_device *dev, return error; val = (dwrq->flags & IW_ENCODE_RESTRICTED) ? 1 : 0; - val = htod32(val); + val = cpu_to_le32(val); error = dev_wlc_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val)); if (error) return error; @@ -2417,7 +2411,7 @@ wl_iw_get_encode(struct net_device *dev, sizeof(val)); if (error) return error; - val = dtoh32(val); + val = le32_to_cpu(val); if (val) break; } @@ -2437,9 +2431,9 @@ wl_iw_get_encode(struct net_device *dev, swap_key_to_BE(&key); - wsec = dtoh32(wsec); - auth = dtoh32(auth); - dwrq->length = min_t(u16, DOT11_MAX_KEY_SIZE, key.len); + wsec = le32_to_cpu(wsec); + auth = le32_to_cpu(auth); + dwrq->length = min_t(u16, WLAN_MAX_KEY_LEN, key.len); dwrq->flags = key.index + 1; if (!(wsec & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))) @@ -2465,7 +2459,7 @@ wl_iw_set_power(struct net_device *dev, pm = vwrq->disabled ? PM_OFF : PM_MAX; - pm = htod32(pm); + pm = cpu_to_le32(pm); error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm)); if (error) return error; @@ -2486,7 +2480,7 @@ wl_iw_get_power(struct net_device *dev, if (error) return error; - pm = dtoh32(pm); + pm = le32_to_cpu(pm); vwrq->disabled = pm ? 0 : 1; vwrq->flags = IW_POWER_ALL_R; @@ -2545,14 +2539,13 @@ wl_iw_set_encodeext(struct net_device *dev, key.len = iwe->key_len; if (!is_multicast_ether_addr(iwe->addr.sa_data)) - bcopy((void *)&iwe->addr.sa_data, (char *)&key.ea, - ETH_ALEN); + memcpy(&key.ea, &iwe->addr.sa_data, ETH_ALEN); 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); + key.index = cpu_to_le32(key.index); error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &key.index, sizeof(key.index)); if (error) @@ -2571,13 +2564,13 @@ wl_iw_set_encodeext(struct net_device *dev, key.flags = WL_PRIMARY_KEY; } - bcopy((void *)iwe->key, key.data, iwe->key_len); + memcpy(key.data, iwe->key, iwe->key_len); if (iwe->alg == IW_ENCODE_ALG_TKIP) { u8 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)); + memcpy(keybuf, &key.data[24], sizeof(keybuf)); + memcpy(&key.data[24], &key.data[16], sizeof(keybuf)); + memcpy(&key.data[16], keybuf, sizeof(keybuf)); } if (iwe->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { @@ -2594,7 +2587,7 @@ wl_iw_set_encodeext(struct net_device *dev, key.algo = CRYPTO_ALGO_OFF; break; case IW_ENCODE_ALG_WEP: - if (iwe->key_len == WEP1_KEY_SIZE) + if (iwe->key_len == WLAN_KEY_LEN_WEP40) key.algo = CRYPTO_ALGO_WEP1; else key.algo = CRYPTO_ALGO_WEP128; @@ -2651,14 +2644,16 @@ wl_iw_set_pmksa(struct net_device *dev, uint j; pmkidptr = &pmkid; - bcopy(&iwpmksa->bssid.sa_data[0], - &pmkidptr->pmkid[0].BSSID, ETH_ALEN); - bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID, - WPA2_PMKID_LEN); + memcpy(&pmkidptr->pmkid[0].BSSID, + &iwpmksa->bssid.sa_data[0], + ETH_ALEN); + memcpy(&pmkidptr->pmkid[0].PMKID, + &iwpmksa->pmkid[0], + WLAN_PMKID_LEN); - WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: %pM = ", - &pmkidptr->pmkid[0].BSSID); - for (j = 0; j < WPA2_PMKID_LEN; j++) + WL_WSEC("wl_iw_set_pmksa:IW_PMKSA_REMOVE:PMKID: " + "%pM = ", &pmkidptr->pmkid[0].BSSID); + for (j = 0; j < WLAN_PMKID_LEN; j++) WL_WSEC("%02x ", pmkidptr->pmkid[0].PMKID[j]); WL_WSEC("\n"); } @@ -2673,12 +2668,12 @@ wl_iw_set_pmksa(struct net_device *dev, && (i < pmkid_list.pmkids.npmkid)) { memset(&pmkid_list.pmkids.pmkid[i], 0, 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, - ETH_ALEN); - bcopy(&pmkid_list.pmkids.pmkid[i + 1].PMKID, - &pmkid_list.pmkids.pmkid[i].PMKID, - WPA2_PMKID_LEN); + memcpy(&pmkid_list.pmkids.pmkid[i].BSSID, + &pmkid_list.pmkids.pmkid[i + 1].BSSID, + ETH_ALEN); + memcpy(&pmkid_list.pmkids.pmkid[i].PMKID, + &pmkid_list.pmkids.pmkid[i + 1].PMKID, + WLAN_PMKID_LEN); } pmkid_list.pmkids.npmkid--; } else @@ -2692,12 +2687,12 @@ wl_iw_set_pmksa(struct net_device *dev, &pmkid_list.pmkids.pmkid[i].BSSID, ETH_ALEN)) break; if (i < MAXPMKID) { - bcopy(&iwpmksa->bssid.sa_data[0], - &pmkid_list.pmkids.pmkid[i].BSSID, - ETH_ALEN); - bcopy(&iwpmksa->pmkid[0], - &pmkid_list.pmkids.pmkid[i].PMKID, - WPA2_PMKID_LEN); + memcpy(&pmkid_list.pmkids.pmkid[i].BSSID, + &iwpmksa->bssid.sa_data[0], + ETH_ALEN); + memcpy(&pmkid_list.pmkids.pmkid[i].PMKID, + &iwpmksa->pmkid[0], + WLAN_PMKID_LEN); if (i == pmkid_list.pmkids.npmkid) pmkid_list.pmkids.npmkid++; } else @@ -2708,7 +2703,7 @@ wl_iw_set_pmksa(struct net_device *dev, k = pmkid_list.pmkids.npmkid; WL_WSEC("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %pM = ", &pmkid_list.pmkids.pmkid[k].BSSID); - for (j = 0; j < WPA2_PMKID_LEN; j++) + for (j = 0; j < WLAN_PMKID_LEN; j++) WL_WSEC("%02x ", pmkid_list.pmkids.pmkid[k].PMKID[j]); WL_WSEC("\n"); @@ -2720,7 +2715,7 @@ wl_iw_set_pmksa(struct net_device *dev, uint j; WL_WSEC("PMKID[%d]: %pM = ", i, &pmkid_list.pmkids.pmkid[i].BSSID); - for (j = 0; j < WPA2_PMKID_LEN; j++) + for (j = 0; j < WLAN_PMKID_LEN; j++) WL_WSEC("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]); WL_WSEC("\n"); } @@ -3342,9 +3337,9 @@ wl_iw_conn_status_str(u32 event_type, u32 status, u32 reason, static bool wl_iw_check_conn_fail(wl_event_msg_t *e, char *stringBuf, uint buflen) { - u32 event = ntoh32(e->event_type); - u32 status = ntoh32(e->status); - u32 reason = ntoh32(e->reason); + u32 event = be32_to_cpu(e->event_type); + u32 status = be32_to_cpu(e->status); + u32 reason = be32_to_cpu(e->reason); if (wl_iw_conn_status_str(event, status, reason, stringBuf, buflen)) { return true; @@ -3363,10 +3358,10 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) union iwreq_data wrqu; char extra[IW_CUSTOM_MAX + 1]; int cmd = 0; - u32 event_type = ntoh32(e->event_type); - u16 flags = ntoh16(e->flags); - u32 datalen = ntoh32(e->datalen); - u32 status = ntoh32(e->status); + u32 event_type = be32_to_cpu(e->event_type); + u16 flags = be16_to_cpu(e->flags); + u32 datalen = be32_to_cpu(e->datalen); + u32 status = be32_to_cpu(e->status); wl_iw_t *iw; u32 toto; memset(&wrqu, 0, sizeof(wrqu)); @@ -3409,8 +3404,6 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) if (!(flags & WLC_EVENT_MSG_LINK)) { memset(wrqu.addr.sa_data, 0, ETH_ALEN); memset(&extra, 0, ETH_ALEN); - WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT, - 20 * HZ); } else { memcpy(wrqu.addr.sa_data, &e->addr, ETH_ALEN); WL_TRACE("Link UP\n"); @@ -3436,10 +3429,10 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) 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); + WL_TRACE("wl_iw_event status %d PacketId %d\n", status, + toto); + WL_TRACE("WLC_E_ACTION_FRAME_COMPLETE len %d\n", + wrqu.data.length); } break; #endif /* WIRELESS_EXT > 14 */ @@ -3471,9 +3464,8 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) cmd = IWEVPMKIDCAND; pmkcandlist = data; - count = - ntoh32_ua((u8 *) & - pmkcandlist->npmkid_cand); + count = get_unaligned_be32(&pmkcandlist-> + npmkid_cand); ASSERT(count >= 0); wrqu.data.length = sizeof(struct iw_pmkid_cand); pmkidcand = pmkcandlist->pmkid_cand; @@ -3483,9 +3475,9 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) if (pmkidcand->preauth) iwpmkidcand->flags |= IW_PMKID_CAND_PREAUTH; - bcopy(&pmkidcand->BSSID, - &iwpmkidcand->bssid.sa_data, - ETH_ALEN); + memcpy(&iwpmkidcand->bssid.sa_data, + &pmkidcand->BSSID, + ETH_ALEN); #ifndef SANDGATE2G wireless_send_event(dev, cmd, &wrqu, extra); @@ -3523,8 +3515,6 @@ void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void *data) WL_ERROR("%s Event WLC_E_PFN_NET_FOUND, send %s up : find %s len=%d\n", __func__, PNO_EVENT_UP, ssid->SSID, ssid->SSID_len); - WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_PNO_FIND_TMOUT, - 20 * HZ); cmd = IWEVCUSTOM; memset(&wrqu, 0, sizeof(wrqu)); strcpy(extra, PNO_EVENT_UP); @@ -3562,7 +3552,7 @@ int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats) { int res = 0; - wl_cnt_t cnt; + struct wl_cnt cnt; int phy_noise; int rssi; scb_val_t scb_val; @@ -3573,7 +3563,7 @@ wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats) if (res) goto done; - phy_noise = dtoh32(phy_noise); + phy_noise = le32_to_cpu(phy_noise); WL_TRACE("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise); memset(&scb_val, 0, sizeof(scb_val_t)); @@ -3581,7 +3571,7 @@ wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats) if (res) goto done; - rssi = dtoh32(scb_val.val); + rssi = le32_to_cpu(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; @@ -3605,47 +3595,50 @@ wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats) #endif #if WIRELESS_EXT > 11 - WL_TRACE("wl_iw_get_wireless_stats counters=%zu\n", sizeof(wl_cnt_t)); + WL_TRACE("wl_iw_get_wireless_stats counters=%zu\n", + sizeof(struct wl_cnt)); - memset(&cnt, 0, sizeof(wl_cnt_t)); + memset(&cnt, 0, sizeof(struct wl_cnt)); res = - dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, sizeof(wl_cnt_t)); + dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, + sizeof(struct wl_cnt)); if (res) { WL_ERROR("wl_iw_get_wireless_stats counters failed error=%d\n", res); goto done; } - cnt.version = dtoh16(cnt.version); + cnt.version = le16_to_cpu(cnt.version); if (cnt.version != WL_CNT_T_VERSION) { - WL_TRACE("\tIncorrect version of counters struct: expected %d; got %d\n", + WL_TRACE("\tIncorrect counter version: 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->discard.code = le32_to_cpu(cnt.rxundec); + wstats->discard.fragment = le32_to_cpu(cnt.rxfragerr); + wstats->discard.retries = le32_to_cpu(cnt.txfail); + wstats->discard.misc = le32_to_cpu(cnt.rxrunt) + + le32_to_cpu(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)); + le32_to_cpu(cnt.txframe), le32_to_cpu(cnt.txbyte)); WL_TRACE("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n", - dtoh32(cnt.rxfrmtoolong)); + le32_to_cpu(cnt.rxfrmtoolong)); WL_TRACE("wl_iw_get_wireless_stats counters rxbadplcp=%d\n", - dtoh32(cnt.rxbadplcp)); + le32_to_cpu(cnt.rxbadplcp)); WL_TRACE("wl_iw_get_wireless_stats counters rxundec=%d\n", - dtoh32(cnt.rxundec)); + le32_to_cpu(cnt.rxundec)); WL_TRACE("wl_iw_get_wireless_stats counters rxfragerr=%d\n", - dtoh32(cnt.rxfragerr)); + le32_to_cpu(cnt.rxfragerr)); WL_TRACE("wl_iw_get_wireless_stats counters txfail=%d\n", - dtoh32(cnt.txfail)); + le32_to_cpu(cnt.txfail)); WL_TRACE("wl_iw_get_wireless_stats counters rxrunt=%d\n", - dtoh32(cnt.rxrunt)); + le32_to_cpu(cnt.rxrunt)); WL_TRACE("wl_iw_get_wireless_stats counters rxgiant=%d\n", - dtoh32(cnt.rxgiant)); + le32_to_cpu(cnt.rxgiant)); #endif /* WIRELESS_EXT > 11 */ done: @@ -3673,11 +3666,10 @@ int wl_iw_attach(struct net_device *dev, void *dhdp) params_size = (WL_SCAN_PARAMS_FIXED_SIZE + offsetof(wl_iscan_params_t, params)); #endif - iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL); + iscan = kzalloc(sizeof(iscan_info_t), GFP_KERNEL); if (!iscan) return -ENOMEM; - memset(iscan, 0, sizeof(iscan_info_t)); iscan->iscan_ex_params_p = kmalloc(params_size, GFP_KERNEL); if (!iscan->iscan_ex_params_p) @@ -3711,11 +3703,10 @@ int wl_iw_attach(struct net_device *dev, void *dhdp) priv_dev = dev; MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub); #endif - g_scan = kmalloc(G_SCAN_RESULTS, GFP_KERNEL); + g_scan = kzalloc(G_SCAN_RESULTS, GFP_KERNEL); if (!g_scan) return -ENOMEM; - memset(g_scan, 0, G_SCAN_RESULTS); g_scan_specified_ssid = 0; return 0; diff --git a/drivers/staging/brcm80211/brcmfmac/wl_iw.h b/drivers/staging/brcm80211/brcmfmac/wl_iw.h index c8637c50dc17..fe06174cee7d 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_iw.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_iw.h @@ -19,7 +19,6 @@ #include <linux/wireless.h> -#include <proto/ethernet.h> #include <wlioctl.h> #define WL_SCAN_PARAMS_SSID_MAX 10 @@ -92,7 +91,7 @@ typedef struct wl_iw { u32 gwsec; bool privacy_invoked; - struct ether_addr spy_addr[IW_MAX_SPY]; + u8 spy_addr[IW_MAX_SPY][ETH_ALEN]; struct iw_quality spy_qual[IW_MAX_SPY]; void *wlinfo; dhd_pub_t *pub; @@ -140,10 +139,4 @@ extern int dhd_dev_get_pno_status(struct net_device *dev); #define PNO_TLV_TYPE_TIME 'T' #define PNO_EVENT_UP "PNO_EVENT" -typedef struct cmd_tlv { - char prefix; - char version; - char subver; - char reserved; -} cmd_tlv_t; #endif /* _wl_iw_h_ */ diff --git a/drivers/staging/brcm80211/brcmsmac/Makefile b/drivers/staging/brcm80211/brcmsmac/Makefile new file mode 100644 index 000000000000..c4aafe5cf7f5 --- /dev/null +++ b/drivers/staging/brcm80211/brcmsmac/Makefile @@ -0,0 +1,63 @@ +# +# Makefile fragment for Broadcom 802.11n Networking Device Driver +# +# Copyright (c) 2010 Broadcom Corporation +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +ccflags-y := \ + -DWLC_HIGH \ + -DWLC_LOW \ + -DSTA \ + -DWME \ + -DWL11N \ + -DDBAND \ + -DBCMNVRAMR \ + -Idrivers/staging/brcm80211/brcmsmac \ + -Idrivers/staging/brcm80211/brcmsmac/phy \ + -Idrivers/staging/brcm80211/util \ + -Idrivers/staging/brcm80211/include + +BRCMSMAC_OFILES := \ + wl_mac80211.o \ + wl_ucode_loader.o \ + wlc_alloc.o \ + wlc_ampdu.o \ + wlc_antsel.o \ + wlc_bmac.o \ + wlc_channel.o \ + wlc_main.o \ + wlc_phy_shim.o \ + wlc_rate.o \ + wlc_stf.o \ + phy/wlc_phy_cmn.o \ + phy/wlc_phy_lcn.o \ + phy/wlc_phy_n.o \ + phy/wlc_phytbl_lcn.o \ + phy/wlc_phytbl_n.o \ + ../util/aiutils.o \ + ../util/siutils.o \ + ../util/bcmutils.o \ + ../util/bcmwifi.o \ + ../util/bcmotp.o \ + ../util/bcmsrom.o \ + ../util/hnddma.o \ + ../util/hndpmu.o \ + ../util/nicpci.o \ + ../util/qmath.o \ + ../util/nvram/nvram_ro.o + +MODULEPFX := brcmsmac + +obj-m += $(MODULEPFX).o +$(MODULEPFX)-objs = $(BRCMSMAC_OFILES) diff --git a/drivers/staging/brcm80211/include/d11.h b/drivers/staging/brcm80211/brcmsmac/d11.h index be2d4970407c..a9d182f49023 100644 --- a/drivers/staging/brcm80211/include/d11.h +++ b/drivers/staging/brcm80211/brcmsmac/d11.h @@ -17,9 +17,6 @@ #ifndef _D11_H #define _D11_H -/* This marks the start of a packed structure section. */ -#include <packed_section_start.h> - #ifndef WL_RSSI_ANT_MAX #define WL_RSSI_ANT_MAX 4 /* max possible rx antennas */ #elif WL_RSSI_ANT_MAX != 4 @@ -62,6 +59,37 @@ typedef volatile struct { u32 intmask; } intctrlregs_t; +/* PIO structure, + * support two PIO format: 2 bytes access and 4 bytes access + * basic FIFO register set is per channel(transmit or receive) + * a pair of channels is defined for convenience + */ +/* 2byte-wide pio register set per channel(xmt or rcv) */ +typedef volatile struct { + u16 fifocontrol; + u16 fifodata; + u16 fifofree; /* only valid in xmt channel, not in rcv channel */ + u16 PAD; +} pio2regs_t; + +/* a pair of pio channels(tx and rx) */ +typedef volatile struct { + pio2regs_t tx; + pio2regs_t rx; +} pio2regp_t; + +/* 4byte-wide pio register set per channel(xmt or rcv) */ +typedef volatile struct { + u32 fifocontrol; + u32 fifodata; +} pio4regs_t; + +/* a pair of pio channels(tx and rx) */ +typedef volatile struct { + pio4regs_t tx; + pio4regs_t rx; +} pio4regp_t; + /* read: 32-bit register that can be read as 32-bit or as 2 16-bit * write: only low 16b-it half can be written */ @@ -73,19 +101,6 @@ typedef volatile union { } w; } pmqreg_t; -/* pio register set 2/4 bytes union for d11 fifo */ -typedef volatile union { - pio2regp_t b2; /* < corerev 8 */ - pio4regp_t b4; /* >= corerev 8 */ -} u_pioreg_t; - -/* dma/pio corerev < 11 */ -typedef volatile struct { - dma32regp_t dmaregs[8]; /* 0x200 - 0x2fc */ - u_pioreg_t pioregs[8]; /* 0x300 */ -} fifo32_t; - -/* dma/pio corerev >= 11 */ typedef volatile struct { dma64regs_t dmaxmt; /* dma tx */ pio4regs_t piotx; /* pio tx */ @@ -104,7 +119,7 @@ typedef volatile struct _d11regs { u32 biststatus; /* 0xC */ u32 biststatus2; /* 0x10 */ u32 PAD; /* 0x14 */ - u32 gptimer; /* 0x18 *//* for corerev >= 3 */ + u32 gptimer; /* 0x18 */ u32 usectimer; /* 0x1c *//* for corerev >= 26 */ /* Interrupt Control *//* 0x20 */ @@ -112,7 +127,6 @@ typedef volatile struct _d11regs { u32 PAD[40]; /* 0x60 - 0xFC */ - /* tx fifos 6-7 and rx fifos 1-3 removed in corerev 5 */ u32 intrcvlazy[4]; /* 0x100 - 0x10C */ u32 PAD[4]; /* 0x110 - 0x11c */ @@ -134,22 +148,20 @@ typedef volatile struct _d11regs { u32 PAD; /* 0x14C */ u32 chnstatus; /* 0x150 */ - u32 psmdebug; /* 0x154 *//* for corerev >= 3 */ - u32 phydebug; /* 0x158 *//* for corerev >= 3 */ - u32 machwcap; /* 0x15C *//* Corerev >= 13 */ + u32 psmdebug; /* 0x154 */ + u32 phydebug; /* 0x158 */ + u32 machwcap; /* 0x15C */ /* Extended Internal Objects */ u32 objaddr; /* 0x160 */ u32 objdata; /* 0x164 */ u32 PAD[2]; /* 0x168 - 0x16c */ - /* New txstatus registers on corerev >= 5 */ u32 frmtxstatus; /* 0x170 */ u32 frmtxstatus2; /* 0x174 */ u32 PAD[2]; /* 0x178 - 0x17c */ - /* New TSF host access on corerev >= 3 */ - + /* TSF host access */ u32 tsf_timerlow; /* 0x180 */ u32 tsf_timerhigh; /* 0x184 */ u32 tsf_cfprep; /* 0x188 */ @@ -161,19 +173,16 @@ typedef volatile struct _d11regs { u32 machwcap1; /* 0x1a4 */ u32 PAD[14]; /* 0x1a8 - 0x1dc */ - /* Clock control and hardware workarounds (corerev >= 13) */ + /* Clock control and hardware workarounds*/ u32 clk_ctl_st; /* 0x1e0 */ u32 hw_war; - u32 d11_phypllctl; /* 0x1e8 (corerev == 16), the phypll request/avail bits are - * moved to clk_ctl_st for corerev >= 17 + u32 d11_phypllctl; /* the phypll request/avail bits are + * moved to clk_ctl_st */ u32 PAD[5]; /* 0x1ec - 0x1fc */ /* 0x200-0x37F dma/pio registers */ - volatile union { - fifo32_t f32regs; /* tx fifos 6-7 and rx fifos 1-3 (corerev < 5) */ - fifo64_t f64regs[6]; /* on corerev >= 11 */ - } fifo; + fifo64_t fifo64regs[6]; /* FIFO diagnostic port access */ dma32diag_t dmafifo; /* 0x380 - 0x38C */ @@ -184,7 +193,10 @@ typedef volatile struct _d11regs { u16 radioregaddr; /* 0x3d8 */ u16 radioregdata; /* 0x3da */ - /* time delay between the change on rf disable input and radio shutdown corerev 10 */ + /* + * time delay between the change on rf disable input and + * radio shutdown + */ u32 rfdisabledly; /* 0x3DC */ /* PHY register access */ @@ -351,7 +363,7 @@ typedef volatile struct _d11regs { u16 PAD[0X14]; /* 0x632 - 0x658 */ u16 tsf_random; /* 0x65A */ u16 PAD[0x05]; /* 0x65C - 0x664 */ - /* GPTimer 2 registers are corerev >= 3 */ + /* GPTimer 2 registers */ u16 tsf_gpt2_stat; /* 0x666 */ u16 tsf_gpt2_ctr_l; /* 0x668 */ u16 tsf_gpt2_ctr_h; /* 0x66A */ @@ -371,11 +383,11 @@ typedef volatile struct _d11regs { u16 ifsmedbusyctl; /* 0x692 */ u16 iftxdur; /* 0x694 */ u16 PAD[0x3]; /* 0x696 - 0x69b */ - /* EDCF support in dot11macs with corerevs >= 16 */ + /* EDCF support in dot11macs */ u16 ifs_aifsn; /* 0x69c */ u16 ifs_ctl1; /* 0x69e */ - /* New slow clock registers on corerev >= 5 */ + /* slow clock registers */ u16 scc_ctl; /* 0x6a0 */ u16 scc_timer_l; /* 0x6a2 */ u16 scc_timer_h; /* 0x6a4 */ @@ -510,12 +522,11 @@ typedef volatile struct _d11regs { #define MI_RESERVED3 (1 << 22) #define MI_RESERVED2 (1 << 23) #define MI_RESERVED1 (1 << 25) -#define MI_RFDISABLE (1 << 28) /* MAC detected a change on RF Disable input - * (corerev >= 10) - */ -#define MI_TFS (1 << 29) /* MAC has completed a TX (corerev >= 5) */ +/* MAC detected change on RF Disable input*/ +#define MI_RFDISABLE (1 << 28) +#define MI_TFS (1 << 29) /* MAC has completed a TX */ #define MI_PHYCHANGED (1 << 30) /* A phy status change wrt G mode */ -#define MI_TO (1U << 31) /* general purpose timeout (corerev >= 3) */ +#define MI_TO (1U << 31) /* general purpose timeout */ /* Mac capabilities registers */ /* machwcap */ @@ -533,7 +544,7 @@ typedef volatile struct _d11regs { #define PMQH_OFLO 0x00000004 /* pmq overflow indication */ #define PMQH_NOT_EMPTY 0x00000008 /* entries are present in pmq */ -/* phydebug (corerev >= 3) */ +/* phydebug */ #define PDBG_CRS (1 << 0) /* phy is asserting carrier sense */ #define PDBG_TXA (1 << 1) /* phy is taking xmit byte from mac this cycle */ #define PDBG_TXF (1 << 2) /* mac is instructing the phy to transmit a frame */ @@ -562,9 +573,6 @@ typedef volatile struct _d11regs { /* frmtxstatus */ #define TXS_V (1 << 0) /* valid bit */ #define TXS_STATUS_MASK 0xffff -/* sw mask to map txstatus for corerevs <= 4 to be the same as for corerev > 4 */ -#define TXS_COMPAT_MASK 0x3 -#define TXS_COMPAT_SHIFT 1 #define TXS_FID_MASK 0xffff0000 #define TXS_FID_SHIFT 16 @@ -575,7 +583,7 @@ typedef volatile struct _d11regs { #define TXS_MU_MASK 0x01000000 #define TXS_MU_SHIFT 24 -/* clk_ctl_st, corerev >= 17 */ +/* clk_ctl_st */ #define CCS_ERSRC_REQ_D11PLL 0x00000100 /* d11 core pll request */ #define CCS_ERSRC_REQ_PHYPLL 0x00000200 /* PHY pll request */ #define CCS_ERSRC_AVAIL_D11PLL 0x01000000 /* d11 core pll available */ @@ -585,16 +593,11 @@ typedef volatile struct _d11regs { #define CCS_ERSRC_REQ_HT 0x00000010 /* HT avail request */ #define CCS_ERSRC_AVAIL_HT 0x00020000 /* HT clock available */ -/* d11_pwrctl, corerev16 only */ -#define D11_PHYPLL_AVAIL_REQ 0x000010000 /* request PHY PLL resource */ -#define D11_PHYPLL_AVAIL_STS 0x001000000 /* PHY PLL is available */ - /* tsf_cfprep register */ #define CFPREP_CBI_MASK 0xffffffc0 #define CFPREP_CBI_SHIFT 6 #define CFPREP_CFPP 0x00000001 -/* tx fifo sizes for corerev >= 9 */ /* tx fifo sizes values are in terms of 256 byte blocks */ #define TXFIFOCMD_RESET_MASK (1 << 15) /* reset */ #define TXFIFOCMD_FIFOSEL_SHIFT 8 /* fifo */ @@ -625,11 +628,11 @@ typedef volatile struct _d11regs { /* 802.11a PLCP header def */ typedef struct ofdm_phy_hdr ofdm_phy_hdr_t; -BWL_PRE_PACKED_STRUCT struct ofdm_phy_hdr { +struct ofdm_phy_hdr { u8 rlpt[3]; /* rate, length, parity, tail */ u16 service; u8 pad; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define D11A_PHY_HDR_GRATE(phdr) ((phdr)->rlpt[0] & 0x0f) #define D11A_PHY_HDR_GRES(phdr) (((phdr)->rlpt[0] >> 4) & 0x01) @@ -660,12 +663,12 @@ BWL_PRE_PACKED_STRUCT struct ofdm_phy_hdr { /* 802.11b PLCP header def */ typedef struct cck_phy_hdr cck_phy_hdr_t; -BWL_PRE_PACKED_STRUCT struct cck_phy_hdr { +struct cck_phy_hdr { u8 signal; u8 service; u16 length; u16 crc; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define D11B_PHY_HDR_LEN 6 @@ -706,7 +709,7 @@ BWL_PRE_PACKED_STRUCT struct cck_phy_hdr { /* TX DMA buffer header */ typedef struct d11txh d11txh_t; -BWL_PRE_PACKED_STRUCT struct d11txh { +struct d11txh { u16 MacTxControlLow; /* 0x0 */ u16 MacTxControlHigh; /* 0x1 */ u16 MacFrameControl; /* 0x2 */ @@ -734,14 +737,14 @@ BWL_PRE_PACKED_STRUCT struct d11txh { u16 AmpduSeqCtl; /* 0x25 */ u16 TxFrameID; /* 0x26 */ u16 TxStatus; /* 0x27 */ - u16 MaxNMpdus; /* 0x28 corerev >=16 */ - u16 MaxABytes_MRT; /* 0x29 corerev >=16 */ - u16 MaxABytes_FBR; /* 0x2a corerev >=16 */ - u16 MinMBytes; /* 0x2b corerev >=16 */ + u16 MaxNMpdus; /* 0x28 */ + u16 MaxABytes_MRT; /* 0x29 */ + u16 MaxABytes_FBR; /* 0x2a */ + u16 MinMBytes; /* 0x2b */ u8 RTSPhyHeader[D11_PHY_HDR_LEN]; /* 0x2c - 0x2e */ - struct dot11_rts_frame rts_frame; /* 0x2f - 0x36 */ + struct ieee80211_rts rts_frame; /* 0x2f - 0x36 */ u16 PAD; /* 0x37 */ -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define D11_TXH_LEN 112 /* bytes */ @@ -850,7 +853,7 @@ BWL_PRE_PACKED_STRUCT struct d11txh { /* tx status packet */ typedef struct tx_status tx_status_t; -BWL_PRE_PACKED_STRUCT struct tx_status { +struct tx_status { u16 framelen; u16 PAD; u16 frameid; @@ -859,7 +862,7 @@ BWL_PRE_PACKED_STRUCT struct tx_status { u16 sequence; u16 phyerr; u16 ackphyrxsh; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define TXSTATUS_LEN 16 @@ -875,7 +878,7 @@ BWL_PRE_PACKED_STRUCT struct tx_status { #define TX_STATUS_SUPR_MASK 0x1C /* suppress status bits (4:2) */ #define TX_STATUS_SUPR_SHIFT 2 #define TX_STATUS_ACK_RCV (1 << 1) /* ACK received */ -#define TX_STATUS_VALID (1 << 0) /* Tx status valid (corerev >= 5) */ +#define TX_STATUS_VALID (1 << 0) /* Tx status valid */ #define TX_STATUS_NO_ACK 0 /* suppress status reason codes */ @@ -1243,7 +1246,7 @@ BWL_PRE_PACKED_STRUCT struct tx_status { #define MIMO_ANTSEL_OVERRIDE 0x8000 /* flag */ typedef struct shm_acparams shm_acparams_t; -BWL_PRE_PACKED_STRUCT struct shm_acparams { +struct shm_acparams { u16 txop; u16 cwmin; u16 cwmax; @@ -1253,7 +1256,7 @@ BWL_PRE_PACKED_STRUCT struct shm_acparams { u16 reggap; u16 status; u16 rsvd[8]; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define M_EDCF_QLEN (16 * 2) #define WME_STATUS_NEWAC (1 << 8) @@ -1302,7 +1305,7 @@ BWL_PRE_PACKED_STRUCT struct shm_acparams { /* Receive Frame Data Header for 802.11b DCF-only frames */ typedef struct d11rxhdr d11rxhdr_t; -BWL_PRE_PACKED_STRUCT struct d11rxhdr { +struct d11rxhdr { u16 RxFrameSize; /* Actual byte length of the frame data received */ u16 PAD; u16 PhyRxStatus_0; /* PhyRxStatus 15:0 */ @@ -1315,13 +1318,13 @@ BWL_PRE_PACKED_STRUCT struct d11rxhdr { u16 RxStatus2; /* extended MAC Rx status */ u16 RxTSFTime; /* RxTSFTime time of first MAC symbol + M_PHY_PLCPRX_DLY */ u16 RxChan; /* gain code, channel radio code, and phy type */ -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); #define RXHDR_LEN 24 /* sizeof d11rxhdr_t */ #define FRAMELEN(h) ((h)->RxFrameSize) typedef struct wlc_d11rxhdr wlc_d11rxhdr_t; -BWL_PRE_PACKED_STRUCT struct wlc_d11rxhdr { +struct wlc_d11rxhdr { d11rxhdr_t rxhdr; u32 tsf_l; /* TSF_L reading */ s8 rssi; /* computed instanteneous rssi in BMAC */ @@ -1329,7 +1332,7 @@ BWL_PRE_PACKED_STRUCT struct wlc_d11rxhdr { s8 rxpwr1; /* obsoleted, place holder for legacy ROM code. use rxpwr[] */ s8 do_rssi_ma; /* do per-pkt sampling for per-antenna ma in HIGH */ s8 rxpwr[WL_RSSI_ANT_MAX]; /* rssi for supported antennas */ -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); /* PhyRxStatus_0: */ #define PRXS0_FT_MASK 0x0003 /* NPHY only: CCK, OFDM, preN, N */ @@ -1622,9 +1625,9 @@ typedef struct macstat { #define SICF_PCLKE 0x0004 /* PHY clock enable */ #define SICF_PRST 0x0008 /* PHY reset */ #define SICF_MPCLKE 0x0010 /* MAC PHY clockcontrol enable */ -#define SICF_FREF 0x0020 /* PLL FreqRefSelect (corerev >= 5) */ +#define SICF_FREF 0x0020 /* PLL FreqRefSelect */ /* NOTE: the following bw bits only apply when the core is attached - * to a NPHY (and corerev >= 11 which it will always be for NPHYs). + * to a NPHY */ #define SICF_BWMASK 0x00c0 /* phy clock mask (b6 & b7) */ #define SICF_BW40 0x0080 /* 40MHz BW (160MHz phyclk) */ @@ -1633,10 +1636,10 @@ typedef struct macstat { #define SICF_GMODE 0x2000 /* gmode enable */ /* dot11 core-specific status flags */ -#define SISF_2G_PHY 0x0001 /* 2.4G capable phy (corerev >= 5) */ -#define SISF_5G_PHY 0x0002 /* 5G capable phy (corerev >= 5) */ -#define SISF_FCLKA 0x0004 /* FastClkAvailable (corerev >= 5) */ -#define SISF_DB_PHY 0x0008 /* Dualband phy (corerev >= 11) */ +#define SISF_2G_PHY 0x0001 /* 2.4G capable phy */ +#define SISF_5G_PHY 0x0002 /* 5G capable phy */ +#define SISF_FCLKA 0x0004 /* FastClkAvailable */ +#define SISF_DB_PHY 0x0008 /* Dualband phy */ /* === End of MAC reg, Beginning of PHY(b/a/g/n) reg, radio and LPPHY regs are separated === */ @@ -1762,9 +1765,6 @@ typedef struct macstat { #define TST_TXTEST_RATE_11MBPS 3 #define TST_TXTEST_RATE_SHIFT 3 -/* This marks the end of a packed structure section. */ -#include <packed_section_end.h> - #define SHM_BYT_CNT 0x2 /* IHR location */ #define MAX_BYT_CNT 0x600 /* Maximum frame len */ diff --git a/drivers/staging/brcm80211/phy/phy_version.h b/drivers/staging/brcm80211/brcmsmac/phy/phy_version.h index 51a223880bcf..51a223880bcf 100644 --- a/drivers/staging/brcm80211/phy/phy_version.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/phy_version.h diff --git a/drivers/staging/brcm80211/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c index 3bed37cb59b8..8f75af2ffc58 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c @@ -19,15 +19,12 @@ #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> -#include <osl.h> #include <linux/delay.h> #include <linux/module.h> #include <linux/pci.h> -#include <bcmendian.h> #include <bcmnvram.h> #include <sbchipc.h> #include <bcmdevs.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <wlc_phy_int.h> @@ -214,7 +211,7 @@ void wlc_radioreg_exit(wlc_phy_t *pih) phy_info_t *pi = (phy_info_t *) pih; volatile u16 dummy; - dummy = R_REG(pi->sh->osh, &pi->regs->phyversion); + dummy = R_REG(&pi->regs->phyversion); pi->phy_wreg = 0; wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, 0); } @@ -250,23 +247,23 @@ u16 read_radio_reg(phy_info_t *pi, u16 addr) if ((D11REV_GE(pi->sh->corerev, 24)) || (D11REV_IS(pi->sh->corerev, 22) && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - W_REG(pi->sh->osh, &pi->regs->radioregaddr, addr); + W_REG(&pi->regs->radioregaddr, addr); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->radioregaddr); + (void)R_REG(&pi->regs->radioregaddr); #endif - data = R_REG(pi->sh->osh, &pi->regs->radioregdata); + data = R_REG(&pi->regs->radioregdata); } else { - W_REG(pi->sh->osh, &pi->regs->phy4waddr, addr); + W_REG(&pi->regs->phy4waddr, addr); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->phy4waddr); + (void)R_REG(&pi->regs->phy4waddr); #endif #ifdef __ARM_ARCH_4T__ __asm__(" .align 4 "); __asm__(" nop "); - data = R_REG(pi->sh->osh, &pi->regs->phy4wdatalo); + data = R_REG(&pi->regs->phy4wdatalo); #else - data = R_REG(pi->sh->osh, &pi->regs->phy4wdatalo); + data = R_REG(&pi->regs->phy4wdatalo); #endif } @@ -277,33 +274,29 @@ u16 read_radio_reg(phy_info_t *pi, u16 addr) void write_radio_reg(phy_info_t *pi, u16 addr, u16 val) { - struct osl_info *osh; - if (NORADIO_ENAB(pi->pubpi)) return; - osh = pi->sh->osh; - if ((D11REV_GE(pi->sh->corerev, 24)) || (D11REV_IS(pi->sh->corerev, 22) && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - W_REG(osh, &pi->regs->radioregaddr, addr); + W_REG(&pi->regs->radioregaddr, addr); #ifdef __mips__ - (void)R_REG(osh, &pi->regs->radioregaddr); + (void)R_REG(&pi->regs->radioregaddr); #endif - W_REG(osh, &pi->regs->radioregdata, val); + W_REG(&pi->regs->radioregdata, val); } else { - W_REG(osh, &pi->regs->phy4waddr, addr); + W_REG(&pi->regs->phy4waddr, addr); #ifdef __mips__ - (void)R_REG(osh, &pi->regs->phy4waddr); + (void)R_REG(&pi->regs->phy4waddr); #endif - W_REG(osh, &pi->regs->phy4wdatalo, val); + W_REG(&pi->regs->phy4wdatalo, val); } if (pi->sh->bustype == PCI_BUS) { if (++pi->phy_wreg >= pi->phy_wreg_limit) { - (void)R_REG(osh, &pi->regs->maccontrol); + (void)R_REG(&pi->regs->maccontrol); pi->phy_wreg = 0; } } @@ -319,31 +312,31 @@ static u32 read_radio_id(phy_info_t *pi) if (D11REV_GE(pi->sh->corerev, 24)) { u32 b0, b1, b2; - W_REG(pi->sh->osh, &pi->regs->radioregaddr, 0); + W_REG(&pi->regs->radioregaddr, 0); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->radioregaddr); + (void)R_REG(&pi->regs->radioregaddr); #endif - b0 = (u32) R_REG(pi->sh->osh, &pi->regs->radioregdata); - W_REG(pi->sh->osh, &pi->regs->radioregaddr, 1); + b0 = (u32) R_REG(&pi->regs->radioregdata); + W_REG(&pi->regs->radioregaddr, 1); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->radioregaddr); + (void)R_REG(&pi->regs->radioregaddr); #endif - b1 = (u32) R_REG(pi->sh->osh, &pi->regs->radioregdata); - W_REG(pi->sh->osh, &pi->regs->radioregaddr, 2); + b1 = (u32) R_REG(&pi->regs->radioregdata); + W_REG(&pi->regs->radioregaddr, 2); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->radioregaddr); + (void)R_REG(&pi->regs->radioregaddr); #endif - b2 = (u32) R_REG(pi->sh->osh, &pi->regs->radioregdata); + b2 = (u32) R_REG(&pi->regs->radioregdata); id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4) & 0xf); } else { - W_REG(pi->sh->osh, &pi->regs->phy4waddr, RADIO_IDCODE); + W_REG(&pi->regs->phy4waddr, RADIO_IDCODE); #ifdef __mips__ - (void)R_REG(pi->sh->osh, &pi->regs->phy4waddr); + (void)R_REG(&pi->regs->phy4waddr); #endif - id = (u32) R_REG(pi->sh->osh, &pi->regs->phy4wdatalo); - id |= (u32) R_REG(pi->sh->osh, &pi->regs->phy4wdatahi) << 16; + id = (u32) R_REG(&pi->regs->phy4wdatalo); + id |= (u32) R_REG(&pi->regs->phy4wdatahi) << 16; } pi->phy_wreg = 0; return id; @@ -395,13 +388,13 @@ void mod_radio_reg(phy_info_t *pi, u16 addr, u16 mask, u16 val) void write_phy_channel_reg(phy_info_t *pi, uint val) { - W_REG(pi->sh->osh, &pi->regs->phychannel, val); + W_REG(&pi->regs->phychannel, val); } #if defined(BCMDBG) static bool wlc_phy_war41476(phy_info_t *pi) { - u32 mc = R_REG(pi->sh->osh, &pi->regs->maccontrol); + u32 mc = R_REG(&pi->regs->maccontrol); return ((mc & MCTL_EN_MAC) == 0) || ((mc & MCTL_PHYLOCK) == MCTL_PHYLOCK); @@ -410,15 +403,13 @@ static bool wlc_phy_war41476(phy_info_t *pi) u16 read_phy_reg(phy_info_t *pi, u16 addr) { - struct osl_info *osh; d11regs_t *regs; - osh = pi->sh->osh; regs = pi->regs; - W_REG(osh, ®s->phyregaddr, addr); + W_REG(®s->phyregaddr, addr); #ifdef __mips__ - (void)R_REG(osh, ®s->phyregaddr); + (void)R_REG(®s->phyregaddr); #endif ASSERT(! @@ -426,30 +417,28 @@ u16 read_phy_reg(phy_info_t *pi, u16 addr) || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); pi->phy_wreg = 0; - return R_REG(osh, ®s->phyregdata); + return R_REG(®s->phyregdata); } void write_phy_reg(phy_info_t *pi, u16 addr, u16 val) { - struct osl_info *osh; d11regs_t *regs; - osh = pi->sh->osh; regs = pi->regs; #ifdef __mips__ - W_REG(osh, ®s->phyregaddr, addr); - (void)R_REG(osh, ®s->phyregaddr); - W_REG(osh, ®s->phyregdata, val); + W_REG(®s->phyregaddr, addr); + (void)R_REG(®s->phyregaddr); + W_REG(®s->phyregdata, val); if (addr == 0x72) - (void)R_REG(osh, ®s->phyregdata); + (void)R_REG(®s->phyregdata); #else - W_REG(osh, (volatile u32 *)(®s->phyregaddr), + W_REG((u32 *)(®s->phyregaddr), addr | (val << 16)); if (pi->sh->bustype == PCI_BUS) { if (++pi->phy_wreg >= pi->phy_wreg_limit) { pi->phy_wreg = 0; - (void)R_REG(osh, ®s->phyversion); + (void)R_REG(®s->phyversion); } } #endif @@ -457,65 +446,59 @@ void write_phy_reg(phy_info_t *pi, u16 addr, u16 val) void and_phy_reg(phy_info_t *pi, u16 addr, u16 val) { - struct osl_info *osh; d11regs_t *regs; - osh = pi->sh->osh; regs = pi->regs; - W_REG(osh, ®s->phyregaddr, addr); + W_REG(®s->phyregaddr, addr); #ifdef __mips__ - (void)R_REG(osh, ®s->phyregaddr); + (void)R_REG(®s->phyregaddr); #endif ASSERT(! (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(osh, ®s->phyregdata, (R_REG(osh, ®s->phyregdata) & val)); + W_REG(®s->phyregdata, (R_REG(®s->phyregdata) & val)); pi->phy_wreg = 0; } void or_phy_reg(phy_info_t *pi, u16 addr, u16 val) { - struct osl_info *osh; d11regs_t *regs; - osh = pi->sh->osh; regs = pi->regs; - W_REG(osh, ®s->phyregaddr, addr); + W_REG(®s->phyregaddr, addr); #ifdef __mips__ - (void)R_REG(osh, ®s->phyregaddr); + (void)R_REG(®s->phyregaddr); #endif ASSERT(! (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(osh, ®s->phyregdata, (R_REG(osh, ®s->phyregdata) | val)); + W_REG(®s->phyregdata, (R_REG(®s->phyregdata) | val)); pi->phy_wreg = 0; } void mod_phy_reg(phy_info_t *pi, u16 addr, u16 mask, u16 val) { - struct osl_info *osh; d11regs_t *regs; - osh = pi->sh->osh; regs = pi->regs; - W_REG(osh, ®s->phyregaddr, addr); + W_REG(®s->phyregaddr, addr); #ifdef __mips__ - (void)R_REG(osh, ®s->phyregaddr); + (void)R_REG(®s->phyregaddr); #endif ASSERT(! (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(osh, ®s->phyregdata, - ((R_REG(osh, ®s->phyregdata) & ~mask) | (val & mask))); + W_REG(®s->phyregdata, + ((R_REG(®s->phyregdata) & ~mask) | (val & mask))); pi->phy_wreg = 0; } @@ -565,7 +548,6 @@ shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp) return NULL; } - sh->osh = shp->osh; sh->sih = shp->sih; sh->physhim = shp->physhim; sh->unit = shp->unit; @@ -596,11 +578,7 @@ shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp) void wlc_phy_shared_detach(shared_phy_t *phy_sh) { - struct osl_info *osh; - if (phy_sh) { - osh = phy_sh->osh; - if (phy_sh->phy_head) { ASSERT(!phy_sh->phy_head); } @@ -614,9 +592,6 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars u32 sflags = 0; uint phyversion; int i; - struct osl_info *osh; - - osh = sh->osh; if (D11REV_IS(sh->corerev, 4)) sflags = SISF_2G_PHY | SISF_5G_PHY; @@ -660,7 +635,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars } wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); - phyversion = R_REG(osh, &pi->regs->phyversion); + phyversion = R_REG(&pi->regs->phyversion); pi->pubpi.phy_type = PHY_TYPE(phyversion); pi->pubpi.phy_rev = phyversion & PV_PV_MASK; @@ -779,13 +754,12 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars pi->vars = (char *)&pi->vars; - bcopy(&pi->pubpi, &pi->pubpi_ro, sizeof(wlc_phy_t)); + memcpy(&pi->pubpi_ro, &pi->pubpi, sizeof(wlc_phy_t)); return &pi->pubpi_ro; err: - if (pi) - kfree(pi); + kfree(pi); return NULL; } @@ -987,7 +961,7 @@ void WLBANDINITFN(wlc_phy_init) (wlc_phy_t *pih, chanspec_t chanspec) pi->radio_chanspec = chanspec; - mc = R_REG(pi->sh->osh, &pi->regs->maccontrol); + mc = R_REG(&pi->regs->maccontrol); if ((mc & MCTL_EN_MAC) != 0) { ASSERT((const char *) "wlc_phy_init: Called with the MAC running!" == NULL); @@ -1039,7 +1013,7 @@ void wlc_phy_cal_init(wlc_phy_t *pih) phy_info_t *pi = (phy_info_t *) pih; initfn_t cal_init = NULL; - ASSERT((R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC) == 0); + ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0); if (!pi->initialized) { cal_init = pi->pi_fptr.calinit; @@ -1269,34 +1243,34 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) }; u32 *dummypkt; - ASSERT((R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC) == 0); + ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0); dummypkt = (u32 *) (ofdm ? ofdmpkt : cckpkt); wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, dummypkt); - W_REG(pi->sh->osh, ®s->xmtsel, 0); + W_REG(®s->xmtsel, 0); if (D11REV_GE(pi->sh->corerev, 11)) - W_REG(pi->sh->osh, ®s->wepctl, 0x100); + W_REG(®s->wepctl, 0x100); else - W_REG(pi->sh->osh, ®s->wepctl, 0); + W_REG(®s->wepctl, 0); - W_REG(pi->sh->osh, ®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); + W_REG(®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); if (ISNPHY(pi) || ISLCNPHY(pi)) { ASSERT(ofdm); - W_REG(pi->sh->osh, ®s->txe_phyctl1, 0x1A02); + W_REG(®s->txe_phyctl1, 0x1A02); } - W_REG(pi->sh->osh, ®s->txe_wm_0, 0); - W_REG(pi->sh->osh, ®s->txe_wm_1, 0); + W_REG(®s->txe_wm_0, 0); + W_REG(®s->txe_wm_1, 0); - W_REG(pi->sh->osh, ®s->xmttplatetxptr, 0); - W_REG(pi->sh->osh, ®s->xmttxcnt, DUMMY_PKT_LEN); + W_REG(®s->xmttplatetxptr, 0); + W_REG(®s->xmttxcnt, DUMMY_PKT_LEN); - W_REG(pi->sh->osh, ®s->xmtsel, ((8 << 8) | (1 << 5) | (1 << 2) | 2)); + W_REG(®s->xmtsel, ((8 << 8) | (1 << 5) | (1 << 2) | 2)); - W_REG(pi->sh->osh, ®s->txe_ctl, 0); + W_REG(®s->txe_ctl, 0); if (!pa_on) { if (ISNPHY(pi)) @@ -1304,11 +1278,11 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) } if (ISNPHY(pi) || ISLCNPHY(pi)) - W_REG(pi->sh->osh, ®s->txe_aux, 0xD0); + W_REG(®s->txe_aux, 0xD0); else - W_REG(pi->sh->osh, ®s->txe_aux, ((1 << 5) | (1 << 4))); + W_REG(®s->txe_aux, ((1 << 5) | (1 << 4))); - (void)R_REG(pi->sh->osh, ®s->txe_aux); + (void)R_REG(®s->txe_aux); i = 0; count = ofdm ? 30 : 250; @@ -1318,22 +1292,22 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) } while ((i++ < count) - && (R_REG(pi->sh->osh, ®s->txe_status) & (1 << 7))) { + && (R_REG(®s->txe_status) & (1 << 7))) { udelay(10); } i = 0; while ((i++ < 10) - && ((R_REG(pi->sh->osh, ®s->txe_status) & (1 << 10)) == 0)) { + && ((R_REG(®s->txe_status) & (1 << 10)) == 0)) { udelay(10); } i = 0; - while ((i++ < 10) && ((R_REG(pi->sh->osh, ®s->ifsstat) & (1 << 8)))) { + while ((i++ < 10) && ((R_REG(®s->ifsstat) & (1 << 8)))) udelay(10); - } + if (!pa_on) { if (ISNPHY(pi)) wlc_phy_pa_override_nphy(pi, ON); @@ -1398,7 +1372,7 @@ void wlc_phy_switch_radio(wlc_phy_t *pih, bool on) { uint mc; - mc = R_REG(pi->sh->osh, &pi->regs->maccontrol); + mc = R_REG(&pi->regs->maccontrol); } if (ISNPHY(pi)) { @@ -1619,42 +1593,38 @@ void wlc_phy_txpower_target_set(wlc_phy_t *ppi, struct txpwr_limits *txpwr) bool mac_enabled = false; phy_info_t *pi = (phy_info_t *) ppi; - bcopy(&txpwr->cck[0], &pi->tx_user_target[TXP_FIRST_CCK], - WLC_NUM_RATES_CCK); - - bcopy(&txpwr->ofdm[0], &pi->tx_user_target[TXP_FIRST_OFDM], - WLC_NUM_RATES_OFDM); - bcopy(&txpwr->ofdm_cdd[0], &pi->tx_user_target[TXP_FIRST_OFDM_20_CDD], - WLC_NUM_RATES_OFDM); - - bcopy(&txpwr->ofdm_40_siso[0], - &pi->tx_user_target[TXP_FIRST_OFDM_40_SISO], WLC_NUM_RATES_OFDM); - bcopy(&txpwr->ofdm_40_cdd[0], - &pi->tx_user_target[TXP_FIRST_OFDM_40_CDD], WLC_NUM_RATES_OFDM); - - bcopy(&txpwr->mcs_20_siso[0], - &pi->tx_user_target[TXP_FIRST_MCS_20_SISO], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_20_cdd[0], &pi->tx_user_target[TXP_FIRST_MCS_20_CDD], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_20_stbc[0], - &pi->tx_user_target[TXP_FIRST_MCS_20_STBC], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_20_mimo[0], &pi->tx_user_target[TXP_FIRST_MCS_20_SDM], - WLC_NUM_RATES_MCS_2_STREAM); - - bcopy(&txpwr->mcs_40_siso[0], - &pi->tx_user_target[TXP_FIRST_MCS_40_SISO], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_40_cdd[0], &pi->tx_user_target[TXP_FIRST_MCS_40_CDD], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_40_stbc[0], - &pi->tx_user_target[TXP_FIRST_MCS_40_STBC], - WLC_NUM_RATES_MCS_1_STREAM); - bcopy(&txpwr->mcs_40_mimo[0], &pi->tx_user_target[TXP_FIRST_MCS_40_SDM], - WLC_NUM_RATES_MCS_2_STREAM); - - if (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC) + memcpy(&pi->tx_user_target[TXP_FIRST_CCK], + &txpwr->cck[0], WLC_NUM_RATES_CCK); + + memcpy(&pi->tx_user_target[TXP_FIRST_OFDM], + &txpwr->ofdm[0], WLC_NUM_RATES_OFDM); + memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_20_CDD], + &txpwr->ofdm_cdd[0], WLC_NUM_RATES_OFDM); + + memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_SISO], + &txpwr->ofdm_40_siso[0], WLC_NUM_RATES_OFDM); + memcpy(&pi->tx_user_target[TXP_FIRST_OFDM_40_CDD], + &txpwr->ofdm_40_cdd[0], WLC_NUM_RATES_OFDM); + + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SISO], + &txpwr->mcs_20_siso[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_CDD], + &txpwr->mcs_20_cdd[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_STBC], + &txpwr->mcs_20_stbc[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_20_SDM], + &txpwr->mcs_20_mimo[0], WLC_NUM_RATES_MCS_2_STREAM); + + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SISO], + &txpwr->mcs_40_siso[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_CDD], + &txpwr->mcs_40_cdd[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_STBC], + &txpwr->mcs_40_stbc[0], WLC_NUM_RATES_MCS_1_STREAM); + memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SDM], + &txpwr->mcs_40_mimo[0], WLC_NUM_RATES_MCS_2_STREAM); + + if (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) mac_enabled = true; if (mac_enabled) @@ -1686,7 +1656,7 @@ int wlc_phy_txpower_set(wlc_phy_t *ppi, uint qdbm, bool override) suspend = (0 == - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) @@ -2102,18 +2072,18 @@ void wlc_phy_runbist_config(wlc_phy_t *ppi, bool start_end) if (NREV_IS(pi->pubpi.phy_rev, 3) || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(pi->sh->osh, &pi->regs->phyregaddr, 0xa0); - (void)R_REG(pi->sh->osh, &pi->regs->phyregaddr); - rxc = R_REG(pi->sh->osh, &pi->regs->phyregdata); - W_REG(pi->sh->osh, &pi->regs->phyregdata, + W_REG(&pi->regs->phyregaddr, 0xa0); + (void)R_REG(&pi->regs->phyregaddr); + rxc = R_REG(&pi->regs->phyregdata); + W_REG(&pi->regs->phyregdata, (0x1 << 15) | rxc); } } else { if (NREV_IS(pi->pubpi.phy_rev, 3) || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(pi->sh->osh, &pi->regs->phyregaddr, 0xa0); - (void)R_REG(pi->sh->osh, &pi->regs->phyregaddr); - W_REG(pi->sh->osh, &pi->regs->phyregdata, rxc); + W_REG(&pi->regs->phyregaddr, 0xa0); + (void)R_REG(&pi->regs->phyregaddr); + W_REG(&pi->regs->phyregdata, rxc); } wlc_phy_por_inform(ppi); @@ -2240,7 +2210,7 @@ void wlc_phy_txpower_hw_ctrl_set(wlc_phy_t *ppi, bool hwpwrctrl) if (ISNPHY(pi)) { suspend = (0 == - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2482,7 +2452,7 @@ void wlc_phy_ant_rxdiv_set(wlc_phy_t *ppi, u8 val) return; suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2596,7 +2566,7 @@ wlc_phy_noise_sample_request(wlc_phy_t *pih, u8 reason, u8 ch) wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - OR_REG(pi->sh->osh, &pi->regs->maccommand, + OR_REG(&pi->regs->maccommand, MCMD_BG_NOISE); } else { wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2615,7 +2585,7 @@ wlc_phy_noise_sample_request(wlc_phy_t *pih, u8 reason, u8 ch) wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - OR_REG(pi->sh->osh, &pi->regs->maccommand, + OR_REG(&pi->regs->maccommand, MCMD_BG_NOISE); } else { phy_iq_est_t est[PHY_CORE_MAX]; @@ -2863,7 +2833,7 @@ void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx) { wlc_d11rxhdr_t *wlc_rxhdr = (wlc_d11rxhdr_t *) ctx; d11rxhdr_t *rxh = &wlc_rxhdr->rxhdr; - int rssi = ltoh16(rxh->PhyRxStatus_1) & PRXS1_JSSI_MASK; + int rssi = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_JSSI_MASK; uint radioid = pih->radioid; phy_info_t *pi = (phy_info_t *) pih; @@ -2873,13 +2843,13 @@ void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx) } if ((pi->sh->corerev >= 11) - && !(ltoh16(rxh->RxStatus2) & RXS_PHYRXST_VALID)) { + && !(le16_to_cpu(rxh->RxStatus2) & RXS_PHYRXST_VALID)) { rssi = WLC_RSSI_INVALID; goto end; } if (ISLCNPHY(pi)) { - u8 gidx = (ltoh16(rxh->PhyRxStatus_2) & 0xFC00) >> 10; + u8 gidx = (le16_to_cpu(rxh->PhyRxStatus_2) & 0xFC00) >> 10; phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy; if (rssi > 127) diff --git a/drivers/staging/brcm80211/phy/wlc_phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h index 514e15e00283..bf962d5b339a 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_hal.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h @@ -125,7 +125,6 @@ struct phy_pub; typedef struct phy_pub wlc_phy_t; typedef struct shared_phy_params { - void *osh; si_t *sih; void *physhim; uint unit; diff --git a/drivers/staging/brcm80211/phy/wlc_phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h index 72eee9120c2f..6e12a95c7360 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_int.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h @@ -527,7 +527,6 @@ typedef struct { struct shared_phy { struct phy_info *phy_head; uint unit; - struct osl_info *osh; si_t *sih; void *physhim; uint corerev; @@ -1159,7 +1158,7 @@ extern void wlc_phy_table_write_nphy(phy_info_t *pi, u32, u32, u32, #define WLC_PHY_WAR_PR51571(pi) \ if (((pi)->sh->bustype == PCI_BUS) && NREV_LT((pi)->pubpi.phy_rev, 3)) \ - (void)R_REG((pi)->sh->osh, &(pi)->regs->maccontrol) + (void)R_REG(&(pi)->regs->maccontrol) extern void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype); extern void wlc_phy_aci_reset_nphy(phy_info_t *pi); diff --git a/drivers/staging/brcm80211/phy/wlc_phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c index 3ac2b49d9a9d..a5a7bb82ab42 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c @@ -20,13 +20,11 @@ #include <linux/delay.h> #include <wlc_cfg.h> #include <qmath.h> -#include <osl.h> #include <linux/pci.h> #include <siutils.h> #include <hndpmu.h> #include <bcmdevs.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <wlc_phy_radio.h> @@ -1965,8 +1963,9 @@ wlc_lcnphy_tx_iqlo_cal(phy_info_t *pi, tbl_iqcal_gainparams_lcnphy[band_idx][j][2]; cal_gains.pad_gain = tbl_iqcal_gainparams_lcnphy[band_idx][j][3]; - bcopy(&tbl_iqcal_gainparams_lcnphy[band_idx][j][3], - ncorr_override, sizeof(ncorr_override)); + memcpy(ncorr_override, + &tbl_iqcal_gainparams_lcnphy[band_idx][j][3], + sizeof(ncorr_override)); break; } } @@ -2100,7 +2099,7 @@ static void wlc_lcnphy_idle_tssi_est(wlc_phy_t *ppi) idleTssi = read_phy_reg(pi, 0x4ab); suspend = (0 == - (R_REG(pi->sh->osh, &((phy_info_t *) pi)->regs->maccontrol) & + (R_REG(&((phy_info_t *) pi)->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2176,7 +2175,7 @@ static void wlc_lcnphy_vbat_temp_sense_setup(phy_info_t *pi, u8 mode) for (i = 0; i < 14; i++) values_to_save[i] = read_phy_reg(pi, tempsense_phy_regs[i]); suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); save_txpwrCtrlEn = read_radio_reg(pi, 0x4a4); @@ -2303,7 +2302,7 @@ void WLBANDINITFN(wlc_lcnphy_tx_pwr_ctrl_init) (wlc_phy_t *ppi) phy_info_t *pi = (phy_info_t *) ppi; suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2989,7 +2988,7 @@ s16 wlc_lcnphy_tempsense_new(phy_info_t *pi, bool mode) if (mode == 1) { suspend = (0 == - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -3036,7 +3035,7 @@ u16 wlc_lcnphy_tempsense(phy_info_t *pi, bool mode) if (mode == 1) { suspend = (0 == - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -3104,7 +3103,7 @@ s8 wlc_lcnphy_vbatsense(phy_info_t *pi, bool mode) if (mode == 1) { suspend = (0 == - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, VBATSENSE); @@ -3459,7 +3458,7 @@ static void wlc_lcnphy_glacial_timer_based_cal(phy_info_t *pi) u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy; suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_deaf_mode(pi, true); @@ -3501,7 +3500,7 @@ static void wlc_lcnphy_periodic_cal(phy_info_t *pi) index = pi_lcn->lcnphy_current_index; suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) { wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); @@ -3859,15 +3858,15 @@ wlc_lcnphy_samp_cap(phy_info_t *pi, int clip_detect_algo, u16 thresh, timer = 0; old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - curval1 = R_REG(pi->sh->osh, &pi->regs->psm_corectlsts); + curval1 = R_REG(&pi->regs->psm_corectlsts); ptr[130] = 0; - W_REG(pi->sh->osh, &pi->regs->psm_corectlsts, ((1 << 6) | curval1)); + W_REG(&pi->regs->psm_corectlsts, ((1 << 6) | curval1)); - W_REG(pi->sh->osh, &pi->regs->smpl_clct_strptr, 0x7E00); - W_REG(pi->sh->osh, &pi->regs->smpl_clct_stpptr, 0x8000); + W_REG(&pi->regs->smpl_clct_strptr, 0x7E00); + W_REG(&pi->regs->smpl_clct_stpptr, 0x8000); udelay(20); - curval2 = R_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, curval2 | 0x30); + curval2 = R_REG(&pi->regs->psm_phy_hdr_param); + W_REG(&pi->regs->psm_phy_hdr_param, curval2 | 0x30); write_phy_reg(pi, 0x555, 0x0); write_phy_reg(pi, 0x5a6, 0x5); @@ -3884,19 +3883,19 @@ wlc_lcnphy_samp_cap(phy_info_t *pi, int clip_detect_algo, u16 thresh, sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); write_phy_reg(pi, 0x6da, (u32) (sslpnCalibClkEnCtrl | 0x2008)); - stpptr = R_REG(pi->sh->osh, &pi->regs->smpl_clct_stpptr); - curptr = R_REG(pi->sh->osh, &pi->regs->smpl_clct_curptr); + stpptr = R_REG(&pi->regs->smpl_clct_stpptr); + curptr = R_REG(&pi->regs->smpl_clct_curptr); do { udelay(10); - curptr = R_REG(pi->sh->osh, &pi->regs->smpl_clct_curptr); + curptr = R_REG(&pi->regs->smpl_clct_curptr); timer++; } while ((curptr != stpptr) && (timer < 500)); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, 0x2); + W_REG(&pi->regs->psm_phy_hdr_param, 0x2); strptr = 0x7E00; - W_REG(pi->sh->osh, &pi->regs->tplatewrptr, strptr); + W_REG(&pi->regs->tplatewrptr, strptr); while (strptr < 0x8000) { - val = R_REG(pi->sh->osh, &pi->regs->tplatewrdata); + val = R_REG(&pi->regs->tplatewrdata); imag = ((val >> 16) & 0x3ff); real = ((val) & 0x3ff); if (imag > 511) { @@ -3919,8 +3918,8 @@ wlc_lcnphy_samp_cap(phy_info_t *pi, int clip_detect_algo, u16 thresh, } write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, curval2); - W_REG(pi->sh->osh, &pi->regs->psm_corectlsts, curval1); + W_REG(&pi->regs->psm_phy_hdr_param, curval2); + W_REG(&pi->regs->psm_corectlsts, curval1); } static void wlc_lcnphy_tx_iqlo_soft_cal_full(phy_info_t *pi) @@ -4050,6 +4049,7 @@ wlc_lcnphy_a1(phy_info_t *pi, int cal_type, int num_levels, int step_size_lg2) phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); if (NULL == phy_c32) { + kfree(ptr); return; } phy_c26 = read_phy_reg(pi, 0x6da); diff --git a/drivers/staging/brcm80211/phy/wlc_phy_lcn.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.h index b7bfc7230dfc..b7bfc7230dfc 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_lcn.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.h diff --git a/drivers/staging/brcm80211/phy/wlc_phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c index c6cce8de1aee..7947c6028b6e 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c @@ -20,14 +20,11 @@ #include <wlc_cfg.h> #include <linux/delay.h> #include <linux/pci.h> -#include <osl.h> #include <siutils.h> #include <sbchipc.h> #include <hndpmu.h> -#include <bcmendian.h> #include <bcmdevs.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <wlc_phy_radio.h> @@ -14571,11 +14568,11 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi) &origidx, &intr_val); ASSERT(regs != NULL); - d11_clk_ctl_st = R_REG(pi->sh->osh, ®s->clk_ctl_st); - AND_REG(pi->sh->osh, ®s->clk_ctl_st, + d11_clk_ctl_st = R_REG(®s->clk_ctl_st); + AND_REG(®s->clk_ctl_st, ~(CCS_FORCEHT | CCS_HTAREQ)); - W_REG(pi->sh->osh, ®s->clk_ctl_st, d11_clk_ctl_st); + W_REG(®s->clk_ctl_st, d11_clk_ctl_st); si_restore_core(pi->sh->sih, origidx, intr_val); } @@ -14966,7 +14963,7 @@ static void wlc_phy_resetcca_nphy(phy_info_t *pi) { u16 val; - ASSERT(0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON); @@ -15059,7 +15056,7 @@ void wlc_phy_rxcore_setstate_nphy(wlc_phy_t *pih, u8 rxcore_bitmask) return; suspend = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -18985,28 +18982,28 @@ wlc_phy_chanspec_nphy_setup(phy_info_t *pi, chanspec_t chanspec, val = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; if (CHSPEC_IS5G(chanspec) && !val) { - val = R_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, + val = R_REG(&pi->regs->psm_phy_hdr_param); + W_REG(&pi->regs->psm_phy_hdr_param, (val | MAC_PHY_FORCE_CLK)); or_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), (BBCFG_RESETCCA | BBCFG_RESETRX)); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, val); + W_REG(&pi->regs->psm_phy_hdr_param, val); or_phy_reg(pi, 0x09, NPHY_BandControl_currentBand); } else if (!CHSPEC_IS5G(chanspec) && val) { and_phy_reg(pi, 0x09, ~NPHY_BandControl_currentBand); - val = R_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, + val = R_REG(&pi->regs->psm_phy_hdr_param); + W_REG(&pi->regs->psm_phy_hdr_param, (val | MAC_PHY_FORCE_CLK)); and_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), (u16) (~(BBCFG_RESETCCA | BBCFG_RESETRX))); - W_REG(pi->sh->osh, &pi->regs->psm_phy_hdr_param, val); + W_REG(&pi->regs->psm_phy_hdr_param, val); } write_phy_reg(pi, 0x1ce, ci->PHY_BW1a); @@ -19084,10 +19081,10 @@ wlc_phy_chanspec_nphy_setup(phy_info_t *pi, chanspec_t chanspec, if ((pi->sh->chip == BCM4716_CHIP_ID) || (pi->sh->chip == BCM47162_CHIP_ID)) { - si_pmu_spuravoid(pi->sh->sih, pi->sh->osh, spuravoid); + si_pmu_spuravoid(pi->sh->sih, spuravoid); } else { wlapi_bmac_core_phypll_ctl(pi->sh->physhim, false); - si_pmu_spuravoid(pi->sh->sih, pi->sh->osh, spuravoid); + si_pmu_spuravoid(pi->sh->sih, spuravoid); wlapi_bmac_core_phypll_ctl(pi->sh->physhim, true); } @@ -19097,15 +19094,15 @@ wlc_phy_chanspec_nphy_setup(phy_info_t *pi, chanspec_t chanspec, if (spuravoid == 1) { - W_REG(pi->sh->osh, &pi->regs->tsf_clk_frac_l, + W_REG(&pi->regs->tsf_clk_frac_l, 0x5341); - W_REG(pi->sh->osh, &pi->regs->tsf_clk_frac_h, + W_REG(&pi->regs->tsf_clk_frac_h, 0x8); } else { - W_REG(pi->sh->osh, &pi->regs->tsf_clk_frac_l, + W_REG(&pi->regs->tsf_clk_frac_l, 0x8889); - W_REG(pi->sh->osh, &pi->regs->tsf_clk_frac_h, + W_REG(&pi->regs->tsf_clk_frac_h, 0x8); } } @@ -19611,13 +19608,13 @@ void wlc_phy_antsel_init(wlc_phy_t *ppi, bool lut_init) si_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY); - mc = R_REG(pi->sh->osh, &pi->regs->maccontrol); + mc = R_REG(&pi->regs->maccontrol); mc &= ~MCTL_GPOUT_SEL_MASK; - W_REG(pi->sh->osh, &pi->regs->maccontrol, mc); + W_REG(&pi->regs->maccontrol, mc); - OR_REG(pi->sh->osh, &pi->regs->psm_gpio_oe, mask); + OR_REG(&pi->regs->psm_gpio_oe, mask); - AND_REG(pi->sh->osh, &pi->regs->psm_gpio_out, ~mask); + AND_REG(&pi->regs->psm_gpio_out, ~mask); if (lut_init) { write_phy_reg(pi, 0xf8, 0x02d8); @@ -19635,7 +19632,7 @@ u16 wlc_phy_classifier_nphy(phy_info_t *pi, u16 mask, u16 val) if (D11REV_IS(pi->sh->corerev, 16)) { suspended = - (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC) ? + (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) ? false : true; if (!suspended) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -21478,16 +21475,16 @@ wlc_phy_rssi_compute_nphy(phy_info_t *pi, wlc_d11rxhdr_t *wlc_rxh) s16 phyRx0_l, phyRx2_l; rxpwr = 0; - rxpwr0 = ltoh16(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR0_MASK; - rxpwr1 = (ltoh16(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR1_MASK) >> 8; + rxpwr0 = le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR0_MASK; + rxpwr1 = (le16_to_cpu(rxh->PhyRxStatus_1) & PRXS1_nphy_PWR1_MASK) >> 8; if (rxpwr0 > 127) rxpwr0 -= 256; if (rxpwr1 > 127) rxpwr1 -= 256; - phyRx0_l = ltoh16(rxh->PhyRxStatus_0) & 0x00ff; - phyRx2_l = ltoh16(rxh->PhyRxStatus_2) & 0x00ff; + phyRx0_l = le16_to_cpu(rxh->PhyRxStatus_0) & 0x00ff; + phyRx2_l = le16_to_cpu(rxh->PhyRxStatus_2) & 0x00ff; if (phyRx2_l > 127) phyRx2_l -= 256; @@ -22386,8 +22383,7 @@ wlc_phy_gen_load_samples_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val, wlc_phy_loadsampletable_nphy(pi, tone_buf, num_samps); - if (tone_buf != NULL) - kfree(tone_buf); + kfree(tone_buf); return num_samps; } @@ -22434,8 +22430,7 @@ wlc_phy_loadsampletable_nphy(phy_info_t *pi, cs32 *tone_buf, wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, data_buf); - if (data_buf != NULL) - kfree(data_buf); + kfree(data_buf); if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, false); @@ -27259,7 +27254,7 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal) return; phy_b3 = - (0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (!phy_b3) { wlapi_suspend_mac_and_wait(pi->sh->physhim); } @@ -28223,7 +28218,7 @@ void wlc_phy_txpower_recalc_target_nphy(phy_info_t *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(pi->sh->osh, &pi->regs->maccontrol); + (void)R_REG(&pi->regs->maccontrol); udelay(1); } @@ -28494,7 +28489,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(phy_info_t *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(pi->sh->osh, &pi->regs->maccontrol); + (void)R_REG(&pi->regs->maccontrol); udelay(1); } @@ -28651,7 +28646,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(phy_info_t *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(pi->sh->osh, &pi->regs->maccontrol); + (void)R_REG(&pi->regs->maccontrol); udelay(1); } @@ -29196,7 +29191,7 @@ void wlc_phy_stay_in_carriersearch_nphy(phy_info_t *pi, bool enable) { u16 clip_off[] = { 0xffff, 0xffff }; - ASSERT(0 == (R_REG(pi->sh->osh, &pi->regs->maccontrol) & MCTL_EN_MAC)); + ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); if (enable) { if (pi->nphy_deaf_count == 0) { diff --git a/drivers/staging/brcm80211/phy/wlc_phy_radio.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_radio.h index 72176ae2882c..72176ae2882c 100644 --- a/drivers/staging/brcm80211/phy/wlc_phy_radio.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_radio.h diff --git a/drivers/staging/brcm80211/phy/wlc_phyreg_n.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phyreg_n.h index 211bc3a842af..211bc3a842af 100644 --- a/drivers/staging/brcm80211/phy/wlc_phyreg_n.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phyreg_n.h diff --git a/drivers/staging/brcm80211/phy/wlc_phytbl_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_lcn.c index 330b88152b65..81c59b05482a 100644 --- a/drivers/staging/brcm80211/phy/wlc_phytbl_lcn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_lcn.c @@ -15,9 +15,7 @@ */ #include <linux/types.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <osl.h> #include <wlc_phy_int.h> #include <wlc_phytbl_lcn.h> diff --git a/drivers/staging/brcm80211/phy/wlc_phytbl_lcn.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_lcn.h index 5a64a988d107..5a64a988d107 100644 --- a/drivers/staging/brcm80211/phy/wlc_phytbl_lcn.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_lcn.h diff --git a/drivers/staging/brcm80211/phy/wlc_phytbl_n.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_n.c index a9fc193721ef..742df997a3b1 100644 --- a/drivers/staging/brcm80211/phy/wlc_phytbl_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_n.c @@ -16,9 +16,7 @@ #include <linux/kernel.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <osl.h> #include <wlc_phy_int.h> #include <wlc_phytbl_n.h> diff --git a/drivers/staging/brcm80211/phy/wlc_phytbl_n.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_n.h index 396122f5e50b..396122f5e50b 100644 --- a/drivers/staging/brcm80211/phy/wlc_phytbl_n.h +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phytbl_n.h diff --git a/drivers/staging/brcm80211/sys/wl_dbg.h b/drivers/staging/brcm80211/brcmsmac/wl_dbg.h index 54af257598c2..54af257598c2 100644 --- a/drivers/staging/brcm80211/sys/wl_dbg.h +++ b/drivers/staging/brcm80211/brcmsmac/wl_dbg.h diff --git a/drivers/staging/brcm80211/sys/wl_export.h b/drivers/staging/brcm80211/brcmsmac/wl_export.h index aa8b5a3ed633..9ff760f4c865 100644 --- a/drivers/staging/brcm80211/sys/wl_export.h +++ b/drivers/staging/brcm80211/brcmsmac/wl_export.h @@ -26,14 +26,12 @@ extern uint wl_reset(struct wl_info *wl); extern void wl_intrson(struct wl_info *wl); extern u32 wl_intrsoff(struct wl_info *wl); extern void wl_intrsrestore(struct wl_info *wl, u32 macintmask); -extern void wl_event(struct wl_info *wl, char *ifname, wlc_event_t *e); -extern void wl_event_sendup(struct wl_info *wl, const wlc_event_t *e, - u8 *data, u32 len); extern int wl_up(struct wl_info *wl); extern void wl_down(struct wl_info *wl); extern void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state, int prio); extern bool wl_alloc_dma_resources(struct wl_info *wl, uint dmaddrwidth); +extern bool wl_rfkill_set_hw_state(struct wl_info *wl); /* timer functions */ struct wl_timer; @@ -45,19 +43,4 @@ extern void wl_add_timer(struct wl_info *wl, struct wl_timer *timer, uint ms, int periodic); extern bool wl_del_timer(struct wl_info *wl, struct wl_timer *timer); -extern uint wl_buf_to_pktcopy(struct osl_info *osh, void *p, unsigned char *buf, - int len, uint offset); -extern void *wl_get_pktbuffer(struct osl_info *osh, int len); -extern int wl_set_pktlen(struct osl_info *osh, void *p, int len); - -#define wl_sort_bsslist(a, b) false - -extern int wl_tkip_miccheck(struct wl_info *wl, void *p, int hdr_len, - bool group_key, int id); -extern int wl_tkip_micadd(struct wl_info *wl, void *p, int hdr_len); -extern int wl_tkip_encrypt(struct wl_info *wl, void *p, int hdr_len); -extern int wl_tkip_decrypt(struct wl_info *wl, void *p, int hdr_len, - bool group_key); -extern void wl_tkip_printstats(struct wl_info *wl, bool group_key); -extern int wl_tkip_keyset(struct wl_info *wl, wsec_key_t *key); #endif /* _wl_export_h_ */ diff --git a/drivers/staging/brcm80211/sys/wl_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c index cd8392badff0..774b4e916b29 100644 --- a/drivers/staging/brcm80211/sys/wl_mac80211.c +++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c @@ -18,38 +18,38 @@ #include <linux/kernel.h> #include <linux/etherdevice.h> -#include <linux/string.h> +#include <linux/types.h> #include <linux/pci_ids.h> -#include <bcmdefs.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/sched.h> -#include <osl.h> -#define WLC_MAXBSSCFG 1 /* single BSS configs */ - -#include <wlc_cfg.h> +#include <linux/firmware.h> #include <net/mac80211.h> -#include <phy_version.h> + +#include <proto/802.11.h> +#include <bcmdefs.h> +#include <bcmwifi.h> #include <bcmutils.h> #include <pcicfg.h> #include <wlioctl.h> -#include <wlc_key.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <wlc_channel.h> -#include <wlc_pub.h> -#include <wlc_scb.h> -#include <wl_dbg.h> -#include <wl_export.h> - -#include <wl_mac80211.h> -#include <linux/firmware.h> -#include <wl_ucode.h> -#include <d11ucode_ext.h> +#include "phy/wlc_phy_int.h" +#include "d11.h" +#include "wlc_types.h" +#include "wlc_cfg.h" +#include "phy/phy_version.h" +#include "wlc_key.h" +#include "wlc_channel.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wl_dbg.h" +#include "wl_export.h" +#include "wl_ucode.h" +#include "wl_mac80211.h" static void wl_timer(unsigned long data); -static void _wl_timer(wl_timer_t *t); +static void _wl_timer(struct wl_timer *t); static int ieee_hw_init(struct ieee80211_hw *hw); @@ -68,46 +68,19 @@ static int wl_linux_watchdog(void *ctx); static int wl_found; -struct ieee80211_tkip_data { -#define TKIP_KEY_LEN 32 - u8 key[TKIP_KEY_LEN]; - int key_set; - - u32 tx_iv32; - u16 tx_iv16; - u16 tx_ttak[5]; - int tx_phase1_done; - - u32 rx_iv32; - u16 rx_iv16; - u16 rx_ttak[5]; - int rx_phase1_done; - u32 rx_iv32_new; - u16 rx_iv16_new; - - u32 dot11RSNAStatsTKIPReplays; - u32 dot11RSNAStatsTKIPICVErrors; - u32 dot11RSNAStatsTKIPLocalMICFailures; - - int key_idx; - - struct crypto_tfm *tfm_arc4; - struct crypto_tfm *tfm_michael; - - /* scratch buffers for virt_to_page() (crypto API) */ - u8 rx_hdr[16], tx_hdr[16]; -}; - #define WL_DEV_IF(dev) ((struct wl_if *)netdev_priv(dev)) #define WL_INFO(dev) ((struct wl_info *)(WL_DEV_IF(dev)->wl)) static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev); static void wl_release_fw(struct wl_info *wl); /* local prototypes */ -static int wl_start(struct sk_buff *skb, struct wl_info *wl); -static int wl_start_int(struct wl_info *wl, struct ieee80211_hw *hw, - struct sk_buff *skb); static void wl_dpc(unsigned long data); +static irqreturn_t wl_isr(int irq, void *dev_id); + +static int __devinit wl_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *ent); +static void wl_remove(struct pci_dev *pdev); +static void wl_free(struct wl_info *wl); MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); @@ -123,8 +96,6 @@ static struct pci_device_id wl_id_table[] = { }; MODULE_DEVICE_TABLE(pci, wl_id_table); -static void wl_remove(struct pci_dev *pdev); - #ifdef BCMDBG static int msglevel = 0xdeadbeef; @@ -135,7 +106,8 @@ module_param(phymsglevel, int, 0); #define HW_TO_WL(hw) (hw->priv) #define WL_TO_HW(wl) (wl->pub->ieee_hw) -static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb); + +/* MAC80211 callback functions */ static int wl_ops_start(struct ieee80211_hw *hw); static void wl_ops_stop(struct ieee80211_hw *hw); static int wl_ops_add_interface(struct ieee80211_hw *hw, @@ -165,52 +137,58 @@ static void wl_ops_sta_notify(struct ieee80211_hw *hw, static int wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, const struct ieee80211_tx_queue_params *params); static u64 wl_ops_get_tsf(struct ieee80211_hw *hw); -static int wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, +static int wl_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -static int wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, +static int wl_ops_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -static int wl_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn); - -static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +static int wl_ops_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size); +static void wl_ops_rfkill_poll(struct ieee80211_hw *hw); + +static void wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - int status; struct wl_info *wl = hw->priv; + WL_LOCK(wl); if (!wl->pub->up) { WL_ERROR("ops->tx called while down\n"); - status = -ENETDOWN; + kfree_skb(skb); goto done; } - status = wl_start(skb, wl); + wlc_sendpkt_mac80211(wl->wlc, skb, hw); done: WL_UNLOCK(wl); - return status; } static int wl_ops_start(struct ieee80211_hw *hw) { struct wl_info *wl = hw->priv; + bool blocked; /* struct ieee80211_channel *curchan = hw->conf.channel; WL_NONE("%s : Initial channel: %d\n", __func__, curchan->hw_value); */ - WL_LOCK(wl); ieee80211_wake_queues(hw); + WL_LOCK(wl); + blocked = wl_rfkill_set_hw_state(wl); WL_UNLOCK(wl); + if (!blocked) + wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); return 0; } static void wl_ops_stop(struct ieee80211_hw *hw) { +#ifdef BRCMDBG struct wl_info *wl = hw->priv; ASSERT(wl); - WL_LOCK(wl); +#endif /*BRCMDBG*/ ieee80211_stop_queues(hw); - WL_UNLOCK(wl); } static int @@ -235,8 +213,9 @@ wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) err = wl_up(wl); WL_UNLOCK(wl); - if (err != 0) + if (err != 0) { WL_ERROR("%s: wl_up() returned %d\n", __func__, err); + } return err; } @@ -253,6 +232,9 @@ wl_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) WL_UNLOCK(wl); } +/* + * precondition: perimeter lock has been acquired + */ static int ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, enum nl80211_channel_type type) @@ -268,6 +250,7 @@ ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, case NL80211_CHAN_HT40MINUS: case NL80211_CHAN_HT40PLUS: WL_ERROR("%s: Need to implement 40 Mhz Channels!\n", __func__); + err = 1; break; } @@ -285,8 +268,6 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed) WL_LOCK(wl); if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { - WL_NONE("%s: Setting listen interval to %d\n", - __func__, conf->listen_interval); if (wlc_iovar_setint (wl->wlc, "bcn_li_bcn", conf->listen_interval)) { WL_ERROR("%s: Error setting listen_interval\n", @@ -298,13 +279,15 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed) ASSERT(new_int == conf->listen_interval); } if (changed & IEEE80211_CONF_CHANGE_MONITOR) - WL_NONE("Need to set monitor mode\n"); + WL_ERROR("%s: change monitor mode: %s (implement)\n", __func__, + conf->flags & IEEE80211_CONF_MONITOR ? + "true" : "false"); if (changed & IEEE80211_CONF_CHANGE_PS) - WL_NONE("Need to set Power-save mode\n"); + WL_ERROR("%s: change power-save mode: %s (implement)\n", + __func__, conf->flags & IEEE80211_CONF_PS ? + "true" : "false"); if (changed & IEEE80211_CONF_CHANGE_POWER) { - WL_NONE("%s: Setting tx power to %d dbm\n", - __func__, conf->power_level); if (wlc_iovar_setint (wl->wlc, "qtxpower", conf->power_level * 4)) { WL_ERROR("%s: Error setting power_level\n", __func__); @@ -320,10 +303,6 @@ static int wl_ops_config(struct ieee80211_hw *hw, u32 changed) err = ieee_set_channel(hw, conf->channel, conf->channel_type); } if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { - WL_NONE("%s: srl %d, lrl %d\n", - __func__, - conf->short_frame_max_tx_count, - conf->long_frame_max_tx_count); if (wlc_set (wl->wlc, WLC_SET_SRL, conf->short_frame_max_tx_count) < 0) { @@ -352,64 +331,103 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw, struct wl_info *wl = HW_TO_WL(hw); int val; - if (changed & BSS_CHANGED_ASSOC) { - WL_ERROR("Associated:\t%s\n", info->assoc ? "True" : "False"); /* association status changed (associated/disassociated) * also implies a change in the AID. */ + WL_ERROR("%s: %s: %sassociated\n", KBUILD_MODNAME, __func__, + info->assoc ? "" : "dis"); + wlc_associate_upd(wl->wlc, info->assoc); } if (changed & BSS_CHANGED_ERP_CTS_PROT) { - WL_NONE("Use_cts_prot:\t%s Implement me\n", - info->use_cts_prot ? "True" : "False"); /* CTS protection changed */ + WL_ERROR("%s: use_cts_prot: %s (implement)\n", __func__, + info->use_cts_prot ? "true" : "false"); } if (changed & BSS_CHANGED_ERP_PREAMBLE) { - WL_NONE("Short preamble:\t%s Implement me\n", - info->use_short_preamble ? "True" : "False"); /* preamble changed */ + WL_ERROR("%s: short preamble: %s (implement)\n", __func__, + info->use_short_preamble ? "true" : "false"); } if (changed & BSS_CHANGED_ERP_SLOT) { - WL_NONE("Changing short slot:\t%s\n", - info->use_short_slot ? "True" : "False"); + /* slot timing changed */ if (info->use_short_slot) val = 1; else val = 0; + WL_LOCK(wl); wlc_set(wl->wlc, WLC_SET_SHORTSLOT_OVERRIDE, val); - /* slot timing changed */ + WL_UNLOCK(wl); } if (changed & BSS_CHANGED_HT) { - WL_NONE("%s: HT mode - Implement me\n", __func__); /* 802.11n parameters changed */ + u16 mode = info->ht_operation_mode; + WL_NONE("%s: HT mode: 0x%04X\n", __func__, mode); + wlc_protection_upd(wl->wlc, WLC_PROT_N_CFG, + mode & IEEE80211_HT_OP_MODE_PROTECTION); + wlc_protection_upd(wl->wlc, WLC_PROT_N_NONGF, + mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + wlc_protection_upd(wl->wlc, WLC_PROT_N_OBSS, + mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT); } if (changed & BSS_CHANGED_BASIC_RATES) { - WL_NONE("Need to change Basic Rates:\t0x%x! Implement me\n", - (u32) info->basic_rates); /* Basic rateset changed */ + WL_ERROR("%s: Need to change Basic Rates: 0x%x (implement)\n", + __func__, (u32) info->basic_rates); } if (changed & BSS_CHANGED_BEACON_INT) { - WL_NONE("Beacon Interval:\t%d Implement me\n", - info->beacon_int); /* Beacon interval changed */ + WL_NONE("%s: Beacon Interval: %d\n", + __func__, info->beacon_int); + wlc_set(wl->wlc, WLC_SET_BCNPRD, info->beacon_int); } if (changed & BSS_CHANGED_BSSID) { - WL_NONE("new BSSID:\taid %d bss:%pM\n", - info->aid, info->bssid); /* BSSID changed, for whatever reason (IBSS and managed mode) */ - /* FIXME: need to store bssid in bsscfg */ + WL_NONE("%s: new BSSID: aid %d bss:%pM\n", __func__, + info->aid, info->bssid); + WL_LOCK(wl); wlc_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, - (struct ether_addr *)info->bssid); + info->bssid); + WL_UNLOCK(wl); } if (changed & BSS_CHANGED_BEACON) { - WL_ERROR("BSS_CHANGED_BEACON\n"); /* Beacon data changed, retrieve new beacon (beaconing modes) */ + WL_ERROR("%s: beacon changed\n", __func__); } if (changed & BSS_CHANGED_BEACON_ENABLED) { - WL_ERROR("Beacon enabled:\t%s\n", - info->enable_beacon ? "True" : "False"); /* Beaconing should be enabled/disabled (beaconing modes) */ + WL_ERROR("%s: Beacon enabled: %s\n", __func__, + info->enable_beacon ? "true" : "false"); + } + if (changed & BSS_CHANGED_CQM) { + /* Connection quality monitor config changed */ + WL_ERROR("%s: cqm change: threshold %d, hys %d (implement)\n", + __func__, info->cqm_rssi_thold, info->cqm_rssi_hyst); + } + if (changed & BSS_CHANGED_IBSS) { + /* IBSS join status changed */ + WL_ERROR("%s: IBSS joined: %s (implement)\n", __func__, + info->ibss_joined ? "true" : "false"); + } + if (changed & BSS_CHANGED_ARP_FILTER) { + /* Hardware ARP filter address list or state changed */ + WL_ERROR("%s: arp filtering: enabled %s, count %d (implement)\n", + __func__, info->arp_filter_enabled ? "true" : "false", + info->arp_addr_cnt); + } + if (changed & BSS_CHANGED_QOS) { + /* + * QoS for this association was enabled/disabled. + * Note that it is only ever disabled for station mode. + */ + WL_ERROR("%s: qos enabled: %s (implement)\n", __func__, + info->qos ? "true" : "false"); + } + if (changed & BSS_CHANGED_IDLE) { + /* Idle changed for this BSS/interface */ + WL_ERROR("%s: BSS idle: %s (implement)\n", __func__, + info->idle ? "true" : "false"); } return; } @@ -453,7 +471,7 @@ wl_ops_configure_filter(struct ieee80211_hw *hw, static int wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) { - WL_ERROR("%s: Enter\n", __func__); + WL_NONE("%s: Enter\n", __func__); return 0; } @@ -487,13 +505,26 @@ static int wl_ops_get_stats(struct ieee80211_hw *hw, struct ieee80211_low_level_stats *stats) { - WL_ERROR("%s: Enter\n", __func__); + struct wl_info *wl = hw->priv; + struct wl_cnt *cnt; + + WL_LOCK(wl); + cnt = wl->pub->_cnt; + stats->dot11ACKFailureCount = cnt->txnoack; + stats->dot11RTSFailureCount = cnt->txnocts; + stats->dot11FCSErrorCount = cnt->rxcrc; + stats->dot11RTSSuccessCount = cnt->txrts; + WL_UNLOCK(wl); return 0; } static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value) { - WL_ERROR("%s: Enter\n", __func__); + struct wl_info *wl = hw->priv; + + WL_LOCK(wl); + wlc_iovar_setint(wl->wlc, "rtsthresh", value & 0xFFFF); + WL_UNLOCK(wl); return 0; } @@ -534,8 +565,8 @@ static u64 wl_ops_get_tsf(struct ieee80211_hw *hw) } static int -wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +wl_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct scb *scb; @@ -558,7 +589,7 @@ wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); sta->ht_cap.ht_supported = true; - sta->ht_cap.ampdu_factor = AMPDU_RX_FACTOR_64K; + sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | @@ -569,23 +600,25 @@ wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, } static int -wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +wl_ops_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { WL_NONE("%s: Enter\n", __func__); return 0; } static int -wl_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn) +wl_ops_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size) { #if defined(BCMDBG) struct scb *scb = (struct scb *)sta->drv_priv; #endif struct wl_info *wl = hw->priv; + int status; ASSERT(scb->magic == SCB_MAGIC); switch (action) { @@ -596,7 +629,10 @@ wl_ampdu_action(struct ieee80211_hw *hw, WL_NONE("%s: action = IEEE80211_AMPDU_RX_STOP\n", __func__); break; case IEEE80211_AMPDU_TX_START: - if (!wlc_aggregatable(wl->wlc, tid)) { + WL_LOCK(wl); + status = wlc_aggregatable(wl->wlc, tid); + WL_UNLOCK(wl); + if (!status) { /* WL_ERROR("START: tid %d is not agg' able, return FAILURE to stack\n", tid); */ return -1; } @@ -606,6 +642,9 @@ wl_ampdu_action(struct ieee80211_hw *hw, break; case IEEE80211_AMPDU_TX_STOP: + WL_LOCK(wl); + wlc_ampdu_flush(wl->wlc, sta, tid); + WL_UNLOCK(wl); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); break; case IEEE80211_AMPDU_TX_OPERATIONAL: @@ -621,6 +660,19 @@ wl_ampdu_action(struct ieee80211_hw *hw, return 0; } +static void wl_ops_rfkill_poll(struct ieee80211_hw *hw) +{ + struct wl_info *wl = HW_TO_WL(hw); + bool blocked; + + WL_LOCK(wl); + blocked = wlc_check_radio_disabled(wl->wlc); + WL_UNLOCK(wl); + + WL_NONE("wl: rfkill_poll: %d\n", blocked); + wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); +} + static const struct ieee80211_ops wl_ops = { .tx = wl_ops_tx, .start = wl_ops_start, @@ -639,14 +691,18 @@ static const struct ieee80211_ops wl_ops = { .sta_notify = wl_ops_sta_notify, .conf_tx = wl_ops_conf_tx, .get_tsf = wl_ops_get_tsf, - .sta_add = wl_sta_add, - .sta_remove = wl_sta_remove, - .ampdu_action = wl_ampdu_action, + .sta_add = wl_ops_sta_add, + .sta_remove = wl_ops_sta_remove, + .ampdu_action = wl_ops_ampdu_action, + .rfkill_poll = wl_ops_rfkill_poll, }; +/* + * is called in wl_pci_probe() context, therefore no locking required. + */ static int wl_set_hint(struct wl_info *wl, char *abbrev) { - WL_ERROR("%s: Sending country code %c%c to MAC80211\n", + WL_NONE("%s: Sending country code %c%c to MAC80211\n", __func__, abbrev[0], abbrev[1]); return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); } @@ -661,12 +717,14 @@ static int wl_set_hint(struct wl_info *wl, char *abbrev) * is defined, wl_attach will never be called, and thus, gcc will issue * a warning that this function is defined but not used if we declare * it as static. + * + * + * is called in wl_pci_probe() context, therefore no locking required. */ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, uint bustype, void *btparam, uint irq) { struct wl_info *wl; - struct osl_info *osh; int unit, err; unsigned long base_addr; @@ -681,15 +739,11 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, return NULL; } - osh = osl_attach(btparam, bustype); - ASSERT(osh); - /* allocate private info */ hw = pci_get_drvdata(btparam); /* btparam == pdev */ wl = hw->priv; ASSERT(wl); - wl->osh = osh; atomic_set(&wl->callbacks, 0); /* setup the bottom half handler */ @@ -718,21 +772,21 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, spin_lock_init(&wl->isr_lock); /* prepare ucode */ - if (wl_request_fw(wl, (struct pci_dev *)btparam)) { - printf("%s: Failed to find firmware usually in %s\n", - KBUILD_MODNAME, "/lib/firmware/brcm"); + if (wl_request_fw(wl, (struct pci_dev *)btparam) < 0) { + WL_ERROR("%s: Failed to find firmware usually in %s\n", + KBUILD_MODNAME, "/lib/firmware/brcm"); wl_release_fw(wl); wl_remove((struct pci_dev *)btparam); goto fail1; } /* common load-time initialization */ - wl->wlc = wlc_attach((void *)wl, vendor, device, unit, wl->piomode, osh, + wl->wlc = wlc_attach((void *)wl, vendor, device, unit, wl->piomode, wl->regsva, wl->bcm_bustype, btparam, &err); wl_release_fw(wl); if (!wl->wlc) { - printf("%s: wlc_attach() failed with code %d\n", - KBUILD_MODNAME, err); + WL_ERROR("%s: wlc_attach() failed with code %d\n", + KBUILD_MODNAME, err); goto fail; } wl->pub = wlc_pub(wl->wlc); @@ -762,7 +816,7 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, goto fail; } - bcopy(&wl->pub->cur_etheraddr, perm, ETH_ALEN); + memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN); ASSERT(is_valid_ether_addr(perm)); SET_IEEE80211_PERM_ADDR(hw, perm); @@ -780,13 +834,6 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs, WL_ERROR("%s: regulatory_hint failed, status %d\n", __func__, err); } - WL_ERROR("wl%d: Broadcom BCM43xx 802.11 MAC80211 Driver (" PHY_VERSION_STR ")", - unit); - -#ifdef BCMDBG - printf(" (Compiled at " __TIME__ " on " __DATE__ ")"); -#endif /* BCMDBG */ - printf("\n"); wl_found++; return wl; @@ -935,7 +982,7 @@ static struct ieee80211_supported_band wl_band_2GHz_nphy = { IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, .ht_supported = true, - .ampdu_factor = AMPDU_RX_FACTOR_64K, + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, .ampdu_density = AMPDU_DEF_MPDU_DENSITY, .mcs = { /* placeholders for now */ @@ -955,7 +1002,7 @@ static struct ieee80211_supported_band wl_band_5GHz_nphy = { /* use IEEE80211_HT_CAP_* from include/linux/ieee80211.h */ .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ .ht_supported = true, - .ampdu_factor = AMPDU_RX_FACTOR_64K, + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, .ampdu_density = AMPDU_DEF_MPDU_DENSITY, .mcs = { /* placeholders for now */ @@ -965,6 +1012,9 @@ static struct ieee80211_supported_band wl_band_5GHz_nphy = { } }; +/* + * is called in wl_pci_probe() context, therefore no locking required. + */ static int ieee_hw_rate_init(struct ieee80211_hw *hw) { struct wl_info *wl = HW_TO_WL(hw); @@ -1009,6 +1059,9 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) return 0; } +/* + * is called in wl_pci_probe() context, therefore no locking required. + */ static int ieee_hw_init(struct ieee80211_hw *hw) { hw->flags = IEEE80211_HW_SIGNAL_DBM @@ -1041,8 +1094,9 @@ static int ieee_hw_init(struct ieee80211_hw *hw) * This function determines if a device pointed to by pdev is a WL device, * and if so, performs a wl_attach() on it. * + * Perimeter lock is initialized in the course of this function. */ -int __devinit +static int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; @@ -1164,10 +1218,15 @@ static int wl_resume(struct pci_dev *pdev) return err; } +/* +* called from both kernel as from wl_*() +* precondition: perimeter lock is not acquired. +*/ static void wl_remove(struct pci_dev *pdev) { struct wl_info *wl; struct ieee80211_hw *hw; + int status; hw = pci_get_drvdata(pdev); wl = HW_TO_WL(hw); @@ -1175,11 +1234,17 @@ static void wl_remove(struct pci_dev *pdev) WL_ERROR("wl: wl_remove: pci_get_drvdata failed\n"); return; } - if (!wlc_chipmatch(pdev->vendor, pdev->device)) { + + WL_LOCK(wl); + status = wlc_chipmatch(pdev->vendor, pdev->device); + WL_UNLOCK(wl); + if (!status) { WL_ERROR("wl: wl_remove: wlc_chipmatch failed\n"); return; } if (wl->wlc) { + wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); + wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); ieee80211_unregister_hw(hw); WL_LOCK(wl); wl_down(wl); @@ -1195,11 +1260,11 @@ static void wl_remove(struct pci_dev *pdev) } static struct pci_driver wl_pci_driver = { - .name = "brcm80211", - .probe = wl_pci_probe, - .suspend = wl_suspend, - .resume = wl_resume, - .remove = __devexit_p(wl_remove), + .name = KBUILD_MODNAME, + .probe = wl_pci_probe, + .suspend = wl_suspend, + .resume = wl_resume, + .remove = __devexit_p(wl_remove), .id_table = wl_id_table, }; @@ -1219,18 +1284,22 @@ static int __init wl_module_init(void) wl_msg_level = msglevel; else { char *var = getvar(NULL, "wl_msglevel"); - if (var) - wl_msg_level = simple_strtoul(var, NULL, 0); - } - { - extern u32 phyhal_msg_level; - - if (phymsglevel != 0xdeadbeef) - phyhal_msg_level = phymsglevel; - else { - char *var = getvar(NULL, "phy_msglevel"); - if (var) - phyhal_msg_level = simple_strtoul(var, NULL, 0); + if (var) { + unsigned long value; + + (void)strict_strtoul(var, 0, &value); + wl_msg_level = value; + } + } + if (phymsglevel != 0xdeadbeef) + phyhal_msg_level = phymsglevel; + else { + char *var = getvar(NULL, "phy_msglevel"); + if (var) { + unsigned long value; + + (void)strict_strtoul(var, 0, &value); + phyhal_msg_level = value; } } #endif /* BCMDBG */ @@ -1266,11 +1335,12 @@ module_exit(wl_module_exit); * This function frees resources owned by the WL device pointed to * by the wl parameter. * + * precondition: can both be called locked and unlocked + * */ -void wl_free(struct wl_info *wl) +static void wl_free(struct wl_info *wl) { - wl_timer_t *t, *next; - struct osl_info *osh; + struct wl_timer *t, *next; ASSERT(wl); /* free ucode data */ @@ -1303,14 +1373,11 @@ void wl_free(struct wl_info *wl) for (t = wl->timers; t; t = next) { next = t->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); } - osh = wl->osh; - /* * unregister_netdev() calls get_stats() which may read chip registers * so we cannot unmap the chip registers until after calling unregister_netdev() . @@ -1320,33 +1387,20 @@ void wl_free(struct wl_info *wl) iounmap((void *)wl->regsva); } wl->regsva = NULL; - - - osl_detach(osh); -} - -/* transmit a packet */ -static int BCMFASTPATH wl_start(struct sk_buff *skb, struct wl_info *wl) -{ - if (!wl) - return -ENETDOWN; - - return wl_start_int(wl, WL_TO_HW(wl), skb); -} - -static int BCMFASTPATH -wl_start_int(struct wl_info *wl, struct ieee80211_hw *hw, struct sk_buff *skb) -{ - wlc_sendpkt_mac80211(wl->wlc, skb, hw); - return NETDEV_TX_OK; } +/* + * precondition: perimeter lock has been acquired + */ void wl_txflowcontrol(struct wl_info *wl, struct wl_if *wlif, bool state, int prio) { WL_ERROR("Shouldn't be here %s\n", __func__); } +/* + * precondition: perimeter lock has been acquired + */ void wl_init(struct wl_info *wl) { WL_TRACE("wl%d: wl_init\n", wl->pub->unit); @@ -1356,6 +1410,9 @@ void wl_init(struct wl_info *wl) wlc_init(wl->wlc); } +/* + * precondition: perimeter lock has been acquired + */ uint wl_reset(struct wl_info *wl) { WL_TRACE("wl%d: wl_reset\n", wl->pub->unit); @@ -1381,6 +1438,9 @@ void BCMFASTPATH wl_intrson(struct wl_info *wl) INT_UNLOCK(wl, flags); } +/* + * precondition: perimeter lock has been acquired + */ bool wl_alloc_dma_resources(struct wl_info *wl, uint addrwidth) { return true; @@ -1406,6 +1466,9 @@ void wl_intrsrestore(struct wl_info *wl, u32 macintmask) INT_UNLOCK(wl, flags); } +/* + * precondition: perimeter lock has been acquired + */ int wl_up(struct wl_info *wl) { int error = 0; @@ -1418,6 +1481,9 @@ int wl_up(struct wl_info *wl) return error; } +/* + * precondition: perimeter lock has been acquired + */ void wl_down(struct wl_info *wl) { uint callbacks, ret_val = 0; @@ -1437,7 +1503,7 @@ void wl_down(struct wl_info *wl) WL_LOCK(wl); } -irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id) +static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id) { struct wl_info *wl; bool ours, wantdpc; @@ -1502,38 +1568,18 @@ static void BCMFASTPATH wl_dpc(unsigned long data) WL_UNLOCK(wl); } -static void wl_link_up(struct wl_info *wl, char *ifname) -{ - WL_ERROR("wl%d: link up (%s)\n", wl->pub->unit, ifname); -} - -static void wl_link_down(struct wl_info *wl, char *ifname) -{ - WL_ERROR("wl%d: link down (%s)\n", wl->pub->unit, ifname); -} - -void wl_event(struct wl_info *wl, char *ifname, wlc_event_t *e) -{ - - switch (e->event.event_type) { - case WLC_E_LINK: - case WLC_E_NDIS_LINK: - if (e->event.flags & WLC_EVENT_MSG_LINK) - wl_link_up(wl, ifname); - else - wl_link_down(wl, ifname); - break; - case WLC_E_RADIO: - break; - } -} - +/* + * is called by the kernel from software irq context + */ static void wl_timer(unsigned long data) { - _wl_timer((wl_timer_t *) data); + _wl_timer((struct wl_timer *) data); } -static void _wl_timer(wl_timer_t *t) +/* +* precondition: perimeter lock is not acquired + */ +static void _wl_timer(struct wl_timer *t) { WL_LOCK(t->wl); @@ -1554,19 +1600,23 @@ static void _wl_timer(wl_timer_t *t) WL_UNLOCK(t->wl); } -wl_timer_t *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), void *arg, - const char *name) +/* + * Adds a timer to the list. Caller supplies a timer function. + * Is called from wlc. + * + * precondition: perimeter lock has been acquired + */ +struct wl_timer *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), + void *arg, const char *name) { - wl_timer_t *t; + struct wl_timer *t; - t = kmalloc(sizeof(wl_timer_t), GFP_ATOMIC); + t = kzalloc(sizeof(struct wl_timer), GFP_ATOMIC); if (!t) { WL_ERROR("wl%d: wl_init_timer: out of memory\n", wl->pub->unit); return 0; } - memset(t, 0, sizeof(wl_timer_t)); - init_timer(&t->timer); t->timer.data = (unsigned long) t; t->timer.function = wl_timer; @@ -1587,8 +1637,10 @@ wl_timer_t *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), void *arg, /* BMAC_NOTE: Add timer adds only the kernel timer since it's going to be more accurate * as well as it's easier to make it periodic + * + * precondition: perimeter lock has been acquired */ -void wl_add_timer(struct wl_info *wl, wl_timer_t *t, uint ms, int periodic) +void wl_add_timer(struct wl_info *wl, struct wl_timer *t, uint ms, int periodic) { #ifdef BCMDBG if (t->set) { @@ -1607,8 +1659,12 @@ void wl_add_timer(struct wl_info *wl, wl_timer_t *t, uint ms, int periodic) add_timer(&t->timer); } -/* return true if timer successfully deleted, false if still pending */ -bool wl_del_timer(struct wl_info *wl, wl_timer_t *t) +/* + * return true if timer successfully deleted, false if still pending + * + * precondition: perimeter lock has been acquired + */ +bool wl_del_timer(struct wl_info *wl, struct wl_timer *t) { if (t->set) { t->set = false; @@ -1621,9 +1677,12 @@ bool wl_del_timer(struct wl_info *wl, wl_timer_t *t) return true; } -void wl_free_timer(struct wl_info *wl, wl_timer_t *t) +/* + * precondition: perimeter lock has been acquired + */ +void wl_free_timer(struct wl_info *wl, struct wl_timer *t) { - wl_timer_t *tmp; + struct wl_timer *tmp; /* delete the timer in case it is active */ wl_del_timer(wl, t); @@ -1631,8 +1690,7 @@ void wl_free_timer(struct wl_info *wl, wl_timer_t *t) if (wl->timers == t) { wl->timers = wl->timers->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); return; @@ -1644,8 +1702,7 @@ void wl_free_timer(struct wl_info *wl, wl_timer_t *t) if (tmp->next == t) { tmp->next = t->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); return; @@ -1655,37 +1712,42 @@ void wl_free_timer(struct wl_info *wl, wl_timer_t *t) } +/* + * runs in software irq context + * + * precondition: perimeter lock is not acquired + */ static int wl_linux_watchdog(void *ctx) { struct wl_info *wl = (struct wl_info *) ctx; + struct wl_cnt *cnt; struct net_device_stats *stats = NULL; uint id; /* refresh stats */ if (wl->pub->up) { ASSERT(wl->stats_id < 2); + cnt = wl->pub->_cnt; id = 1 - wl->stats_id; - stats = &wl->stats_watchdog[id]; - stats->rx_packets = WLCNTVAL(wl->pub->_cnt->rxframe); - stats->tx_packets = WLCNTVAL(wl->pub->_cnt->txframe); - stats->rx_bytes = WLCNTVAL(wl->pub->_cnt->rxbyte); - stats->tx_bytes = WLCNTVAL(wl->pub->_cnt->txbyte); - stats->rx_errors = WLCNTVAL(wl->pub->_cnt->rxerror); - stats->tx_errors = WLCNTVAL(wl->pub->_cnt->txerror); + stats->rx_packets = cnt->rxframe; + stats->tx_packets = cnt->txframe; + stats->rx_bytes = cnt->rxbyte; + stats->tx_bytes = cnt->txbyte; + stats->rx_errors = cnt->rxerror; + stats->tx_errors = cnt->txerror; stats->collisions = 0; stats->rx_length_errors = 0; - stats->rx_over_errors = WLCNTVAL(wl->pub->_cnt->rxoflo); - stats->rx_crc_errors = WLCNTVAL(wl->pub->_cnt->rxcrc); + stats->rx_over_errors = cnt->rxoflo; + stats->rx_crc_errors = cnt->rxcrc; stats->rx_frame_errors = 0; - stats->rx_fifo_errors = WLCNTVAL(wl->pub->_cnt->rxoflo); + stats->rx_fifo_errors = cnt->rxoflo; stats->rx_missed_errors = 0; - stats->tx_fifo_errors = WLCNTVAL(wl->pub->_cnt->txuflo); + stats->tx_fifo_errors = cnt->txuflo; wl->stats_id = id; - } return 0; @@ -1702,6 +1764,9 @@ char *wl_firmwares[WL_MAX_FW] = { NULL }; +/* + * precondition: perimeter lock has been acquired + */ int wl_ucode_init_buf(struct wl_info *wl, void **pbuf, u32 idx) { int i, entry; @@ -1715,19 +1780,25 @@ int wl_ucode_init_buf(struct wl_info *wl, void **pbuf, u32 idx) pdata = wl->fw.fw_bin[i]->data + hdr->offset; *pbuf = kmalloc(hdr->len, GFP_ATOMIC); if (*pbuf == NULL) { - printf("fail to alloc %d bytes\n", - hdr->len); + WL_ERROR("fail to alloc %d bytes\n", + hdr->len); + goto fail; } - bcopy(pdata, *pbuf, hdr->len); + memcpy(*pbuf, pdata, hdr->len); return 0; } } } - printf("ERROR: ucode buf tag:%d can not be found!\n", idx); + WL_ERROR("ERROR: ucode buf tag:%d can not be found!\n", idx); *pbuf = NULL; - return -1; +fail: + return BCME_NOTFOUND; } +/* + * Precondition: Since this function is called in wl_pci_probe() context, + * no locking is required. + */ int wl_ucode_init_uint(struct wl_info *wl, u32 *data, u32 idx) { int i, entry; @@ -1745,10 +1816,14 @@ int wl_ucode_init_uint(struct wl_info *wl, u32 *data, u32 idx) } } } - printf("ERROR: ucode tag:%d can not be found!\n", idx); + WL_ERROR("ERROR: ucode tag:%d can not be found!\n", idx); return -1; } +/* + * Precondition: Since this function is called in wl_pci_probe() context, + * no locking is required. + */ static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev) { int status; @@ -1765,9 +1840,8 @@ static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev) WL_NONE("request fw %s\n", fw_name); status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); if (status) { - printf("%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - wl_release_fw(wl); + WL_ERROR("%s: fail to load firmware %s\n", + KBUILD_MODNAME, fw_name); return status; } WL_NONE("request fw %s\n", fw_name); @@ -1775,9 +1849,8 @@ static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev) UCODE_LOADER_API_VER); status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); if (status) { - printf("%s: fail to load firmware %s\n", - KBUILD_MODNAME, fw_name); - wl_release_fw(wl); + WL_ERROR("%s: fail to load firmware %s\n", + KBUILD_MODNAME, fw_name); return status; } wl->fw.hdr_num_entries[i] = @@ -1789,11 +1862,18 @@ static int wl_request_fw(struct wl_info *wl, struct pci_dev *pdev) return wl_ucode_data_init(wl); } +/* + * precondition: can both be called locked and unlocked + */ void wl_ucode_free_buf(void *p) { kfree(p); } +/* + * Precondition: Since this function is called in wl_pci_probe() context, + * no locking is required. + */ static void wl_release_fw(struct wl_info *wl) { int i; @@ -1806,6 +1886,9 @@ static void wl_release_fw(struct wl_info *wl) /* * checks validity of all firmware images loaded from user space + * + * Precondition: Since this function is called in wl_pci_probe() context, + * no locking is required. */ int wl_check_firmwares(struct wl_info *wl) { @@ -1824,19 +1907,19 @@ int wl_check_firmwares(struct wl_info *wl) WL_ERROR("%s: invalid bin/hdr fw\n", __func__); rc = -EBADF; } else if (fw_hdr->size % sizeof(struct wl_fw_hdr)) { - WL_ERROR("%s: non integral fw hdr file size %d/%zu\n", + WL_ERROR("%s: non integral fw hdr file size %zu/%zu\n", __func__, fw_hdr->size, sizeof(struct wl_fw_hdr)); rc = -EBADF; } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) { - WL_ERROR("%s: out of bounds fw file size %d\n", + WL_ERROR("%s: out of bounds fw file size %zu\n", __func__, fw->size); rc = -EBADF; } else { /* check if ucode section overruns firmware image */ ucode_hdr = (struct wl_fw_hdr *)fw_hdr->data; - for (entry = 0; entry < wl->fw.hdr_num_entries[i] && rc; - entry++, ucode_hdr++) { + for (entry = 0; entry < wl->fw.hdr_num_entries[i] && + !rc; entry++, ucode_hdr++) { if (ucode_hdr->offset + ucode_hdr->len > fw->size) { WL_ERROR("%s: conflicting bin/hdr\n", @@ -1853,3 +1936,19 @@ int wl_check_firmwares(struct wl_info *wl) return rc; } +/* + * precondition: perimeter lock has been acquired + */ +bool wl_rfkill_set_hw_state(struct wl_info *wl) +{ + bool blocked = wlc_check_radio_disabled(wl->wlc); + + WL_NONE("%s: update hw state: blocked=%s\n", __func__, + blocked ? "true" : "false"); + WL_UNLOCK(wl); + wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked); + if (blocked) + wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy); + WL_LOCK(wl); + return blocked; +} diff --git a/drivers/staging/brcm80211/sys/wl_mac80211.h b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.h index bb39b7705947..f3198ccd5f58 100644 --- a/drivers/staging/brcm80211/sys/wl_mac80211.h +++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.h @@ -17,13 +17,11 @@ #ifndef _wl_mac80211_h_ #define _wl_mac80211_h_ -#include <wlc_types.h> - /* BMAC Note: High-only driver is no longer working in softirq context as it needs to block and * sleep so perimeter lock has to be a semaphore instead of spinlock. This requires timers to be * submitted to workqueue instead of being on kernel timer */ -typedef struct wl_timer { +struct wl_timer { struct timer_list timer; struct wl_info *wl; void (*fn) (void *); @@ -35,16 +33,7 @@ typedef struct wl_timer { #ifdef BCMDBG char *name; /* Description of the timer */ #endif -} wl_timer_t; - -/* contortion to call functions at safe time */ -/* In 2.6.20 kernels work functions get passed a pointer to the struct work, so things - * will continue to work as long as the work structure is the first component of the task structure. - */ -typedef struct wl_task { - struct work_struct work; - void *context; -} wl_task_t; +}; struct wl_if { uint subunit; /* WDS/BSS unit */ @@ -62,7 +51,6 @@ struct wl_firmware { struct wl_info { struct wlc_pub *pub; /* pointer to public wlc state */ void *wlc; /* pointer to private common os-independent data */ - struct osl_info *osh; /* pointer to os handler */ u32 magic; int irq; @@ -97,21 +85,4 @@ struct wl_info { #define INT_LOCK(wl, flags) spin_lock_irqsave(&(wl)->isr_lock, flags) #define INT_UNLOCK(wl, flags) spin_unlock_irqrestore(&(wl)->isr_lock, flags) -#ifndef PCI_D0 -#define PCI_D0 0 -#endif - -#ifndef PCI_D3hot -#define PCI_D3hot 3 -#endif - -/* exported functions */ - -extern irqreturn_t wl_isr(int irq, void *dev_id); - -extern int __devinit wl_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent); -extern void wl_free(struct wl_info *wl); -extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); - #endif /* _wl_mac80211_h_ */ diff --git a/drivers/staging/brcm80211/sys/wl_ucode.h b/drivers/staging/brcm80211/brcmsmac/wl_ucode.h index 2a0f4028f6f3..6933fda0e6a0 100644 --- a/drivers/staging/brcm80211/sys/wl_ucode.h +++ b/drivers/staging/brcm80211/brcmsmac/wl_ucode.h @@ -17,27 +17,27 @@ #define MIN_FW_SIZE 40000 /* minimum firmware file size in bytes */ #define MAX_FW_SIZE 150000 -typedef struct d11init { +#define UCODE_LOADER_API_VER 0 + +struct d11init { u16 addr; u16 size; u32 value; -} d11init_t; +}; -extern d11init_t *d11lcn0bsinitvals24; -extern d11init_t *d11lcn0initvals24; -extern d11init_t *d11lcn1bsinitvals24; -extern d11init_t *d11lcn1initvals24; -extern d11init_t *d11lcn2bsinitvals24; -extern d11init_t *d11lcn2initvals24; -extern d11init_t *d11n0absinitvals16; -extern d11init_t *d11n0bsinitvals16; -extern d11init_t *d11n0initvals16; +extern struct d11init *d11lcn0bsinitvals24; +extern struct d11init *d11lcn0initvals24; +extern struct d11init *d11lcn1bsinitvals24; +extern struct d11init *d11lcn1initvals24; +extern struct d11init *d11lcn2bsinitvals24; +extern struct d11init *d11lcn2initvals24; +extern struct d11init *d11n0absinitvals16; +extern struct d11init *d11n0bsinitvals16; +extern struct d11init *d11n0initvals16; extern u32 *bcm43xx_16_mimo; extern u32 bcm43xx_16_mimosz; extern u32 *bcm43xx_24_lcn; extern u32 bcm43xx_24_lcnsz; -extern u32 *bcm43xx_bommajor; -extern u32 *bcm43xx_bomminor; extern int wl_ucode_data_init(struct wl_info *wl); extern void wl_ucode_data_free(void); diff --git a/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c b/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c new file mode 100644 index 000000000000..cc00dd19746b --- /dev/null +++ b/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2010 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <linux/types.h> +#include <bcmdefs.h> +#include <wl_ucode.h> + +enum { + D11UCODE_NAMETAG_START = 0, + D11LCN0BSINITVALS24, + D11LCN0INITVALS24, + D11LCN1BSINITVALS24, + D11LCN1INITVALS24, + D11LCN2BSINITVALS24, + D11LCN2INITVALS24, + D11N0ABSINITVALS16, + D11N0BSINITVALS16, + D11N0INITVALS16, + D11UCODE_OVERSIGHT16_MIMO, + D11UCODE_OVERSIGHT16_MIMOSZ, + D11UCODE_OVERSIGHT24_LCN, + D11UCODE_OVERSIGHT24_LCNSZ, + D11UCODE_OVERSIGHT_BOMMAJOR, + D11UCODE_OVERSIGHT_BOMMINOR +}; + +struct d11init *d11lcn0bsinitvals24; +struct d11init *d11lcn0initvals24; +struct d11init *d11lcn1bsinitvals24; +struct d11init *d11lcn1initvals24; +struct d11init *d11lcn2bsinitvals24; +struct d11init *d11lcn2initvals24; +struct d11init *d11n0absinitvals16; +struct d11init *d11n0bsinitvals16; +struct d11init *d11n0initvals16; +u32 *bcm43xx_16_mimo; +u32 bcm43xx_16_mimosz; +u32 *bcm43xx_24_lcn; +u32 bcm43xx_24_lcnsz; +u32 *bcm43xx_bommajor; +u32 *bcm43xx_bomminor; + +int wl_ucode_data_init(struct wl_info *wl) +{ + int rc; + rc = wl_check_firmwares(wl); + + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn0bsinitvals24, + D11LCN0BSINITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn0initvals24, + D11LCN0INITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn1bsinitvals24, + D11LCN1BSINITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn1initvals24, + D11LCN1INITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn2bsinitvals24, + D11LCN2BSINITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11lcn2initvals24, + D11LCN2INITVALS24); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11n0absinitvals16, + D11N0ABSINITVALS16); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11n0bsinitvals16, + D11N0BSINITVALS16); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&d11n0initvals16, + D11N0INITVALS16); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&bcm43xx_16_mimo, + D11UCODE_OVERSIGHT16_MIMO); + rc = rc < 0 ? rc : wl_ucode_init_uint(wl, &bcm43xx_16_mimosz, + D11UCODE_OVERSIGHT16_MIMOSZ); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&bcm43xx_24_lcn, + D11UCODE_OVERSIGHT24_LCN); + rc = rc < 0 ? rc : wl_ucode_init_uint(wl, &bcm43xx_24_lcnsz, + D11UCODE_OVERSIGHT24_LCNSZ); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&bcm43xx_bommajor, + D11UCODE_OVERSIGHT_BOMMAJOR); + rc = rc < 0 ? rc : wl_ucode_init_buf(wl, (void **)&bcm43xx_bomminor, + D11UCODE_OVERSIGHT_BOMMINOR); + return rc; +} + +void wl_ucode_data_free(void) +{ + wl_ucode_free_buf((void *)d11lcn0bsinitvals24); + wl_ucode_free_buf((void *)d11lcn0initvals24); + wl_ucode_free_buf((void *)d11lcn1bsinitvals24); + wl_ucode_free_buf((void *)d11lcn1initvals24); + wl_ucode_free_buf((void *)d11lcn2bsinitvals24); + wl_ucode_free_buf((void *)d11lcn2initvals24); + wl_ucode_free_buf((void *)d11n0absinitvals16); + wl_ucode_free_buf((void *)d11n0bsinitvals16); + wl_ucode_free_buf((void *)d11n0initvals16); + wl_ucode_free_buf((void *)bcm43xx_16_mimo); + wl_ucode_free_buf((void *)bcm43xx_24_lcn); + wl_ucode_free_buf((void *)bcm43xx_bommajor); + wl_ucode_free_buf((void *)bcm43xx_bomminor); + + return; +} diff --git a/drivers/staging/brcm80211/sys/wlc_alloc.c b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c index 746439e8fd57..e928fa10834e 100644 --- a/drivers/staging/brcm80211/sys/wlc_alloc.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c @@ -14,30 +14,36 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/kernel.h> -#include <linux/string.h> +#include <linux/types.h> + #include <bcmdefs.h> -#include <wlc_cfg.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> #include <wlioctl.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_alloc.h> -#include <wl_dbg.h> -static struct wlc_pub *wlc_pub_malloc(struct osl_info *osh, uint unit, +#include "d11.h" +#include "wlc_types.h" +#include "wlc_cfg.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "wlc_alloc.h" +#include "wl_dbg.h" +#include "wlc_rate.h" +#include "wlc_bsscfg.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_channel.h" +#include "wlc_main.h" + +static struct wlc_bsscfg *wlc_bsscfg_malloc(uint unit); +static void wlc_bsscfg_mfree(struct wlc_bsscfg *cfg); +static struct wlc_pub *wlc_pub_malloc(uint unit, uint *err, uint devid); -static void wlc_pub_mfree(struct osl_info *osh, struct wlc_pub *pub); +static void wlc_pub_mfree(struct wlc_pub *pub); static void wlc_tunables_init(wlc_tunables_t *tunables, uint devid); -void *wlc_calloc(struct osl_info *osh, uint unit, uint size) +void *wlc_calloc(uint unit, uint size) { void *item; @@ -65,18 +71,17 @@ void wlc_tunables_init(wlc_tunables_t *tunables, uint devid) tunables->txsbnd = TXSBND; } -static struct wlc_pub *wlc_pub_malloc(struct osl_info *osh, uint unit, - uint *err, uint devid) +static struct wlc_pub *wlc_pub_malloc(uint unit, uint *err, uint devid) { struct wlc_pub *pub; - pub = (struct wlc_pub *) wlc_calloc(osh, unit, sizeof(struct wlc_pub)); + pub = wlc_calloc(unit, sizeof(struct wlc_pub)); if (pub == NULL) { *err = 1001; goto fail; } - pub->tunables = (wlc_tunables_t *)wlc_calloc(osh, unit, + pub->tunables = wlc_calloc(unit, sizeof(wlc_tunables_t)); if (pub->tunables == NULL) { *err = 1028; @@ -86,8 +91,12 @@ static struct wlc_pub *wlc_pub_malloc(struct osl_info *osh, uint unit, /* need to init the tunables now */ wlc_tunables_init(pub->tunables, devid); - pub->multicast = (struct ether_addr *)wlc_calloc(osh, unit, - (sizeof(struct ether_addr) * MAXMULTILIST)); + pub->_cnt = wlc_calloc(unit, sizeof(struct wl_cnt)); + if (pub->_cnt == NULL) + goto fail; + + pub->multicast = (u8 *)wlc_calloc(unit, + (ETH_ALEN * MAXMULTILIST)); if (pub->multicast == NULL) { *err = 1003; goto fail; @@ -96,34 +105,30 @@ static struct wlc_pub *wlc_pub_malloc(struct osl_info *osh, uint unit, return pub; fail: - wlc_pub_mfree(osh, pub); + wlc_pub_mfree(pub); return NULL; } -static void wlc_pub_mfree(struct osl_info *osh, struct wlc_pub *pub) +static void wlc_pub_mfree(struct wlc_pub *pub) { if (pub == NULL) return; - if (pub->multicast) - kfree(pub->multicast); - if (pub->tunables) { - kfree(pub->tunables); - pub->tunables = NULL; - } - + kfree(pub->multicast); + kfree(pub->_cnt); + kfree(pub->tunables); kfree(pub); } -wlc_bsscfg_t *wlc_bsscfg_malloc(struct osl_info *osh, uint unit) +static struct wlc_bsscfg *wlc_bsscfg_malloc(uint unit) { - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; - cfg = (wlc_bsscfg_t *) wlc_calloc(osh, unit, sizeof(wlc_bsscfg_t)); + cfg = (struct wlc_bsscfg *) wlc_calloc(unit, sizeof(struct wlc_bsscfg)); if (cfg == NULL) goto fail; - cfg->current_bss = (wlc_bss_info_t *)wlc_calloc(osh, unit, + cfg->current_bss = (wlc_bss_info_t *)wlc_calloc(unit, sizeof(wlc_bss_info_t)); if (cfg->current_bss == NULL) goto fail; @@ -131,32 +136,21 @@ wlc_bsscfg_t *wlc_bsscfg_malloc(struct osl_info *osh, uint unit) return cfg; fail: - wlc_bsscfg_mfree(osh, cfg); + wlc_bsscfg_mfree(cfg); return NULL; } -void wlc_bsscfg_mfree(struct osl_info *osh, wlc_bsscfg_t *cfg) +static void wlc_bsscfg_mfree(struct wlc_bsscfg *cfg) { if (cfg == NULL) return; - if (cfg->maclist) { - kfree(cfg->maclist); - cfg->maclist = NULL; - } - - if (cfg->current_bss != NULL) { - wlc_bss_info_t *current_bss = cfg->current_bss; - if (current_bss->bcn_prb != NULL) - kfree(current_bss->bcn_prb); - kfree(current_bss); - cfg->current_bss = NULL; - } - + kfree(cfg->maclist); + kfree(cfg->current_bss); kfree(cfg); } -void wlc_bsscfg_ID_assign(struct wlc_info *wlc, wlc_bsscfg_t *bsscfg) +void wlc_bsscfg_ID_assign(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg) { bsscfg->ID = wlc->next_bsscfg_ID; wlc->next_bsscfg_ID++; @@ -165,13 +159,11 @@ void wlc_bsscfg_ID_assign(struct wlc_info *wlc, wlc_bsscfg_t *bsscfg) /* * The common driver entry routine. Error codes should be unique */ -struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, - uint devid) +struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid) { struct wlc_info *wlc; - wlc = (struct wlc_info *) wlc_calloc(osh, unit, - sizeof(struct wlc_info)); + wlc = (struct wlc_info *) wlc_calloc(unit, sizeof(struct wlc_info)); if (wlc == NULL) { *err = 1002; goto fail; @@ -180,7 +172,7 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, wlc->hwrxoff = WL_HWRXOFF; /* allocate struct wlc_pub state structure */ - wlc->pub = wlc_pub_malloc(osh, unit, err, devid); + wlc->pub = wlc_pub_malloc(unit, err, devid); if (wlc->pub == NULL) { *err = 1003; goto fail; @@ -189,16 +181,16 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, /* allocate struct wlc_hw_info state structure */ - wlc->hw = (struct wlc_hw_info *)wlc_calloc(osh, unit, - sizeof(struct wlc_hw_info)); + wlc->hw = (struct wlc_hw_info *)wlc_calloc(unit, + sizeof(struct wlc_hw_info)); if (wlc->hw == NULL) { *err = 1005; goto fail; } wlc->hw->wlc = wlc; - wlc->hw->bandstate[0] = (wlc_hwband_t *)wlc_calloc(osh, unit, - (sizeof(wlc_hwband_t) * MAXBANDS)); + wlc->hw->bandstate[0] = wlc_calloc(unit, + (sizeof(struct wlc_hwband) * MAXBANDS)); if (wlc->hw->bandstate[0] == NULL) { *err = 1006; goto fail; @@ -206,41 +198,41 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, int i; for (i = 1; i < MAXBANDS; i++) { - wlc->hw->bandstate[i] = (wlc_hwband_t *) + wlc->hw->bandstate[i] = (struct wlc_hwband *) ((unsigned long)wlc->hw->bandstate[0] + - (sizeof(wlc_hwband_t) * i)); + (sizeof(struct wlc_hwband) * i)); } } - wlc->modulecb = (modulecb_t *)wlc_calloc(osh, unit, - sizeof(modulecb_t) * WLC_MAXMODULES); + wlc->modulecb = wlc_calloc(unit, + sizeof(struct modulecb) * WLC_MAXMODULES); if (wlc->modulecb == NULL) { *err = 1009; goto fail; } - wlc->default_bss = (wlc_bss_info_t *)wlc_calloc(osh, unit, + wlc->default_bss = (wlc_bss_info_t *)wlc_calloc(unit, sizeof(wlc_bss_info_t)); if (wlc->default_bss == NULL) { *err = 1010; goto fail; } - wlc->cfg = wlc_bsscfg_malloc(osh, unit); + wlc->cfg = wlc_bsscfg_malloc(unit); if (wlc->cfg == NULL) { *err = 1011; goto fail; } wlc_bsscfg_ID_assign(wlc, wlc->cfg); - wlc->pkt_callback = (pkt_cb_t *)wlc_calloc(osh, unit, - (sizeof(pkt_cb_t) * (wlc->pub->tunables->maxpktcb + 1))); + wlc->pkt_callback = wlc_calloc(unit, + (sizeof(struct pkt_cb) * (wlc->pub->tunables->maxpktcb + 1))); if (wlc->pkt_callback == NULL) { *err = 1013; goto fail; } - wlc->wsec_def_keys[0] = (wsec_key_t *)wlc_calloc(osh, unit, + wlc->wsec_def_keys[0] = (wsec_key_t *)wlc_calloc(unit, (sizeof(wsec_key_t) * WLC_DEFAULT_KEYS)); if (wlc->wsec_def_keys[0] == NULL) { *err = 1015; @@ -254,20 +246,20 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, } } - wlc->protection = (wlc_protection_t *)wlc_calloc(osh, unit, - sizeof(wlc_protection_t)); + wlc->protection = wlc_calloc(unit, + sizeof(struct wlc_protection)); if (wlc->protection == NULL) { *err = 1016; goto fail; } - wlc->stf = (wlc_stf_t *)wlc_calloc(osh, unit, sizeof(wlc_stf_t)); + wlc->stf = wlc_calloc(unit, sizeof(struct wlc_stf)); if (wlc->stf == NULL) { *err = 1017; goto fail; } - wlc->bandstate[0] = (struct wlcband *)wlc_calloc(osh, unit, + wlc->bandstate[0] = (struct wlcband *)wlc_calloc(unit, (sizeof(struct wlcband)*MAXBANDS)); if (wlc->bandstate[0] == NULL) { *err = 1025; @@ -282,7 +274,7 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, } } - wlc->corestate = (struct wlccore *)wlc_calloc(osh, unit, + wlc->corestate = (struct wlccore *)wlc_calloc(unit, sizeof(struct wlccore)); if (wlc->corestate == NULL) { *err = 1026; @@ -290,7 +282,7 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, } wlc->corestate->macstat_snapshot = - (macstat_t *)wlc_calloc(osh, unit, sizeof(macstat_t)); + (macstat_t *)wlc_calloc(unit, sizeof(macstat_t)); if (wlc->corestate->macstat_snapshot == NULL) { *err = 1027; goto fail; @@ -299,73 +291,28 @@ struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, uint *err, return wlc; fail: - wlc_detach_mfree(wlc, osh); + wlc_detach_mfree(wlc); return NULL; } -void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh) +void wlc_detach_mfree(struct wlc_info *wlc) { if (wlc == NULL) return; - if (wlc->modulecb) { - kfree(wlc->modulecb); - wlc->modulecb = NULL; - } - - if (wlc->default_bss) { - kfree(wlc->default_bss); - wlc->default_bss = NULL; - } - if (wlc->cfg) { - wlc_bsscfg_mfree(osh, wlc->cfg); - wlc->cfg = NULL; - } - - if (wlc->pkt_callback && wlc->pub && wlc->pub->tunables) { - kfree(wlc->pkt_callback); - wlc->pkt_callback = NULL; - } - - if (wlc->wsec_def_keys[0]) - kfree(wlc->wsec_def_keys[0]); - if (wlc->protection) { - kfree(wlc->protection); - wlc->protection = NULL; - } - - if (wlc->stf) { - kfree(wlc->stf); - wlc->stf = NULL; - } - - if (wlc->bandstate[0]) - kfree(wlc->bandstate[0]); - - if (wlc->corestate) { - if (wlc->corestate->macstat_snapshot) { - kfree(wlc->corestate->macstat_snapshot); wlc->corestate->macstat_snapshot = NULL; - } - kfree(wlc->corestate); - wlc->corestate = NULL; - } - - if (wlc->pub) { - /* free pub struct */ - wlc_pub_mfree(osh, wlc->pub); - wlc->pub = NULL; - } - - if (wlc->hw) { - if (wlc->hw->bandstate[0]) { - kfree(wlc->hw->bandstate[0]); - wlc->hw->bandstate[0] = NULL; - } - - /* free hw struct */ - kfree(wlc->hw); - wlc->hw = NULL; - } + wlc_bsscfg_mfree(wlc->cfg); + wlc_pub_mfree(wlc->pub); + kfree(wlc->modulecb); + kfree(wlc->default_bss); + kfree(wlc->pkt_callback); + kfree(wlc->wsec_def_keys[0]); + kfree(wlc->protection); + kfree(wlc->stf); + kfree(wlc->bandstate[0]); + kfree(wlc->corestate->macstat_snapshot); + kfree(wlc->corestate); + kfree(wlc->hw->bandstate[0]); + kfree(wlc->hw); /* free the wlc */ kfree(wlc); diff --git a/drivers/staging/brcm80211/sys/wlc_alloc.h b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.h index ac34f782b400..1fb7430b26a9 100644 --- a/drivers/staging/brcm80211/sys/wlc_alloc.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.h @@ -14,12 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -extern void *wlc_calloc(struct osl_info *osh, uint unit, uint size); +extern void *wlc_calloc(uint unit, uint size); -extern struct wlc_info *wlc_attach_malloc(struct osl_info *osh, uint unit, - uint *err, uint devid); -extern void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh); - -struct wlc_bsscfg; -extern struct wlc_bsscfg *wlc_bsscfg_malloc(struct osl_info *osh, uint unit); -extern void wlc_bsscfg_mfree(struct osl_info *osh, struct wlc_bsscfg *cfg); +extern struct wlc_info *wlc_attach_malloc(uint unit, uint *err, uint devid); +extern void wlc_detach_mfree(struct wlc_info *wlc); diff --git a/drivers/staging/brcm80211/sys/wlc_ampdu.c b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c index d749917f5912..c6cdcd940956 100644 --- a/drivers/staging/brcm80211/sys/wlc_ampdu.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c @@ -14,30 +14,35 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/kernel.h> -#include <wlc_cfg.h> +#include <net/mac80211.h> + #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> #include <wlioctl.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <hnddma.h> #include <d11.h> -#include <wlc_rate.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_phy_hal.h> -#include <wlc_antsel.h> -#include <wlc_scb.h> -#include <net/mac80211.h> -#include <wlc_ampdu.h> -#include <wl_export.h> -#include <wl_dbg.h> +#include "wlc_types.h" +#include "wlc_cfg.h" +#include "wlc_rate.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_antsel.h" +#include "wl_export.h" +#include "wl_dbg.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wlc_ampdu.h" + +/* + * Disable AMPDU statistics counters for now + */ +#define WLCNTINCR(a) +#define WLCNTADD(a, b) #define AMPDU_MAX_MPDU 32 /* max number of mpdus in an ampdu */ #define AMPDU_NUM_MPDU_LEGACY 16 /* max number of mpdus in an ampdu to a legacy */ @@ -67,7 +72,8 @@ #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE) /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */ -#define AMPDU_MAX_MPDU_OVERHEAD (DOT11_FCS_LEN + DOT11_ICV_AES_LEN + AMPDU_DELIMITER_LEN + 3 \ +#define AMPDU_MAX_MPDU_OVERHEAD (FCS_LEN + DOT11_ICV_AES_LEN +\ + AMPDU_DELIMITER_LEN + 3\ + DOT11_A4_HDR_LEN + DOT11_QOS_LEN + DOT11_IV_MAX_LEN) #ifdef BCMDBG @@ -150,15 +156,8 @@ static void wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p, tx_status_t *txs, u32 frmtxstatus, u32 frmtxstatus2); - -static inline u16 pkt_txh_seqnum(struct wlc_info *wlc, struct sk_buff *p) -{ - d11txh_t *txh; - struct dot11_header *h; - txh = (d11txh_t *) p->data; - h = (struct dot11_header *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - return ltoh16(h->seq) >> SEQNUM_SHIFT; -} +static bool wlc_ampdu_cap(struct ampdu_info *ampdu); +static int wlc_ampdu_set(struct ampdu_info *ampdu, bool on); struct ampdu_info *wlc_ampdu_attach(struct wlc_info *wlc) { @@ -200,9 +199,9 @@ struct ampdu_info *wlc_ampdu_attach(struct wlc_info *wlc) ampdu->ffpld_rsvd = AMPDU_DEF_FFPLD_RSVD; /* bump max ampdu rcv size to 64k for all 11n devices except 4321A0 and 4321A1 */ if (WLCISNPHY(wlc->band) && NREV_LT(wlc->band->phyrev, 2)) - ampdu->rx_factor = AMPDU_RX_FACTOR_32K; + ampdu->rx_factor = IEEE80211_HT_MAX_AMPDU_32K; else - ampdu->rx_factor = AMPDU_RX_FACTOR_64K; + ampdu->rx_factor = IEEE80211_HT_MAX_AMPDU_64K; ampdu->retry_limit = AMPDU_DEF_RETRY_LIMIT; ampdu->rr_retry_limit = AMPDU_DEF_RR_RETRY_LIMIT; @@ -231,9 +230,7 @@ void wlc_ampdu_detach(struct ampdu_info *ampdu) /* free all ini's which were to be freed on callbacks which were never called */ for (i = 0; i < AMPDU_INI_FREE; i++) { - if (ampdu->ini_free[i]) { - kfree(ampdu->ini_free[i]); - } + kfree(ampdu->ini_free[i]); } wlc_module_unregister(ampdu->wlc->pub, "ampdu", ampdu); @@ -491,11 +488,10 @@ wlc_ampdu_agg(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p, } int BCMFASTPATH -wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, +wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi, struct sk_buff **pdu, int prec) { struct wlc_info *wlc; - struct osl_info *osh; struct sk_buff *p, *pkt[AMPDU_MAX_MPDU]; u8 tid, ndelim; int err = 0; @@ -510,7 +506,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, u32 ampdu_len, maxlen = 0; d11txh_t *txh = NULL; u8 *plcp; - struct dot11_header *h; + struct ieee80211_hdr *h; struct scb *scb; scb_ampdu_t *scb_ampdu; scb_ampdu_tid_ini_t *ini; @@ -519,7 +515,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, ratespec_t rspec = 0, rspec_fallback = 0; ratespec_t rts_rspec = 0, rts_rspec_fallback = 0; u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; - struct dot11_rts_frame *rts; + struct ieee80211_rts *rts; u8 rr_retry_limit; wlc_fifo_info_t *f; bool fbr_iscck; @@ -527,7 +523,6 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, u16 qlen; wlc = ampdu->wlc; - osh = wlc->osh; p = *pdu; ASSERT(p); @@ -596,14 +591,14 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU); txh = (d11txh_t *) p->data; plcp = (u8 *) (txh + 1); - h = (struct dot11_header *)(plcp + D11_PHY_HDR_LEN); - seq = ltoh16(h->seq) >> SEQNUM_SHIFT; + h = (struct ieee80211_hdr *)(plcp + D11_PHY_HDR_LEN); + seq = le16_to_cpu(h->seq_ctrl) >> SEQNUM_SHIFT; index = TX_SEQ_TO_INDEX(seq); /* check mcl fields and test whether it can be agg'd */ - mcl = ltoh16(txh->MacTxControlLow); + mcl = le16_to_cpu(txh->MacTxControlLow); mcl &= ~TXC_AMPDU_MASK; - fbr_iscck = !(ltoh16(txh->XtraFrameTypes) & 0x3); + fbr_iscck = !(le16_to_cpu(txh->XtraFrameTypes) & 0x3); ASSERT(!fbr_iscck); txh->PreloadSize = 0; /* always default to 0 */ @@ -635,17 +630,16 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, * test whether need to break or change the epoch */ if (count == 0) { - u16 fc; mcl |= (TXC_AMPDU_FIRST << TXC_AMPDU_SHIFT); /* refill the bits since might be a retx mpdu */ mcl |= TXC_STARTMSDU; - rts = (struct dot11_rts_frame *)&txh->rts_frame; - fc = ltoh16(rts->fc); - if ((fc & FC_KIND_MASK) == FC_RTS) { + rts = (struct ieee80211_rts *)&txh->rts_frame; + + if (ieee80211_is_rts(rts->frame_control)) { mcl |= TXC_SENDRTS; use_rts = true; } - if ((fc & FC_KIND_MASK) == FC_CTS) { + if (ieee80211_is_cts(rts->frame_control)) { mcl |= TXC_SENDCTS; use_cts = true; } @@ -657,12 +651,12 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, len = roundup(len, 4); ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); - dma_len += (u16) pkttotlen(osh, p); + dma_len += (u16) pkttotlen(p); WL_AMPDU_TX("wl%d: wlc_sendampdu: ampdu_len %d seg_cnt %d null delim %d\n", wlc->pub->unit, ampdu_len, seg_cnt, ndelim); - txh->MacTxControlLow = htol16(mcl); + txh->MacTxControlLow = cpu_to_le16(mcl); /* this packet is added */ pkt[count++] = p; @@ -754,7 +748,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, ((u8) (p->priority) == tid)) { plen = - pkttotlen(osh, p) + AMPDU_MAX_MPDU_OVERHEAD; + pkttotlen(p) + AMPDU_MAX_MPDU_OVERHEAD; plen = max(scb_ampdu->min_len, plen); if ((plen + ampdu_len) > maxlen) { @@ -787,10 +781,10 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, /* patch up the last txh */ txh = (d11txh_t *) pkt[count - 1]->data; - mcl = ltoh16(txh->MacTxControlLow); + mcl = le16_to_cpu(txh->MacTxControlLow); mcl &= ~TXC_AMPDU_MASK; mcl |= (TXC_AMPDU_LAST << TXC_AMPDU_SHIFT); - txh->MacTxControlLow = htol16(mcl); + txh->MacTxControlLow = cpu_to_le16(mcl); /* remove the null delimiter after last mpdu */ ndelim = txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM]; @@ -798,7 +792,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, ampdu_len -= ndelim * AMPDU_DELIMITER_LEN; /* remove the pad len from last mpdu */ - fbr_iscck = ((ltoh16(txh->XtraFrameTypes) & 0x3) == 0); + fbr_iscck = ((le16_to_cpu(txh->XtraFrameTypes) & 0x3) == 0); len = fbr_iscck ? WLC_GET_CCK_PLCP_LEN(txh->FragPLCPFallback) : WLC_GET_MIMO_PLCP_LEN(txh->FragPLCPFallback); ampdu_len -= roundup(len, 4) - len; @@ -815,29 +809,29 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, if (txh->MModeLen) { u16 mmodelen = wlc_calc_lsig_len(wlc, rspec, ampdu_len); - txh->MModeLen = htol16(mmodelen); + txh->MModeLen = cpu_to_le16(mmodelen); preamble_type = WLC_MM_PREAMBLE; } if (txh->MModeFbrLen) { u16 mmfbrlen = wlc_calc_lsig_len(wlc, rspec_fallback, ampdu_len); - txh->MModeFbrLen = htol16(mmfbrlen); + txh->MModeFbrLen = cpu_to_le16(mmfbrlen); fbr_preamble_type = WLC_MM_PREAMBLE; } /* set the preload length */ if (MCS_RATE(mcs, true, false) >= f->dmaxferrate) { dma_len = min(dma_len, f->ampdu_pld_size); - txh->PreloadSize = htol16(dma_len); + txh->PreloadSize = cpu_to_le16(dma_len); } else txh->PreloadSize = 0; - mch = ltoh16(txh->MacTxControlHigh); + mch = le16_to_cpu(txh->MacTxControlHigh); /* update RTS dur fields */ if (use_rts || use_cts) { u16 durid; - rts = (struct dot11_rts_frame *)&txh->rts_frame; + rts = (struct ieee80211_rts *)&txh->rts_frame; if ((mch & TXC_PREAMBLE_RTS_MAIN_SHORT) == TXC_PREAMBLE_RTS_MAIN_SHORT) rts_preamble_type = WLC_SHORT_PREAMBLE; @@ -851,16 +845,16 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, rspec, rts_preamble_type, preamble_type, ampdu_len, true); - rts->durid = htol16(durid); + rts->duration = cpu_to_le16(durid); durid = wlc_compute_rtscts_dur(wlc, use_cts, rts_rspec_fallback, rspec_fallback, rts_fbr_preamble_type, fbr_preamble_type, ampdu_len, true); - txh->RTSDurFallback = htol16(durid); + txh->RTSDurFallback = cpu_to_le16(durid); /* set TxFesTimeNormal */ - txh->TxFesTimeNormal = rts->durid; + txh->TxFesTimeNormal = rts->duration; /* set fallback rate version of TxFesTimeNormal */ txh->TxFesTimeFallback = txh->RTSDurFallback; } @@ -870,7 +864,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, WLCNTADD(ampdu->cnt->txfbr_mpdu, count); WLCNTINCR(ampdu->cnt->txfbr_ampdu); mch |= TXC_AMPDU_FBR; - txh->MacTxControlHigh = htol16(mch); + txh->MacTxControlHigh = cpu_to_le16(mch); WLC_SET_MIMO_PLCP_AMPDU(plcp); WLC_SET_MIMO_PLCP_AMPDU(txh->FragPLCPFallback); } @@ -879,7 +873,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, wlc->pub->unit, count, ampdu_len); /* inform rate_sel if it this is a rate probe pkt */ - frameid = ltoh16(txh->TxFrameID); + frameid = le16_to_cpu(txh->TxFrameID); if (frameid & TXFID_RATE_PROBE_MASK) { WL_ERROR("%s: XXX what to do with TXFID_RATE_PROBE_MASK!?\n", __func__); @@ -905,13 +899,7 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, tx_info = IEEE80211_SKB_CB(p); ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU); - ASSERT(scb); - ASSERT(scb->magic == SCB_MAGIC); ASSERT(txs->status & TX_STATUS_AMPDU); - scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); - ASSERT(scb_ampdu); - ini = SCB_AMPDU_INI(scb_ampdu, p->priority); - ASSERT(ini->scb == scb); /* BMAC_NOTE: For the split driver, second level txstatus comes later * So if the ACK was received then wait for the second level else just @@ -921,9 +909,7 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, u8 status_delay = 0; /* wait till the next 8 bytes of txstatus is available */ - while (((s1 = - R_REG(wlc->osh, - &wlc->regs->frmtxstatus)) & TXS_V) == 0) { + while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { udelay(1); status_delay++; if (status_delay > 10) { @@ -934,10 +920,36 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, ASSERT(!(s1 & TX_STATUS_INTERMEDIATE)); ASSERT(s1 & TX_STATUS_AMPDU); - s2 = R_REG(wlc->osh, &wlc->regs->frmtxstatus2); + s2 = R_REG(&wlc->regs->frmtxstatus2); } - wlc_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); + if (likely(scb)) { + ASSERT(scb->magic == SCB_MAGIC); + scb_ampdu = SCB_AMPDU_CUBBY(ampdu, scb); + ASSERT(scb_ampdu); + ini = SCB_AMPDU_INI(scb_ampdu, p->priority); + ASSERT(ini->scb == scb); + wlc_ampdu_dotxstatus_complete(ampdu, scb, p, txs, s1, s2); + } else { + /* loop through all pkts and free */ + u8 queue = txs->frameid & TXFID_QUEUE_MASK; + d11txh_t *txh; + u16 mcl; + while (p) { + tx_info = IEEE80211_SKB_CB(p); + txh = (d11txh_t *) p->data; + mcl = le16_to_cpu(txh->MacTxControlLow); + ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU); + pkt_buf_free_skb(p); + /* break out if last packet of ampdu */ + if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) == + TXC_AMPDU_LAST) + break; + p = GETNEXTTXP(wlc, queue); + ASSERT(p != NULL); + } + wlc_txfifo_complete(wlc, queue, ampdu->txpkt_weight); + } wlc_ampdu_txflowcontrol(wlc, scb_ampdu, ini); } @@ -968,7 +980,7 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, u8 bitmap[8], queue, tid; d11txh_t *txh; u8 *plcp; - struct dot11_header *h; + struct ieee80211_hdr *h; u16 seq, start_seq = 0, bindex, index, mcl; u8 mcs = 0; bool ba_recd = false, ack_recd = false; @@ -1051,10 +1063,10 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, if (supr_status == TX_STATUS_SUPR_BADCH || supr_status == TX_STATUS_SUPR_EXPTIME) { retry = false; - WLCNTINCR(wlc->pub->_cnt->txchanrej); + wlc->pub->_cnt->txchanrej++; } else if (supr_status == TX_STATUS_SUPR_EXPTIME) { - WLCNTINCR(wlc->pub->_cnt->txexptime); + wlc->pub->_cnt->txexptime++; /* TX underflow : try tuning pre-loading or ampdu size */ } else if (supr_status == TX_STATUS_SUPR_FRAG) { @@ -1068,17 +1080,15 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, } } else if (txs->phyerr) { update_rate = false; - WLCNTINCR(wlc->pub->_cnt->txphyerr); + wlc->pub->_cnt->txphyerr++; WL_ERROR("wl%d: wlc_ampdu_dotxstatus: tx phy error (0x%x)\n", wlc->pub->unit, txs->phyerr); -#ifdef BCMDBG if (WL_ERROR_ON()) { - prpkt("txpkt (AMPDU)", wlc->osh, p); + prpkt("txpkt (AMPDU)", p); wlc_print_txdesc((d11txh_t *) p->data); - wlc_print_txstatus(txs); } -#endif /* BCMDBG */ + wlc_print_txstatus(txs); } } @@ -1087,14 +1097,14 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, tx_info = IEEE80211_SKB_CB(p); ASSERT(tx_info->flags & IEEE80211_TX_CTL_AMPDU); txh = (d11txh_t *) p->data; - mcl = ltoh16(txh->MacTxControlLow); + mcl = le16_to_cpu(txh->MacTxControlLow); plcp = (u8 *) (txh + 1); - h = (struct dot11_header *)(plcp + D11_PHY_HDR_LEN); - seq = ltoh16(h->seq) >> SEQNUM_SHIFT; + h = (struct ieee80211_hdr *)(plcp + D11_PHY_HDR_LEN); + seq = le16_to_cpu(h->seq_ctrl) >> SEQNUM_SHIFT; if (tot_mpdu == 0) { mcs = plcp[0] & MIMO_PLCP_MCS_MASK; - mimoantsel = ltoh16(txh->ABI_MimoAntSel); + mimoantsel = le16_to_cpu(txh->ABI_MimoAntSel); } index = TX_SEQ_TO_INDEX(seq); @@ -1179,8 +1189,7 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb, wlc_send_q(wlc, wlc->active_queue); /* update rate state */ - if (WLANTSEL_ENAB(wlc)) - antselid = wlc_antsel_antsel2id(wlc->asi, mimoantsel); + antselid = wlc_antsel_antsel2id(wlc->asi, mimoantsel); wlc_txfifo_complete(wlc, queue, ampdu->txpkt_weight); } @@ -1204,7 +1213,7 @@ ampdu_cleanup_tid_ini(struct ampdu_info *ampdu, scb_ampdu_t *scb_ampdu, u8 tid, ASSERT(ini == &scb_ampdu->ini[ini->tid]); /* free all buffered tx packets */ - pktq_pflush(ampdu->wlc->osh, &scb_ampdu->txq, ini->tid, true, NULL, 0); + pktq_pflush(&scb_ampdu->txq, ini->tid, true, NULL, 0); } /* initialize the initiator code for tid */ @@ -1234,7 +1243,7 @@ static scb_ampdu_tid_ini_t *wlc_ampdu_init_tid_ini(struct ampdu_info *ampdu, return ini; } -int wlc_ampdu_set(struct ampdu_info *ampdu, bool on) +static int wlc_ampdu_set(struct ampdu_info *ampdu, bool on) { struct wlc_info *wlc = ampdu->wlc; @@ -1257,7 +1266,7 @@ int wlc_ampdu_set(struct ampdu_info *ampdu, bool on) return 0; } -bool wlc_ampdu_cap(struct ampdu_info *ampdu) +static bool wlc_ampdu_cap(struct ampdu_info *ampdu) { if (WLC_PHY_11N_CAP(ampdu->wlc->band)) return true; @@ -1329,7 +1338,7 @@ void wlc_ampdu_macaddr_upd(struct wlc_info *wlc) /* driver needs to write the ta in the template; ta is at offset 16 */ memset(template, 0, sizeof(template)); - bcopy((char *)wlc->pub->cur_etheraddr.octet, template, ETH_ALEN); + memcpy(template, wlc->pub->cur_etheraddr, ETH_ALEN); wlc_write_template_ram(wlc, (T_BA_TPL_BASE + 16), (T_RAM_ACCESS_SZ * 2), template); } @@ -1344,8 +1353,8 @@ void wlc_ampdu_shm_upd(struct ampdu_info *ampdu) struct wlc_info *wlc = ampdu->wlc; /* Extend ucode internal watchdog timer to match larger received frames */ - if ((ampdu->rx_factor & HT_PARAMS_RX_FACTOR_MASK) == - AMPDU_RX_FACTOR_64K) { + if ((ampdu->rx_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) == + IEEE80211_HT_MAX_AMPDU_64K) { wlc_write_shm(wlc, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX); wlc_write_shm(wlc, M_WATCHDOG_8TU, WATCHDOG_8TU_MAX); } else { @@ -1353,3 +1362,60 @@ void wlc_ampdu_shm_upd(struct ampdu_info *ampdu) wlc_write_shm(wlc, M_WATCHDOG_8TU, WATCHDOG_8TU_DEF); } } + +struct cb_del_ampdu_pars { + struct ieee80211_sta *sta; + u16 tid; +}; + +/* + * callback function that helps flushing ampdu packets from a priority queue + */ +static bool cb_del_ampdu_pkt(void *p, int arg_a) +{ + struct sk_buff *mpdu = (struct sk_buff *)p; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(mpdu); + struct cb_del_ampdu_pars *ampdu_pars = + (struct cb_del_ampdu_pars *)arg_a; + bool rc; + + rc = tx_info->flags & IEEE80211_TX_CTL_AMPDU ? true : false; + rc = rc && (tx_info->control.sta == NULL || ampdu_pars->sta == NULL || + tx_info->control.sta == ampdu_pars->sta); + rc = rc && ((u8)(mpdu->priority) == ampdu_pars->tid); + return rc; +} + +/* + * callback function that helps invalidating ampdu packets in a DMA queue + */ +static void dma_cb_fn_ampdu(void *txi, void *arg_a) +{ + struct ieee80211_sta *sta = arg_a; + struct ieee80211_tx_info *tx_info = (struct ieee80211_tx_info *)txi; + + if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && + (tx_info->control.sta == sta || sta == NULL)) + tx_info->control.sta = NULL; +} + +/* + * When a remote party is no longer available for ampdu communication, any + * pending tx ampdu packets in the driver have to be flushed. + */ +void wlc_ampdu_flush(struct wlc_info *wlc, + struct ieee80211_sta *sta, u16 tid) +{ + struct wlc_txq_info *qi = wlc->active_queue; + struct pktq *pq = &qi->q; + int prec; + struct cb_del_ampdu_pars ampdu_pars; + + ampdu_pars.sta = sta; + ampdu_pars.tid = tid; + for (prec = 0; prec < pq->num_prec; prec++) { + pktq_pflush(pq, prec, true, cb_del_ampdu_pkt, + (int)&du_pars); + } + wlc_inval_dma_pkts(wlc->hw, sta, dma_cb_fn_ampdu); +} diff --git a/drivers/staging/brcm80211/sys/wlc_ampdu.h b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.h index 03457f63f2ab..17e9ebc0dfe2 100644 --- a/drivers/staging/brcm80211/sys/wlc_ampdu.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_ampdu.h @@ -19,18 +19,14 @@ extern struct ampdu_info *wlc_ampdu_attach(struct wlc_info *wlc); extern void wlc_ampdu_detach(struct ampdu_info *ampdu); -extern bool wlc_ampdu_cap(struct ampdu_info *ampdu); -extern int wlc_ampdu_set(struct ampdu_info *ampdu, bool on); -extern int wlc_sendampdu(struct ampdu_info *ampdu, wlc_txq_info_t *qi, +extern int wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi, struct sk_buff **aggp, int prec); extern void wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, struct sk_buff *p, tx_status_t *txs); extern void wlc_ampdu_reset(struct ampdu_info *ampdu); extern void wlc_ampdu_macaddr_upd(struct wlc_info *wlc); extern void wlc_ampdu_shm_upd(struct ampdu_info *ampdu); - extern u8 wlc_ampdu_null_delim_cnt(struct ampdu_info *ampdu, struct scb *scb, ratespec_t rspec, int phylen); -extern void scb_ampdu_cleanup(struct ampdu_info *ampdu, struct scb *scb); #endif /* _wlc_ampdu_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_antsel.c b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c index 402ddf8f3371..85a73a978d4f 100644 --- a/drivers/staging/brcm80211/sys/wlc_antsel.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.c @@ -16,32 +16,30 @@ #include <wlc_cfg.h> -#ifdef WLANTSEL - #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> + #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> -#include <wlioctl.h> - #include <bcmdevs.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_key.h> -#include <wlc_pub.h> -#include <wl_dbg.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_bmac.h> -#include <wlc_phy_hal.h> -#include <wl_export.h> -#include <wlc_antsel.h> -#include <wlc_phy_shim.h> +#include <wlioctl.h> + +#include "d11.h" +#include "wlc_rate.h" +#include "wlc_key.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wl_dbg.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_bmac.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wl_export.h" +#include "wlc_phy_shim.h" +#include "wlc_antsel.h" /* useful macros */ #define WLC_ANTSEL_11N_0(ant) ((((ant) & ANT_SELCFG_MASK) >> 4) & 0xf) @@ -94,20 +92,19 @@ const u8 mimo_2x3_div_antselid_tbl[16] = { 0, 0, 0, 0, 0, 0, 0, 0 /* pat to antselid */ }; -struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc, - struct osl_info *osh, - struct wlc_pub *pub, - struct wlc_hw_info *wlc_hw) { +struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc) +{ struct antsel_info *asi; asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC); if (!asi) { - WL_ERROR("wl%d: wlc_antsel_attach: out of mem\n", pub->unit); + WL_ERROR("wl%d: wlc_antsel_attach: out of mem\n", + wlc->pub->unit); return NULL; } asi->wlc = wlc; - asi->pub = pub; + asi->pub = wlc->pub; asi->antsel_type = ANTSEL_NA; asi->antsel_avail = false; asi->antsel_antswitch = (u8) getintvar(asi->pub->vars, "antswitch"); @@ -150,7 +147,7 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc, } /* Set the antenna selection type for the low driver */ - wlc_bmac_antsel_type_set(wlc_hw, asi->antsel_type); + wlc_bmac_antsel_type_set(wlc->hw, asi->antsel_type); /* Init (auto/manual) antenna selection */ wlc_antsel_init_cfg(asi, &asi->antcfg_11n, true); @@ -161,9 +158,6 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc, void wlc_antsel_detach(struct antsel_info *asi) { - if (!asi) - return; - kfree(asi); } @@ -325,5 +319,3 @@ static int wlc_antsel_cfgupd(struct antsel_info *asi, wlc_antselcfg_t *antsel) return 0; } - -#endif /* WLANTSEL */ diff --git a/drivers/staging/brcm80211/sys/wlc_antsel.h b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.h index 8875b5848665..2470c73fc4ed 100644 --- a/drivers/staging/brcm80211/sys/wlc_antsel.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_antsel.h @@ -16,10 +16,8 @@ #ifndef _wlc_antsel_h_ #define _wlc_antsel_h_ -extern struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc, - struct osl_info *osh, - struct wlc_pub *pub, - struct wlc_hw_info *wlc_hw); + +extern struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc); extern void wlc_antsel_detach(struct antsel_info *asi); extern void wlc_antsel_init(struct antsel_info *asi); extern void wlc_antsel_antcfg_get(struct antsel_info *asi, bool usedef, @@ -27,4 +25,5 @@ extern void wlc_antsel_antcfg_get(struct antsel_info *asi, bool usedef, u8 id, u8 fbid, u8 *antcfg, u8 *fbantcfg); extern u8 wlc_antsel_antsel2id(struct antsel_info *asi, u16 antsel); -#endif /* _wlc_antsel_h_ */ + +#endif /* _wlc_antsel_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_bmac.c b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c index 69f600affa46..5a96dc3cdb36 100644 --- a/drivers/staging/brcm80211/sys/wlc_bmac.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c @@ -16,59 +16,45 @@ #include <linux/kernel.h> -#include <wlc_cfg.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> -#include <bcmdefs.h> -#include <osl.h> + #include <proto/802.11.h> +#include <bcmdefs.h> +#include <bcmdevs.h> #include <bcmwifi.h> -#include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> +#include <bcmsrom.h> +#include <bcmotp.h> +#include <bcmutils.h> #include <wlioctl.h> #include <sbconfig.h> #include <sbchipc.h> #include <pcicfg.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <hnddma.h> #include <hndpmu.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_pub.h> -#include <wlc_channel.h> -#include <bcmsrom.h> -#include <wlc_key.h> -#include <bcmdevs.h> -/* BMAC_NOTE: a WLC_HIGH compile include of wlc.h adds in more structures and type - * dependencies. Need to include these to files to allow a clean include of wlc.h - * with WLC_HIGH defined. - * At some point we may be able to skip the include of wlc.h and instead just - * define a stub wlc_info and band struct to allow rpc calls to get the rpc handle. - */ -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_bmac.h> -#include <wlc_phy_shim.h> -#include <wlc_phy_hal.h> -#include <wl_export.h> -#include "wl_ucode.h" -#include "d11ucode_ext.h" -#include <bcmotp.h> -/* BMAC_NOTE: With WLC_HIGH defined, some fns in this file make calls to high level - * functions defined in the headers below. We should be eliminating those calls and - * will be able to delete these include lines. - */ -#include <wlc_antsel.h> - -#include <pcie_core.h> - -#include <wlc_alloc.h> -#include <wl_dbg.h> +#include "wlc_types.h" +#include "d11.h" +#include "wlc_cfg.h" +#include "wlc_rate.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "wlc_phy_shim.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wl_export.h" +#include "wl_ucode.h" +#include "wlc_antsel.h" +#include "pcie_core.h" +#include "wlc_alloc.h" +#include "wl_dbg.h" +#include "wlc_bmac.h" #define TIMER_INTERVAL_WATCHDOG_BMAC 1000 /* watchdog timer, in unit of ms */ @@ -86,13 +72,10 @@ #endif /* BMAC_DUP_TO_REMOVE */ -#define DMAREG(wlc_hw, direction, fifonum) (D11REV_LT(wlc_hw->corerev, 11) ? \ - ((direction == DMA_TX) ? \ - (void *)&(wlc_hw->regs->fifo.f32regs.dmaregs[fifonum].xmt) : \ - (void *)&(wlc_hw->regs->fifo.f32regs.dmaregs[fifonum].rcv)) : \ +#define DMAREG(wlc_hw, direction, fifonum) \ ((direction == DMA_TX) ? \ - (void *)&(wlc_hw->regs->fifo.f64regs[fifonum].dmaxmt) : \ - (void *)&(wlc_hw->regs->fifo.f64regs[fifonum].dmarcv))) + (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \ + (void *)&(wlc_hw->regs->fifo64regs[fifonum].dmarcv)) /* * The following table lists the buffer memory allocated to xmt fifos in HW. @@ -117,7 +100,8 @@ static void wlc_clkctl_clk(struct wlc_hw_info *wlc, uint mode); static void wlc_coreinit(struct wlc_info *wlc); /* used by wlc_wakeucode_init() */ -static void wlc_write_inits(struct wlc_hw_info *wlc_hw, const d11init_t *inits); +static void wlc_write_inits(struct wlc_hw_info *wlc_hw, + const struct d11init *inits); static void wlc_ucode_write(struct wlc_hw_info *wlc_hw, const u32 ucode[], const uint nbytes); static void wlc_ucode_download(struct wlc_hw_info *wlc); @@ -126,7 +110,6 @@ static void wlc_ucode_txant_set(struct wlc_hw_info *wlc_hw); /* used by wlc_dpc() */ static bool wlc_bmac_dotxstatus(struct wlc_hw_info *wlc, tx_status_t *txs, u32 s2); -static bool wlc_bmac_txstatus_corerev4(struct wlc_hw_info *wlc); static bool wlc_bmac_txstatus(struct wlc_hw_info *wlc, bool bound, bool *fatal); static bool wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound); @@ -136,20 +119,30 @@ static void wlc_flushqueues(struct wlc_info *wlc); static void wlc_write_mhf(struct wlc_hw_info *wlc_hw, u16 *mhfs); static void wlc_mctrl_reset(struct wlc_hw_info *wlc_hw); static void wlc_corerev_fifofixup(struct wlc_hw_info *wlc_hw); +static bool wlc_bmac_tx_fifo_suspended(struct wlc_hw_info *wlc_hw, + uint tx_fifo); +static void wlc_bmac_tx_fifo_suspend(struct wlc_hw_info *wlc_hw, uint tx_fifo); +static void wlc_bmac_tx_fifo_resume(struct wlc_hw_info *wlc_hw, uint tx_fifo); /* Low Level Prototypes */ +static int wlc_bmac_bandtype(struct wlc_hw_info *wlc_hw); +static void wlc_bmac_info_init(struct wlc_hw_info *wlc_hw); +static void wlc_bmac_xtal(struct wlc_hw_info *wlc_hw, bool want); static u16 wlc_bmac_read_objmem(struct wlc_hw_info *wlc_hw, uint offset, u32 sel); static void wlc_bmac_write_objmem(struct wlc_hw_info *wlc_hw, uint offset, u16 v, u32 sel); +static void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk); static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme); static void wlc_bmac_detach_dmapio(struct wlc_hw_info *wlc_hw); static void wlc_ucode_bsinit(struct wlc_hw_info *wlc_hw); static bool wlc_validboardtype(struct wlc_hw_info *wlc); static bool wlc_isgoodchip(struct wlc_hw_info *wlc_hw); +static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw); static char *wlc_get_macaddr(struct wlc_hw_info *wlc_hw); static void wlc_mhfdef(struct wlc_info *wlc, u16 *mhfs, u16 mhf2_init); static void wlc_mctrl_write(struct wlc_hw_info *wlc_hw); +static void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool want, mbool flags); static void wlc_ucode_mute_override_set(struct wlc_hw_info *wlc_hw); static void wlc_ucode_mute_override_clear(struct wlc_hw_info *wlc_hw); static u32 wlc_wlintrsoff(struct wlc_info *wlc); @@ -175,7 +168,7 @@ void wlc_bmac_set_shortslot(struct wlc_hw_info *wlc_hw, bool shortslot) { wlc_hw->shortslot = shortslot; - if (BAND_2G(wlc_hw->band->bandtype) && wlc_hw->up) { + if (BAND_2G(wlc_bmac_bandtype(wlc_hw)) && wlc_hw->up) { wlc_suspend_mac_and_wait(wlc_hw->wlc); wlc_bmac_update_slot_timing(wlc_hw, shortslot); wlc_enable_mac(wlc_hw->wlc); @@ -190,19 +183,17 @@ void wlc_bmac_set_shortslot(struct wlc_hw_info *wlc_hw, bool shortslot) static void wlc_bmac_update_slot_timing(struct wlc_hw_info *wlc_hw, bool shortslot) { - struct osl_info *osh; d11regs_t *regs; - osh = wlc_hw->osh; regs = wlc_hw->regs; if (shortslot) { /* 11g short slot: 11a timing */ - W_REG(osh, ®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ + W_REG(®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ wlc_bmac_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); } else { /* 11g long slot: 11b timing */ - W_REG(osh, ®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ + W_REG(®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ wlc_bmac_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); } } @@ -240,13 +231,12 @@ static u32 WLBANDINITFN(wlc_setband_inact) (struct wlc_info *wlc, uint bandunit) { struct wlc_hw_info *wlc_hw = wlc->hw; u32 macintmask; - u32 tmp; WL_TRACE("wl%d: wlc_setband_inact\n", wlc_hw->unit); ASSERT(bandunit != wlc_hw->band->bandunit); ASSERT(si_iscoreup(wlc_hw->sih)); - ASSERT((R_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol) & MCTL_EN_MAC) == + ASSERT((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) == 0); /* disable interrupts */ @@ -257,9 +247,6 @@ static u32 WLBANDINITFN(wlc_setband_inact) (struct wlc_info *wlc, uint bandunit) ASSERT(wlc_hw->clk); - if (D11REV_LT(wlc_hw->corerev, 17)) - tmp = R_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol); - wlc_bmac_core_phy_clk(wlc_hw, OFF); wlc_setxband(wlc_hw, bandunit); @@ -312,7 +299,7 @@ wlc_bmac_recv(struct wlc_hw_info *wlc_hw, uint fifo, bool bound) /* record the tsf_l in wlc_rxd11hdr */ wlc_rxhdr = (wlc_d11rxhdr_t *) p->data; - wlc_rxhdr->tsf_l = htol32(tsf_l); + wlc_rxhdr->tsf_l = cpu_to_le32(tsf_l); /* compute the RSSI from d11rxhdr and record it in wlc_rxd11hr */ wlc_phy_rssi_compute(wlc_hw->band->pi, wlc_rxhdr); @@ -380,13 +367,13 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded) if (macintstatus & MI_ATIMWINEND) { WL_TRACE("wlc_isr: end of ATIM window\n"); - OR_REG(wlc_hw->osh, ®s->maccommand, wlc->qvalid); + OR_REG(®s->maccommand, wlc->qvalid); wlc->qvalid = 0; } /* phy tx error */ if (macintstatus & MI_PHYTXERR) { - WLCNTINCR(wlc->pub->_cnt->txphyerr); + wlc->pub->_cnt->txphyerr++; } /* received data or control frame, MI_DMAINT is indication of RX_FIFO interrupt */ @@ -416,7 +403,7 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded) __func__, wlc_hw->sih->chip, wlc_hw->sih->chiprev); - WLCNTINCR(wlc->pub->_cnt->psmwds); + wlc->pub->_cnt->psmwds++; /* big hammer */ wl_init(wlc->wl); @@ -424,18 +411,14 @@ bool BCMFASTPATH wlc_dpc(struct wlc_info *wlc, bool bounded) /* gptimer timeout */ if (macintstatus & MI_TO) { - W_REG(wlc_hw->osh, ®s->gptimer, 0); + W_REG(®s->gptimer, 0); } if (macintstatus & MI_RFDISABLE) { -#if defined(BCMDBG) - u32 rfd = R_REG(wlc_hw->osh, ®s->phydebug) & PDBG_RFD; -#endif + WL_TRACE("wl%d: BMAC Detected a change on the RF Disable Input\n", wlc_hw->unit); - WL_ERROR("wl%d: MAC Detected a change on the RF Disable Input 0x%x\n", - wlc_hw->unit, rfd); - - WLCNTINCR(wlc->pub->_cnt->rfdisable); + wlc->pub->_cnt->rfdisable++; + wl_rfkill_set_hw_state(wlc->wl); } /* send any enq'd tx packets. Just makes sure to jump start tx */ @@ -474,9 +457,6 @@ void wlc_bmac_watchdog(void *arg) /* make sure RX dma has buffers */ dma_rxfill(wlc->hw->di[RX_FIFO]); - if (D11REV_IS(wlc_hw->corerev, 4)) { - dma_rxfill(wlc->hw->di[RX_TXSTATUS_FIFO]); - } wlc_phy_watchdog(wlc_hw->band->pi); } @@ -526,45 +506,6 @@ wlc_bmac_set_chanspec(struct wlc_hw_info *wlc_hw, chanspec_t chanspec, } } -int wlc_bmac_revinfo_get(struct wlc_hw_info *wlc_hw, - wlc_bmac_revinfo_t *revinfo) -{ - si_t *sih = wlc_hw->sih; - uint idx; - - revinfo->vendorid = wlc_hw->vendorid; - revinfo->deviceid = wlc_hw->deviceid; - - revinfo->boardrev = wlc_hw->boardrev; - revinfo->corerev = wlc_hw->corerev; - revinfo->sromrev = wlc_hw->sromrev; - revinfo->chiprev = sih->chiprev; - revinfo->chip = sih->chip; - revinfo->chippkg = sih->chippkg; - revinfo->boardtype = sih->boardtype; - revinfo->boardvendor = sih->boardvendor; - revinfo->bustype = sih->bustype; - revinfo->buscoretype = sih->buscoretype; - revinfo->buscorerev = sih->buscorerev; - revinfo->issim = sih->issim; - - revinfo->nbands = NBANDS_HW(wlc_hw); - - for (idx = 0; idx < NBANDS_HW(wlc_hw); idx++) { - wlc_hwband_t *band = wlc_hw->bandstate[idx]; - revinfo->band[idx].bandunit = band->bandunit; - revinfo->band[idx].bandtype = band->bandtype; - revinfo->band[idx].phytype = band->phytype; - revinfo->band[idx].phyrev = band->phyrev; - revinfo->band[idx].radioid = band->radioid; - revinfo->band[idx].radiorev = band->radiorev; - revinfo->band[idx].abgphy_encore = band->abgphy_encore; - revinfo->band[idx].anarev = 0; - - } - return 0; -} - int wlc_bmac_state_get(struct wlc_hw_info *wlc_hw, wlc_bmac_state_t *state) { state->machwcap = wlc_hw->machwcap; @@ -588,8 +529,6 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme) if (wlc_hw->di[0] == 0) { /* Init FIFOs */ uint addrwidth; int dma_attach_err = 0; - struct osl_info *osh = wlc_hw->osh; - /* Find out the DMA addressing capability and let OS know * All the channels within one DMA core have 'common-minimum' same * capability @@ -610,7 +549,7 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme) */ ASSERT(TX_AC_BK_FIFO == 0); ASSERT(RX_FIFO == 0); - wlc_hw->di[0] = dma_attach(osh, name, wlc_hw->sih, + wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, (wme ? DMAREG(wlc_hw, DMA_TX, 0) : NULL), DMAREG(wlc_hw, DMA_RX, 0), (wme ? tune->ntxd : 0), tune->nrxd, @@ -626,7 +565,7 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme) */ ASSERT(TX_AC_BE_FIFO == 1); ASSERT(TX_DATA_FIFO == 1); - wlc_hw->di[1] = dma_attach(osh, name, wlc_hw->sih, + wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 1), NULL, tune->ntxd, 0, 0, -1, 0, 0, &wl_msg_level); @@ -638,7 +577,7 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme) * RX: UNUSED */ ASSERT(TX_AC_VI_FIFO == 2); - wlc_hw->di[2] = dma_attach(osh, name, wlc_hw->sih, + wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, DMAREG(wlc_hw, DMA_TX, 2), NULL, tune->ntxd, 0, 0, -1, 0, 0, &wl_msg_level); @@ -647,28 +586,14 @@ static bool wlc_bmac_attach_dmapio(struct wlc_info *wlc, uint j, bool wme) * FIFO 3 * TX: TX_AC_VO_FIFO (TX AC Voice data packets) * (legacy) TX_CTL_FIFO (TX control & mgmt packets) - * RX: RX_TXSTATUS_FIFO (transmit-status packets) - * for corerev < 5 only */ ASSERT(TX_AC_VO_FIFO == 3); ASSERT(TX_CTL_FIFO == 3); - if (D11REV_IS(wlc_hw->corerev, 4)) { - ASSERT(RX_TXSTATUS_FIFO == 3); - wlc_hw->di[3] = dma_attach(osh, name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 3), - DMAREG(wlc_hw, DMA_RX, 3), - tune->ntxd, tune->nrxd, - sizeof(tx_status_t), -1, - tune->nrxbufpost, 0, - &wl_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[3]); - } else { - wlc_hw->di[3] = dma_attach(osh, name, wlc_hw->sih, - DMAREG(wlc_hw, DMA_TX, 3), - NULL, tune->ntxd, 0, 0, -1, - 0, 0, &wl_msg_level); - dma_attach_err |= (NULL == wlc_hw->di[3]); - } + wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, + DMAREG(wlc_hw, DMA_TX, 3), + NULL, tune->ntxd, 0, 0, -1, + 0, 0, &wl_msg_level); + dma_attach_err |= (NULL == wlc_hw->di[3]); /* Cleaner to leave this as if with AP defined */ if (dma_attach_err) { @@ -709,8 +634,7 @@ static void wlc_bmac_detach_dmapio(struct wlc_hw_info *wlc_hw) * put the whole chip in reset(driver down state), no clock */ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, - bool piomode, struct osl_info *osh, void *regsva, - uint bustype, void *btparam) + bool piomode, void *regsva, uint bustype, void *btparam) { struct wlc_hw_info *wlc_hw; d11regs_t *regs; @@ -731,7 +655,6 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, wlc_hw = wlc->hw; wlc_hw->wlc = wlc; wlc_hw->unit = unit; - wlc_hw->osh = osh; wlc_hw->band = wlc_hw->bandstate[0]; wlc_hw->_piomode = piomode; @@ -743,7 +666,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, * Also initialize software state that depends on the particular hardware * we are running. */ - wlc_hw->sih = si_attach((uint) device, osh, regsva, bustype, btparam, + wlc_hw->sih = si_attach((uint) device, regsva, bustype, btparam, &wlc_hw->vars, &wlc_hw->vars_size); if (wlc_hw->sih == NULL) { WL_ERROR("wl%d: wlc_bmac_attach: si_attach failed\n", unit); @@ -838,8 +761,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, wlc_hw->boardflags = (u32) getintvar(vars, "boardflags"); wlc_hw->boardflags2 = (u32) getintvar(vars, "boardflags2"); - if (D11REV_LE(wlc_hw->corerev, 4) - || (wlc_hw->boardflags & BFL_NOPLLDOWN)) + if (wlc_hw->boardflags & BFL_NOPLLDOWN) wlc_bmac_pllreq(wlc_hw, true, WLC_PLLREQ_SHARED); if ((wlc_hw->sih->bustype == PCI_BUS) @@ -879,7 +801,6 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, } /* pass all the parameters to wlc_phy_shared_attach in one struct */ - sha_params.osh = osh; sha_params.sih = wlc_hw->sih; sha_params.physhim = wlc_hw->physhim; sha_params.unit = unit; @@ -925,10 +846,8 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, wlc->band->bandtype = j ? WLC_BAND_5G : WLC_BAND_2G; wlc->core->coreidx = si_coreidx(wlc_hw->sih); - if (D11REV_GE(wlc_hw->corerev, 13)) { - wlc_hw->machwcap = R_REG(wlc_hw->osh, ®s->machwcap); - wlc_hw->machwcap_backup = wlc_hw->machwcap; - } + wlc_hw->machwcap = R_REG(®s->machwcap); + wlc_hw->machwcap_backup = wlc_hw->machwcap; /* init tx fifo size */ ASSERT((wlc_hw->corerev - XMTFIFOTBL_STARTREV) < @@ -938,7 +857,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, /* Get a phy for this band */ wlc_hw->band->pi = wlc_phy_attach(wlc_hw->phy_sh, - (void *)regs, wlc_hw->band->bandtype, vars); + (void *)regs, wlc_bmac_bandtype(wlc_hw), vars); if (wlc_hw->band->pi == NULL) { WL_ERROR("wl%d: wlc_bmac_attach: wlc_phy_attach failed\n", unit); @@ -1032,16 +951,16 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, err = 21; goto fail; } - bcm_ether_atoe(macaddr, &wlc_hw->etheraddr); - if (is_broadcast_ether_addr(wlc_hw->etheraddr.octet) || - is_zero_ether_addr(wlc_hw->etheraddr.octet)) { + bcm_ether_atoe(macaddr, wlc_hw->etheraddr); + if (is_broadcast_ether_addr(wlc_hw->etheraddr) || + is_zero_ether_addr(wlc_hw->etheraddr)) { WL_ERROR("wl%d: wlc_bmac_attach: bad macaddr %s\n", unit, macaddr); err = 22; goto fail; } - WL_ERROR("%s:: deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", + WL_TRACE("%s:: deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", __func__, wlc_hw->deviceid, wlc_hw->_nbands, wlc_hw->sih->boardtype, macaddr); @@ -1057,7 +976,7 @@ int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, uint unit, * may get overrides later in this function * BMAC_NOTES, move low out and resolve the dangling ones */ -void wlc_bmac_info_init(struct wlc_hw_info *wlc_hw) +static void wlc_bmac_info_init(struct wlc_hw_info *wlc_hw) { struct wlc_info *wlc = wlc_hw->wlc; @@ -1082,7 +1001,7 @@ void wlc_bmac_info_init(struct wlc_hw_info *wlc_hw) int wlc_bmac_detach(struct wlc_info *wlc) { uint i; - wlc_hwband_t *band; + struct wlc_hwband *band; struct wlc_hw_info *wlc_hw = wlc->hw; int callbacks; @@ -1116,10 +1035,8 @@ int wlc_bmac_detach(struct wlc_info *wlc) wlc_phy_shim_detach(wlc_hw->physhim); /* free vars */ - if (wlc_hw->vars) { - kfree(wlc_hw->vars); - wlc_hw->vars = NULL; - } + kfree(wlc_hw->vars); + wlc_hw->vars = NULL; if (wlc_hw->sih) { si_detach(wlc_hw->sih); @@ -1134,7 +1051,7 @@ void wlc_bmac_reset(struct wlc_hw_info *wlc_hw) { WL_TRACE("wl%d: wlc_bmac_reset\n", wlc_hw->unit); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->reset); + wlc_hw->wlc->pub->_cnt->reset++; /* reset the core */ if (!DEVICEREMOVED(wlc_hw->wlc)) @@ -1314,7 +1231,7 @@ int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw) /* Reset and disable the core */ if (si_iscoreup(wlc_hw->sih)) { - if (R_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol) & + if (R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) wlc_suspend_mac_and_wait(wlc_hw->wlc); callbacks += wl_reset(wlc_hw->wlc->wl); @@ -1334,42 +1251,26 @@ int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw) void wlc_bmac_wait_for_wake(struct wlc_hw_info *wlc_hw) { - if (D11REV_IS(wlc_hw->corerev, 4)) /* no slowclock */ - udelay(5); - else { - /* delay before first read of ucode state */ - udelay(40); + /* delay before first read of ucode state */ + udelay(40); - /* wait until ucode is no longer asleep */ - SPINWAIT((wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) == - DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); - } + /* wait until ucode is no longer asleep */ + SPINWAIT((wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) == + DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); ASSERT(wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) != DBGST_ASLEEP); } -void wlc_bmac_hw_etheraddr(struct wlc_hw_info *wlc_hw, struct ether_addr *ea) +void wlc_bmac_hw_etheraddr(struct wlc_hw_info *wlc_hw, u8 *ea) { - bcopy(&wlc_hw->etheraddr, ea, ETH_ALEN); + memcpy(ea, wlc_hw->etheraddr, ETH_ALEN); } -void wlc_bmac_set_hw_etheraddr(struct wlc_hw_info *wlc_hw, - struct ether_addr *ea) -{ - bcopy(ea, &wlc_hw->etheraddr, ETH_ALEN); -} - -int wlc_bmac_bandtype(struct wlc_hw_info *wlc_hw) +static int wlc_bmac_bandtype(struct wlc_hw_info *wlc_hw) { return wlc_hw->band->bandtype; } -void *wlc_cur_phy(struct wlc_info *wlc) -{ - struct wlc_hw_info *wlc_hw = wlc->hw; - return (void *)wlc_hw->band->pi; -} - /* control chip clock to save power, enable dynamic clock or force fast clock */ static void wlc_clkctl_clk(struct wlc_hw_info *wlc_hw, uint mode) { @@ -1382,65 +1283,43 @@ static void wlc_clkctl_clk(struct wlc_hw_info *wlc_hw, uint mode) if (wlc_hw->clk) { if (mode == CLK_FAST) { - OR_REG(wlc_hw->osh, &wlc_hw->regs->clk_ctl_st, + OR_REG(&wlc_hw->regs->clk_ctl_st, CCS_FORCEHT); udelay(64); SPINWAIT(((R_REG - (wlc_hw->osh, - &wlc_hw->regs-> + (&wlc_hw->regs-> clk_ctl_st) & CCS_HTAVAIL) == 0), PMU_MAX_TRANSITION_DLY); ASSERT(R_REG - (wlc_hw->osh, - &wlc_hw->regs-> + (&wlc_hw->regs-> clk_ctl_st) & CCS_HTAVAIL); } else { if ((wlc_hw->sih->pmurev == 0) && (R_REG - (wlc_hw->osh, - &wlc_hw->regs-> + (&wlc_hw->regs-> clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) SPINWAIT(((R_REG - (wlc_hw->osh, - &wlc_hw->regs-> + (&wlc_hw->regs-> clk_ctl_st) & CCS_HTAVAIL) == 0), PMU_MAX_TRANSITION_DLY); - AND_REG(wlc_hw->osh, &wlc_hw->regs->clk_ctl_st, + AND_REG(&wlc_hw->regs->clk_ctl_st, ~CCS_FORCEHT); } } wlc_hw->forcefastclk = (mode == CLK_FAST); } else { - bool wakeup_ucode; /* old chips w/o PMU, force HT through cc, * then use FCA to verify mac is running fast clock */ - wakeup_ucode = D11REV_LT(wlc_hw->corerev, 9); - - if (wlc_hw->up && wakeup_ucode) - wlc_ucode_wake_override_set(wlc_hw, - WLC_WAKE_OVERRIDE_CLKCTL); - wlc_hw->forcefastclk = si_clkctl_cc(wlc_hw->sih, mode); - if (D11REV_LT(wlc_hw->corerev, 11)) { - /* ucode WAR for old chips */ - if (wlc_hw->forcefastclk) - wlc_bmac_mhf(wlc_hw, MHF1, MHF1_FORCEFASTCLK, - MHF1_FORCEFASTCLK, WLC_BAND_ALL); - else - wlc_bmac_mhf(wlc_hw, MHF1, MHF1_FORCEFASTCLK, 0, - WLC_BAND_ALL); - } - /* check fast clock is available (if core is not in reset) */ - if (D11REV_GT(wlc_hw->corerev, 4) && wlc_hw->forcefastclk - && wlc_hw->clk) + if (wlc_hw->forcefastclk && wlc_hw->clk) ASSERT(si_core_sflags(wlc_hw->sih, 0, 0) & SISF_FCLKA); /* keep the ucode wake bit on if forcefastclk is on @@ -1458,11 +1337,6 @@ static void wlc_clkctl_clk(struct wlc_hw_info *wlc_hw, uint mode) else mboolclr(wlc_hw->wake_override, WLC_WAKE_OVERRIDE_FORCEFAST); - - /* ok to clear the wakeup now */ - if (wlc_hw->up && wakeup_ucode) - wlc_ucode_wake_override_clear(wlc_hw, - WLC_WAKE_OVERRIDE_CLKCTL); } } @@ -1506,7 +1380,7 @@ wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val, M_HOST_FLAGS1, M_HOST_FLAGS2, M_HOST_FLAGS3, M_HOST_FLAGS4, M_HOST_FLAGS5 }; - wlc_hwband_t *band; + struct wlc_hwband *band; ASSERT((val & ~mask) == 0); ASSERT(idx < MHFMAX); @@ -1554,7 +1428,7 @@ wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val, u16 wlc_bmac_mhf_get(struct wlc_hw_info *wlc_hw, u8 idx, int bands) { - wlc_hwband_t *band; + struct wlc_hwband *band; ASSERT(idx < MHFMAX); switch (bands) { @@ -1643,7 +1517,7 @@ static void wlc_mctrl_write(struct wlc_hw_info *wlc_hw) maccontrol |= MCTL_INFRA; } - W_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol, maccontrol); + W_REG(&wlc_hw->regs->maccontrol, maccontrol); } void wlc_ucode_wake_override_set(struct wlc_hw_info *wlc_hw, u32 override_bit) @@ -1721,32 +1595,26 @@ static void wlc_ucode_mute_override_clear(struct wlc_hw_info *wlc_hw) */ void wlc_bmac_set_rcmta(struct wlc_hw_info *wlc_hw, int idx, - const struct ether_addr *addr) + const u8 *addr) { d11regs_t *regs = wlc_hw->regs; volatile u16 *objdata16 = (volatile u16 *)®s->objdata; u32 mac_hm; u16 mac_l; - struct osl_info *osh; WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__); - ASSERT(wlc_hw->corerev > 4); - mac_hm = - (addr->octet[3] << 24) | (addr->octet[2] << 16) | (addr-> - octet[1] << 8) | - addr->octet[0]; - mac_l = (addr->octet[5] << 8) | addr->octet[4]; - - osh = wlc_hw->osh; - - W_REG(osh, ®s->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2))); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, mac_hm); - W_REG(osh, ®s->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1))); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, objdata16, mac_l); + (addr[3] << 24) | (addr[2] << 16) | + (addr[1] << 8) | addr[0]; + mac_l = (addr[5] << 8) | addr[4]; + + W_REG(®s->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2))); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, mac_hm); + W_REG(®s->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1))); + (void)R_REG(®s->objaddr); + W_REG(objdata16, mac_l); } /* @@ -1754,30 +1622,27 @@ wlc_bmac_set_rcmta(struct wlc_hw_info *wlc_hw, int idx, */ void wlc_bmac_set_addrmatch(struct wlc_hw_info *wlc_hw, int match_reg_offset, - const struct ether_addr *addr) + const u8 *addr) { d11regs_t *regs; u16 mac_l; u16 mac_m; u16 mac_h; - struct osl_info *osh; WL_TRACE("wl%d: wlc_bmac_set_addrmatch\n", wlc_hw->unit); - ASSERT((match_reg_offset < RCM_SIZE) || (wlc_hw->corerev == 4)); + ASSERT(match_reg_offset < RCM_SIZE); regs = wlc_hw->regs; - mac_l = addr->octet[0] | (addr->octet[1] << 8); - mac_m = addr->octet[2] | (addr->octet[3] << 8); - mac_h = addr->octet[4] | (addr->octet[5] << 8); - - osh = wlc_hw->osh; + mac_l = addr[0] | (addr[1] << 8); + mac_m = addr[2] | (addr[3] << 8); + mac_h = addr[4] | (addr[5] << 8); /* enter the MAC addr into the RXE match registers */ - W_REG(osh, ®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); - W_REG(osh, ®s->rcm_mat_data, mac_l); - W_REG(osh, ®s->rcm_mat_data, mac_m); - W_REG(osh, ®s->rcm_mat_data, mac_h); + W_REG(®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); + W_REG(®s->rcm_mat_data, mac_l); + W_REG(®s->rcm_mat_data, mac_m); + W_REG(®s->rcm_mat_data, mac_h); } @@ -1791,34 +1656,31 @@ wlc_bmac_write_template_ram(struct wlc_hw_info *wlc_hw, int offset, int len, #ifdef IL_BIGENDIAN volatile u16 *dptr = NULL; #endif /* IL_BIGENDIAN */ - struct osl_info *osh; - WL_TRACE("wl%d: wlc_bmac_write_template_ram\n", wlc_hw->unit); regs = wlc_hw->regs; - osh = wlc_hw->osh; ASSERT(IS_ALIGNED(offset, sizeof(u32))); ASSERT(IS_ALIGNED(len, sizeof(u32))); ASSERT((offset & ~0xffff) == 0); - W_REG(osh, ®s->tplatewrptr, offset); + W_REG(®s->tplatewrptr, offset); /* if MCTL_BIGEND bit set in mac control register, * the chip swaps data in fifo, as well as data in * template ram */ - be_bit = (R_REG(osh, ®s->maccontrol) & MCTL_BIGEND) != 0; + be_bit = (R_REG(®s->maccontrol) & MCTL_BIGEND) != 0; while (len > 0) { - bcopy((u8 *) buf, &word, sizeof(u32)); + memcpy(&word, buf, sizeof(u32)); if (be_bit) - word = hton32(word); + word = cpu_to_be32(word); else - word = htol32(word); + word = cpu_to_le32(word); - W_REG(osh, ®s->tplatewrdata, word); + W_REG(®s->tplatewrdata, word); buf = (u8 *) buf + sizeof(u32); len -= sizeof(u32); @@ -1827,32 +1689,25 @@ wlc_bmac_write_template_ram(struct wlc_hw_info *wlc_hw, int offset, int len, void wlc_bmac_set_cwmin(struct wlc_hw_info *wlc_hw, u16 newmin) { - struct osl_info *osh; - - osh = wlc_hw->osh; wlc_hw->band->CWmin = newmin; - W_REG(osh, &wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); - (void)R_REG(osh, &wlc_hw->regs->objaddr); - W_REG(osh, &wlc_hw->regs->objdata, newmin); + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, newmin); } void wlc_bmac_set_cwmax(struct wlc_hw_info *wlc_hw, u16 newmax) { - struct osl_info *osh; - - osh = wlc_hw->osh; wlc_hw->band->CWmax = newmax; - W_REG(osh, &wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); - (void)R_REG(osh, &wlc_hw->regs->objaddr); - W_REG(osh, &wlc_hw->regs->objdata, newmax); + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, newmax); } void wlc_bmac_bw_set(struct wlc_hw_info *wlc_hw, u16 bw) { bool fastclk; - u32 tmp; /* request FAST clock if not on */ fastclk = wlc_hw->forcefastclk; @@ -1862,8 +1717,6 @@ void wlc_bmac_bw_set(struct wlc_hw_info *wlc_hw, u16 bw) wlc_phy_bw_state_set(wlc_hw->band->pi, bw); ASSERT(wlc_hw->clk); - if (D11REV_LT(wlc_hw->corerev, 17)) - tmp = R_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol); wlc_bmac_phy_reset(wlc_hw); wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); @@ -1884,7 +1737,7 @@ wlc_write_hw_bcntemplate0(struct wlc_hw_info *wlc_hw, void *bcn, int len) ASSERT(len < 65536); wlc_bmac_write_shm(wlc_hw, M_BCN0_FRM_BYTESZ, (u16) len); /* mark beacon0 valid */ - OR_REG(wlc_hw->osh, ®s->maccommand, MCMD_BCN0VLD); + OR_REG(®s->maccommand, MCMD_BCN0VLD); } static void @@ -1898,7 +1751,7 @@ wlc_write_hw_bcntemplate1(struct wlc_hw_info *wlc_hw, void *bcn, int len) ASSERT(len < 65536); wlc_bmac_write_shm(wlc_hw, M_BCN1_FRM_BYTESZ, (u16) len); /* mark beacon1 valid */ - OR_REG(wlc_hw->osh, ®s->maccommand, MCMD_BCN1VLD); + OR_REG(®s->maccommand, MCMD_BCN1VLD); } /* mac is assumed to be suspended at this point */ @@ -1913,11 +1766,11 @@ wlc_bmac_write_hw_bcntemplates(struct wlc_hw_info *wlc_hw, void *bcn, int len, wlc_write_hw_bcntemplate1(wlc_hw, bcn, len); } else { /* bcn 0 */ - if (!(R_REG(wlc_hw->osh, ®s->maccommand) & MCMD_BCN0VLD)) + if (!(R_REG(®s->maccommand) & MCMD_BCN0VLD)) wlc_write_hw_bcntemplate0(wlc_hw, bcn, len); /* bcn 1 */ else if (! - (R_REG(wlc_hw->osh, ®s->maccommand) & MCMD_BCN1VLD)) + (R_REG(®s->maccommand) & MCMD_BCN1VLD)) wlc_write_hw_bcntemplate1(wlc_hw, bcn, len); else /* one template should always have been available */ ASSERT(0); @@ -1951,10 +1804,10 @@ WLBANDINITFN(wlc_bmac_bsinit) (struct wlc_info *wlc, chanspec_t chanspec) wlc_hw->unit, wlc_hw->band->bandunit); /* sanity check */ - if (PHY_TYPE(R_REG(wlc_hw->osh, &wlc_hw->regs->phyversion)) != + if (PHY_TYPE(R_REG(&wlc_hw->regs->phyversion)) != PHY_TYPE_LCNXN) ASSERT((uint) - PHY_TYPE(R_REG(wlc_hw->osh, &wlc_hw->regs->phyversion)) + PHY_TYPE(R_REG(&wlc_hw->regs->phyversion)) == wlc_hw->band->phytype); wlc_ucode_bsinit(wlc_hw); @@ -1982,7 +1835,7 @@ WLBANDINITFN(wlc_bmac_bsinit) (struct wlc_info *wlc, chanspec_t chanspec) wlc_bmac_upd_synthpu(wlc_hw); } -void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk) +static void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk) { WL_TRACE("wl%d: wlc_bmac_core_phy_clk: clk %d\n", wlc_hw->unit, clk); @@ -2130,7 +1983,7 @@ WLBANDINITFN(wlc_bmac_setband) (struct wlc_hw_info *wlc_hw, uint bandunit, wl_intrsrestore(wlc->wl, macintmask); /* ucode should still be suspended.. */ - ASSERT((R_REG(wlc_hw->osh, &wlc_hw->regs->maccontrol) & MCTL_EN_MAC) == + ASSERT((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) == 0); } @@ -2229,15 +2082,12 @@ bool wlc_bmac_radio_read_hwdisabled(struct wlc_hw_info *wlc_hw) /* may need to take core out of reset first */ clk = wlc_hw->clk; if (!clk) { - if (D11REV_LE(wlc_hw->corerev, 11)) - resetbits |= SICF_PCLKE; - /* - * corerev >= 18, mac no longer enables phyclk automatically when driver accesses - * phyreg throughput mac. This can be skipped since only mac reg is accessed below + * mac no longer enables phyclk automatically when driver + * accesses phyreg throughput mac. This can be skipped since + * only mac reg is accessed below */ - if (D11REV_GE(wlc_hw->corerev, 18)) - flags |= SICF_PCLKE; + flags |= SICF_PCLKE; /* AI chip doesn't restore bar0win2 on hibernation/resume, need sw fixup */ if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || @@ -2250,7 +2100,7 @@ bool wlc_bmac_radio_read_hwdisabled(struct wlc_hw_info *wlc_hw) wlc_mctrl_reset(wlc_hw); } - v = ((R_REG(wlc_hw->osh, &wlc_hw->regs->phydebug) & PDBG_RFD) != 0); + v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); /* put core back into reset */ if (!clk) @@ -2308,26 +2158,6 @@ void wlc_bmac_hw_up(struct wlc_hw_info *wlc_hw) static bool wlc_dma_rxreset(struct wlc_hw_info *wlc_hw, uint fifo) { struct hnddma_pub *di = wlc_hw->di[fifo]; - struct osl_info *osh; - - if (D11REV_LT(wlc_hw->corerev, 12)) { - bool rxidle = true; - u16 rcv_frm_cnt = 0; - - osh = wlc_hw->osh; - - W_REG(osh, &wlc_hw->regs->rcv_fifo_ctl, fifo << 8); - SPINWAIT((!(rxidle = dma_rxidle(di))) && - ((rcv_frm_cnt = - R_REG(osh, &wlc_hw->regs->rcv_frm_cnt)) != 0), - 50000); - - if (!rxidle && (rcv_frm_cnt != 0)) - WL_ERROR("wl%d: %s: rxdma[%d] not idle && rcv_frm_cnt(%d) not zero\n", - wlc_hw->unit, __func__, fifo, rcv_frm_cnt); - mdelay(2); - } - return dma_rxreset(di); } @@ -2371,12 +2201,6 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags) WL_ERROR("wl%d: %s: dma_rxreset[%d]: cannot stop dma\n", wlc_hw->unit, __func__, RX_FIFO); } - if (D11REV_IS(wlc_hw->corerev, 4) - && wlc_hw->di[RX_TXSTATUS_FIFO] - && (!wlc_dma_rxreset(wlc_hw, RX_TXSTATUS_FIFO))) { - WL_ERROR("wl%d: %s: dma_rxreset[%d]: cannot stop dma\n", - wlc_hw->unit, __func__, RX_TXSTATUS_FIFO); - } } /* if noreset, just stop the psm and return */ if (wlc_hw->noreset) { @@ -2385,16 +2209,12 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags) return; } - if (D11REV_LE(wlc_hw->corerev, 11)) - resetbits |= SICF_PCLKE; - /* - * corerev >= 18, mac no longer enables phyclk automatically when driver accesses phyreg - * throughput mac, AND phy_reset is skipped at early stage when band->pi is invalid - * need to enable PHY CLK + * mac no longer enables phyclk automatically when driver accesses + * phyreg throughput mac, AND phy_reset is skipped at early stage when + * band->pi is invalid. need to enable PHY CLK */ - if (D11REV_GE(wlc_hw->corerev, 18)) - flags |= SICF_PCLKE; + flags |= SICF_PCLKE; /* reset the core * In chips with PMU, the fastclk request goes through d11 core reg 0x1e0, which @@ -2427,8 +2247,7 @@ void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags) wlc_clkctl_clk(wlc_hw, CLK_DYNAMIC); } -/* If the ucode that supports corerev 5 is used for corerev 9 and above, - * txfifo sizes needs to be modified(increased) since the newer cores +/* txfifo sizes needs to be modified(increased) since the newer cores * have more memory. */ static void wlc_corerev_fifofixup(struct wlc_hw_info *wlc_hw) @@ -2438,16 +2257,10 @@ static void wlc_corerev_fifofixup(struct wlc_hw_info *wlc_hw) u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; u16 txfifo_def, txfifo_def1; u16 txfifo_cmd; - struct osl_info *osh; - - if (D11REV_LT(wlc_hw->corerev, 9)) - goto exit; /* tx fifos start at TXFIFO_START_BLK from the Base address */ txfifo_startblk = TXFIFO_START_BLK; - osh = wlc_hw->osh; - /* sequence of operations: reset fifo, set fifo size, reset fifo */ for (fifo_nu = 0; fifo_nu < NFIFO; fifo_nu++) { @@ -2460,17 +2273,18 @@ static void wlc_corerev_fifofixup(struct wlc_hw_info *wlc_hw) txfifo_cmd = TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); - W_REG(osh, ®s->xmtfifocmd, txfifo_cmd); - W_REG(osh, ®s->xmtfifodef, txfifo_def); - if (D11REV_GE(wlc_hw->corerev, 16)) - W_REG(osh, ®s->xmtfifodef1, txfifo_def1); + W_REG(®s->xmtfifocmd, txfifo_cmd); + W_REG(®s->xmtfifodef, txfifo_def); + W_REG(®s->xmtfifodef1, txfifo_def1); - W_REG(osh, ®s->xmtfifocmd, txfifo_cmd); + W_REG(®s->xmtfifocmd, txfifo_cmd); txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; } - exit: - /* need to propagate to shm location to be in sync since ucode/hw won't do this */ + /* + * need to propagate to shm location to be in sync since ucode/hw won't + * do this + */ wlc_bmac_write_shm(wlc_hw, M_FIFOSIZE0, wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); wlc_bmac_write_shm(wlc_hw, M_FIFOSIZE1, @@ -2499,12 +2313,10 @@ static void wlc_coreinit(struct wlc_info *wlc) uint bcnint_us; uint i = 0; bool fifosz_fixup = false; - struct osl_info *osh; int err = 0; u16 buf[NFIFO]; regs = wlc_hw->regs; - osh = wlc_hw->osh; WL_TRACE("wl%d: wlc_coreinit\n", wlc_hw->unit); @@ -2513,22 +2325,19 @@ static void wlc_coreinit(struct wlc_info *wlc) wlc_ucode_download(wlc_hw); /* - * FIFOSZ fixup - * 1) core5-9 use ucode 5 to save space since the PSM is the same - * 2) newer chips, driver wants to controls the fifo allocation + * FIFOSZ fixup. driver wants to controls the fifo allocation. */ - if (D11REV_GE(wlc_hw->corerev, 4)) - fifosz_fixup = true; + fifosz_fixup = true; /* let the PSM run to the suspended state, set mode to BSS STA */ - W_REG(osh, ®s->macintstatus, -1); + W_REG(®s->macintstatus, -1); wlc_bmac_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); /* wait for ucode to self-suspend after auto-init */ - SPINWAIT(((R_REG(osh, ®s->macintstatus) & MI_MACSSPNDD) == 0), + SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), 1000 * 1000); - if ((R_REG(osh, ®s->macintstatus) & MI_MACSSPNDD) == 0) + if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) WL_ERROR("wl%d: wlc_coreinit: ucode did not self-suspend!\n", wlc_hw->unit); @@ -2554,7 +2363,7 @@ static void wlc_coreinit(struct wlc_info *wlc) __func__, wlc_hw->unit, wlc_hw->corerev); } - /* For old ucode, txfifo sizes needs to be modified(increased) for Corerev >= 9 */ + /* For old ucode, txfifo sizes needs to be modified(increased) */ if (fifosz_fixup == true) { wlc_corerev_fifofixup(wlc_hw); } @@ -2595,16 +2404,11 @@ static void wlc_coreinit(struct wlc_info *wlc) if (err != 0) { WL_ERROR("wlc_coreinit: txfifo mismatch: ucode size %d driver size %d index %d\n", buf[i], wlc_hw->xmtfifo_sz[i], i); - /* DO NOT ASSERT corerev < 4 even there is a mismatch - * shmem, since driver don't overwrite those chip and - * ucode initialize data will be used. - */ - if (D11REV_GE(wlc_hw->corerev, 4)) - ASSERT(0); + ASSERT(0); } /* make sure we can still talk to the mac */ - ASSERT(R_REG(osh, ®s->maccontrol) != 0xffffffff); + ASSERT(R_REG(®s->maccontrol) != 0xffffffff); /* band-specific inits done by wlc_bsinit() */ @@ -2613,9 +2417,7 @@ static void wlc_coreinit(struct wlc_info *wlc) wlc_bmac_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); /* enable one rx interrupt per received frame */ - W_REG(osh, ®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); - if (D11REV_IS(wlc_hw->corerev, 4)) - W_REG(osh, ®s->intrcvlazy[3], (1 << IRL_FC_SHIFT)); + W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); /* set the station mode (BSS STA) */ wlc_bmac_mctrl(wlc_hw, @@ -2624,53 +2426,44 @@ static void wlc_coreinit(struct wlc_info *wlc) /* set up Beacon interval */ bcnint_us = 0x8000 << 10; - W_REG(osh, ®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); - W_REG(osh, ®s->tsf_cfpstart, bcnint_us); - W_REG(osh, ®s->macintstatus, MI_GP1); + W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); + W_REG(®s->tsf_cfpstart, bcnint_us); + W_REG(®s->macintstatus, MI_GP1); /* write interrupt mask */ - W_REG(osh, ®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); - if (D11REV_IS(wlc_hw->corerev, 4)) - W_REG(osh, ®s->intctrlregs[RX_TXSTATUS_FIFO].intmask, - DEF_RXINTMASK); + W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); /* allow the MAC to control the PHY clock (dynamic on/off) */ wlc_bmac_macphyclk_set(wlc_hw, ON); /* program dynamic clock control fast powerup delay register */ - if (D11REV_GT(wlc_hw->corerev, 4)) { - wlc->fastpwrup_dly = si_clkctl_fast_pwrup_delay(wlc_hw->sih); - W_REG(osh, ®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); - } + wlc->fastpwrup_dly = si_clkctl_fast_pwrup_delay(wlc_hw->sih); + W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); /* tell the ucode the corerev */ wlc_bmac_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); /* tell the ucode MAC capabilities */ - if (D11REV_GE(wlc_hw->corerev, 13)) { - wlc_bmac_write_shm(wlc_hw, M_MACHW_CAP_L, - (u16) (wlc_hw->machwcap & 0xffff)); - wlc_bmac_write_shm(wlc_hw, M_MACHW_CAP_H, - (u16) ((wlc_hw-> - machwcap >> 16) & 0xffff)); - } + wlc_bmac_write_shm(wlc_hw, M_MACHW_CAP_L, + (u16) (wlc_hw->machwcap & 0xffff)); + wlc_bmac_write_shm(wlc_hw, M_MACHW_CAP_H, + (u16) ((wlc_hw-> + machwcap >> 16) & 0xffff)); /* write retry limits to SCR, this done after PSM init */ - W_REG(osh, ®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, wlc_hw->SRL); - W_REG(osh, ®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, wlc_hw->LRL); + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->SRL); + W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, wlc_hw->LRL); /* write rate fallback retry limits */ wlc_bmac_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); wlc_bmac_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); - if (D11REV_GE(wlc_hw->corerev, 16)) { - AND_REG(osh, ®s->ifs_ctl, 0x0FFF); - W_REG(osh, ®s->ifs_aifsn, EDCF_AIFSN_MIN); - } + AND_REG(®s->ifs_ctl, 0x0FFF); + W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); /* dma initializations */ wlc->txpend16165war = 0; @@ -2684,10 +2477,6 @@ static void wlc_coreinit(struct wlc_info *wlc) /* init the rx dma engine(s) and post receive buffers */ dma_rxinit(wlc_hw->di[RX_FIFO]); dma_rxfill(wlc_hw->di[RX_FIFO]); - if (D11REV_IS(wlc_hw->corerev, 4)) { - dma_rxinit(wlc_hw->di[RX_TXSTATUS_FIFO]); - dma_rxfill(wlc_hw->di[RX_TXSTATUS_FIFO]); - } } /* This function is used for changing the tsf frac register @@ -2706,29 +2495,27 @@ static void wlc_coreinit(struct wlc_info *wlc) void wlc_bmac_switch_macfreq(struct wlc_hw_info *wlc_hw, u8 spurmode) { d11regs_t *regs; - struct osl_info *osh; regs = wlc_hw->regs; - osh = wlc_hw->osh; if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ - W_REG(osh, ®s->tsf_clk_frac_l, 0x2082); - W_REG(osh, ®s->tsf_clk_frac_h, 0x8); + W_REG(®s->tsf_clk_frac_l, 0x2082); + W_REG(®s->tsf_clk_frac_h, 0x8); } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ - W_REG(osh, ®s->tsf_clk_frac_l, 0x5341); - W_REG(osh, ®s->tsf_clk_frac_h, 0x8); + W_REG(®s->tsf_clk_frac_l, 0x5341); + W_REG(®s->tsf_clk_frac_h, 0x8); } else { /* 120Mhz */ - W_REG(osh, ®s->tsf_clk_frac_l, 0x8889); - W_REG(osh, ®s->tsf_clk_frac_h, 0x8); + W_REG(®s->tsf_clk_frac_l, 0x8889); + W_REG(®s->tsf_clk_frac_h, 0x8); } } else if (WLCISLCNPHY(wlc_hw->band)) { if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ - W_REG(osh, ®s->tsf_clk_frac_l, 0x7CE0); - W_REG(osh, ®s->tsf_clk_frac_h, 0xC); + W_REG(®s->tsf_clk_frac_l, 0x7CE0); + W_REG(®s->tsf_clk_frac_h, 0xC); } else { /* 80Mhz */ - W_REG(osh, ®s->tsf_clk_frac_l, 0xCCCD); - W_REG(osh, ®s->tsf_clk_frac_h, 0xC); + W_REG(®s->tsf_clk_frac_l, 0xCCCD); + W_REG(®s->tsf_clk_frac_h, 0xC); } } } @@ -2739,10 +2526,8 @@ static void wlc_gpio_init(struct wlc_info *wlc) struct wlc_hw_info *wlc_hw = wlc->hw; d11regs_t *regs; u32 gc, gm; - struct osl_info *osh; regs = wlc_hw->regs; - osh = wlc_hw->osh; /* use GPIO select 0 to get all gpio signals from the gpio out reg */ wlc_bmac_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); @@ -2758,39 +2543,39 @@ static void wlc_gpio_init(struct wlc_info *wlc) gc = gm = 0; /* Allocate GPIOs for mimo antenna diversity feature */ - if (WLANTSEL_ENAB(wlc)) { - if (wlc_hw->antsel_type == ANTSEL_2x3) { - /* Enable antenna diversity, use 2x3 mode */ - wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, WLC_BAND_ALL); - wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, - MHF3_ANTSEL_MODE, WLC_BAND_ALL); - - /* init superswitch control */ - wlc_phy_antsel_init(wlc_hw->band->pi, false); - - } else if (wlc_hw->antsel_type == ANTSEL_2x4) { - ASSERT((gm & BOARD_GPIO_12) == 0); - gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13); - /* The board itself is powered by these GPIOs (when not sending pattern) - * So set them high - */ - OR_REG(osh, ®s->psm_gpio_oe, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - OR_REG(osh, ®s->psm_gpio_out, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - - /* Enable antenna diversity, use 2x4 mode */ - wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, - MHF3_ANTSEL_EN, WLC_BAND_ALL); - wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, - WLC_BAND_ALL); - - /* Configure the desired clock to be 4Mhz */ - wlc_bmac_write_shm(wlc_hw, M_ANTSEL_CLKDIV, - ANTSEL_CLKDIV_4MHZ); - } + if (wlc_hw->antsel_type == ANTSEL_2x3) { + /* Enable antenna diversity, use 2x3 mode */ + wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, + MHF3_ANTSEL_EN, WLC_BAND_ALL); + wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, + MHF3_ANTSEL_MODE, WLC_BAND_ALL); + + /* init superswitch control */ + wlc_phy_antsel_init(wlc_hw->band->pi, false); + + } else if (wlc_hw->antsel_type == ANTSEL_2x4) { + ASSERT((gm & BOARD_GPIO_12) == 0); + gm |= gc |= (BOARD_GPIO_12 | BOARD_GPIO_13); + /* + * The board itself is powered by these GPIOs + * (when not sending pattern) so set them high + */ + OR_REG(®s->psm_gpio_oe, + (BOARD_GPIO_12 | BOARD_GPIO_13)); + OR_REG(®s->psm_gpio_out, + (BOARD_GPIO_12 | BOARD_GPIO_13)); + + /* Enable antenna diversity, use 2x4 mode */ + wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, + MHF3_ANTSEL_EN, WLC_BAND_ALL); + wlc_bmac_mhf(wlc_hw, MHF3, MHF3_ANTSEL_MODE, 0, + WLC_BAND_ALL); + + /* Configure the desired clock to be 4Mhz */ + wlc_bmac_write_shm(wlc_hw, M_ANTSEL_CLKDIV, + ANTSEL_CLKDIV_4MHZ); } + /* gpio 9 controls the PA. ucode is responsible for wiggling out and oe */ if (wlc_hw->boardflags & BFL_PACTRL) gm |= gc |= BOARD_GPIO_PACTRL; @@ -2829,44 +2614,40 @@ static void wlc_ucode_download(struct wlc_hw_info *wlc_hw) static void wlc_ucode_write(struct wlc_hw_info *wlc_hw, const u32 ucode[], const uint nbytes) { - struct osl_info *osh; d11regs_t *regs = wlc_hw->regs; uint i; uint count; - osh = wlc_hw->osh; - WL_TRACE("wl%d: wlc_ucode_write\n", wlc_hw->unit); ASSERT(IS_ALIGNED(nbytes, sizeof(u32))); count = (nbytes / sizeof(u32)); - W_REG(osh, ®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); - (void)R_REG(osh, ®s->objaddr); + W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); + (void)R_REG(®s->objaddr); for (i = 0; i < count; i++) - W_REG(osh, ®s->objdata, ucode[i]); + W_REG(®s->objdata, ucode[i]); } -static void wlc_write_inits(struct wlc_hw_info *wlc_hw, const d11init_t *inits) +static void wlc_write_inits(struct wlc_hw_info *wlc_hw, + const struct d11init *inits) { int i; - struct osl_info *osh; volatile u8 *base; WL_TRACE("wl%d: wlc_write_inits\n", wlc_hw->unit); - osh = wlc_hw->osh; base = (volatile u8 *)wlc_hw->regs; for (i = 0; inits[i].addr != 0xffff; i++) { ASSERT((inits[i].size == 2) || (inits[i].size == 4)); if (inits[i].size == 2) - W_REG(osh, (u16 *)(base + inits[i].addr), + W_REG((u16 *)(base + inits[i].addr), inits[i].value); else if (inits[i].size == 4) - W_REG(osh, (u32 *)(base + inits[i].addr), + W_REG((u32 *)(base + inits[i].addr), inits[i].value); } } @@ -2925,8 +2706,7 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw) for (idx = 0; idx < NFIFO; idx++) { /* read intstatus register and ignore any non-error bits */ intstatus = - R_REG(wlc_hw->osh, - ®s->intctrlregs[idx].intstatus) & I_ERRORS; + R_REG(®s->intctrlregs[idx].intstatus) & I_ERRORS; if (!intstatus) continue; @@ -2936,40 +2716,40 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw) if (intstatus & I_RO) { WL_ERROR("wl%d: fifo %d: receive fifo overflow\n", unit, idx); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->rxoflo); + wlc_hw->wlc->pub->_cnt->rxoflo++; fatal = true; } if (intstatus & I_PC) { WL_ERROR("wl%d: fifo %d: descriptor error\n", unit, idx); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->dmade); + wlc_hw->wlc->pub->_cnt->dmade++; fatal = true; } if (intstatus & I_PD) { WL_ERROR("wl%d: fifo %d: data error\n", unit, idx); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->dmada); + wlc_hw->wlc->pub->_cnt->dmada++; fatal = true; } if (intstatus & I_DE) { WL_ERROR("wl%d: fifo %d: descriptor protocol error\n", unit, idx); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->dmape); + wlc_hw->wlc->pub->_cnt->dmape++; fatal = true; } if (intstatus & I_RU) { WL_ERROR("wl%d: fifo %d: receive descriptor underflow\n", idx, unit); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->rxuflo[idx]); + wlc_hw->wlc->pub->_cnt->rxuflo[idx]++; } if (intstatus & I_XU) { WL_ERROR("wl%d: fifo %d: transmit fifo underflow\n", idx, unit); - WLCNTINCR(wlc_hw->wlc->pub->_cnt->txuflo); + wlc_hw->wlc->pub->_cnt->txuflo++; fatal = true; } @@ -2977,7 +2757,7 @@ void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw) wlc_fatal_error(wlc_hw->wlc); /* big hammer */ break; } else - W_REG(wlc_hw->osh, ®s->intctrlregs[idx].intstatus, + W_REG(®s->intctrlregs[idx].intstatus, intstatus); } } @@ -2987,7 +2767,7 @@ void wlc_intrson(struct wlc_info *wlc) struct wlc_hw_info *wlc_hw = wlc->hw; ASSERT(wlc->defmacintmask); wlc->macintmask = wlc->defmacintmask; - W_REG(wlc_hw->osh, &wlc_hw->regs->macintmask, wlc->macintmask); + W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); } /* callback for siutils.c, which has only wlc handler, no wl @@ -3021,8 +2801,8 @@ u32 wlc_intrsoff(struct wlc_info *wlc) macintmask = wlc->macintmask; /* isr can still happen */ - W_REG(wlc_hw->osh, &wlc_hw->regs->macintmask, 0); - (void)R_REG(wlc_hw->osh, &wlc_hw->regs->macintmask); /* sync readback */ + W_REG(&wlc_hw->regs->macintmask, 0); + (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ udelay(1); /* ensure int line is no longer driven */ wlc->macintmask = 0; @@ -3037,12 +2817,12 @@ void wlc_intrsrestore(struct wlc_info *wlc, u32 macintmask) return; wlc->macintmask = macintmask; - W_REG(wlc_hw->osh, &wlc_hw->regs->macintmask, wlc->macintmask); + W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); } -void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags) +static void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags) { - struct ether_addr null_ether_addr = { {0, 0, 0, 0, 0, 0} }; + u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; if (on) { /* suspend tx fifos */ @@ -3053,7 +2833,7 @@ void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags) /* zero the address match register so we do not send ACKs */ wlc_bmac_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - &null_ether_addr); + null_ether_addr); } else { /* resume tx fifos */ if (!wlc_hw->wlc->tx_suspended) { @@ -3065,7 +2845,7 @@ void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags) /* Restore address */ wlc_bmac_set_addrmatch(wlc_hw, RCM_MAC_OFFSET, - &wlc_hw->etheraddr); + wlc_hw->etheraddr); } wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); @@ -3076,11 +2856,6 @@ void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool on, mbool flags) wlc_ucode_mute_override_clear(wlc_hw); } -void wlc_bmac_set_deaf(struct wlc_hw_info *wlc_hw, bool user_flag) -{ - wlc_phy_set_deaf(wlc_hw->band->pi, user_flag); -} - int wlc_bmac_xmtfifo_sz_get(struct wlc_hw_info *wlc_hw, uint fifo, uint *blocks) { if (fifo >= NFIFO) @@ -3091,17 +2866,6 @@ int wlc_bmac_xmtfifo_sz_get(struct wlc_hw_info *wlc_hw, uint fifo, uint *blocks) return 0; } -int wlc_bmac_xmtfifo_sz_set(struct wlc_hw_info *wlc_hw, uint fifo, uint blocks) -{ - if (fifo >= NFIFO || blocks > 299) - return BCME_RANGE; - - /* BMAC_NOTE, change blocks to u16 */ - wlc_hw->xmtfifo_sz[fifo] = (u16) blocks; - - return 0; -} - /* wlc_bmac_tx_fifo_suspended: * Check the MAC's tx suspend status for a tx fifo. * @@ -3111,7 +2875,7 @@ int wlc_bmac_xmtfifo_sz_set(struct wlc_hw_info *wlc_hw, uint fifo, uint blocks) * be pulling data into a tx fifo, by the time the MAC acks the suspend * request. */ -bool wlc_bmac_tx_fifo_suspended(struct wlc_hw_info *wlc_hw, uint tx_fifo) +static bool wlc_bmac_tx_fifo_suspended(struct wlc_hw_info *wlc_hw, uint tx_fifo) { /* check that a suspend has been requested and is no longer pending */ @@ -3123,14 +2887,14 @@ bool wlc_bmac_tx_fifo_suspended(struct wlc_hw_info *wlc_hw, uint tx_fifo) * may be acked before or after the DMA is suspended. */ if (dma_txsuspended(wlc_hw->di[tx_fifo]) && - (R_REG(wlc_hw->osh, &wlc_hw->regs->chnstatus) & + (R_REG(&wlc_hw->regs->chnstatus) & (1 << tx_fifo)) == 0) return true; return false; } -void wlc_bmac_tx_fifo_suspend(struct wlc_hw_info *wlc_hw, uint tx_fifo) +static void wlc_bmac_tx_fifo_suspend(struct wlc_hw_info *wlc_hw, uint tx_fifo) { u8 fifo = 1 << tx_fifo; @@ -3161,7 +2925,7 @@ void wlc_bmac_tx_fifo_suspend(struct wlc_hw_info *wlc_hw, uint tx_fifo) } } -void wlc_bmac_tx_fifo_resume(struct wlc_hw_info *wlc_hw, uint tx_fifo) +static void wlc_bmac_tx_fifo_resume(struct wlc_hw_info *wlc_hw, uint tx_fifo) { /* BMAC_NOTE: WLC_TX_FIFO_ENAB is done in wlc_dpc() for DMA case but need to be done * here for PIO otherwise the watchdog will catch the inconsistency and fire @@ -3194,13 +2958,9 @@ static inline u32 wlc_intstatus(struct wlc_info *wlc, bool in_isr) struct wlc_hw_info *wlc_hw = wlc->hw; d11regs_t *regs = wlc_hw->regs; u32 macintstatus; - u32 intstatus_rxfifo, intstatus_txsfifo; - struct osl_info *osh; - - osh = wlc_hw->osh; /* macintstatus includes a DMA interrupt summary bit */ - macintstatus = R_REG(osh, ®s->macintstatus); + macintstatus = R_REG(®s->macintstatus); WL_TRACE("wl%d: macintstatus: 0x%x\n", wlc_hw->unit, macintstatus); @@ -3226,54 +2986,22 @@ static inline u32 wlc_intstatus(struct wlc_info *wlc, bool in_isr) * consequences */ /* turn off the interrupts */ - W_REG(osh, ®s->macintmask, 0); - (void)R_REG(osh, ®s->macintmask); /* sync readback */ + W_REG(®s->macintmask, 0); + (void)R_REG(®s->macintmask); /* sync readback */ wlc->macintmask = 0; /* clear device interrupts */ - W_REG(osh, ®s->macintstatus, macintstatus); + W_REG(®s->macintstatus, macintstatus); /* MI_DMAINT is indication of non-zero intstatus */ if (macintstatus & MI_DMAINT) { - if (D11REV_IS(wlc_hw->corerev, 4)) { - intstatus_rxfifo = - R_REG(osh, ®s->intctrlregs[RX_FIFO].intstatus); - intstatus_txsfifo = - R_REG(osh, - ®s->intctrlregs[RX_TXSTATUS_FIFO]. - intstatus); - WL_TRACE("wl%d: intstatus_rxfifo 0x%x, intstatus_txsfifo 0x%x\n", - wlc_hw->unit, - intstatus_rxfifo, intstatus_txsfifo); - - /* defer unsolicited interrupt hints */ - intstatus_rxfifo &= DEF_RXINTMASK; - intstatus_txsfifo &= DEF_RXINTMASK; - - /* MI_DMAINT bit in macintstatus is indication of RX_FIFO interrupt */ - /* clear interrupt hints */ - if (intstatus_rxfifo) - W_REG(osh, - ®s->intctrlregs[RX_FIFO].intstatus, - intstatus_rxfifo); - else - macintstatus &= ~MI_DMAINT; - - /* MI_TFS bit in macintstatus is encoding of RX_TXSTATUS_FIFO interrupt */ - if (intstatus_txsfifo) { - W_REG(osh, - ®s->intctrlregs[RX_TXSTATUS_FIFO]. - intstatus, intstatus_txsfifo); - macintstatus |= MI_TFS; - } - } else { - /* - * For corerevs >= 5, only fifo interrupt enabled is I_RI in RX_FIFO. - * If MI_DMAINT is set, assume it is set and clear the interrupt. - */ - W_REG(osh, ®s->intctrlregs[RX_FIFO].intstatus, - DEF_RXINTMASK); - } + /* + * only fifo interrupt enabled is I_RI in + * RX_FIFO. If MI_DMAINT is set, assume it + * is set and clear the interrupt. + */ + W_REG(®s->intctrlregs[RX_FIFO].intstatus, + DEF_RXINTMASK); } return macintstatus; @@ -3336,42 +3064,6 @@ bool BCMFASTPATH wlc_isr(struct wlc_info *wlc, bool *wantdpc) } -/* process tx completion events for corerev < 5 */ -static bool wlc_bmac_txstatus_corerev4(struct wlc_hw_info *wlc_hw) -{ - struct sk_buff *status_p; - tx_status_t *txs; - struct osl_info *osh; - bool fatal = false; - - WL_TRACE("wl%d: wlc_txstatusrecv\n", wlc_hw->unit); - - osh = wlc_hw->osh; - - while (!fatal && (status_p = dma_rx(wlc_hw->di[RX_TXSTATUS_FIFO]))) { - - txs = (tx_status_t *) status_p->data; - /* MAC uses little endian only */ - ltoh16_buf((void *)txs, sizeof(tx_status_t)); - - /* shift low bits for tx_status_t status compatibility */ - txs->status = (txs->status & ~TXS_COMPAT_MASK) - | (((txs->status & TXS_COMPAT_MASK) << TXS_COMPAT_SHIFT)); - - fatal = wlc_bmac_dotxstatus(wlc_hw, txs, 0); - - pkt_buf_free_skb(osh, status_p, false); - } - - if (fatal) - return true; - - /* post more rbufs */ - dma_rxfill(wlc_hw->di[RX_TXSTATUS_FIFO]); - - return false; -} - static bool BCMFASTPATH wlc_bmac_dotxstatus(struct wlc_hw_info *wlc_hw, tx_status_t *txs, u32 s2) { @@ -3396,59 +3088,50 @@ wlc_bmac_txstatus(struct wlc_hw_info *wlc_hw, bool bound, bool *fatal) { bool morepending = false; struct wlc_info *wlc = wlc_hw->wlc; + d11regs_t *regs; + tx_status_t txstatus, *txs; + u32 s1, s2; + uint n = 0; + /* + * Param 'max_tx_num' indicates max. # tx status to process before + * break out. + */ + uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; WL_TRACE("wl%d: wlc_bmac_txstatus\n", wlc_hw->unit); - if (D11REV_IS(wlc_hw->corerev, 4)) { - /* to retire soon */ - *fatal = wlc_bmac_txstatus_corerev4(wlc->hw); - - if (*fatal) - return 0; - } else { - /* corerev >= 5 */ - d11regs_t *regs; - struct osl_info *osh; - tx_status_t txstatus, *txs; - u32 s1, s2; - uint n = 0; - /* Param 'max_tx_num' indicates max. # tx status to process before break out. */ - uint max_tx_num = bound ? wlc->pub->tunables->txsbnd : -1; - - txs = &txstatus; - regs = wlc_hw->regs; - osh = wlc_hw->osh; - while (!(*fatal) - && (s1 = R_REG(osh, ®s->frmtxstatus)) & TXS_V) { - - if (s1 == 0xffffffff) { - WL_ERROR("wl%d: %s: dead chip\n", - wlc_hw->unit, __func__); - ASSERT(s1 != 0xffffffff); - return morepending; - } + txs = &txstatus; + regs = wlc_hw->regs; + while (!(*fatal) + && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { + + if (s1 == 0xffffffff) { + WL_ERROR("wl%d: %s: dead chip\n", + wlc_hw->unit, __func__); + ASSERT(s1 != 0xffffffff); + return morepending; + } - s2 = R_REG(osh, ®s->frmtxstatus2); + s2 = R_REG(®s->frmtxstatus2); - txs->status = s1 & TXS_STATUS_MASK; - txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; - txs->sequence = s2 & TXS_SEQ_MASK; - txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; - txs->lasttxtime = 0; + txs->status = s1 & TXS_STATUS_MASK; + txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; + txs->sequence = s2 & TXS_SEQ_MASK; + txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; + txs->lasttxtime = 0; - *fatal = wlc_bmac_dotxstatus(wlc_hw, txs, s2); + *fatal = wlc_bmac_dotxstatus(wlc_hw, txs, s2); - /* !give others some time to run! */ - if (++n >= max_tx_num) - break; - } + /* !give others some time to run! */ + if (++n >= max_tx_num) + break; + } - if (*fatal) - return 0; + if (*fatal) + return 0; - if (n >= max_tx_num) - morepending = true; - } + if (n >= max_tx_num) + morepending = true; if (!pktq_empty(&wlc->active_queue->q)) wlc_send_q(wlc, wlc->active_queue); @@ -3461,7 +3144,6 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc) struct wlc_hw_info *wlc_hw = wlc->hw; d11regs_t *regs = wlc_hw->regs; u32 mc, mi; - struct osl_info *osh; WL_TRACE("wl%d: wlc_suspend_mac_and_wait: bandunit %d\n", wlc_hw->unit, wlc_hw->band->bandunit); @@ -3473,12 +3155,10 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc) if (wlc_hw->mac_suspend_depth > 1) return; - osh = wlc_hw->osh; - /* force the core awake */ wlc_ucode_wake_override_set(wlc_hw, WLC_WAKE_OVERRIDE_MACSUSPEND); - mc = R_REG(osh, ®s->maccontrol); + mc = R_REG(®s->maccontrol); if (mc == 0xffffffff) { WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__); @@ -3489,7 +3169,7 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc) ASSERT(mc & MCTL_PSM_RUN); ASSERT(mc & MCTL_EN_MAC); - mi = R_REG(osh, ®s->macintstatus); + mi = R_REG(®s->macintstatus); if (mi == 0xffffffff) { WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__); wl_down(wlc->wl); @@ -3499,20 +3179,20 @@ void wlc_suspend_mac_and_wait(struct wlc_info *wlc) wlc_bmac_mctrl(wlc_hw, MCTL_EN_MAC, 0); - SPINWAIT(!(R_REG(osh, ®s->macintstatus) & MI_MACSSPNDD), + SPINWAIT(!(R_REG(®s->macintstatus) & MI_MACSSPNDD), WLC_MAX_MAC_SUSPEND); - if (!(R_REG(osh, ®s->macintstatus) & MI_MACSSPNDD)) { + if (!(R_REG(®s->macintstatus) & MI_MACSSPNDD)) { WL_ERROR("wl%d: wlc_suspend_mac_and_wait: waited %d uS and MI_MACSSPNDD is still not on.\n", wlc_hw->unit, WLC_MAX_MAC_SUSPEND); WL_ERROR("wl%d: psmdebug 0x%08x, phydebug 0x%08x, psm_brc 0x%04x\n", wlc_hw->unit, - R_REG(osh, ®s->psmdebug), - R_REG(osh, ®s->phydebug), - R_REG(osh, ®s->psm_brc)); + R_REG(®s->psmdebug), + R_REG(®s->phydebug), + R_REG(®s->psm_brc)); } - mc = R_REG(osh, ®s->maccontrol); + mc = R_REG(®s->maccontrol); if (mc == 0xffffffff) { WL_ERROR("wl%d: %s: dead chip\n", wlc_hw->unit, __func__); wl_down(wlc->wl); @@ -3528,7 +3208,6 @@ void wlc_enable_mac(struct wlc_info *wlc) struct wlc_hw_info *wlc_hw = wlc->hw; d11regs_t *regs = wlc_hw->regs; u32 mc, mi; - struct osl_info *osh; WL_TRACE("wl%d: wlc_enable_mac: bandunit %d\n", wlc_hw->unit, wlc->band->bandunit); @@ -3541,63 +3220,25 @@ void wlc_enable_mac(struct wlc_info *wlc) if (wlc_hw->mac_suspend_depth > 0) return; - osh = wlc_hw->osh; - - mc = R_REG(osh, ®s->maccontrol); + mc = R_REG(®s->maccontrol); ASSERT(!(mc & MCTL_PSM_JMP_0)); ASSERT(!(mc & MCTL_EN_MAC)); ASSERT(mc & MCTL_PSM_RUN); wlc_bmac_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); - W_REG(osh, ®s->macintstatus, MI_MACSSPNDD); + W_REG(®s->macintstatus, MI_MACSSPNDD); - mc = R_REG(osh, ®s->maccontrol); + mc = R_REG(®s->maccontrol); ASSERT(!(mc & MCTL_PSM_JMP_0)); ASSERT(mc & MCTL_EN_MAC); ASSERT(mc & MCTL_PSM_RUN); - mi = R_REG(osh, ®s->macintstatus); + mi = R_REG(®s->macintstatus); ASSERT(!(mi & MI_MACSSPNDD)); wlc_ucode_wake_override_clear(wlc_hw, WLC_WAKE_OVERRIDE_MACSUSPEND); } -void wlc_bmac_ifsctl_edcrs_set(struct wlc_hw_info *wlc_hw, bool abie, bool isht) -{ - if (!(WLCISNPHY(wlc_hw->band) && (D11REV_GE(wlc_hw->corerev, 16)))) - return; - - if (isht) { - if (WLCISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 3)) { - AND_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - ~IFS_CTL1_EDCRS); - } - } else { - /* enable EDCRS for non-11n association */ - OR_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, IFS_CTL1_EDCRS); - } - - if (WLCISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3)) { - if (CHSPEC_IS20(wlc_hw->chanspec)) { - /* 20 mhz, use 20U ED only */ - OR_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - IFS_CTL1_EDCRS); - AND_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - ~IFS_CTL1_EDCRS_20L); - AND_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - ~IFS_CTL1_EDCRS_40); - } else { - /* 40 mhz, use 20U 20L and 40 ED */ - OR_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - IFS_CTL1_EDCRS); - OR_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - IFS_CTL1_EDCRS_20L); - OR_REG(wlc_hw->osh, &wlc_hw->regs->ifs_ctl1, - IFS_CTL1_EDCRS_40); - } - } -} - static void wlc_upd_ofdm_pctl1_table(struct wlc_hw_info *wlc_hw) { u8 rate; @@ -3680,100 +3321,62 @@ wlc_bmac_read_tsf(struct wlc_hw_info *wlc_hw, u32 *tsf_l_ptr, d11regs_t *regs = wlc_hw->regs; /* read the tsf timer low, then high to get an atomic read */ - *tsf_l_ptr = R_REG(wlc_hw->osh, ®s->tsf_timerlow); - *tsf_h_ptr = R_REG(wlc_hw->osh, ®s->tsf_timerhigh); + *tsf_l_ptr = R_REG(®s->tsf_timerlow); + *tsf_h_ptr = R_REG(®s->tsf_timerhigh); return; } -bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw) +static bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw) { d11regs_t *regs; u32 w, val; - volatile u16 *reg16; - struct osl_info *osh; WL_TRACE("wl%d: validate_chip_access\n", wlc_hw->unit); regs = wlc_hw->regs; - osh = wlc_hw->osh; /* Validate dchip register access */ - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - w = R_REG(osh, ®s->objdata); + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + w = R_REG(®s->objdata); /* Can we write and read back a 32bit register? */ - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, (u32) 0xaa5555aa); + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, (u32) 0xaa5555aa); - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - val = R_REG(osh, ®s->objdata); + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + val = R_REG(®s->objdata); if (val != (u32) 0xaa5555aa) { WL_ERROR("wl%d: validate_chip_access: SHM = 0x%x, expected 0xaa5555aa\n", wlc_hw->unit, val); return false; } - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, (u32) 0x55aaaa55); + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, (u32) 0x55aaaa55); - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - val = R_REG(osh, ®s->objdata); + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + val = R_REG(®s->objdata); if (val != (u32) 0x55aaaa55) { WL_ERROR("wl%d: validate_chip_access: SHM = 0x%x, expected 0x55aaaa55\n", wlc_hw->unit, val); return false; } - W_REG(osh, ®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(osh, ®s->objaddr); - W_REG(osh, ®s->objdata, w); - - if (D11REV_LT(wlc_hw->corerev, 11)) { - /* if 32 bit writes are split into 16 bit writes, are they in the correct order - * for our interface, low to high - */ - reg16 = (volatile u16 *)®s->tsf_cfpstart; - - /* write the CFPStart register low half explicitly, starting a buffered write */ - W_REG(osh, reg16, 0xAAAA); - - /* Write a 32 bit value to CFPStart to test the 16 bit split order. - * If the low 16 bits are written first, followed by the high 16 bits then the - * 32 bit value 0xCCCCBBBB should end up in the register. - * If the order is reversed, then the write to the high half will trigger a buffered - * write of 0xCCCCAAAA. - * If the bus is 32 bits, then this is not much of a test, and the reg should - * have the correct value 0xCCCCBBBB. - */ - W_REG(osh, ®s->tsf_cfpstart, 0xCCCCBBBB); - - /* verify with the 16 bit registers that have no side effects */ - val = R_REG(osh, ®s->tsf_cfpstrt_l); - if (val != (uint) 0xBBBB) { - WL_ERROR("wl%d: validate_chip_access: tsf_cfpstrt_l = 0x%x, expected 0x%x\n", - wlc_hw->unit, val, 0xBBBB); - return false; - } - val = R_REG(osh, ®s->tsf_cfpstrt_h); - if (val != (uint) 0xCCCC) { - WL_ERROR("wl%d: validate_chip_access: tsf_cfpstrt_h = 0x%x, expected 0x%x\n", - wlc_hw->unit, val, 0xCCCC); - return false; - } - - } + W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); + (void)R_REG(®s->objaddr); + W_REG(®s->objdata, w); /* clear CFPStart */ - W_REG(osh, ®s->tsf_cfpstart, 0); + W_REG(®s->tsf_cfpstart, 0); - w = R_REG(osh, ®s->maccontrol); + w = R_REG(®s->maccontrol); if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { WL_ERROR("wl%d: validate_chip_access: maccontrol = 0x%x, expected 0x%x or 0x%x\n", @@ -3791,28 +3394,23 @@ bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw) void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on) { d11regs_t *regs; - struct osl_info *osh; u32 tmp; WL_TRACE("wl%d: wlc_bmac_core_phypll_ctl\n", wlc_hw->unit); tmp = 0; regs = wlc_hw->regs; - osh = wlc_hw->osh; - - if (D11REV_LE(wlc_hw->corerev, 16) || D11REV_IS(wlc_hw->corerev, 20)) - return; if (on) { if ((wlc_hw->sih->chip == BCM4313_CHIP_ID)) { - OR_REG(osh, ®s->clk_ctl_st, + OR_REG(®s->clk_ctl_st, (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(osh, ®s->clk_ctl_st) & + SPINWAIT((R_REG(®s->clk_ctl_st) & (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), PHYPLL_WAIT_US); - tmp = R_REG(osh, ®s->clk_ctl_st); + tmp = R_REG(®s->clk_ctl_st); if ((tmp & (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT)) { WL_ERROR("%s: turn on PHY PLL failed\n", @@ -3820,15 +3418,15 @@ void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on) ASSERT(0); } } else { - OR_REG(osh, ®s->clk_ctl_st, + OR_REG(®s->clk_ctl_st, (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(osh, ®s->clk_ctl_st) & + SPINWAIT((R_REG(®s->clk_ctl_st) & (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) != (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); - tmp = R_REG(osh, ®s->clk_ctl_st); + tmp = R_REG(®s->clk_ctl_st); if ((tmp & (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) != @@ -3842,8 +3440,8 @@ void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on) /* Since the PLL may be shared, other cores can still be requesting it; * so we'll deassert the request but not wait for status to comply. */ - AND_REG(osh, ®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); - tmp = R_REG(osh, ®s->clk_ctl_st); + AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); + tmp = R_REG(®s->clk_ctl_st); } } @@ -3887,7 +3485,7 @@ void wlc_coredisable(struct wlc_hw_info *wlc_hw) } /* power both the pll and external oscillator on/off */ -void wlc_bmac_xtal(struct wlc_hw_info *wlc_hw, bool want) +static void wlc_bmac_xtal(struct wlc_hw_info *wlc_hw, bool want) { WL_TRACE("wl%d: wlc_bmac_xtal: want %d\n", wlc_hw->unit, want); @@ -3924,8 +3522,6 @@ static void wlc_flushqueues(struct wlc_info *wlc) /* free any posted rx packets */ dma_rxreclaim(wlc_hw->di[RX_FIFO]); - if (D11REV_IS(wlc_hw->corerev, 4)) - dma_rxreclaim(wlc_hw->di[RX_TXSTATUS_FIFO]); } u16 wlc_bmac_read_shm(struct wlc_hw_info *wlc_hw, uint offset) @@ -3968,12 +3564,12 @@ wlc_bmac_read_objmem(struct wlc_hw_info *wlc_hw, uint offset, u32 sel) ASSERT((offset & 1) == 0); - W_REG(wlc_hw->osh, ®s->objaddr, sel | (offset >> 2)); - (void)R_REG(wlc_hw->osh, ®s->objaddr); + W_REG(®s->objaddr, sel | (offset >> 2)); + (void)R_REG(®s->objaddr); if (offset & 2) { - v = R_REG(wlc_hw->osh, objdata_hi); + v = R_REG(objdata_hi); } else { - v = R_REG(wlc_hw->osh, objdata_lo); + v = R_REG(objdata_lo); } return v; @@ -3988,12 +3584,12 @@ wlc_bmac_write_objmem(struct wlc_hw_info *wlc_hw, uint offset, u16 v, u32 sel) ASSERT((offset & 1) == 0); - W_REG(wlc_hw->osh, ®s->objaddr, sel | (offset >> 2)); - (void)R_REG(wlc_hw->osh, ®s->objaddr); + W_REG(®s->objaddr, sel | (offset >> 2)); + (void)R_REG(®s->objaddr); if (offset & 2) { - W_REG(wlc_hw->osh, objdata_hi, v); + W_REG(objdata_hi, v); } else { - W_REG(wlc_hw->osh, objdata_lo, v); + W_REG(objdata_lo, v); } } @@ -4066,14 +3662,14 @@ void wlc_bmac_retrylimit_upd(struct wlc_hw_info *wlc_hw, u16 SRL, u16 LRL) /* write retry limit to SCR, shouldn't need to suspend */ if (wlc_hw->up) { - W_REG(wlc_hw->osh, &wlc_hw->regs->objaddr, + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(wlc_hw->osh, &wlc_hw->regs->objaddr); - W_REG(wlc_hw->osh, &wlc_hw->regs->objdata, wlc_hw->SRL); - W_REG(wlc_hw->osh, &wlc_hw->regs->objaddr, + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); + W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(wlc_hw->osh, &wlc_hw->regs->objaddr); - W_REG(wlc_hw->osh, &wlc_hw->regs->objdata, wlc_hw->LRL); + (void)R_REG(&wlc_hw->regs->objaddr); + W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); } } @@ -4082,11 +3678,6 @@ void wlc_bmac_set_noreset(struct wlc_hw_info *wlc_hw, bool noreset_flag) wlc_hw->noreset = noreset_flag; } -void wlc_bmac_set_ucode_loaded(struct wlc_hw_info *wlc_hw, bool ucode_loaded) -{ - wlc_hw->ucode_loaded = ucode_loaded; -} - void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set, mbool req_bit) { ASSERT(req_bit); @@ -4118,89 +3709,12 @@ void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set, mbool req_bit) return; } -void wlc_bmac_set_clk(struct wlc_hw_info *wlc_hw, bool on) -{ - if (on) { - /* power up pll and oscillator */ - wlc_bmac_xtal(wlc_hw, ON); - - /* enable core(s), ignore bandlocked - * Leave with the same band selected as we entered - */ - wlc_bmac_corereset(wlc_hw, WLC_USE_COREFLAGS); - } else { - /* if already down, must skip the core disable */ - if (wlc_hw->clk) { - /* disable core(s), ignore bandlocked */ - wlc_coredisable(wlc_hw); - } - /* power down pll and oscillator */ - wlc_bmac_xtal(wlc_hw, OFF); - } -} - /* this will be true for all ai chips */ bool wlc_bmac_taclear(struct wlc_hw_info *wlc_hw, bool ta_ok) { return true; } -/* Lower down relevant GPIOs like LED when going down w/o - * doing PCI config cycles or touching interrupts - */ -void wlc_gpio_fast_deinit(struct wlc_hw_info *wlc_hw) -{ - if ((wlc_hw == NULL) || (wlc_hw->sih == NULL)) - return; - - /* Only chips with internal bus or PCIE cores or certain PCI cores - * are able to switch cores w/o disabling interrupts - */ - if (!((wlc_hw->sih->bustype == SI_BUS) || - ((wlc_hw->sih->bustype == PCI_BUS) && - ((wlc_hw->sih->buscoretype == PCIE_CORE_ID) || - (wlc_hw->sih->buscorerev >= 13))))) - return; - - WL_TRACE("wl%d: %s\n", wlc_hw->unit, __func__); - return; -} - -bool wlc_bmac_radio_hw(struct wlc_hw_info *wlc_hw, bool enable) -{ - /* Do not access Phy registers if core is not up */ - if (si_iscoreup(wlc_hw->sih) == false) - return false; - - if (enable) { - if (PMUCTL_ENAB(wlc_hw->sih)) { - AND_REG(wlc_hw->osh, &wlc_hw->regs->clk_ctl_st, - ~CCS_FORCEHWREQOFF); - si_pmu_radio_enable(wlc_hw->sih, true); - } - - wlc_phy_anacore(wlc_hw->band->pi, ON); - wlc_phy_switch_radio(wlc_hw->band->pi, ON); - - /* resume d11 core */ - wlc_enable_mac(wlc_hw->wlc); - } else { - /* suspend d11 core */ - wlc_suspend_mac_and_wait(wlc_hw->wlc); - - wlc_phy_switch_radio(wlc_hw->band->pi, OFF); - wlc_phy_anacore(wlc_hw->band->pi, OFF); - - if (PMUCTL_ENAB(wlc_hw->sih)) { - si_pmu_radio_enable(wlc_hw->sih, false); - OR_REG(wlc_hw->osh, &wlc_hw->regs->clk_ctl_st, - CCS_FORCEHWREQOFF); - } - } - - return true; -} - u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate) { u16 table_ptr; @@ -4225,11 +3739,6 @@ u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate) return 2 * wlc_bmac_read_shm(wlc_hw, table_ptr + (index * 2)); } -void wlc_bmac_set_txpwr_percent(struct wlc_hw_info *wlc_hw, u8 val) -{ - wlc_phy_txpwr_percent_set(wlc_hw->band->pi, val); -} - void wlc_bmac_antsel_set(struct wlc_hw_info *wlc_hw, u32 antsel_avail) { wlc_hw->antsel_avail = antsel_avail; diff --git a/drivers/staging/brcm80211/sys/wlc_bmac.h b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.h index 98150aaff3a3..9c2c658d05ab 100644 --- a/drivers/staging/brcm80211/sys/wlc_bmac.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.h @@ -13,6 +13,8 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef _wlc_bmac_h_ +#define _wlc_bmac_h_ /* XXXXX this interface is under wlc.c by design * http://hwnbu-twiki.broadcom.com/bin/view/Mwgroup/WlBmacDesign @@ -25,38 +27,6 @@ * create wrappers in wlc.c if needed */ -/* Revision and other info required from BMAC driver for functioning of high ONLY driver */ -typedef struct wlc_bmac_revinfo { - uint vendorid; /* PCI vendor id */ - uint deviceid; /* device id of chip */ - - uint boardrev; /* version # of particular board */ - uint corerev; /* core revision */ - uint sromrev; /* srom revision */ - uint chiprev; /* chip revision */ - uint chip; /* chip number */ - uint chippkg; /* chip package */ - uint boardtype; /* board type */ - uint boardvendor; /* board vendor */ - uint bustype; /* SB_BUS, PCI_BUS */ - uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ - uint buscorerev; /* buscore rev */ - u32 issim; /* chip is in simulation or emulation */ - - uint nbands; - - struct band_info { - uint bandunit; /* To match on both sides */ - uint bandtype; /* To match on both sides */ - uint radiorev; - uint phytype; - uint phyrev; - uint anarev; - uint radioid; - bool abgphy_encore; - } band[MAXBANDS]; -} wlc_bmac_revinfo_t; - /* dup state between BMAC(struct wlc_hw_info) and HIGH(struct wlc_info) driver */ typedef struct wlc_bmac_state { @@ -109,38 +79,13 @@ enum { IOV_BMAC_LAST }; -typedef enum { - BMAC_DUMP_GPIO_ID, - BMAC_DUMP_SI_ID, - BMAC_DUMP_SIREG_ID, - BMAC_DUMP_SICLK_ID, - BMAC_DUMP_CCREG_ID, - BMAC_DUMP_PCIEREG_ID, - BMAC_DUMP_PHYREG_ID, - BMAC_DUMP_PHYTBL_ID, - BMAC_DUMP_PHYTBL2_ID, - BMAC_DUMP_PHY_RADIOREG_ID, - BMAC_DUMP_LAST -} wlc_bmac_dump_id_t; - -typedef enum { - WLCHW_STATE_ATTACH, - WLCHW_STATE_CLK, - WLCHW_STATE_UP, - WLCHW_STATE_ASSOC, - WLCHW_STATE_LAST -} wlc_bmac_state_id_t; - extern int wlc_bmac_attach(struct wlc_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, struct osl_info *osh, - void *regsva, uint bustype, void *btparam); + uint unit, bool piomode, void *regsva, uint bustype, + void *btparam); extern int wlc_bmac_detach(struct wlc_info *wlc); extern void wlc_bmac_watchdog(void *arg); -extern void wlc_bmac_info_init(struct wlc_hw_info *wlc_hw); /* up/down, reset, clk */ -extern void wlc_bmac_xtal(struct wlc_hw_info *wlc_hw, bool want); - extern void wlc_bmac_copyto_objmem(struct wlc_hw_info *wlc_hw, uint offset, const void *buf, int len, u32 sel); @@ -151,7 +96,6 @@ extern void wlc_bmac_copyfrom_objmem(struct wlc_hw_info *wlc_hw, uint offset, #define wlc_bmac_copyto_shm(wlc_hw, offset, buf, len) \ wlc_bmac_copyto_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL) -extern void wlc_bmac_core_phy_clk(struct wlc_hw_info *wlc_hw, bool clk); extern void wlc_bmac_core_phypll_reset(struct wlc_hw_info *wlc_hw); extern void wlc_bmac_core_phypll_ctl(struct wlc_hw_info *wlc_hw, bool on); extern void wlc_bmac_phyclk_fgc(struct wlc_hw_info *wlc_hw, bool clk); @@ -165,31 +109,23 @@ extern int wlc_bmac_up_prep(struct wlc_hw_info *wlc_hw); extern int wlc_bmac_up_finish(struct wlc_hw_info *wlc_hw); extern int wlc_bmac_down_prep(struct wlc_hw_info *wlc_hw); extern int wlc_bmac_down_finish(struct wlc_hw_info *wlc_hw); -extern void wlc_bmac_corereset(struct wlc_hw_info *wlc_hw, u32 flags); extern void wlc_bmac_switch_macfreq(struct wlc_hw_info *wlc_hw, u8 spurmode); /* chanspec, ucode interface */ -extern int wlc_bmac_bandtype(struct wlc_hw_info *wlc_hw); extern void wlc_bmac_set_chanspec(struct wlc_hw_info *wlc_hw, chanspec_t chanspec, bool mute, struct txpwr_limits *txpwr); -extern void wlc_bmac_txfifo(struct wlc_hw_info *wlc_hw, uint fifo, void *p, - bool commit, u16 frameid, u8 txpktpend); extern int wlc_bmac_xmtfifo_sz_get(struct wlc_hw_info *wlc_hw, uint fifo, uint *blocks); extern void wlc_bmac_mhf(struct wlc_hw_info *wlc_hw, u8 idx, u16 mask, u16 val, int bands); extern void wlc_bmac_mctrl(struct wlc_hw_info *wlc_hw, u32 mask, u32 val); extern u16 wlc_bmac_mhf_get(struct wlc_hw_info *wlc_hw, u8 idx, int bands); -extern int wlc_bmac_xmtfifo_sz_set(struct wlc_hw_info *wlc_hw, uint fifo, - uint blocks); extern void wlc_bmac_txant_set(struct wlc_hw_info *wlc_hw, u16 phytxant); extern u16 wlc_bmac_get_txant(struct wlc_hw_info *wlc_hw); extern void wlc_bmac_antsel_type_set(struct wlc_hw_info *wlc_hw, u8 antsel_type); -extern int wlc_bmac_revinfo_get(struct wlc_hw_info *wlc_hw, - wlc_bmac_revinfo_t *revinfo); extern int wlc_bmac_state_get(struct wlc_hw_info *wlc_hw, wlc_bmac_state_t *state); extern void wlc_bmac_write_shm(struct wlc_hw_info *wlc_hw, uint offset, u16 v); @@ -201,25 +137,14 @@ extern void wlc_bmac_write_template_ram(struct wlc_hw_info *wlc_hw, int offset, extern void wlc_bmac_copyfrom_vars(struct wlc_hw_info *wlc_hw, char **buf, uint *len); -extern void wlc_bmac_process_ps_switch(struct wlc_hw_info *wlc, - struct ether_addr *ea, s8 ps_on); extern void wlc_bmac_hw_etheraddr(struct wlc_hw_info *wlc_hw, - struct ether_addr *ea); -extern void wlc_bmac_set_hw_etheraddr(struct wlc_hw_info *wlc_hw, - struct ether_addr *ea); -extern bool wlc_bmac_validate_chip_access(struct wlc_hw_info *wlc_hw); + u8 *ea); extern bool wlc_bmac_radio_read_hwdisabled(struct wlc_hw_info *wlc_hw); extern void wlc_bmac_set_shortslot(struct wlc_hw_info *wlc_hw, bool shortslot); -extern void wlc_bmac_mute(struct wlc_hw_info *wlc_hw, bool want, mbool flags); -extern void wlc_bmac_set_deaf(struct wlc_hw_info *wlc_hw, bool user_flag); extern void wlc_bmac_band_stf_ss_set(struct wlc_hw_info *wlc_hw, u8 stf_mode); extern void wlc_bmac_wait_for_wake(struct wlc_hw_info *wlc_hw); -extern bool wlc_bmac_tx_fifo_suspended(struct wlc_hw_info *wlc_hw, - uint tx_fifo); -extern void wlc_bmac_tx_fifo_suspend(struct wlc_hw_info *wlc_hw, uint tx_fifo); -extern void wlc_bmac_tx_fifo_resume(struct wlc_hw_info *wlc_hw, uint tx_fifo); extern void wlc_ucode_wake_override_set(struct wlc_hw_info *wlc_hw, u32 override_bit); @@ -227,10 +152,10 @@ extern void wlc_ucode_wake_override_clear(struct wlc_hw_info *wlc_hw, u32 override_bit); extern void wlc_bmac_set_rcmta(struct wlc_hw_info *wlc_hw, int idx, - const struct ether_addr *addr); + const u8 *addr); extern void wlc_bmac_set_addrmatch(struct wlc_hw_info *wlc_hw, int match_reg_offset, - const struct ether_addr *addr); + const u8 *addr); extern void wlc_bmac_write_hw_bcntemplates(struct wlc_hw_info *wlc_hw, void *bcn, int len, bool both); @@ -239,8 +164,6 @@ extern void wlc_bmac_read_tsf(struct wlc_hw_info *wlc_hw, u32 *tsf_l_ptr, extern void wlc_bmac_set_cwmin(struct wlc_hw_info *wlc_hw, u16 newmin); extern void wlc_bmac_set_cwmax(struct wlc_hw_info *wlc_hw, u16 newmax); extern void wlc_bmac_set_noreset(struct wlc_hw_info *wlc, bool noreset_flag); -extern void wlc_bmac_set_ucode_loaded(struct wlc_hw_info *wlc, - bool ucode_loaded); extern void wlc_bmac_retrylimit_upd(struct wlc_hw_info *wlc_hw, u16 SRL, u16 LRL); @@ -253,21 +176,9 @@ extern void wlc_bmac_fifoerrors(struct wlc_hw_info *wlc_hw); extern void wlc_bmac_bw_set(struct wlc_hw_info *wlc_hw, u16 bw); extern void wlc_bmac_pllreq(struct wlc_hw_info *wlc_hw, bool set, mbool req_bit); -extern void wlc_bmac_set_clk(struct wlc_hw_info *wlc_hw, bool on); extern bool wlc_bmac_taclear(struct wlc_hw_info *wlc_hw, bool ta_ok); extern void wlc_bmac_hw_up(struct wlc_hw_info *wlc_hw); - -extern void wlc_bmac_dump(struct wlc_hw_info *wlc_hw, struct bcmstrbuf *b, - wlc_bmac_dump_id_t dump_id); -extern void wlc_gpio_fast_deinit(struct wlc_hw_info *wlc_hw); - -extern bool wlc_bmac_radio_hw(struct wlc_hw_info *wlc_hw, bool enable); extern u16 wlc_bmac_rate_shm_offset(struct wlc_hw_info *wlc_hw, u8 rate); - -extern void wlc_bmac_assert_type_set(struct wlc_hw_info *wlc_hw, u32 type); -extern void wlc_bmac_set_txpwr_percent(struct wlc_hw_info *wlc_hw, u8 val); -extern void wlc_bmac_blink_sync(struct wlc_hw_info *wlc_hw, u32 led_pins); -extern void wlc_bmac_ifsctl_edcrs_set(struct wlc_hw_info *wlc_hw, bool abie, - bool isht); - extern void wlc_bmac_antsel_set(struct wlc_hw_info *wlc_hw, u32 antsel_avail); + +#endif /* _wlc_bmac_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_bsscfg.h b/drivers/staging/brcm80211/brcmsmac/wlc_bsscfg.h index d6a1971c69a0..bbcff4fb5147 100644 --- a/drivers/staging/brcm80211/sys/wlc_bsscfg.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_bsscfg.h @@ -17,25 +17,18 @@ #ifndef _WLC_BSSCFG_H_ #define _WLC_BSSCFG_H_ -#include <wlc_types.h> - /* Check if a particular BSS config is AP or STA */ #define BSSCFG_AP(cfg) (0) #define BSSCFG_STA(cfg) (1) #define BSSCFG_IBSS(cfg) (!(cfg)->BSS) -/* forward declarations */ -typedef struct wlc_bsscfg wlc_bsscfg_t; - -#include <wlc_rate.h> - #define NTXRATE 64 /* # tx MPDUs rate is reported for */ #define MAXMACLIST 64 /* max # source MAC matches */ #define BCN_TEMPLATE_COUNT 2 /* Iterator for "associated" STA bss configs: - (struct wlc_info *wlc, int idx, wlc_bsscfg_t *cfg) */ + (struct wlc_info *wlc, int idx, struct wlc_bsscfg *cfg) */ #define FOREACH_AS_STA(wlc, idx, cfg) \ for (idx = 0; (int) idx < WLC_MAXBSSCFG; idx++) \ if ((cfg = (wlc)->bsscfg[idx]) && BSSCFG_STA(cfg) && cfg->associated) @@ -53,17 +46,9 @@ struct wlc_bsscfg { bool associated; /* is BSS in ASSOCIATED state */ bool BSS; /* infraustructure or adhac */ bool dtim_programmed; -#ifdef LATER - bool _ap; /* is this configuration an AP */ - struct wlc_if *wlcif; /* virtual interface, NULL for primary bsscfg */ - void *sup; /* pointer to supplicant state */ - s8 sup_type; /* type of supplicant */ - bool sup_enable_wpa; /* supplicant WPA on/off */ - void *authenticator; /* pointer to authenticator state */ - bool sup_auth_pending; /* flag for auth timeout */ -#endif + u8 SSID_len; /* the length of SSID */ - u8 SSID[DOT11_MAX_SSID_LEN]; /* SSID string */ + u8 SSID[IEEE80211_MAX_SSID_LEN]; /* SSID string */ struct scb *bcmc_scb[MAXBANDS]; /* one bcmc_scb per band */ s8 _idx; /* the index of this bsscfg, * assigned at wlc_bsscfg_alloc() @@ -93,8 +78,8 @@ struct wlc_bsscfg { u32 tk_cm_bt_tmstmp; /* Timestamp when TKIP BT is activated */ bool tk_cm_activate; /* activate countermeasures after EAPOL-Key sent */ - struct ether_addr BSSID; /* BSSID (associated) */ - struct ether_addr cur_etheraddr; /* h/w address */ + u8 BSSID[ETH_ALEN]; /* BSSID (associated) */ + u8 cur_etheraddr[ETH_ALEN]; /* h/w address */ u16 bcmc_fid; /* the last BCMC FID queued to TX_BCMC_FIFO */ u16 bcmc_fid_shm; /* the last BCMC FID written to shared mem */ @@ -111,7 +96,6 @@ struct wlc_bsscfg { pmkid_t pmkid[MAXPMKID]; /* PMKID cache */ uint npmkid; /* num cached PMKIDs */ - wlc_bss_info_t *target_bss; /* BSS parms during tran. to ASSOCIATED state */ wlc_bss_info_t *current_bss; /* BSS parms in ASSOCIATED state */ /* PM states */ @@ -138,7 +122,8 @@ struct wlc_bsscfg { #define HWBCN_ENAB(cfg) (((cfg)->flags & WLC_BSSCFG_HW_BCN) != 0) #define HWPRB_ENAB(cfg) (((cfg)->flags & WLC_BSSCFG_HW_PRB) != 0) -extern void wlc_bsscfg_ID_assign(struct wlc_info *wlc, wlc_bsscfg_t * bsscfg); +extern void wlc_bsscfg_ID_assign(struct wlc_info *wlc, + struct wlc_bsscfg *bsscfg); /* Extend N_ENAB to per-BSS */ #define BSS_N_ENAB(wlc, cfg) \ diff --git a/drivers/staging/brcm80211/sys/wlc_cfg.h b/drivers/staging/brcm80211/brcmsmac/wlc_cfg.h index 3decb7d1a5e5..85fbd0635310 100644 --- a/drivers/staging/brcm80211/sys/wlc_cfg.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_cfg.h @@ -69,10 +69,6 @@ #define SSLPNCONF SSLPNPHY_DEFAULT #endif -#define BAND2G -#define BAND5G -#define WLANTSEL 1 - /******************************************************************** * Phy/Core Configuration. Defines macros to to check core phy/rev * * compile-time configuration. Defines default core support. * @@ -281,6 +277,4 @@ #define WLBANDINITDATA(_data) _data #define WLBANDINITFN(_fn) _fn -#define WLANTSEL_ENAB(wlc) 1 - #endif /* _wlc_cfg_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_channel.c b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c index a35c15214880..96161c0ab65a 100644 --- a/drivers/staging/brcm80211/sys/wlc_channel.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c @@ -15,25 +15,34 @@ */ #include <linux/kernel.h> -#include <linux/string.h> -#include <bcmdefs.h> -#include <wlc_cfg.h> -#include <osl.h> +#include <linux/types.h> #include <linux/module.h> #include <linux/pci.h> + +#include <bcmdefs.h> #include <bcmutils.h> #include <siutils.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <wlioctl.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_bmac.h> -#include <wlc_stf.h> -#include <wlc_channel.h> -#include <wl_dbg.h> + +#include "wlc_types.h" +#include "d11.h" +#include "wlc_cfg.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_bmac.h" +#include "wlc_rate.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wlc_stf.h" +#include "wl_dbg.h" + +#define VALID_CHANNEL20_DB(wlc, val) wlc_valid_channel20_db((wlc)->cmi, val) +#define VALID_CHANNEL20_IN_BAND(wlc, bandunit, val) \ + wlc_valid_channel20_in_band((wlc)->cmi, bandunit, val) +#define VALID_CHANNEL20(wlc, val) wlc_valid_channel20((wlc)->cmi, val) typedef struct wlc_cm_band { u8 locale_flags; /* locale_info_t flags */ @@ -63,6 +72,10 @@ static void wlc_set_country_common(wlc_cm_info_t *wlc_cm, const char *country_abbrev, const char *ccode, uint regrev, const country_info_t *country); +static int wlc_set_countrycode(wlc_cm_info_t *wlc_cm, const char *ccode); +static int wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm, + const char *country_abbrev, + const char *ccode, int regrev); static int wlc_country_aggregate_map(wlc_cm_info_t *wlc_cm, const char *ccode, char *mapped_ccode, uint *mapped_regrev); static const country_info_t *wlc_country_lookup_direct(const char *ccode, @@ -72,6 +85,19 @@ static const country_info_t *wlc_countrycode_map(wlc_cm_info_t *wlc_cm, char *mapped_ccode, uint *mapped_regrev); static void wlc_channels_commit(wlc_cm_info_t *wlc_cm); +static void wlc_quiet_channels_reset(wlc_cm_info_t *wlc_cm); +static bool wlc_quiet_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec); +static bool wlc_valid_channel20_db(wlc_cm_info_t *wlc_cm, uint val); +static bool wlc_valid_channel20_in_band(wlc_cm_info_t *wlc_cm, uint bandunit, + uint val); +static bool wlc_valid_channel20(wlc_cm_info_t *wlc_cm, uint val); +static const country_info_t *wlc_country_lookup(struct wlc_info *wlc, + const char *ccode); +static void wlc_locale_get_channels(const locale_info_t *locale, + chanvec_t *valid_channels); +static const locale_info_t *wlc_get_locale_2g(u8 locale_idx); +static const locale_info_t *wlc_get_locale_5g(u8 locale_idx); +static bool wlc_japan(struct wlc_info *wlc); static bool wlc_japan_ccode(const char *ccode); static void wlc_channel_min_txpower_limits_with_local_constraint(wlc_cm_info_t * wlc_cm, @@ -378,7 +404,8 @@ void wlc_locale_add_channels(chanvec_t *target, const chanvec_t *channels) } } -void wlc_locale_get_channels(const locale_info_t *locale, chanvec_t *channels) +static void wlc_locale_get_channels(const locale_info_t *locale, + chanvec_t *channels) { u8 i; @@ -564,7 +591,7 @@ struct chan20_info chan20_info[] = { }; #endif /* SUPPORT_40MHZ */ -const locale_info_t *wlc_get_locale_2g(u8 locale_idx) +static const locale_info_t *wlc_get_locale_2g(u8 locale_idx) { if (locale_idx >= ARRAY_SIZE(g_locale_2g_table)) { WL_ERROR("%s: locale 2g index size out of range %d\n", @@ -575,7 +602,7 @@ const locale_info_t *wlc_get_locale_2g(u8 locale_idx) return g_locale_2g_table[locale_idx]; } -const locale_info_t *wlc_get_locale_5g(u8 locale_idx) +static const locale_info_t *wlc_get_locale_5g(u8 locale_idx) { if (locale_idx >= ARRAY_SIZE(g_locale_5g_table)) { WL_ERROR("%s: locale 5g index size out of range %d\n", @@ -654,20 +681,7 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc) void wlc_channel_mgr_detach(wlc_cm_info_t *wlc_cm) { - if (wlc_cm) - kfree(wlc_cm); -} - -const char *wlc_channel_country_abbrev(wlc_cm_info_t *wlc_cm) -{ - return wlc_cm->country_abbrev; -} - -u8 wlc_channel_locale_flags(wlc_cm_info_t *wlc_cm) -{ - struct wlc_info *wlc = wlc_cm->wlc; - - return wlc_cm->bandstate[wlc->band->bandunit].locale_flags; + kfree(wlc_cm); } u8 wlc_channel_locale_flags_in_band(wlc_cm_info_t *wlc_cm, uint bandunit) @@ -675,40 +689,17 @@ u8 wlc_channel_locale_flags_in_band(wlc_cm_info_t *wlc_cm, uint bandunit) return wlc_cm->bandstate[bandunit].locale_flags; } -/* return chanvec for a given country code and band */ -bool -wlc_channel_get_chanvec(struct wlc_info *wlc, const char *country_abbrev, - int bandtype, chanvec_t *channels) -{ - const country_info_t *country; - const locale_info_t *locale = NULL; - - country = wlc_country_lookup(wlc, country_abbrev); - if (country == NULL) - return false; - - if (bandtype == WLC_BAND_2G) - locale = wlc_get_locale_2g(country->locale_2G); - else if (bandtype == WLC_BAND_5G) - locale = wlc_get_locale_5g(country->locale_5G); - if (locale == NULL) - return false; - - wlc_locale_get_channels(locale, channels); - return true; -} - /* set the driver's current country and regulatory information using a country code * as the source. Lookup built in country information found with the country code. */ -int wlc_set_countrycode(wlc_cm_info_t *wlc_cm, const char *ccode) +static int wlc_set_countrycode(wlc_cm_info_t *wlc_cm, const char *ccode) { char country_abbrev[WLC_CNTRY_BUF_SZ]; strncpy(country_abbrev, ccode, WLC_CNTRY_BUF_SZ); return wlc_set_countrycode_rev(wlc_cm, country_abbrev, ccode, -1); } -int +static int wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm, const char *country_abbrev, const char *ccode, int regrev) @@ -803,7 +794,7 @@ wlc_set_country_common(wlc_cm_info_t *wlc_cm, /* Lookup a country info structure from a null terminated country code * The lookup is case sensitive. */ -const country_info_t *wlc_country_lookup(struct wlc_info *wlc, +static const country_info_t *wlc_country_lookup(struct wlc_info *wlc, const char *ccode) { const country_info_t *country; @@ -1006,7 +997,7 @@ static void wlc_channels_commit(wlc_cm_info_t *wlc_cm) } /* reset the quiet channels vector to the union of the restricted and radar channel sets */ -void wlc_quiet_channels_reset(wlc_cm_info_t *wlc_cm) +static void wlc_quiet_channels_reset(wlc_cm_info_t *wlc_cm) { struct wlc_info *wlc = wlc_cm->wlc; uint i, j; @@ -1027,7 +1018,7 @@ void wlc_quiet_channels_reset(wlc_cm_info_t *wlc_cm) } } -bool wlc_quiet_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec) +static bool wlc_quiet_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec) { return N_ENAB(wlc_cm->wlc->pub) && CHSPEC_IS40(chspec) ? (isset @@ -1044,7 +1035,7 @@ bool wlc_quiet_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec) /* Is the channel valid for the current locale? (but don't consider channels not * available due to bandlocking) */ -bool wlc_valid_channel20_db(wlc_cm_info_t *wlc_cm, uint val) +static bool wlc_valid_channel20_db(wlc_cm_info_t *wlc_cm, uint val) { struct wlc_info *wlc = wlc_cm->wlc; @@ -1054,7 +1045,7 @@ bool wlc_valid_channel20_db(wlc_cm_info_t *wlc_cm, uint val) } /* Is the channel valid for the current locale and specified band? */ -bool +static bool wlc_valid_channel20_in_band(wlc_cm_info_t *wlc_cm, uint bandunit, uint val) { return ((val < MAXCHANNEL) @@ -1062,7 +1053,7 @@ wlc_valid_channel20_in_band(wlc_cm_info_t *wlc_cm, uint bandunit, uint val) } /* Is the channel valid for the current locale and current band? */ -bool wlc_valid_channel20(wlc_cm_info_t *wlc_cm, uint val) +static bool wlc_valid_channel20(wlc_cm_info_t *wlc_cm, uint val) { struct wlc_info *wlc = wlc_cm->wlc; @@ -1071,16 +1062,6 @@ bool wlc_valid_channel20(wlc_cm_info_t *wlc_cm, uint val) val)); } -/* Is the 40 MHz allowed for the current locale and specified band? */ -bool wlc_valid_40chanspec_in_band(wlc_cm_info_t *wlc_cm, uint bandunit) -{ - struct wlc_info *wlc = wlc_cm->wlc; - - return (((wlc_cm->bandstate[bandunit]. - locale_flags & (WLC_NO_MIMO | WLC_NO_40MHZ)) == 0) - && wlc->bandstate[bandunit]->mimo_cap_40); -} - static void wlc_channel_min_txpower_limits_with_local_constraint(wlc_cm_info_t *wlc_cm, struct txpwr_limits *txpwr, @@ -1185,121 +1166,118 @@ wlc_channel_set_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chanspec, &txpwr); } -int -wlc_channel_set_txpower_limit(wlc_cm_info_t *wlc_cm, - u8 local_constraint_qdbm) -{ - struct wlc_info *wlc = wlc_cm->wlc; - struct txpwr_limits txpwr; - - wlc_channel_reg_limits(wlc_cm, wlc->chanspec, &txpwr); - - wlc_channel_min_txpower_limits_with_local_constraint(wlc_cm, &txpwr, - local_constraint_qdbm); - - wlc_phy_txpower_limit_set(wlc->band->pi, &txpwr, wlc->chanspec); - - return 0; -} - #ifdef POWER_DBG static void wlc_phy_txpower_limits_dump(txpwr_limits_t *txpwr) { int i; + char buf[80]; char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; - printf("CCK "); + sprintf(buf, "CCK "); for (i = 0; i < WLC_NUM_RATES_CCK; i++) { - printf(" %2d%s", txpwr->cck[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->cck[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->cck[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->cck[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz OFDM SISO "); + sprintf(buf, "20 MHz OFDM SISO "); for (i = 0; i < WLC_NUM_RATES_OFDM; i++) { - printf(" %2d%s", txpwr->ofdm[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->ofdm[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->ofdm[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz OFDM CDD "); + sprintf(buf, "20 MHz OFDM CDD "); for (i = 0; i < WLC_NUM_RATES_OFDM; i++) { - printf(" %2d%s", txpwr->ofdm_cdd[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_cdd[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->ofdm_cdd[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->ofdm_cdd[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz OFDM SISO "); + sprintf(buf, "40 MHz OFDM SISO "); for (i = 0; i < WLC_NUM_RATES_OFDM; i++) { - printf(" %2d%s", txpwr->ofdm_40_siso[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_siso[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->ofdm_40_siso[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->ofdm_40_siso[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz OFDM CDD "); + sprintf(buf, "40 MHz OFDM CDD "); for (i = 0; i < WLC_NUM_RATES_OFDM; i++) { - printf(" %2d%s", txpwr->ofdm_40_cdd[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->ofdm_40_cdd[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->ofdm_40_cdd[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->ofdm_40_cdd[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz MCS0-7 SISO "); + sprintf(buf, "20 MHz MCS0-7 SISO "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_20_siso[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_siso[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_20_siso[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_20_siso[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz MCS0-7 CDD "); + sprintf(buf, "20 MHz MCS0-7 CDD "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_20_cdd[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_cdd[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_20_cdd[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_20_cdd[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz MCS0-7 STBC "); + sprintf(buf, "20 MHz MCS0-7 STBC "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_20_stbc[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_stbc[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_20_stbc[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_20_stbc[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("20 MHz MCS8-15 SDM "); + sprintf(buf, "20 MHz MCS8-15 SDM "); for (i = 0; i < WLC_NUM_RATES_MCS_2_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_20_mimo[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_20_mimo[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_20_mimo[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_20_mimo[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz MCS0-7 SISO "); + sprintf(buf, "40 MHz MCS0-7 SISO "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_40_siso[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_siso[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_40_siso[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_40_siso[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz MCS0-7 CDD "); + sprintf(buf, "40 MHz MCS0-7 CDD "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_40_cdd[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_cdd[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_40_cdd[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_40_cdd[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz MCS0-7 STBC "); + sprintf(buf, "40 MHz MCS0-7 STBC "); for (i = 0; i < WLC_NUM_RATES_MCS_1_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_40_stbc[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_stbc[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_40_stbc[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_40_stbc[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("40 MHz MCS8-15 SDM "); + sprintf(buf, "40 MHz MCS8-15 SDM "); for (i = 0; i < WLC_NUM_RATES_MCS_2_STREAM; i++) { - printf(" %2d%s", txpwr->mcs_40_mimo[i] / WLC_TXPWR_DB_FACTOR, - fraction[txpwr->mcs_40_mimo[i] % WLC_TXPWR_DB_FACTOR]); + sprintf(buf[strlen(buf)], " %2d%s", + txpwr->mcs_40_mimo[i] / WLC_TXPWR_DB_FACTOR, + fraction[txpwr->mcs_40_mimo[i] % WLC_TXPWR_DB_FACTOR]); } - printf("\n"); + printk(KERN_DEBUG "%s\n", buf); - printf("MCS32 %2d%s\n", + printk(KERN_DEBUG "MCS32 %2d%s\n", txpwr->mcs32 / WLC_TXPWR_DB_FACTOR, fraction[txpwr->mcs32 % WLC_TXPWR_DB_FACTOR]); } @@ -1519,7 +1497,7 @@ wlc_channel_reg_limits(wlc_cm_info_t *wlc_cm, chanspec_t chanspec, } /* Returns true if currently set country is Japan or variant */ -bool wlc_japan(struct wlc_info *wlc) +static bool wlc_japan(struct wlc_info *wlc) { return wlc_japan_ccode(wlc->cmi->country_abbrev); } @@ -1598,11 +1576,6 @@ wlc_valid_chanspec_ext(wlc_cm_info_t *wlc_cm, chanspec_t chspec, bool dualband) return false; } -bool wlc_valid_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec) -{ - return wlc_valid_chanspec_ext(wlc_cm, chspec, false); -} - bool wlc_valid_chanspec_db(wlc_cm_info_t *wlc_cm, chanspec_t chspec) { return wlc_valid_chanspec_ext(wlc_cm, chspec, true); diff --git a/drivers/staging/brcm80211/sys/wlc_channel.h b/drivers/staging/brcm80211/brcmsmac/wlc_channel.h index 1f170aff68fd..b8dec5b39d85 100644 --- a/drivers/staging/brcm80211/sys/wlc_channel.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_channel.h @@ -17,8 +17,6 @@ #ifndef _WLC_CHANNEL_H_ #define _WLC_CHANNEL_H_ -#include <wlc_phy_hal.h> - #define WLC_TXPWR_DB_FACTOR 4 /* conversion for phy txpwr cacluations that use .25 dB units */ struct wlc_info; @@ -107,32 +105,10 @@ typedef struct wlc_cm_info wlc_cm_info_t; extern wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc); extern void wlc_channel_mgr_detach(wlc_cm_info_t *wlc_cm); -extern int wlc_set_countrycode(wlc_cm_info_t *wlc_cm, const char *ccode); -extern int wlc_set_countrycode_rev(wlc_cm_info_t *wlc_cm, - const char *country_abbrev, - const char *ccode, int regrev); - -extern const char *wlc_channel_country_abbrev(wlc_cm_info_t *wlc_cm); -extern u8 wlc_channel_locale_flags(wlc_cm_info_t *wlc_cm); extern u8 wlc_channel_locale_flags_in_band(wlc_cm_info_t *wlc_cm, - uint bandunit); - -extern void wlc_quiet_channels_reset(wlc_cm_info_t *wlc_cm); -extern bool wlc_quiet_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec); - -#define VALID_CHANNEL20_DB(wlc, val) wlc_valid_channel20_db((wlc)->cmi, val) -#define VALID_CHANNEL20_IN_BAND(wlc, bandunit, val) \ - wlc_valid_channel20_in_band((wlc)->cmi, bandunit, val) -#define VALID_CHANNEL20(wlc, val) wlc_valid_channel20((wlc)->cmi, val) -#define VALID_40CHANSPEC_IN_BAND(wlc, bandunit) wlc_valid_40chanspec_in_band((wlc)->cmi, bandunit) + uint bandunit); -extern bool wlc_valid_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chspec); extern bool wlc_valid_chanspec_db(wlc_cm_info_t *wlc_cm, chanspec_t chspec); -extern bool wlc_valid_channel20_db(wlc_cm_info_t *wlc_cm, uint val); -extern bool wlc_valid_channel20_in_band(wlc_cm_info_t *wlc_cm, uint bandunit, - uint val); -extern bool wlc_valid_channel20(wlc_cm_info_t *wlc_cm, uint val); -extern bool wlc_valid_40chanspec_in_band(wlc_cm_info_t *wlc_cm, uint bandunit); extern void wlc_channel_reg_limits(wlc_cm_info_t *wlc_cm, chanspec_t chanspec, @@ -140,20 +116,5 @@ extern void wlc_channel_reg_limits(wlc_cm_info_t *wlc_cm, extern void wlc_channel_set_chanspec(wlc_cm_info_t *wlc_cm, chanspec_t chanspec, u8 local_constraint_qdbm); -extern int wlc_channel_set_txpower_limit(wlc_cm_info_t *wlc_cm, - u8 local_constraint_qdbm); - -extern const country_info_t *wlc_country_lookup(struct wlc_info *wlc, - const char *ccode); -extern void wlc_locale_get_channels(const locale_info_t *locale, - chanvec_t *valid_channels); -extern const locale_info_t *wlc_get_locale_2g(u8 locale_idx); -extern const locale_info_t *wlc_get_locale_5g(u8 locale_idx); -extern bool wlc_japan(struct wlc_info *wlc); - -extern u8 wlc_get_regclass(wlc_cm_info_t *wlc_cm, chanspec_t chanspec); -extern bool wlc_channel_get_chanvec(struct wlc_info *wlc, - const char *country_abbrev, int bandtype, - chanvec_t *channels); #endif /* _WLC_CHANNEL_H */ diff --git a/drivers/staging/brcm80211/sys/wlc_key.h b/drivers/staging/brcm80211/brcmsmac/wlc_key.h index 6678c69f1e1c..50a4e38b4cca 100644 --- a/drivers/staging/brcm80211/sys/wlc_key.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_key.h @@ -45,11 +45,10 @@ struct wlc_bsscfg; #define WLC_MAX_WSEC_HW_KEYS(wlc) WSEC_MAX_RCMTA_KEYS /* Max # of hardware TKIP MIC keys supported */ -#define WLC_MAX_TKMIC_HW_KEYS(wlc) ((D11REV_GE((wlc)->pub->corerev, 13)) ? \ - WSEC_MAX_TKMIC_ENGINE_KEYS : 0) +#define WLC_MAX_TKMIC_HW_KEYS(wlc) (WSEC_MAX_TKMIC_ENGINE_KEYS) #define WSEC_HW_TKMIC_KEY(wlc, key, bsscfg) \ - (((D11REV_GE((wlc)->pub->corerev, 13)) && ((wlc)->machwcap & MCAP_TKIPMIC)) && \ + ((((wlc)->machwcap & MCAP_TKIPMIC)) && \ (key) && ((key)->algo == CRYPTO_ALGO_TKIP) && \ !WSEC_SOFTKEY(wlc, key, bsscfg) && \ WSEC_KEY_INDEX(wlc, key) >= WLC_DEFAULT_KEYS && \ @@ -87,7 +86,7 @@ typedef struct wsec_iv { #define WLC_NUMRXIVS 16 /* # rx IVs (one per 802.11e TID) */ typedef struct wsec_key { - struct ether_addr ea; /* per station */ + u8 ea[ETH_ALEN]; /* per station */ u8 idx; /* key index in wsec_keys array */ u8 id; /* key ID [0-3] */ u8 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ @@ -99,16 +98,13 @@ typedef struct wsec_key { s8 icv_len; /* ICV length */ u32 len; /* key length..don't move this var */ /* data is 4byte aligned */ - u8 data[DOT11_MAX_KEY_SIZE]; /* key data */ + u8 data[WLAN_MAX_KEY_LEN]; /* key data */ wsec_iv_t rxiv[WLC_NUMRXIVS]; /* Rx IV (one per TID) */ wsec_iv_t txiv; /* Tx IV */ } wsec_key_t; #define broken_roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) -typedef struct { - u8 vec[broken_roundup(WSEC_MAX_KEYS, NBBY) / NBBY]; /* bitvec of wsec_key indexes */ -} wsec_key_vec_t; /* For use with wsec_key_t.flags */ diff --git a/drivers/staging/brcm80211/sys/wlc_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wlc_main.c index e37e8058e2b8..639b5d7c9603 100644 --- a/drivers/staging/brcm80211/sys/wlc_mac80211.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_main.c @@ -16,50 +16,68 @@ #include <linux/kernel.h> #include <linux/ctype.h> #include <linux/etherdevice.h> +#include <net/mac80211.h> + #include <bcmdefs.h> #include <bcmdevs.h> -#include <wlc_cfg.h> -#include <osl.h> #include <bcmutils.h> #include <bcmwifi.h> #include <siutils.h> -#include <bcmendian.h> -#include <proto/wpa.h> #include <pcicfg.h> #include <bcmsrom.h> #include <wlioctl.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <hnddma.h> #include <hndpmu.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <wlc_bsscfg.h> -#include <wlc_channel.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_bmac.h> -#include <wlc_scb.h> -#include <wlc_phy_hal.h> -#include <wlc_phy_shim.h> -#include <wlc_antsel.h> -#include <wlc_stf.h> -#include <wlc_ampdu.h> -#include <wlc_event.h> -#include <wl_export.h> -#include "d11ucode_ext.h" -#include <wlc_alloc.h> -#include <net/mac80211.h> -#include <wl_dbg.h> +#include "d11.h" +#include "wlc_types.h" +#include "wlc_cfg.h" +#include "wlc_rate.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "wlc_bsscfg.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wlc_bmac.h" +#include "wlc_phy_hal.h" +#include "wlc_phy_shim.h" +#include "wlc_antsel.h" +#include "wlc_stf.h" +#include "wlc_ampdu.h" +#include "wl_export.h" +#include "wlc_alloc.h" +#include "wl_dbg.h" + +/* + * Disable statistics counting for WME + */ +#define WLCNTSET(a, b) +#define WLCNTINCR(a) +#define WLCNTADD(a, b) + +/* + * WPA(2) definitions + */ +#define RSN_CAP_4_REPLAY_CNTRS 2 +#define RSN_CAP_16_REPLAY_CNTRS 3 + +#define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS +#define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS + +/* + * Indication for txflowcontrol that all priority bits in + * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. + */ +#define ALLPRIO -1 /* * buffer length needed for wlc_format_ssid * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. */ -#define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1) +#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) #define TIMER_INTERVAL_WATCHDOG 1000 /* watchdog timer, in unit of ms */ #define TIMER_INTERVAL_RADIOCHK 800 /* radio monitor timer, in unit of ms */ @@ -132,16 +150,17 @@ static struct wlc_info *wlc_info_dbg = (struct wlc_info *) (NULL); */ enum { IOV_MPC = 1, + IOV_RTSTHRESH, IOV_QTXPOWER, IOV_BCN_LI_BCN, /* Beacon listen interval in # of beacons */ IOV_LAST /* In case of a need to check max ID number */ }; const bcm_iovar_t wlc_iovars[] = { - {"mpc", IOV_MPC, (IOVF_OPEN_ALLOW), IOVT_BOOL, 0}, - {"qtxpower", IOV_QTXPOWER, (IOVF_WHL | IOVF_OPEN_ALLOW), IOVT_UINT32, - 0}, - {"bcn_li_bcn", IOV_BCN_LI_BCN, 0, IOVT_UINT8, 0}, + {"mpc", IOV_MPC, (0), IOVT_BOOL, 0}, + {"rtsthresh", IOV_RTSTHRESH, (IOVF_WHL), IOVT_UINT16, 0}, + {"qtxpower", IOV_QTXPOWER, (IOVF_WHL), IOVT_UINT32, 0}, + {"bcn_li_bcn", IOV_BCN_LI_BCN, (0), IOVT_UINT8, 0}, {NULL, 0, 0, 0, 0} }; @@ -205,7 +224,8 @@ static bool in_send_q = false; #ifdef BCMDBG static const char *fifo_names[] = { "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; -const char *aci_names[] = { "AC_BE", "AC_BK", "AC_VI", "AC_VO" }; +#else +static const char fifo_names[6][0]; #endif static const u8 acbitmap2maxprio[] = { @@ -231,6 +251,7 @@ static u16 BCMFASTPATH wlc_d11hdrs_mac80211(struct wlc_info *wlc, wsec_key_t *key, ratespec_t rspec_override); +static void wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat); static void wlc_bss_default_init(struct wlc_info *wlc); static void wlc_ucode_mac_upd(struct wlc_info *wlc); static ratespec_t mac80211_wlc_set_nrate(struct wlc_info *wlc, @@ -238,17 +259,18 @@ static ratespec_t mac80211_wlc_set_nrate(struct wlc_info *wlc, static void wlc_tx_prec_map_init(struct wlc_info *wlc); static void wlc_watchdog(void *arg); static void wlc_watchdog_by_timer(void *arg); +static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate); static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg); static int wlc_iovar_rangecheck(struct wlc_info *wlc, u32 val, const bcm_iovar_t *vi); static u8 wlc_local_constraint_qdbm(struct wlc_info *wlc); /* send and receive */ -static wlc_txq_info_t *wlc_txq_alloc(struct wlc_info *wlc, - struct osl_info *osh); -static void wlc_txq_free(struct wlc_info *wlc, struct osl_info *osh, - wlc_txq_info_t *qi); -static void wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi, +static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc); +static void wlc_txq_free(struct wlc_info *wlc, + struct wlc_txq_info *qi); +static void wlc_txflowcontrol_signal(struct wlc_info *wlc, + struct wlc_txq_info *qi, bool on, int prio); static void wlc_txflowcontrol_reset(struct wlc_info *wlc); static u16 wlc_compute_airtime(struct wlc_info *wlc, ratespec_t rspec, @@ -258,7 +280,7 @@ static void wlc_compute_ofdm_plcp(ratespec_t rate, uint length, u8 *plcp); static void wlc_compute_mimo_plcp(ratespec_t rate, uint length, u8 *plcp); static u16 wlc_compute_frame_dur(struct wlc_info *wlc, ratespec_t rate, u8 preamble_type, uint next_frag_len); -static void wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, +static void wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p); static uint wlc_calc_frame_len(struct wlc_info *wlc, ratespec_t rate, u8 preamble_type, uint dur); @@ -287,7 +309,6 @@ static void wlc_ht_update_sgi_rx(struct wlc_info *wlc, int val); static void wlc_ht_update_ldpc(struct wlc_info *wlc, s8 val); static void wlc_war16165(struct wlc_info *wlc, bool tx); -static void wlc_process_eventq(void *arg); static void wlc_wme_retries_write(struct wlc_info *wlc); static bool wlc_attach_stf_ant_init(struct wlc_info *wlc); static uint wlc_attach_module(struct wlc_info *wlc); @@ -300,30 +321,25 @@ static int _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, struct wlc_if *wlcif); #if defined(BCMDBG) -void wlc_get_rcmta(struct wlc_info *wlc, int idx, struct ether_addr *addr) +void wlc_get_rcmta(struct wlc_info *wlc, int idx, u8 *addr) { d11regs_t *regs = wlc->regs; u32 v32; - struct osl_info *osh; WL_TRACE("wl%d: %s\n", WLCWLUNIT(wlc), __func__); - ASSERT(wlc->pub->corerev > 4); - - osh = wlc->osh; - - W_REG(osh, ®s->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2))); - (void)R_REG(osh, ®s->objaddr); - v32 = R_REG(osh, ®s->objdata); - addr->octet[0] = (u8) v32; - addr->octet[1] = (u8) (v32 >> 8); - addr->octet[2] = (u8) (v32 >> 16); - addr->octet[3] = (u8) (v32 >> 24); - W_REG(osh, ®s->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1))); - (void)R_REG(osh, ®s->objaddr); - v32 = R_REG(osh, (volatile u16 *)®s->objdata); - addr->octet[4] = (u8) v32; - addr->octet[5] = (u8) (v32 >> 8); + W_REG(®s->objaddr, (OBJADDR_RCMTA_SEL | (idx * 2))); + (void)R_REG(®s->objaddr); + v32 = R_REG(®s->objdata); + addr[0] = (u8) v32; + addr[1] = (u8) (v32 >> 8); + addr[2] = (u8) (v32 >> 16); + addr[3] = (u8) (v32 >> 24); + W_REG(®s->objaddr, (OBJADDR_RCMTA_SEL | ((idx * 2) + 1))); + (void)R_REG(®s->objaddr); + v32 = R_REG(®s->objdata); + addr[4] = (u8) v32; + addr[5] = (u8) (v32 >> 8); } #endif /* defined(BCMDBG) */ @@ -338,7 +354,7 @@ bool wlc_stay_awake(struct wlc_info *wlc) bool wlc_ps_allowed(struct wlc_info *wlc) { int idx; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; /* disallow PS when one of the following global conditions meets */ if (!wlc->pub->associated || !wlc->PMenabled || wlc->PM_override) @@ -369,13 +385,11 @@ void wlc_reset(struct wlc_info *wlc) wlc->check_for_unaligned_tbtt = false; /* slurp up hw mac counters before core reset */ - if (WLC_UPDATE_STATS(wlc)) { - wlc_statsupd(wlc); + wlc_statsupd(wlc); - /* reset our snapshot of macstat counters */ - memset((char *)wlc->core->macstat_snapshot, 0, - sizeof(macstat_t)); - } + /* reset our snapshot of macstat counters */ + memset((char *)wlc->core->macstat_snapshot, 0, + sizeof(macstat_t)); wlc_bmac_reset(wlc->hw); wlc_ampdu_reset(wlc->ampdu); @@ -423,7 +437,7 @@ void wlc_init(struct wlc_info *wlc) d11regs_t *regs; chanspec_t chanspec; int i; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; bool mute = false; WL_TRACE("wl%d: wlc_init\n", wlc->pub->unit); @@ -441,7 +455,7 @@ void wlc_init(struct wlc_info *wlc) wlc_bmac_init(wlc->hw, chanspec, mute); wlc->seckeys = wlc_bmac_read_shm(wlc->hw, M_SECRXKEYS_PTR) * 2; - if (D11REV_GE(wlc->pub->corerev, 15) && (wlc->machwcap & MCAP_TKIPMIC)) + if (wlc->machwcap & MCAP_TKIPMIC) wlc->tkmickeys = wlc_bmac_read_shm(wlc->hw, M_TKMICKEYS_PTR) * 2; @@ -466,11 +480,13 @@ void wlc_init(struct wlc_info *wlc) if (bsscfg->up) { u32 bi; - /* get beacon period from bsscfg and convert to uS */ + /* get beacon period and convert to uS */ bi = bsscfg->current_bss->beacon_period << 10; - /* update the tsf_cfprep register */ - /* since init path would reset to default value */ - W_REG(wlc->osh, ®s->tsf_cfprep, + /* + * update since init path would reset + * to default value + */ + W_REG(®s->tsf_cfprep, (bi << CFPREP_CBI_SHIFT)); /* Update maccontrol PM related bits */ @@ -507,7 +523,7 @@ void wlc_init(struct wlc_info *wlc) /* Enable EDCF mode (while the MAC is suspended) */ if (EDCF_ENAB(wlc->pub)) { - OR_REG(wlc->osh, ®s->ifs_ctl, IFS_USEEDCF); + OR_REG(®s->ifs_ctl, IFS_USEEDCF); wlc_edcf_setparams(wlc->cfg, false); } @@ -531,8 +547,7 @@ void wlc_init(struct wlc_info *wlc) wlc->tx_suspended = false; /* enable the RF Disable Delay timer */ - if (D11REV_GE(wlc->pub->corerev, 10)) - W_REG(wlc->osh, &wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); + W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); /* initialize mpc delay */ wlc->mpc_delay_off = wlc->mpc_dlycnt = WLC_MPC_MIN_DELAYCNT; @@ -541,7 +556,7 @@ void wlc_init(struct wlc_info *wlc) * Initialize WME parameters; if they haven't been set by some other * mechanism (IOVar, etc) then read them from the hardware. */ - if (WLC_WME_RETRY_SHORT_GET(wlc, 0) == 0) { /* Unintialized; read from HW */ + if (WLC_WME_RETRY_SHORT_GET(wlc, 0) == 0) { /* Uninitialized; read from HW */ int ac; ASSERT(wlc->clk); @@ -597,12 +612,13 @@ bool wlc_ps_check(struct wlc_info *wlc) bool wake_ok; if (!AP_ACTIVE(wlc)) { - volatile u32 tmp; - tmp = R_REG(wlc->osh, &wlc->regs->maccontrol); + u32 tmp; + tmp = R_REG(&wlc->regs->maccontrol); - /* If deviceremoved is detected, then don't take any action as this can be called - * in any context. Assume that caller will take care of the condition. This is just - * to avoid assert + /* + * If deviceremoved is detected, then don't take any action as + * this can be called in any context. Assume that caller will + * take care of the condition. This is just to avoid assert */ if (tmp == 0xffffffff) { WL_ERROR("wl%d: %s: dead chip\n", @@ -614,7 +630,7 @@ bool wlc_ps_check(struct wlc_info *wlc) if (hps != ((tmp & MCTL_HPS) != 0)) { int idx; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; WL_ERROR("wl%d: hps not sync, sw %d, maccontrol 0x%x\n", wlc->pub->unit, hps, tmp); FOREACH_BSS(wlc, idx, cfg) { @@ -652,7 +668,7 @@ void wlc_set_ps_ctrl(struct wlc_info *wlc) WL_TRACE("wl%d: wlc_set_ps_ctrl: hps %d wake %d\n", wlc->pub->unit, hps, wake); - v1 = R_REG(wlc->osh, &wlc->regs->maccontrol); + v1 = R_REG(&wlc->regs->maccontrol); v2 = 0; if (hps) v2 |= MCTL_HPS; @@ -672,14 +688,14 @@ void wlc_set_ps_ctrl(struct wlc_info *wlc) * Write this BSS config's MAC address to core. * Updates RXE match engine. */ -int wlc_set_mac(wlc_bsscfg_t *cfg) +int wlc_set_mac(struct wlc_bsscfg *cfg) { int err = 0; struct wlc_info *wlc = cfg->wlc; if (cfg == wlc->cfg) { /* enter the MAC addr into the RXE match registers */ - wlc_set_addrmatch(wlc, RCM_MAC_OFFSET, &cfg->cur_etheraddr); + wlc_set_addrmatch(wlc, RCM_MAC_OFFSET, cfg->cur_etheraddr); } wlc_ampdu_macaddr_upd(wlc); @@ -690,13 +706,13 @@ int wlc_set_mac(wlc_bsscfg_t *cfg) /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl). * Updates RXE match engine. */ -void wlc_set_bssid(wlc_bsscfg_t *cfg) +void wlc_set_bssid(struct wlc_bsscfg *cfg) { struct wlc_info *wlc = cfg->wlc; /* if primary config, we need to update BSSID in RXE match registers */ if (cfg == wlc->cfg) { - wlc_set_addrmatch(wlc, RCM_BSSID_OFFSET, &cfg->BSSID); + wlc_set_addrmatch(wlc, RCM_BSSID_OFFSET, cfg->BSSID); } #ifdef SUPPORT_HWKEYS else if (BSSCFG_STA(cfg) && cfg->BSS) { @@ -712,7 +728,7 @@ void wlc_set_bssid(wlc_bsscfg_t *cfg) void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot) { int idx; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; ASSERT(wlc->band->gmode); @@ -729,9 +745,11 @@ void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot) FOREACH_BSS(wlc, idx, cfg) { if (!cfg->associated) continue; - cfg->current_bss->capability &= ~DOT11_CAP_SHORTSLOT; + cfg->current_bss->capability &= + ~WLAN_CAPABILITY_SHORT_SLOT_TIME; if (wlc->shortslot) - cfg->current_bss->capability |= DOT11_CAP_SHORTSLOT; + cfg->current_bss->capability |= + WLAN_CAPABILITY_SHORT_SLOT_TIME; } wlc_bmac_set_shortslot(wlc->hw, shortslot); @@ -768,14 +786,14 @@ void wlc_set_home_chanspec(struct wlc_info *wlc, chanspec_t chanspec) { if (wlc->home_chanspec != chanspec) { int idx; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; wlc->home_chanspec = chanspec; FOREACH_BSS(wlc, idx, cfg) { if (!cfg->associated) continue; - cfg->target_bss->chanspec = chanspec; + cfg->current_bss->chanspec = chanspec; } @@ -841,8 +859,7 @@ void wlc_set_chanspec(struct wlc_info *wlc, chanspec_t chanspec) /* init antenna selection */ if (CHSPEC_WLC_BW(old_chanspec) != CHSPEC_WLC_BW(chanspec)) { - if (WLANTSEL_ENAB(wlc)) - wlc_antsel_init(wlc->asi); + wlc_antsel_init(wlc->asi); /* Fix the hardware rateset based on bw. * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz @@ -990,7 +1007,7 @@ static int wlc_get_current_txpwr(struct wlc_info *wlc, void *pwr, uint len) * or convert to a tx_power_legacy_t struct */ if (!old_power) { - bcopy(&power, pwr, sizeof(tx_power_t)); + memcpy(pwr, &power, sizeof(tx_power_t)); } else { int band_idx = CHSPEC_IS2G(power.chanspec) ? 0 : 1; @@ -1170,9 +1187,12 @@ void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val) static void wlc_ht_update_sgi_rx(struct wlc_info *wlc, int val) { - wlc->ht_cap.cap &= ~(HT_CAP_SHORT_GI_20 | HT_CAP_SHORT_GI_40); - wlc->ht_cap.cap |= (val & WLC_N_SGI_20) ? HT_CAP_SHORT_GI_20 : 0; - wlc->ht_cap.cap |= (val & WLC_N_SGI_40) ? HT_CAP_SHORT_GI_40 : 0; + wlc->ht_cap.cap_info &= ~(IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40); + wlc->ht_cap.cap_info |= (val & WLC_N_SGI_20) ? + IEEE80211_HT_CAP_SGI_20 : 0; + wlc->ht_cap.cap_info |= (val & WLC_N_SGI_40) ? + IEEE80211_HT_CAP_SGI_40 : 0; if (wlc->pub->up) { wlc_update_beacon(wlc); @@ -1184,9 +1204,9 @@ static void wlc_ht_update_ldpc(struct wlc_info *wlc, s8 val) { wlc->stf->ldpc = val; - wlc->ht_cap.cap &= ~HT_CAP_LDPC_CODING; + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_LDPC_CODING; if (wlc->stf->ldpc != OFF) - wlc->ht_cap.cap |= HT_CAP_LDPC_CODING; + wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_LDPC_CODING; if (wlc->pub->up) { wlc_update_beacon(wlc); @@ -1285,8 +1305,7 @@ static void WLBANDINITFN(wlc_bsinit) (struct wlc_info *wlc) wlc_ucode_mac_upd(wlc); /* init antenna selection */ - if (WLANTSEL_ENAB(wlc)) - wlc_antsel_init(wlc->asi); + wlc_antsel_init(wlc->asi); } @@ -1294,7 +1313,7 @@ static void WLBANDINITFN(wlc_bsinit) (struct wlc_info *wlc) static void WLBANDINITFN(wlc_setband) (struct wlc_info *wlc, uint bandunit) { int idx; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; ASSERT(NBANDS(wlc) > 1); ASSERT(!wlc->bandlocked); @@ -1327,13 +1346,13 @@ void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe) 0, { {EDCF_AC_BE_ACI_STA, EDCF_AC_BE_ECW_STA, - HTOL16(EDCF_AC_BE_TXOP_STA)}, + cpu_to_le16(EDCF_AC_BE_TXOP_STA)}, {EDCF_AC_BK_ACI_STA, EDCF_AC_BK_ECW_STA, - HTOL16(EDCF_AC_BK_TXOP_STA)}, + cpu_to_le16(EDCF_AC_BK_TXOP_STA)}, {EDCF_AC_VI_ACI_STA, EDCF_AC_VI_ECW_STA, - HTOL16(EDCF_AC_VI_TXOP_STA)}, + cpu_to_le16(EDCF_AC_VI_TXOP_STA)}, {EDCF_AC_VO_ACI_STA, EDCF_AC_VO_ECW_STA, - HTOL16(EDCF_AC_VO_TXOP_STA)} + cpu_to_le16(EDCF_AC_VO_TXOP_STA)} } }; @@ -1372,7 +1391,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend) /* wlc->wme_admctl |= 1 << aci; *//* should be set ?? seems like off by default */ /* fill in shm ac params struct */ - acp_shm.txop = ltoh16(params->txop); + acp_shm.txop = le16_to_cpu(params->txop); /* convert from units of 32us to us for ucode */ wlc->edcf_txop[aci & 0x3] = acp_shm.txop = EDCF_TXOP2USEC(acp_shm.txop); @@ -1393,7 +1412,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend) acp_shm.cwmax = params->cw_max; acp_shm.cwcur = acp_shm.cwmin; acp_shm.bslots = - R_REG(wlc->osh, &wlc->regs->tsf_random) & acp_shm.cwcur; + R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; /* Indicate the new params to the ucode */ acp_shm.status = wlc_read_shm(wlc, (M_EDCF_QINFO + @@ -1420,7 +1439,7 @@ void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend) } -void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend) +void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend) { struct wlc_info *wlc = cfg->wlc; uint aci, i, j; @@ -1456,7 +1475,7 @@ void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend) } /* fill in shm ac params struct */ - acp_shm.txop = ltoh16(edcf_acp->TXOP); + acp_shm.txop = le16_to_cpu(edcf_acp->TXOP); /* convert from units of 32us to us for ucode */ wlc->edcf_txop[aci] = acp_shm.txop = EDCF_TXOP2USEC(acp_shm.txop); @@ -1480,7 +1499,7 @@ void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend) >> EDCF_ECWMAX_SHIFT); acp_shm.cwcur = acp_shm.cwmin; acp_shm.bslots = - R_REG(wlc->osh, &wlc->regs->tsf_random) & acp_shm.cwcur; + R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; /* Indicate the new params to the ucode */ acp_shm.status = wlc_read_shm(wlc, (M_EDCF_QINFO + @@ -1642,7 +1661,7 @@ void wlc_info_init(struct wlc_info *wlc, int unit) wlc->ibss_coalesce_allowed = true; wlc->pub->_coex = ON; - /* intialize mpc delay */ + /* initialize mpc delay */ wlc->mpc_delay_off = wlc->mpc_dlycnt = WLC_MPC_MIN_DELAYCNT; wlc->pr80838_war = true; @@ -1668,7 +1687,7 @@ static uint wlc_attach_module(struct wlc_info *wlc) uint unit; unit = wlc->pub->unit; - wlc->asi = wlc_antsel_attach(wlc, wlc->osh, wlc->pub, wlc->hw); + wlc->asi = wlc_antsel_attach(wlc); if (wlc->asi == NULL) { WL_ERROR("wl%d: wlc_attach: wlc_antsel_attach failed\n", unit); err = 44; @@ -1682,15 +1701,6 @@ static uint wlc_attach_module(struct wlc_info *wlc) goto fail; } - /* Initialize event queue; needed before following calls */ - wlc->eventq = - wlc_eventq_attach(wlc->pub, wlc, wlc->wl, wlc_process_eventq); - if (wlc->eventq == NULL) { - WL_ERROR("wl%d: wlc_attach: wlc_eventq_attachfailed\n", unit); - err = 57; - goto fail; - } - if ((wlc_stf_attach(wlc) != 0)) { WL_ERROR("wl%d: wlc_attach: wlc_stf_attach failed\n", unit); err = 68; @@ -1711,14 +1721,13 @@ struct wlc_pub *wlc_pub(void *wlc) * The common driver entry routine. Error codes should be unique */ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, - struct osl_info *osh, void *regsva, uint bustype, - void *btparam, uint *perr) + void *regsva, uint bustype, void *btparam, uint *perr) { struct wlc_info *wlc; uint err = 0; uint j; struct wlc_pub *pub; - wlc_txq_info_t *qi; + struct wlc_txq_info *qi; uint n_disabled; WL_NONE("wl%d: %s: vendor 0x%x device 0x%x\n", @@ -1728,19 +1737,16 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, ASSERT(WSEC_MAX_DEFAULT_KEYS == WLC_DEFAULT_KEYS); /* some code depends on packed structures */ - ASSERT(sizeof(struct ether_addr) == ETH_ALEN); - ASSERT(sizeof(struct ether_header) == ETH_HLEN); + ASSERT(sizeof(struct ethhdr) == ETH_HLEN); ASSERT(sizeof(d11regs_t) == SI_CORE_SIZE); ASSERT(sizeof(ofdm_phy_hdr_t) == D11_PHY_HDR_LEN); ASSERT(sizeof(cck_phy_hdr_t) == D11_PHY_HDR_LEN); ASSERT(sizeof(d11txh_t) == D11_TXH_LEN); ASSERT(sizeof(d11rxhdr_t) == RXHDR_LEN); - ASSERT(sizeof(struct dot11_header) == DOT11_A4_HDR_LEN); - ASSERT(sizeof(struct dot11_rts_frame) == DOT11_RTS_LEN); - ASSERT(sizeof(struct dot11_management_header) == DOT11_MGMT_HDR_LEN); - ASSERT(sizeof(struct dot11_bcn_prb) == DOT11_BCN_PRB_LEN); + ASSERT(sizeof(struct ieee80211_hdr) == DOT11_A4_HDR_LEN); + ASSERT(sizeof(struct ieee80211_rts) == DOT11_RTS_LEN); ASSERT(sizeof(tx_status_t) == TXSTATUS_LEN); - ASSERT(sizeof(ht_cap_ie_t) == HT_CAP_IE_LEN); + ASSERT(sizeof(struct ieee80211_ht_cap) == HT_CAP_IE_LEN); #ifdef BRCM_FULLMAC ASSERT(offsetof(wl_scan_params_t, channel_list) == WL_SCAN_PARAMS_FIXED_SIZE); @@ -1761,10 +1767,9 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, && 4 == WLC_NUMRXIVS)); /* allocate struct wlc_info state and its substructures */ - wlc = (struct wlc_info *) wlc_attach_malloc(osh, unit, &err, device); + wlc = (struct wlc_info *) wlc_attach_malloc(unit, &err, device); if (wlc == NULL) goto fail; - wlc->osh = osh; pub = wlc->pub; #if defined(BCMDBG) @@ -1775,7 +1780,6 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, wlc->core = wlc->corestate; wlc->wl = wl; pub->unit = unit; - pub->osh = osh; wlc->btparam = btparam; pub->_piomode = piomode; wlc->bandinit_pending = false; @@ -1795,8 +1799,11 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, wlc_module_register(wlc->pub, wlc_iovars, "wlc_iovars", wlc, wlc_doiovar, NULL, NULL); - /* low level attach steps(all hw accesses go inside, no more in rest of the attach) */ - err = wlc_bmac_attach(wlc, vendor, device, unit, piomode, osh, regsva, + /* + * low level attach steps(all hw accesses go + * inside, no more in rest of the attach) + */ + err = wlc_bmac_attach(wlc, vendor, device, unit, piomode, regsva, bustype, btparam); if (err) goto fail; @@ -1838,10 +1845,9 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, wlc->core->txavail[i] = wlc->hw->txavail[i]; } - wlc_bmac_hw_etheraddr(wlc->hw, &wlc->perm_etheraddr); + wlc_bmac_hw_etheraddr(wlc->hw, wlc->perm_etheraddr); - bcopy((char *)&wlc->perm_etheraddr, (char *)&pub->cur_etheraddr, - ETH_ALEN); + memcpy(&pub->cur_etheraddr, &wlc->perm_etheraddr, ETH_ALEN); for (j = 0; j < NBANDS(wlc); j++) { /* Use band 1 for single band 11a */ @@ -1921,7 +1927,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, */ /* allocate our initial queue */ - qi = wlc_txq_alloc(wlc, osh); + qi = wlc_txq_alloc(wlc); if (qi == NULL) { WL_ERROR("wl%d: %s: failed to malloc tx queue\n", unit, __func__); @@ -1935,8 +1941,8 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, wlc->cfg->wlc = wlc; pub->txmaxpkts = MAXTXPKTS; - WLCNTSET(pub->_cnt->version, WL_CNT_T_VERSION); - WLCNTSET(pub->_cnt->length, sizeof(wl_cnt_t)); + pub->_cnt->version = WL_CNT_T_VERSION; + pub->_cnt->length = sizeof(struct wl_cnt); WLCNTSET(pub->_wme_cnt->version, WL_WME_CNT_VERSION); WLCNTSET(pub->_wme_cnt->length, sizeof(wl_wme_cnt_t)); @@ -1944,7 +1950,7 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, wlc_wme_initparams_sta(wlc, &wlc->wme_param_ie); wlc->mimoft = FT_HT; - wlc->ht_cap.cap = HT_CAP; + wlc->ht_cap.cap_info = HT_CAP; if (HT_ENAB(wlc->pub)) wlc->stf->ldpc = AUTO; @@ -1981,27 +1987,25 @@ void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, bool piomode, if (n_disabled & WLFEATURE_DISABLE_11N_STBC_TX) { wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = OFF; wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = OFF; - wlc->ht_cap.cap &= ~HT_CAP_TX_STBC; + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC; } if (n_disabled & WLFEATURE_DISABLE_11N_STBC_RX) wlc_stf_stbc_rx_set(wlc, HT_CAP_RX_STBC_NO); /* apply the GF override from nvram conf */ if (n_disabled & WLFEATURE_DISABLE_11N_GF) - wlc->ht_cap.cap &= ~HT_CAP_GF; + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_GRN_FLD; /* initialize radio_mpc_disable according to wlc->mpc */ wlc_radio_mpc_upd(wlc); - if (WLANTSEL_ENAB(wlc)) { - if ((wlc->pub->sih->chip) == BCM43235_CHIP_ID) { - if ((getintvar(wlc->pub->vars, "aa2g") == 7) || - (getintvar(wlc->pub->vars, "aa5g") == 7)) { - wlc_bmac_antsel_set(wlc->hw, 1); - } - } else { - wlc_bmac_antsel_set(wlc->hw, wlc->asi->antsel_avail); + if ((wlc->pub->sih->chip) == BCM43235_CHIP_ID) { + if ((getintvar(wlc->pub->vars, "aa2g") == 7) || + (getintvar(wlc->pub->vars, "aa5g") == 7)) { + wlc_bmac_antsel_set(wlc->hw, 1); } + } else { + wlc_bmac_antsel_set(wlc->hw, wlc->asi->antsel_avail); } if (perr) @@ -2146,11 +2150,6 @@ uint wlc_detach(struct wlc_info *wlc) if (!wlc_radio_monitor_stop(wlc)) callbacks++; - if (wlc->eventq) { - wlc_eventq_detach(wlc->eventq); - wlc->eventq = NULL; - } - wlc_channel_mgr_detach(wlc->cmi); wlc_timers_deinit(wlc); @@ -2161,15 +2160,13 @@ uint wlc_detach(struct wlc_info *wlc) #ifdef BCMDBG - if (wlc->country_ie_override) { - kfree(wlc->country_ie_override); - wlc->country_ie_override = NULL; - } + kfree(wlc->country_ie_override); + wlc->country_ie_override = NULL; #endif /* BCMDBG */ { /* free dumpcb list */ - dumpcb_t *prev, *ptr; + struct dumpcb_s *prev, *ptr; prev = ptr = wlc->dumpcb_head; while (ptr) { ptr = prev->next; @@ -2182,9 +2179,8 @@ uint wlc_detach(struct wlc_info *wlc) /* Detach from iovar manager */ wlc_module_unregister(wlc->pub, "wlc_iovars", wlc); - while (wlc->tx_queues != NULL) { - wlc_txq_free(wlc, wlc->osh, wlc->tx_queues); - } + while (wlc->tx_queues != NULL) + wlc_txq_free(wlc, wlc->tx_queues); /* * consistency check: wlc_module_register/wlc_module_unregister calls @@ -2193,7 +2189,7 @@ uint wlc_detach(struct wlc_info *wlc) for (i = 0; i < WLC_MAXMODULES; i++) ASSERT(wlc->modulecb[i].name[0] == '\0'); - wlc_detach_mfree(wlc, wlc->osh); + wlc_detach_mfree(wlc); return callbacks; } @@ -2294,10 +2290,11 @@ void wlc_radio_mpc_upd(struct wlc_info *wlc) */ static void wlc_radio_upd(struct wlc_info *wlc) { - if (wlc->pub->radio_disabled) + if (wlc->pub->radio_disabled) { wlc_radio_disable(wlc); - else + } else { wlc_radio_enable(wlc); + } } /* maintain LED behavior in down state */ @@ -2314,6 +2311,14 @@ static void wlc_down_led_upd(struct wlc_info *wlc) } } +/* update hwradio status and return it */ +bool wlc_check_radio_disabled(struct wlc_info *wlc) +{ + wlc_radio_hwdisable_upd(wlc); + + return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? true : false; +} + void wlc_radio_disable(struct wlc_info *wlc) { if (!wlc->pub->up) { @@ -2443,7 +2448,7 @@ static void wlc_watchdog(void *arg) { struct wlc_info *wlc = (struct wlc_info *) arg; int i; - wlc_bsscfg_t *cfg; + struct wlc_bsscfg *cfg; WL_TRACE("wl%d: wlc_watchdog\n", wlc->pub->unit); @@ -2485,8 +2490,7 @@ static void wlc_watchdog(void *arg) wlc_bmac_watchdog(wlc); /* occasionally sample mac stat counters to detect 16-bit counter wrap */ - if ((WLC_UPDATE_STATS(wlc)) - && (!(wlc->pub->now % SW_TIMER_MAC_STAT_UPD))) + if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) wlc_statsupd(wlc); /* Manage TKIP countermeasures timers */ @@ -2560,7 +2564,7 @@ int wlc_up(struct wlc_info *wlc) if (!mboolisset (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { int idx; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); @@ -2667,7 +2671,7 @@ uint wlc_down(struct wlc_info *wlc) uint callbacks = 0; int i; bool dev_gone = false; - wlc_txq_info_t *qi; + struct wlc_txq_info *qi; WL_TRACE("wl%d: %s:\n", wlc->pub->unit, __func__); @@ -2715,27 +2719,15 @@ uint wlc_down(struct wlc_info *wlc) /* flush tx queues */ for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { - pktq_flush(wlc->osh, &qi->q, true, NULL, 0); + pktq_flush(&qi->q, true, NULL, 0); ASSERT(pktq_empty(&qi->q)); } - /* flush event queue. - * Should be the last thing done after all the events are generated - * Just delivers the events synchronously instead of waiting for a timer - */ - callbacks += wlc_eventq_down(wlc->eventq); - callbacks += wlc_bmac_down_finish(wlc->hw); /* wlc_bmac_down_finish has done wlc_coredisable(). so clk is off */ wlc->clk = false; - - /* Verify all packets are flushed from the driver */ - if (wlc->osh->pktalloced != 0) { - WL_ERROR("%d packets not freed at wlc_down!!!!!!\n", - wlc->osh->pktalloced); - } #ifdef BCMDBG /* Since all the packets should have been freed, * all callbacks should have been called @@ -2866,16 +2858,17 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config) if ((AP_ENAB(wlc->pub) && preamble != WLC_PLCP_LONG) || preamble == WLC_PLCP_SHORT) - wlc->default_bss->capability |= DOT11_CAP_SHORT; + wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; else - wlc->default_bss->capability &= ~DOT11_CAP_SHORT; + wlc->default_bss->capability &= ~WLAN_CAPABILITY_SHORT_PREAMBLE; /* Update shortslot capability bit for AP and IBSS */ if ((AP_ENAB(wlc->pub) && shortslot == WLC_SHORTSLOT_AUTO) || shortslot == WLC_SHORTSLOT_ON) - wlc->default_bss->capability |= DOT11_CAP_SHORTSLOT; + wlc->default_bss->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME; else - wlc->default_bss->capability &= ~DOT11_CAP_SHORTSLOT; + wlc->default_bss->capability &= + ~WLAN_CAPABILITY_SHORT_SLOT_TIME; /* Use the default 11g rateset */ if (!rs.count) @@ -2892,8 +2885,8 @@ int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config) /* Set default bss rateset */ wlc->default_bss->rateset.count = rs.count; - bcopy((char *)rs.rates, (char *)wlc->default_bss->rateset.rates, - sizeof(wlc->default_bss->rateset.rates)); + memcpy(wlc->default_bss->rateset.rates, rs.rates, + sizeof(wlc->default_bss->rateset.rates)); return ret; } @@ -2986,7 +2979,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg) wlc_rateset_t rs, new; uint bandunit; - bcopy((char *)rs_arg, (char *)&rs, sizeof(wlc_rateset_t)); + memcpy(&rs, rs_arg, sizeof(wlc_rateset_t)); /* check for bad count value */ if ((rs.count == 0) || (rs.count > WLC_NUMRATES)) @@ -2994,7 +2987,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg) /* try the current band */ bandunit = wlc->band->bandunit; - bcopy((char *)&rs, (char *)&new, sizeof(wlc_rateset_t)); + memcpy(&new, &rs, sizeof(wlc_rateset_t)); if (wlc_rate_hwrs_filter_sort_validate (&new, &wlc->bandstate[bandunit]->hw_rateset, true, wlc->stf->txstreams)) @@ -3003,7 +2996,7 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg) /* try the other band */ if (IS_MBAND_UNLOCKED(wlc)) { bandunit = OTHERBANDUNIT(wlc); - bcopy((char *)&rs, (char *)&new, sizeof(wlc_rateset_t)); + memcpy(&new, &rs, sizeof(wlc_rateset_t)); if (wlc_rate_hwrs_filter_sort_validate(&new, &wlc-> bandstate[bandunit]-> @@ -3016,10 +3009,9 @@ static int wlc_set_rateset(struct wlc_info *wlc, wlc_rateset_t *rs_arg) good: /* apply new rateset */ - bcopy((char *)&new, (char *)&wlc->default_bss->rateset, - sizeof(wlc_rateset_t)); - bcopy((char *)&new, (char *)&wlc->bandstate[bandunit]->defrateset, - sizeof(wlc_rateset_t)); + memcpy(&wlc->default_bss->rateset, &new, sizeof(wlc_rateset_t)); + memcpy(&wlc->bandstate[bandunit]->defrateset, &new, + sizeof(wlc_rateset_t)); return 0; } @@ -3071,8 +3063,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, bool ta_ok; uint band; rw_reg_t *r; - wlc_bsscfg_t *bsscfg; - struct osl_info *osh; + struct wlc_bsscfg *bsscfg; wlc_bss_info_t *current_bss; /* update bsscfg pointer */ @@ -3099,7 +3090,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, /* This will prevent the misaligned access */ if (pval && (u32) len >= sizeof(val)) - bcopy(pval, &val, sizeof(val)); + memcpy(&val, pval, sizeof(val)); else val = 0; @@ -3112,7 +3103,6 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, bcmerror = 0; regs = wlc->regs; - osh = wlc->osh; /* A few commands don't need any arguments; all the others do. */ switch (cmd) { @@ -3188,7 +3178,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, wlc->default_bss->chanspec = chspec; /* wlc_BSSinit() will sanitize the rateset before using it.. */ - if (wlc->pub->up && !wlc->pub->associated && + if (wlc->pub->up && (WLC_BAND_PI_RADIO_CHANSPEC != chspec)) { wlc_set_home_chanspec(wlc, chspec); wlc_suspend_mac_and_wait(wlc); @@ -3316,13 +3306,11 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, } if (r->size == sizeof(u32)) r->val = - R_REG(osh, - (u32 *)((unsigned char *)(unsigned long)regs + + R_REG((u32 *)((unsigned char *)(unsigned long)regs + r->byteoff)); else if (r->size == sizeof(u16)) r->val = - R_REG(osh, - (u16 *)((unsigned char *)(unsigned long)regs + + R_REG((u16 *)((unsigned char *)(unsigned long)regs + r->byteoff)); else bcmerror = BCME_BADADDR; @@ -3351,12 +3339,10 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, break; } if (r->size == sizeof(u32)) - W_REG(osh, - (u32 *)((unsigned char *)(unsigned long) regs + + W_REG((u32 *)((unsigned char *)(unsigned long) regs + r->byteoff), r->val); else if (r->size == sizeof(u16)) - W_REG(osh, - (u16 *)((unsigned char *)(unsigned long) regs + + W_REG((u16 *)((unsigned char *)(unsigned long) regs + r->byteoff), r->val); else bcmerror = BCME_BADADDR; @@ -3426,7 +3412,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, break; } - rxstatus = R_REG(wlc->osh, &wlc->regs->phyrxstatus0); + rxstatus = R_REG(&wlc->regs->phyrxstatus0); if (rxstatus == 0xdead || rxstatus == (u16) -1) { bcmerror = BCME_ERROR; break; @@ -3459,15 +3445,8 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, break; } - /* 4322 supports antdiv in phy, no need to set it to ucode */ - if (WLCISNPHY(wlc->band) - && D11REV_IS(wlc->pub->corerev, 16)) { - WL_ERROR("wl%d: can't set ucantdiv for 4322\n", - wlc->pub->unit); - bcmerror = BCME_UNSUPPORTED; - } else - wlc_mhf(wlc, MHF1, MHF1_ANTDIV, - (val ? MHF1_ANTDIV : 0), WLC_BAND_AUTO); + wlc_mhf(wlc, MHF1, MHF1_ANTDIV, + (val ? MHF1_ANTDIV : 0), WLC_BAND_AUTO); break; } #endif /* defined(BCMDBG) */ @@ -3595,18 +3574,17 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, if (src_key) { key.index = src_key->id; key.len = src_key->len; - bcopy(src_key->data, key.data, key.len); + memcpy(key.data, src_key->data, key.len); key.algo = src_key->algo; if (WSEC_SOFTKEY(wlc, src_key, bsscfg)) key.flags |= WL_SOFT_KEY; if (src_key->flags & WSEC_PRIMARY_KEY) key.flags |= WL_PRIMARY_KEY; - bcopy(src_key->ea.octet, key.ea.octet, - ETH_ALEN); + memcpy(key.ea, src_key->ea, ETH_ALEN); } - bcopy((char *)&key, arg, sizeof(key)); + memcpy(arg, &key, sizeof(key)); } else bcmerror = BCME_BADKEYIDX; break; @@ -3639,7 +3617,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, u32 hi; /* group keys in WPA-NONE (IBSS only, AES and TKIP) use a global TXIV */ if ((bsscfg->WPA_auth & WPA_AUTH_NONE) && - is_zero_ether_addr(key->ea.octet)) { + is_zero_ether_addr(key->ea)) { lo = bsscfg->wpa_none_txiv.lo; hi = bsscfg->wpa_none_txiv.hi; } else { @@ -3657,7 +3635,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, seq[6] = 0; seq[7] = 0; - bcopy((char *)seq, arg, sizeof(seq)); + memcpy(arg, seq, sizeof(seq)); } else { bcmerror = BCME_BADKEYIDX; } @@ -3680,7 +3658,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, /* Copy only legacy rateset section */ ret_rs->count = rs->count; - bcopy(&rs->rates, &ret_rs->rates, rs->count); + memcpy(&ret_rs->rates, &rs->rates, rs->count); break; } @@ -3698,7 +3676,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, /* Copy only legacy rateset section */ ret_rs->count = rs.count; - bcopy(&rs.rates, &ret_rs->rates, rs.count); + memcpy(&ret_rs->rates, &rs.rates, rs.count); break; } @@ -3720,16 +3698,18 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, /* Copy only legacy rateset section */ rs.count = in_rs->count; - bcopy(&in_rs->rates, &rs.rates, rs.count); + memcpy(&rs.rates, &in_rs->rates, rs.count); /* merge rateset coming in with the current mcsset */ if (N_ENAB(wlc->pub)) { if (bsscfg->associated) - bcopy(¤t_bss->rateset.mcs[0], - rs.mcs, MCSSET_LEN); + memcpy(rs.mcs, + ¤t_bss->rateset.mcs[0], + MCSSET_LEN); else - bcopy(&wlc->default_bss->rateset.mcs[0], - rs.mcs, MCSSET_LEN); + memcpy(rs.mcs, + &wlc->default_bss->rateset.mcs[0], + MCSSET_LEN); } bcmerror = wlc_set_rateset(wlc, &rs); @@ -3838,19 +3818,18 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, case WLC_GET_PKTCNTS:{ get_pktcnt_t *pktcnt = (get_pktcnt_t *) pval; - if (WLC_UPDATE_STATS(wlc)) - wlc_statsupd(wlc); - pktcnt->rx_good_pkt = WLCNTVAL(wlc->pub->_cnt->rxframe); - pktcnt->rx_bad_pkt = WLCNTVAL(wlc->pub->_cnt->rxerror); + wlc_statsupd(wlc); + pktcnt->rx_good_pkt = wlc->pub->_cnt->rxframe; + pktcnt->rx_bad_pkt = wlc->pub->_cnt->rxerror; pktcnt->tx_good_pkt = - WLCNTVAL(wlc->pub->_cnt->txfrmsnt); + wlc->pub->_cnt->txfrmsnt; pktcnt->tx_bad_pkt = - WLCNTVAL(wlc->pub->_cnt->txerror) + - WLCNTVAL(wlc->pub->_cnt->txfail); + wlc->pub->_cnt->txerror + + wlc->pub->_cnt->txfail; if (len >= (int)sizeof(get_pktcnt_t)) { /* Be backward compatible - only if buffer is large enough */ pktcnt->rx_ocast_good_pkt = - WLCNTVAL(wlc->pub->_cnt->rxmfrmocast); + wlc->pub->_cnt->rxmfrmocast; } break; } @@ -4032,7 +4011,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, bcmerror = BCME_BUFTOOSHORT; break; } - bcopy((char *)arg, (char *)&rs, sizeof(wlc_rateset_t)); + memcpy(&rs, arg, sizeof(wlc_rateset_t)); /* check for bad count value */ if (rs.count > WLC_NUMRATES) { @@ -4068,7 +4047,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, } /* apply new rateset to the override */ - bcopy((char *)&new, (char *)&wlc->sup_rates_override, + memcpy(&wlc->sup_rates_override, &new, sizeof(wlc_rateset_t)); /* update bcn and probe resp if needed */ @@ -4092,8 +4071,7 @@ _wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, bcmerror = BCME_BUFTOOSHORT; break; } - bcopy((char *)&wlc->sup_rates_override, (char *)arg, - sizeof(wlc_rateset_t)); + memcpy(arg, &wlc->sup_rates_override, sizeof(wlc_rateset_t)); break; @@ -4351,7 +4329,7 @@ int wlc_module_unregister(struct wlc_pub *pub, const char *name, void *hdl) for (i = 0; i < WLC_MAXMODULES; i++) { if (!strcmp(wlc->modulecb[i].name, name) && (wlc->modulecb[i].hdl == hdl)) { - memset(&wlc->modulecb[i], 0, sizeof(modulecb_t)); + memset(&wlc->modulecb[i], 0, sizeof(struct modulecb)); return 0; } } @@ -4502,7 +4480,7 @@ wlc_iovar_check(struct wlc_pub *pub, const bcm_iovar_t *vi, void *arg, int len, case IOVT_UINT8: case IOVT_UINT16: case IOVT_UINT32: - bcopy(arg, &int_val, sizeof(int)); + memcpy(&int_val, arg, sizeof(int)); err = wlc_iovar_rangecheck(wlc, int_val, vi); break; } @@ -4526,7 +4504,7 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid, int val_size, struct wlc_if *wlcif) { struct wlc_info *wlc = hdl; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; int err = 0; s32 int_val = 0; s32 int_val2 = 0; @@ -4546,11 +4524,12 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid, /* convenience int and bool vals for first 8 bytes of buffer */ if (p_len >= (int)sizeof(int_val)) - bcopy(params, &int_val, sizeof(int_val)); + memcpy(&int_val, params, sizeof(int_val)); if (p_len >= (int)sizeof(int_val) * 2) - bcopy((void *)((unsigned long)params + sizeof(int_val)), &int_val2, - sizeof(int_val)); + memcpy(&int_val2, + (void *)((unsigned long)params + sizeof(int_val)), + sizeof(int_val)); /* convenience int ptr for 4-byte gets (requires int aligned arg) */ ret_int_ptr = (s32 *) arg; @@ -4562,6 +4541,9 @@ wlc_doiovar(void *hdl, const bcm_iovar_t *vi, u32 actionid, wlc->pub->unit, __func__, IOV_ID(actionid)); /* Do the actual parameter implementation */ switch (actionid) { + case IOV_SVAL(IOV_RTSTHRESH): + wlc->RTSThresh = int_val; + break; case IOV_GVAL(IOV_QTXPOWER):{ uint qdbm; @@ -4683,19 +4665,21 @@ static const char *supr_reason[] = { static void wlc_print_txs_status(u16 s) { - printf("[15:12] %d frame attempts\n", (s & TX_STATUS_FRM_RTX_MASK) >> - TX_STATUS_FRM_RTX_SHIFT); - printf(" [11:8] %d rts attempts\n", (s & TX_STATUS_RTS_RTX_MASK) >> - TX_STATUS_RTS_RTX_SHIFT); - printf(" [7] %d PM mode indicated\n", + printk(KERN_DEBUG "[15:12] %d frame attempts\n", + (s & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT); + printk(KERN_DEBUG " [11:8] %d rts attempts\n", + (s & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT); + printk(KERN_DEBUG " [7] %d PM mode indicated\n", ((s & TX_STATUS_PMINDCTD) ? 1 : 0)); - printf(" [6] %d intermediate status\n", + printk(KERN_DEBUG " [6] %d intermediate status\n", ((s & TX_STATUS_INTERMEDIATE) ? 1 : 0)); - printf(" [5] %d AMPDU\n", (s & TX_STATUS_AMPDU) ? 1 : 0); - printf(" [4:2] %d Frame Suppressed Reason (%s)\n", + printk(KERN_DEBUG " [5] %d AMPDU\n", + (s & TX_STATUS_AMPDU) ? 1 : 0); + printk(KERN_DEBUG " [4:2] %d Frame Suppressed Reason (%s)\n", ((s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT), supr_reason[(s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT]); - printf(" [1] %d acked\n", ((s & TX_STATUS_ACK_RCV) ? 1 : 0)); + printk(KERN_DEBUG " [1] %d acked\n", + ((s & TX_STATUS_ACK_RCV) ? 1 : 0)); } #endif /* BCMDBG */ @@ -4705,30 +4689,47 @@ void wlc_print_txstatus(tx_status_t *txs) u16 s = txs->status; u16 ackphyrxsh = txs->ackphyrxsh; - printf("\ntxpkt (MPDU) Complete\n"); + printk(KERN_DEBUG "\ntxpkt (MPDU) Complete\n"); + + printk(KERN_DEBUG "FrameID: %04x ", txs->frameid); + printk(KERN_DEBUG "TxStatus: %04x", s); + printk(KERN_DEBUG "\n"); - printf("FrameID: %04x ", txs->frameid); - printf("TxStatus: %04x", s); - printf("\n"); -#ifdef BCMDBG wlc_print_txs_status(s); -#endif - printf("LastTxTime: %04x ", txs->lasttxtime); - printf("Seq: %04x ", txs->sequence); - printf("PHYTxStatus: %04x ", txs->phyerr); - printf("RxAckRSSI: %04x ", + + printk(KERN_DEBUG "LastTxTime: %04x ", txs->lasttxtime); + printk(KERN_DEBUG "Seq: %04x ", txs->sequence); + printk(KERN_DEBUG "PHYTxStatus: %04x ", txs->phyerr); + printk(KERN_DEBUG "RxAckRSSI: %04x ", (ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT); - printf("RxAckSQ: %04x", (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); - printf("\n"); + printk(KERN_DEBUG "RxAckSQ: %04x", + (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); + printk(KERN_DEBUG "\n"); #endif /* defined(BCMDBG) */ } +static void +wlc_ctrupd_cache(u16 cur_stat, u16 *macstat_snapshot, u32 *macstat) +{ + u16 v; + u16 delta; + + v = le16_to_cpu(cur_stat); + delta = (u16)(v - *macstat_snapshot); + + if (delta != 0) { + *macstat += delta; + *macstat_snapshot = v; + } +} + #define MACSTATUPD(name) \ wlc_ctrupd_cache(macstats.name, &wlc->core->macstat_snapshot->name, &wlc->pub->_cnt->name) void wlc_statsupd(struct wlc_info *wlc) { int i; + macstat_t macstats; #ifdef BCMDBG u16 delta; u16 rxf0ovfl; @@ -4748,6 +4749,66 @@ void wlc_statsupd(struct wlc_info *wlc) txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i]; #endif /* BCMDBG */ + /* Read mac stats from contiguous shared memory */ + wlc_bmac_copyfrom_shm(wlc->hw, M_UCODE_MACSTAT, + &macstats, sizeof(macstat_t)); + + /* update mac stats */ + MACSTATUPD(txallfrm); + MACSTATUPD(txrtsfrm); + MACSTATUPD(txctsfrm); + MACSTATUPD(txackfrm); + MACSTATUPD(txdnlfrm); + MACSTATUPD(txbcnfrm); + for (i = 0; i < NFIFO; i++) + MACSTATUPD(txfunfl[i]); + MACSTATUPD(txtplunfl); + MACSTATUPD(txphyerr); + MACSTATUPD(rxfrmtoolong); + MACSTATUPD(rxfrmtooshrt); + MACSTATUPD(rxinvmachdr); + MACSTATUPD(rxbadfcs); + MACSTATUPD(rxbadplcp); + MACSTATUPD(rxcrsglitch); + MACSTATUPD(rxstrt); + MACSTATUPD(rxdfrmucastmbss); + MACSTATUPD(rxmfrmucastmbss); + MACSTATUPD(rxcfrmucast); + MACSTATUPD(rxrtsucast); + MACSTATUPD(rxctsucast); + MACSTATUPD(rxackucast); + MACSTATUPD(rxdfrmocast); + MACSTATUPD(rxmfrmocast); + MACSTATUPD(rxcfrmocast); + MACSTATUPD(rxrtsocast); + MACSTATUPD(rxctsocast); + MACSTATUPD(rxdfrmmcast); + MACSTATUPD(rxmfrmmcast); + MACSTATUPD(rxcfrmmcast); + MACSTATUPD(rxbeaconmbss); + MACSTATUPD(rxdfrmucastobss); + MACSTATUPD(rxbeaconobss); + MACSTATUPD(rxrsptmout); + MACSTATUPD(bcntxcancl); + MACSTATUPD(rxf0ovfl); + MACSTATUPD(rxf1ovfl); + MACSTATUPD(rxf2ovfl); + MACSTATUPD(txsfovfl); + MACSTATUPD(pmqovfl); + MACSTATUPD(rxcgprqfrm); + MACSTATUPD(rxcgprsqovfl); + MACSTATUPD(txcgprsfail); + MACSTATUPD(txcgprssuc); + MACSTATUPD(prs_timeout); + MACSTATUPD(rxnack); + MACSTATUPD(frmscons); + MACSTATUPD(txnack); + MACSTATUPD(txglitch_nack); + MACSTATUPD(txburst); + MACSTATUPD(phywatchdog); + MACSTATUPD(pktengrxducast); + MACSTATUPD(pktengrxdmcast); + #ifdef BCMDBG /* check for rx fifo 0 overflow */ delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl); @@ -4805,7 +4866,7 @@ void wlc_statsupd(struct wlc_info *wlc) wlc->pub->_cnt->rxgiant + wlc->pub->_cnt->rxnoscb + wlc->pub->_cnt->rxbadsrcmac); for (i = 0; i < NFIFO; i++) - WLCNTADD(wlc->pub->_cnt->rxerror, wlc->pub->_cnt->rxuflo[i]); + wlc->pub->_cnt->rxerror += wlc->pub->_cnt->rxuflo[i]; } bool wlc_chipmatch(u16 vendor, u16 device) @@ -4830,85 +4891,84 @@ bool wlc_chipmatch(u16 vendor, u16 device) #if defined(BCMDBG) void wlc_print_txdesc(d11txh_t *txh) { - u16 mtcl = ltoh16(txh->MacTxControlLow); - u16 mtch = ltoh16(txh->MacTxControlHigh); - u16 mfc = ltoh16(txh->MacFrameControl); - u16 tfest = ltoh16(txh->TxFesTimeNormal); - u16 ptcw = ltoh16(txh->PhyTxControlWord); - u16 ptcw_1 = ltoh16(txh->PhyTxControlWord_1); - u16 ptcw_1_Fbr = ltoh16(txh->PhyTxControlWord_1_Fbr); - u16 ptcw_1_Rts = ltoh16(txh->PhyTxControlWord_1_Rts); - u16 ptcw_1_FbrRts = ltoh16(txh->PhyTxControlWord_1_FbrRts); - u16 mainrates = ltoh16(txh->MainRates); - u16 xtraft = ltoh16(txh->XtraFrameTypes); + u16 mtcl = le16_to_cpu(txh->MacTxControlLow); + u16 mtch = le16_to_cpu(txh->MacTxControlHigh); + u16 mfc = le16_to_cpu(txh->MacFrameControl); + u16 tfest = le16_to_cpu(txh->TxFesTimeNormal); + u16 ptcw = le16_to_cpu(txh->PhyTxControlWord); + u16 ptcw_1 = le16_to_cpu(txh->PhyTxControlWord_1); + u16 ptcw_1_Fbr = le16_to_cpu(txh->PhyTxControlWord_1_Fbr); + u16 ptcw_1_Rts = le16_to_cpu(txh->PhyTxControlWord_1_Rts); + u16 ptcw_1_FbrRts = le16_to_cpu(txh->PhyTxControlWord_1_FbrRts); + u16 mainrates = le16_to_cpu(txh->MainRates); + u16 xtraft = le16_to_cpu(txh->XtraFrameTypes); u8 *iv = txh->IV; u8 *ra = txh->TxFrameRA; - u16 tfestfb = ltoh16(txh->TxFesTimeFallback); + u16 tfestfb = le16_to_cpu(txh->TxFesTimeFallback); u8 *rtspfb = txh->RTSPLCPFallback; - u16 rtsdfb = ltoh16(txh->RTSDurFallback); + u16 rtsdfb = le16_to_cpu(txh->RTSDurFallback); u8 *fragpfb = txh->FragPLCPFallback; - u16 fragdfb = ltoh16(txh->FragDurFallback); - u16 mmodelen = ltoh16(txh->MModeLen); - u16 mmodefbrlen = ltoh16(txh->MModeFbrLen); - u16 tfid = ltoh16(txh->TxFrameID); - u16 txs = ltoh16(txh->TxStatus); - u16 mnmpdu = ltoh16(txh->MaxNMpdus); - u16 mabyte = ltoh16(txh->MaxABytes_MRT); - u16 mabyte_f = ltoh16(txh->MaxABytes_FBR); - u16 mmbyte = ltoh16(txh->MinMBytes); + u16 fragdfb = le16_to_cpu(txh->FragDurFallback); + u16 mmodelen = le16_to_cpu(txh->MModeLen); + u16 mmodefbrlen = le16_to_cpu(txh->MModeFbrLen); + u16 tfid = le16_to_cpu(txh->TxFrameID); + u16 txs = le16_to_cpu(txh->TxStatus); + u16 mnmpdu = le16_to_cpu(txh->MaxNMpdus); + u16 mabyte = le16_to_cpu(txh->MaxABytes_MRT); + u16 mabyte_f = le16_to_cpu(txh->MaxABytes_FBR); + u16 mmbyte = le16_to_cpu(txh->MinMBytes); u8 *rtsph = txh->RTSPhyHeader; - struct dot11_rts_frame rts = txh->rts_frame; + struct ieee80211_rts rts = txh->rts_frame; char hexbuf[256]; /* add plcp header along with txh descriptor */ prhex("Raw TxDesc + plcp header", (unsigned char *) txh, sizeof(d11txh_t) + 48); - printf("TxCtlLow: %04x ", mtcl); - printf("TxCtlHigh: %04x ", mtch); - printf("FC: %04x ", mfc); - printf("FES Time: %04x\n", tfest); - printf("PhyCtl: %04x%s ", ptcw, + printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl); + printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch); + printk(KERN_DEBUG "FC: %04x ", mfc); + printk(KERN_DEBUG "FES Time: %04x\n", tfest); + printk(KERN_DEBUG "PhyCtl: %04x%s ", ptcw, (ptcw & PHY_TXC_SHORT_HDR) ? " short" : ""); - printf("PhyCtl_1: %04x ", ptcw_1); - printf("PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); - printf("PhyCtl_1_Rts: %04x ", ptcw_1_Rts); - printf("PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); - printf("MainRates: %04x ", mainrates); - printf("XtraFrameTypes: %04x ", xtraft); - printf("\n"); + printk(KERN_DEBUG "PhyCtl_1: %04x ", ptcw_1); + printk(KERN_DEBUG "PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); + printk(KERN_DEBUG "PhyCtl_1_Rts: %04x ", ptcw_1_Rts); + printk(KERN_DEBUG "PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); + printk(KERN_DEBUG "MainRates: %04x ", mainrates); + printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); + printk(KERN_DEBUG "\n"); bcm_format_hex(hexbuf, iv, sizeof(txh->IV)); - printf("SecIV: %s\n", hexbuf); + printk(KERN_DEBUG "SecIV: %s\n", hexbuf); bcm_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA)); - printf("RA: %s\n", hexbuf); + printk(KERN_DEBUG "RA: %s\n", hexbuf); - printf("Fb FES Time: %04x ", tfestfb); + printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); bcm_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback)); - printf("RTS PLCP: %s ", hexbuf); - printf("RTS DUR: %04x ", rtsdfb); + printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); + printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); bcm_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback)); - printf("PLCP: %s ", hexbuf); - printf("DUR: %04x", fragdfb); - printf("\n"); + printk(KERN_DEBUG "PLCP: %s ", hexbuf); + printk(KERN_DEBUG "DUR: %04x", fragdfb); + printk(KERN_DEBUG "\n"); - printf("MModeLen: %04x ", mmodelen); - printf("MModeFbrLen: %04x\n", mmodefbrlen); + printk(KERN_DEBUG "MModeLen: %04x ", mmodelen); + printk(KERN_DEBUG "MModeFbrLen: %04x\n", mmodefbrlen); - printf("FrameID: %04x\n", tfid); - printf("TxStatus: %04x\n", txs); + printk(KERN_DEBUG "FrameID: %04x\n", tfid); + printk(KERN_DEBUG "TxStatus: %04x\n", txs); - printf("MaxNumMpdu: %04x\n", mnmpdu); - printf("MaxAggbyte: %04x\n", mabyte); - printf("MaxAggbyte_fb: %04x\n", mabyte_f); - printf("MinByte: %04x\n", mmbyte); + printk(KERN_DEBUG "MaxNumMpdu: %04x\n", mnmpdu); + printk(KERN_DEBUG "MaxAggbyte: %04x\n", mabyte); + printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); + printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); bcm_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader)); - printf("RTS PLCP: %s ", hexbuf); + printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); bcm_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame)); - printf("RTS Frame: %s", hexbuf); - printf("\n"); - + printk(KERN_DEBUG "RTS Frame: %s", hexbuf); + printk(KERN_DEBUG "\n"); } #endif /* defined(BCMDBG) */ @@ -4940,13 +5000,14 @@ void wlc_print_rxh(d11rxhdr_t *rxh) snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); - printf("RxFrameSize: %6s (%d)%s\n", lenbuf, len, + printk(KERN_DEBUG "RxFrameSize: %6s (%d)%s\n", lenbuf, len, (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : ""); - printf("RxPHYStatus: %04x %04x %04x %04x\n", + printk(KERN_DEBUG "RxPHYStatus: %04x %04x %04x %04x\n", phystatus_0, phystatus_1, phystatus_2, phystatus_3); - printf("RxMACStatus: %x %s\n", macstatus1, flagstr); - printf("RXMACaggtype: %x\n", (macstatus2 & RXS_AGGTYPE_MASK)); - printf("RxTSFTime: %04x\n", rxh->RxTSFTime); + printk(KERN_DEBUG "RxMACStatus: %x %s\n", macstatus1, flagstr); + printk(KERN_DEBUG "RXMACaggtype: %x\n", + (macstatus2 & RXS_AGGTYPE_MASK)); + printk(KERN_DEBUG "RxTSFTime: %04x\n", rxh->RxTSFTime); } #endif /* defined(BCMDBG) */ @@ -4957,8 +5018,8 @@ int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len) char *p = buf; char *endp = buf + SSID_FMT_BUF_LEN; - if (ssid_len > DOT11_MAX_SSID_LEN) - ssid_len = DOT11_MAX_SSID_LEN; + if (ssid_len > IEEE80211_MAX_SSID_LEN) + ssid_len = IEEE80211_MAX_SSID_LEN; for (i = 0; i < ssid_len; i++) { c = (uint) ssid[i]; @@ -4978,7 +5039,7 @@ int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len) } #endif /* defined(BCMDBG) */ -u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate) +static u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate) { return wlc_bmac_rate_shm_offset(wlc->hw, rate); } @@ -5047,12 +5108,10 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt, tx_failed[WME_PRIO2AC(p->priority)].packets); WLCNTADD(wlc->pub->_wme_cnt-> tx_failed[WME_PRIO2AC(p->priority)].bytes, - pkttotlen(wlc->osh, p)); + pkttotlen(p)); } - - ASSERT(0); - pkt_buf_free_skb(wlc->osh, p, true); - WLCNTINCR(wlc->pub->_cnt->txnobuf); + pkt_buf_free_skb(p); + wlc->pub->_cnt->txnobuf++; } /* Enqueue */ @@ -5069,7 +5128,7 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, uint prec) { struct wlc_info *wlc = (struct wlc_info *) ctx; - wlc_txq_info_t *qi = wlc->active_queue; /* Check me */ + struct wlc_txq_info *qi = wlc->active_queue; /* Check me */ struct pktq *q = &qi->q; int prio; @@ -5083,9 +5142,12 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu, WL_ERROR("wl%d: wlc_txq_enq: txq overflow\n", wlc->pub->unit); - /* ASSERT(9 == 8); *//* XXX we might hit this condtion in case packet flooding from mac80211 stack */ - pkt_buf_free_skb(wlc->osh, sdu, true); - WLCNTINCR(wlc->pub->_cnt->txnobuf); + /* + * XXX we might hit this condtion in case + * packet flooding from mac80211 stack + */ + pkt_buf_free_skb(sdu); + wlc->pub->_cnt->txnobuf++; } /* Check if flow control needs to be turned on after enqueuing the packet @@ -5113,16 +5175,13 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu, uint fifo; void *pkt; struct scb *scb = &global_scb; - struct dot11_header *d11_header = (struct dot11_header *)(sdu->data); - u16 type, fc; + struct ieee80211_hdr *d11_header = (struct ieee80211_hdr *)(sdu->data); ASSERT(sdu); - fc = ltoh16(d11_header->fc); - type = FC_TYPE(fc); - /* 802.11 standard requires management traffic to go at highest priority */ - prio = (type == FC_TYPE_DATA ? sdu->priority : MAXPRIO); + prio = ieee80211_is_data(d11_header->frame_control) ? sdu->priority : + MAXPRIO; fifo = prio2fifo[prio]; ASSERT((uint) skb_headroom(sdu) >= TXOFF); @@ -5137,11 +5196,11 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu, wlc_txq_enq(wlc, scb, pkt, WLC_PRIO_TO_PREC(prio)); wlc_send_q(wlc, wlc->active_queue); - WLCNTINCR(wlc->pub->_cnt->ieee_tx); + wlc->pub->_cnt->ieee_tx++; return 0; } -void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, wlc_txq_info_t *qi) +void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi) { struct sk_buff *pkt[DOT11_MAXNUMFRAGS]; int prec; @@ -5216,11 +5275,13 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc, wlc_txq_info_t *qi) * for MC frames so is used as part of the sequence number. */ static inline u16 -bcmc_fid_generate(struct wlc_info *wlc, wlc_bsscfg_t *bsscfg, d11txh_t *txh) +bcmc_fid_generate(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg, + d11txh_t *txh) { u16 frameid; - frameid = ltoh16(txh->TxFrameID) & ~(TXFID_SEQ_MASK | TXFID_QUEUE_MASK); + frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | + TXFID_QUEUE_MASK); frameid |= (((wlc-> mc_fid_counter++) << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) | @@ -5243,7 +5304,7 @@ wlc_txfifo(struct wlc_info *wlc, uint fifo, struct sk_buff *p, bool commit, * ucode or BSS info as appropriate. */ if (fifo == TX_BCMC_FIFO) { - frameid = ltoh16(txh->TxFrameID); + frameid = le16_to_cpu(txh->TxFrameID); } @@ -5650,13 +5711,12 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, uint nfrags, uint queue, uint next_frag_len, wsec_key_t *key, ratespec_t rspec_override) { - struct dot11_header *h; + struct ieee80211_hdr *h; d11txh_t *txh; u8 *plcp, plcp_fallback[D11_PHY_HDR_LEN]; - struct osl_info *osh; int len, phylen, rts_phylen; - u16 fc, type, frameid, mch, phyctl, xfts, mainrates; - u16 seq = 0, mcl = 0, status = 0; + u16 mch, phyctl, xfts, mainrates; + u16 seq = 0, mcl = 0, status = 0, frameid = 0; ratespec_t rspec[2] = { WLC_RATE_1M, WLC_RATE_1M }, rts_rspec[2] = { WLC_RATE_1M, WLC_RATE_1M}; bool use_rts = false; @@ -5666,17 +5726,15 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, u8 preamble_type[2] = { WLC_LONG_PREAMBLE, WLC_LONG_PREAMBLE }; u8 rts_preamble_type[2] = { WLC_LONG_PREAMBLE, WLC_LONG_PREAMBLE }; u8 *rts_plcp, rts_plcp_fallback[D11_PHY_HDR_LEN]; - struct dot11_rts_frame *rts = NULL; + struct ieee80211_rts *rts = NULL; bool qos; uint ac; u32 rate_val[2]; bool hwtkmic = false; u16 mimo_ctlchbw = PHY_TXC1_BW_20MHZ; -#ifdef WLANTSEL #define ANTCFG_NONE 0xFF u8 antcfg = ANTCFG_NONE; u8 fbantcfg = ANTCFG_NONE; -#endif uint phyctl1_stf = 0; u16 durid = 0; struct ieee80211_tx_rate *txrate[2]; @@ -5686,22 +5744,15 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, u16 mimo_txbw; u8 mimo_preamble_type; - frameid = 0; - ASSERT(queue < NFIFO); - osh = wlc->osh; - /* locate 802.11 MAC header */ - h = (struct dot11_header *)(p->data); - fc = ltoh16(h->fc); - type = FC_TYPE(fc); - - qos = (type == FC_TYPE_DATA && FC_SUBTYPE_ANY_QOS(FC_SUBTYPE(fc))); + h = (struct ieee80211_hdr *)(p->data); + qos = ieee80211_is_data_qos(h->frame_control); /* compute length of frame in bytes for use in PLCP computations */ - len = pkttotlen(osh, p); - phylen = len + DOT11_FCS_LEN; + len = pkttotlen(p); + phylen = len + FCS_LEN; /* If WEP enabled, add room in phylen for the additional bytes of * ICV which MAC generates. We do NOT add the additional bytes to @@ -5721,7 +5772,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, /* add Broadcom tx descriptor header */ txh = (d11txh_t *) skb_push(p, D11_TXH_LEN); - memset((char *)txh, 0, D11_TXH_LEN); + memset(txh, 0, D11_TXH_LEN); /* setup frameid */ if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { @@ -5738,9 +5789,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, } /* extract fragment number from frame first */ - seq = ltoh16(seq) & FRAGNUM_MASK; + seq = le16_to_cpu(seq) & FRAGNUM_MASK; seq |= (SCB_SEQNUM(scb, p->priority) << SEQNUM_SHIFT); - h->seq = htol16(seq); + h->seq_ctrl = cpu_to_le16(seq); frameid = ((seq << TXFID_SEQ_SHIFT) & TXFID_SEQ_MASK) | (queue & TXFID_QUEUE_MASK); @@ -5749,7 +5800,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, frameid |= queue & TXFID_QUEUE_MASK; /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */ - if (SCB_PS(scb) || ((fc & FC_KIND_MASK) == FC_BEACON)) + if (SCB_PS(scb) || ieee80211_is_beacon(h->frame_control)) mcl |= TXC_IGNOREPMQ; ASSERT(hw->max_rates <= IEEE80211_TX_MAX_RATES); @@ -5809,8 +5860,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, ASSERT(RSPEC_ACTIVE(rspec[k])); rspec[k] = WLC_RATE_1M; } else { - if (WLANTSEL_ENAB(wlc) && - !is_multicast_ether_addr(h->a1.octet)) { + if (!is_multicast_ether_addr(h->addr1)) { /* set tx antenna config */ wlc_antsel_antcfg_get(wlc->asi, false, false, 0, 0, &antcfg, &fbantcfg); @@ -5954,11 +6004,17 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, txrate[0]->count = 0; txrate[1]->count = 0; + /* (2) PROTECTION, may change rspec */ + if ((ieee80211_is_data(h->frame_control) || + ieee80211_is_mgmt(h->frame_control)) && + (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) + use_rts = true; + /* (3) PLCP: determine PLCP header and MAC duration, fill d11txh_t */ wlc_compute_plcp(wlc, rspec[0], phylen, plcp); wlc_compute_plcp(wlc, rspec[1], phylen, plcp_fallback); - bcopy(plcp_fallback, (char *)&txh->FragPLCPFallback, - sizeof(txh->FragPLCPFallback)); + memcpy(&txh->FragPLCPFallback, + plcp_fallback, sizeof(txh->FragPLCPFallback)); /* Length field now put in CCK FBR CRC field */ if (IS_CCK(rspec[1])) { @@ -5972,12 +6028,12 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, plcp[0]; /* DUR field for main rate */ - if ((fc != FC_PS_POLL) && - !is_multicast_ether_addr(h->a1.octet) && !use_rifs) { + if (!ieee80211_is_pspoll(h->frame_control) && + !is_multicast_ether_addr(h->addr1) && !use_rifs) { durid = wlc_compute_frame_dur(wlc, rspec[0], preamble_type[0], next_frag_len); - h->durid = htol16(durid); + h->duration_id = cpu_to_le16(durid); } else if (use_rifs) { /* NAV protect to end of next max packet size */ durid = @@ -5985,25 +6041,25 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, preamble_type[0], DOT11_MAX_FRAG_LEN); durid += RIFS_11N_TIME; - h->durid = htol16(durid); + h->duration_id = cpu_to_le16(durid); } /* DUR field for fallback rate */ - if (fc == FC_PS_POLL) - txh->FragDurFallback = h->durid; - else if (is_multicast_ether_addr(h->a1.octet) || use_rifs) + if (ieee80211_is_pspoll(h->frame_control)) + txh->FragDurFallback = h->duration_id; + else if (is_multicast_ether_addr(h->addr1) || use_rifs) txh->FragDurFallback = 0; else { durid = wlc_compute_frame_dur(wlc, rspec[1], preamble_type[1], next_frag_len); - txh->FragDurFallback = htol16(durid); + txh->FragDurFallback = cpu_to_le16(durid); } /* (4) MAC-HDR: MacTxControlLow */ if (frag == 0) mcl |= TXC_STARTMSDU; - if (!is_multicast_ether_addr(h->a1.octet)) + if (!is_multicast_ether_addr(h->addr1)) mcl |= TXC_IMMEDACK; if (BAND_5G(wlc->band->bandtype)) @@ -6016,7 +6072,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, if (hwtkmic) mcl |= TXC_AMIC; - txh->MacTxControlLow = htol16(mcl); + txh->MacTxControlLow = cpu_to_le16(mcl); /* MacTxControlHigh */ mch = 0; @@ -6031,33 +6087,29 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, } /* MacFrameControl */ - bcopy((char *)&h->fc, (char *)&txh->MacFrameControl, sizeof(u16)); + memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); + txh->TxFesTimeNormal = cpu_to_le16(0); - txh->TxFesTimeNormal = htol16(0); - - txh->TxFesTimeFallback = htol16(0); + txh->TxFesTimeFallback = cpu_to_le16(0); /* TxFrameRA */ - bcopy((char *)&h->a1, (char *)&txh->TxFrameRA, ETH_ALEN); + memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); /* TxFrameID */ - txh->TxFrameID = htol16(frameid); + txh->TxFrameID = cpu_to_le16(frameid); /* TxStatus, Note the case of recreating the first frag of a suppressed frame * then we may need to reset the retry cnt's via the status reg */ - txh->TxStatus = htol16(status); + txh->TxStatus = cpu_to_le16(status); - if (D11REV_GE(wlc->pub->corerev, 16)) { - /* extra fields for ucode AMPDU aggregation, the new fields are added to - * the END of previous structure so that it's compatible in driver. - * In old rev ucode, these fields should be ignored - */ - txh->MaxNMpdus = htol16(0); - txh->MaxABytes_MRT = htol16(0); - txh->MaxABytes_FBR = htol16(0); - txh->MinMBytes = htol16(0); - } + /* extra fields for ucode AMPDU aggregation, the new fields are added to + * the END of previous structure so that it's compatible in driver. + */ + txh->MaxNMpdus = cpu_to_le16(0); + txh->MaxABytes_MRT = cpu_to_le16(0); + txh->MaxABytes_FBR = cpu_to_le16(0); + txh->MinMBytes = cpu_to_le16(0); /* (5) RTS/CTS: determine RTS/CTS PLCP header and MAC duration, furnish d11txh_t */ /* RTS PLCP header and RTS frame */ @@ -6087,49 +6139,52 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, /* RTS/CTS additions to MacTxControlLow */ if (use_cts) { - txh->MacTxControlLow |= htol16(TXC_SENDCTS); + txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); } else { - txh->MacTxControlLow |= htol16(TXC_SENDRTS); - txh->MacTxControlLow |= htol16(TXC_LONGFRAME); + txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); + txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); } /* RTS PLCP header */ ASSERT(IS_ALIGNED((unsigned long)txh->RTSPhyHeader, sizeof(u16))); rts_plcp = txh->RTSPhyHeader; if (use_cts) - rts_phylen = DOT11_CTS_LEN + DOT11_FCS_LEN; + rts_phylen = DOT11_CTS_LEN + FCS_LEN; else - rts_phylen = DOT11_RTS_LEN + DOT11_FCS_LEN; + rts_phylen = DOT11_RTS_LEN + FCS_LEN; wlc_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp); /* fallback rate version of RTS PLCP header */ wlc_compute_plcp(wlc, rts_rspec[1], rts_phylen, rts_plcp_fallback); - bcopy(rts_plcp_fallback, (char *)&txh->RTSPLCPFallback, - sizeof(txh->RTSPLCPFallback)); + memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, + sizeof(txh->RTSPLCPFallback)); /* RTS frame fields... */ - rts = (struct dot11_rts_frame *)&txh->rts_frame; + rts = (struct ieee80211_rts *)&txh->rts_frame; durid = wlc_compute_rtscts_dur(wlc, use_cts, rts_rspec[0], rspec[0], rts_preamble_type[0], preamble_type[0], phylen, false); - rts->durid = htol16(durid); + rts->duration = cpu_to_le16(durid); /* fallback rate version of RTS DUR field */ durid = wlc_compute_rtscts_dur(wlc, use_cts, rts_rspec[1], rspec[1], rts_preamble_type[1], preamble_type[1], phylen, false); - txh->RTSDurFallback = htol16(durid); + txh->RTSDurFallback = cpu_to_le16(durid); if (use_cts) { - rts->fc = htol16(FC_CTS); - bcopy((char *)&h->a2, (char *)&rts->ra, ETH_ALEN); + rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | + IEEE80211_STYPE_CTS); + + memcpy(&rts->ra, &h->addr2, ETH_ALEN); } else { - rts->fc = htol16((u16) FC_RTS); - bcopy((char *)&h->a1, (char *)&rts->ra, - 2 * ETH_ALEN); + rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | + IEEE80211_STYPE_RTS); + + memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN); } /* mainrate @@ -6142,7 +6197,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, } else { memset((char *)txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); memset((char *)&txh->rts_frame, 0, - sizeof(struct dot11_rts_frame)); + sizeof(struct ieee80211_rts)); memset((char *)txh->RTSPLCPFallback, 0, sizeof(txh->RTSPLCPFallback)); txh->RTSDurFallback = 0; @@ -6157,10 +6212,10 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, #endif /* Now that RTS/RTS FB preamble types are updated, write the final value */ - txh->MacTxControlHigh = htol16(mch); + txh->MacTxControlHigh = cpu_to_le16(mch); /* MainRates (both the rts and frag plcp rates have been calculated now) */ - txh->MainRates = htol16(mainrates); + txh->MainRates = cpu_to_le16(mainrates); /* XtraFrameTypes */ xfts = FRAMETYPE(rspec[1], wlc->mimoft); @@ -6168,7 +6223,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, xfts |= (FRAMETYPE(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); xfts |= CHSPEC_CHANNEL(WLC_BAND_PI_RADIO_CHANSPEC) << XFTS_CHANNEL_SHIFT; - txh->XtraFrameTypes = htol16(xfts); + txh->XtraFrameTypes = cpu_to_le16(xfts); /* PhyTxControlWord */ phyctl = FRAMETYPE(rspec[0], wlc->mimoft); @@ -6178,27 +6233,27 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, || !IS_MCS(rspec[0])); if (RSPEC2RATE(rspec[0]) != WLC_RATE_1M) phyctl |= PHY_TXC_SHORT_HDR; - WLCNTINCR(wlc->pub->_cnt->txprshort); + wlc->pub->_cnt->txprshort++; } /* phytxant is properly bit shifted */ phyctl |= wlc_stf_d11hdrs_phyctl_txant(wlc, rspec[0]); - txh->PhyTxControlWord = htol16(phyctl); + txh->PhyTxControlWord = cpu_to_le16(phyctl); /* PhyTxControlWord_1 */ if (WLC_PHY_11N_CAP(wlc->band)) { u16 phyctl1 = 0; phyctl1 = wlc_phytxctl1_calc(wlc, rspec[0]); - txh->PhyTxControlWord_1 = htol16(phyctl1); + txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); phyctl1 = wlc_phytxctl1_calc(wlc, rspec[1]); - txh->PhyTxControlWord_1_Fbr = htol16(phyctl1); + txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); if (use_rts || use_cts) { phyctl1 = wlc_phytxctl1_calc(wlc, rts_rspec[0]); - txh->PhyTxControlWord_1_Rts = htol16(phyctl1); + txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); phyctl1 = wlc_phytxctl1_calc(wlc, rts_rspec[1]); - txh->PhyTxControlWord_1_FbrRts = htol16(phyctl1); + txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); } /* @@ -6209,13 +6264,13 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, if (IS_MCS(rspec[0]) && (preamble_type[0] == WLC_MM_PREAMBLE)) { u16 mmodelen = wlc_calc_lsig_len(wlc, rspec[0], phylen); - txh->MModeLen = htol16(mmodelen); + txh->MModeLen = cpu_to_le16(mmodelen); } if (IS_MCS(rspec[1]) && (preamble_type[1] == WLC_MM_PREAMBLE)) { u16 mmodefbrlen = wlc_calc_lsig_len(wlc, rspec[1], phylen); - txh->MModeFbrLen = htol16(mmodefbrlen); + txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); } } @@ -6232,7 +6287,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, if (SCB_WME(scb) && qos && wlc->edcf_txop[ac]) { uint frag_dur, dur, dur_fallback; - ASSERT(!is_multicast_ether_addr(h->a1.octet)); + ASSERT(!is_multicast_ether_addr(h->addr1)); /* WME: Update TXOP threshold */ if ((!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) && (frag == 0)) { @@ -6249,8 +6304,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, wlc_calc_cts_time(wlc, rts_rspec[1], rts_preamble_type[1]); /* (SIFS + CTS) + SIFS + frame + SIFS + ACK */ - dur += ltoh16(rts->durid); - dur_fallback += ltoh16(txh->RTSDurFallback); + dur += le16_to_cpu(rts->duration); + dur_fallback += + le16_to_cpu(txh->RTSDurFallback); } else if (use_rifs) { dur = frag_dur; dur_fallback = 0; @@ -6270,9 +6326,10 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, preamble_type[1], 0); } /* NEED to set TxFesTimeNormal (hard) */ - txh->TxFesTimeNormal = htol16((u16) dur); + txh->TxFesTimeNormal = cpu_to_le16((u16) dur); /* NEED to set fallback rate version of TxFesTimeNormal (hard) */ - txh->TxFesTimeFallback = htol16((u16) dur_fallback); + txh->TxFesTimeFallback = + cpu_to_le16((u16) dur_fallback); /* update txop byte threshold (txop minus intraframe overhead) */ if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { @@ -6320,9 +6377,9 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw, void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs) { - wlc_bsscfg_t *cfg = wlc->cfg; + struct wlc_bsscfg *cfg = wlc->cfg; - WLCNTINCR(wlc->pub->_cnt->tbtt); + wlc->pub->_cnt->tbtt++; if (BSSCFG_STA(cfg)) { /* run watchdog here if the watchdog timer is not armed */ @@ -6356,14 +6413,12 @@ void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs) /* GP timer is a freerunning 32 bit counter, decrements at 1 us rate */ void wlc_hwtimer_gptimer_set(struct wlc_info *wlc, uint us) { - ASSERT(wlc->pub->corerev >= 3); /* no gptimer in earlier revs */ - W_REG(wlc->osh, &wlc->regs->gptimer, us); + W_REG(&wlc->regs->gptimer, us); } void wlc_hwtimer_gptimer_abort(struct wlc_info *wlc) { - ASSERT(wlc->pub->corerev >= 3); - W_REG(wlc->osh, &wlc->regs->gptimer, 0); + W_REG(&wlc->regs->gptimer, 0); } static void wlc_hwtimer_gptimer_cb(struct wlc_info *wlc) @@ -6371,7 +6426,7 @@ static void wlc_hwtimer_gptimer_cb(struct wlc_info *wlc) /* when interrupt is generated, the counter is loaded with last value * written and continue to decrement. So it has to be cleaned first */ - W_REG(wlc->osh, &wlc->regs->gptimer, 0); + W_REG(&wlc->regs->gptimer, 0); } /* @@ -6440,7 +6495,7 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus) __func__, wlc->pub->sih->chip, wlc->pub->sih->chiprev); - WLCNTINCR(wlc->pub->_cnt->psmwds); + wlc->pub->_cnt->psmwds++; /* big hammer */ wl_init(wlc->wl); @@ -6454,11 +6509,11 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus) if (macintstatus & MI_RFDISABLE) { WL_ERROR("wl%d: MAC Detected a change on the RF Disable Input 0x%x\n", wlc->pub->unit, - R_REG(wlc->osh, ®s->phydebug) & PDBG_RFD); + R_REG(®s->phydebug) & PDBG_RFD); /* delay the cleanup to wl_down in IBSS case */ - if ((R_REG(wlc->osh, ®s->phydebug) & PDBG_RFD)) { + if ((R_REG(®s->phydebug) & PDBG_RFD)) { int idx; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; FOREACH_BSS(wlc, idx, bsscfg) { if (!BSSCFG_STA(bsscfg) || !bsscfg->enable || !bsscfg->BSS) @@ -6476,37 +6531,6 @@ void wlc_high_dpc(struct wlc_info *wlc, u32 macintstatus) ASSERT(wlc_ps_check(wlc)); } -static void *wlc_15420war(struct wlc_info *wlc, uint queue) -{ - struct hnddma_pub *di; - void *p; - - ASSERT(queue < NFIFO); - - if ((D11REV_IS(wlc->pub->corerev, 4)) - || (D11REV_GT(wlc->pub->corerev, 6))) - return NULL; - - di = wlc->hw->di[queue]; - ASSERT(di != NULL); - - /* get next packet, ignoring XmtStatus.Curr */ - p = dma_getnexttxp(di, HNDDMA_RANGE_ALL); - - /* sw block tx dma */ - dma_txblock(di); - - /* if tx ring is now empty, reset and re-init the tx dma channel */ - if (dma_txactive(wlc->hw->di[queue]) == 0) { - WLCNTINCR(wlc->pub->_cnt->txdmawar); - if (!dma_txreset(di)) - WL_ERROR("wl%d: %s: dma_txreset[%d]: cannot stop dma\n", - wlc->pub->unit, __func__, queue); - dma_txinit(di); - } - return p; -} - static void wlc_war16165(struct wlc_info *wlc, bool tx) { if (tx) { @@ -6530,12 +6554,10 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) d11txh_t *txh; struct scb *scb = NULL; bool free_pdu; - struct osl_info *osh; int tx_rts, tx_frame_count, tx_rts_count; uint totlen, supr_status; bool lastframe; - struct dot11_header *h; - u16 fc; + struct ieee80211_hdr *h; u16 mcl; struct ieee80211_tx_info *tx_info; struct ieee80211_tx_rate *txrate; @@ -6558,7 +6580,6 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) return false; } - osh = wlc->osh; queue = txs->frameid & TXFID_QUEUE_MASK; ASSERT(queue < NFIFO); if (queue >= NFIFO) { @@ -6570,37 +6591,36 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) if (WLC_WAR16165(wlc)) wlc_war16165(wlc, false); if (p == NULL) - p = wlc_15420war(wlc, queue); - ASSERT(p != NULL); - if (p == NULL) goto fatal; txh = (d11txh_t *) (p->data); - mcl = ltoh16(txh->MacTxControlLow); + mcl = le16_to_cpu(txh->MacTxControlLow); if (txs->phyerr) { - WL_ERROR("phyerr 0x%x, rate 0x%x\n", - txs->phyerr, txh->MainRates); - wlc_print_txdesc(txh); + if (WL_ERROR_ON()) { + WL_ERROR("phyerr 0x%x, rate 0x%x\n", + txs->phyerr, txh->MainRates); + wlc_print_txdesc(txh); + } wlc_print_txstatus(txs); } - ASSERT(txs->frameid == htol16(txh->TxFrameID)); - if (txs->frameid != htol16(txh->TxFrameID)) + ASSERT(txs->frameid == cpu_to_le16(txh->TxFrameID)); + if (txs->frameid != cpu_to_le16(txh->TxFrameID)) goto fatal; tx_info = IEEE80211_SKB_CB(p); - h = (struct dot11_header *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - fc = ltoh16(h->fc); + h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); - scb = (struct scb *)tx_info->control.sta->drv_priv; + if (tx_info->control.sta) + scb = (struct scb *)tx_info->control.sta->drv_priv; if (N_ENAB(wlc->pub)) { u8 *plcp = (u8 *) (txh + 1); if (PLCP3_ISSGI(plcp[3])) - WLCNTINCR(wlc->pub->_cnt->txmpdu_sgi); + wlc->pub->_cnt->txmpdu_sgi++; if (PLCP3_ISSTBC(plcp[3])) - WLCNTINCR(wlc->pub->_cnt->txmpdu_stbc); + wlc->pub->_cnt->txmpdu_stbc++; } if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { @@ -6614,13 +6634,13 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) WL_NONE("%s: Pkt tx suppressed, possibly channel %d\n", __func__, CHSPEC_CHANNEL(wlc->default_bss->chanspec)); - tx_rts = htol16(txh->MacTxControlLow) & TXC_SENDRTS; + tx_rts = cpu_to_le16(txh->MacTxControlLow) & TXC_SENDRTS; tx_frame_count = (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; tx_rts_count = (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT; - lastframe = (fc & FC_MOREFRAG) == 0; + lastframe = !ieee80211_has_morefrags(h->frame_control); if (!lastframe) { WL_ERROR("Not last frame!\n"); @@ -6659,7 +6679,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) tx_info->flags |= IEEE80211_TX_STAT_ACK; } - totlen = pkttotlen(osh, p); + totlen = pkttotlen(p); free_pdu = true; wlc_txfifo_complete(wlc, queue, 1); @@ -6672,7 +6692,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) skb_pull(p, D11_PHY_HDR_LEN); skb_pull(p, D11_TXH_LEN); ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); - WLCNTINCR(wlc->pub->_cnt->ieee_tx_status); + wlc->pub->_cnt->ieee_tx_status++; } else { WL_ERROR("%s: Not last frame => not calling tx_status\n", __func__); @@ -6683,7 +6703,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2) fatal: ASSERT(0); if (p) - pkt_buf_free_skb(osh, p, true); + pkt_buf_free_skb(p); return true; @@ -6818,21 +6838,25 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p, ratespec_t rspec; unsigned char *plcp; +#if 0 + /* Clearly, this is bogus -- reading the TSF now is wrong */ wlc_read_tsf(wlc, &tsf_l, &tsf_h); /* mactime */ rx_status->mactime = tsf_h; rx_status->mactime <<= 32; rx_status->mactime |= tsf_l; - rx_status->flag |= RX_FLAG_TSFT; + rx_status->flag |= RX_FLAG_MACTIME_MPDU; /* clearly wrong */ +#endif channel = WLC_CHAN_CHANNEL(rxh->RxChan); - /* XXX Channel/badn needs to be filtered against whether we are single/dual band card */ if (channel > 14) { rx_status->band = IEEE80211_BAND_5GHZ; - rx_status->freq = wf_channel2mhz(channel, WF_CHAN_FACTOR_5_G); + rx_status->freq = ieee80211_ofdm_chan_to_freq( + WF_CHAN_FACTOR_5_G/2, channel); + } else { rx_status->band = IEEE80211_BAND_2GHZ; - rx_status->freq = wf_channel2mhz(channel, WF_CHAN_FACTOR_2_4_G); + rx_status->freq = ieee80211_dsss_chan_to_freq(channel); } rx_status->signal = wlc_rxh->rssi; /* signal */ @@ -6918,8 +6942,7 @@ prep_mac80211_status(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p, } static void -wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh, - struct sk_buff *p) +wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p) { int len_mpdu; struct ieee80211_rx_status rx_status; @@ -6936,7 +6959,7 @@ wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh, prep_mac80211_status(wlc, rxh, p, &rx_status); /* mac header+body length, exclude CRC and plcp header */ - len_mpdu = p->len - D11_PHY_HDR_LEN - DOT11_FCS_LEN; + len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; skb_pull(p, D11_PHY_HDR_LEN); __skb_trim(p, len_mpdu); @@ -6948,15 +6971,13 @@ wlc_recvctl(struct wlc_info *wlc, struct osl_info *osh, d11rxhdr_t *rxh, memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); - WLCNTINCR(wlc->pub->_cnt->ieee_rx); - osh->pktalloced--; + wlc->pub->_cnt->ieee_rx++; return; } -void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list) +void wlc_bss_list_free(struct wlc_info *wlc, struct wlc_bss_list *bss_list) { uint index; - wlc_bss_info_t *bi; if (!bss_list) { WL_ERROR("%s: Attempting to free NULL list\n", __func__); @@ -6964,14 +6985,8 @@ void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list) } /* inspect all BSS descriptor */ for (index = 0; index < bss_list->count; index++) { - bi = bss_list->ptrs[index]; - if (bi) { - if (bi->bcn_prb) { - kfree(bi->bcn_prb); - } - kfree(bi); - bss_list->ptrs[index] = NULL; - } + kfree(bss_list->ptrs[index]); + bss_list->ptrs[index] = NULL; } bss_list->count = 0; } @@ -6985,16 +7000,12 @@ void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list) void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) { d11rxhdr_t *rxh; - struct dot11_header *h; - struct osl_info *osh; - u16 fc; + struct ieee80211_hdr *h; uint len; bool is_amsdu; WL_TRACE("wl%d: wlc_recv\n", wlc->pub->unit); - osh = wlc->osh; - /* frame starts with rxhdr */ rxh = (d11rxhdr_t *) (p->data); @@ -7002,12 +7013,22 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) skb_pull(p, wlc->hwrxoff); /* fixup rx header endianness */ - ltoh16_buf((void *)rxh, sizeof(d11rxhdr_t)); + rxh->RxFrameSize = le16_to_cpu(rxh->RxFrameSize); + rxh->PhyRxStatus_0 = le16_to_cpu(rxh->PhyRxStatus_0); + rxh->PhyRxStatus_1 = le16_to_cpu(rxh->PhyRxStatus_1); + rxh->PhyRxStatus_2 = le16_to_cpu(rxh->PhyRxStatus_2); + rxh->PhyRxStatus_3 = le16_to_cpu(rxh->PhyRxStatus_3); + rxh->PhyRxStatus_4 = le16_to_cpu(rxh->PhyRxStatus_4); + rxh->PhyRxStatus_5 = le16_to_cpu(rxh->PhyRxStatus_5); + rxh->RxStatus1 = le16_to_cpu(rxh->RxStatus1); + rxh->RxStatus2 = le16_to_cpu(rxh->RxStatus2); + rxh->RxTSFTime = le16_to_cpu(rxh->RxTSFTime); + rxh->RxChan = le16_to_cpu(rxh->RxChan); /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ if (rxh->RxStatus1 & RXS_PBPRES) { if (p->len < 2) { - WLCNTINCR(wlc->pub->_cnt->rxrunt); + wlc->pub->_cnt->rxrunt++; WL_ERROR("wl%d: wlc_recv: rcvd runt of len %d\n", wlc->pub->unit, p->len); goto toss; @@ -7015,7 +7036,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) skb_pull(p, 2); } - h = (struct dot11_header *)(p->data + D11_PHY_HDR_LEN); + h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); len = p->len; if (rxh->RxStatus1 & RXS_FCSERR) { @@ -7029,10 +7050,8 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) } /* check received pkt has at least frame control field */ - if (len >= D11_PHY_HDR_LEN + sizeof(h->fc)) { - fc = ltoh16(h->fc); - } else { - WLCNTINCR(wlc->pub->_cnt->rxrunt); + if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) { + wlc->pub->_cnt->rxrunt++; goto toss; } @@ -7041,34 +7060,35 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p) /* explicitly test bad src address to avoid sending bad deauth */ if (!is_amsdu) { /* CTS and ACK CTL frames are w/o a2 */ - if (FC_TYPE(fc) == FC_TYPE_DATA || FC_TYPE(fc) == FC_TYPE_MNG) { - if ((is_zero_ether_addr(h->a2.octet) || - is_multicast_ether_addr(h->a2.octet))) { - WL_ERROR("wl%d: %s: dropping a frame with invalid src mac address, a2: %pM\n", - wlc->pub->unit, __func__, &h->a2); - WLCNTINCR(wlc->pub->_cnt->rxbadsrcmac); + + if (ieee80211_is_data(h->frame_control) || + ieee80211_is_mgmt(h->frame_control)) { + if ((is_zero_ether_addr(h->addr2) || + is_multicast_ether_addr(h->addr2))) { + WL_ERROR("wl%d: %s: dropping a frame with " + "invalid src mac address, a2: %pM\n", + wlc->pub->unit, __func__, h->addr2); + wlc->pub->_cnt->rxbadsrcmac++; goto toss; } - WLCNTINCR(wlc->pub->_cnt->rxfrag); + wlc->pub->_cnt->rxfrag++; } } /* due to sheer numbers, toss out probe reqs for now */ - if (FC_TYPE(fc) == FC_TYPE_MNG) { - if ((fc & FC_KIND_MASK) == FC_PROBE_REQ) - goto toss; - } + if (ieee80211_is_probe_req(h->frame_control)) + goto toss; if (is_amsdu) { WL_ERROR("%s: is_amsdu causing toss\n", __func__); goto toss; } - wlc_recvctl(wlc, osh, rxh, p); + wlc_recvctl(wlc, rxh, p); return; toss: - pkt_buf_free_skb(osh, p, false); + pkt_buf_free_skb(p); } /* calculate frame duration for Mixed-mode L-SIG spoofing, return @@ -7250,7 +7270,7 @@ wlc_calc_ba_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type) /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ return wlc_calc_frame_time(wlc, rspec, preamble_type, (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + - DOT11_FCS_LEN)); + FCS_LEN)); } static uint BCMFASTPATH @@ -7269,7 +7289,7 @@ wlc_calc_ack_time(struct wlc_info *wlc, ratespec_t rspec, u8 preamble_type) /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ dur = wlc_calc_frame_time(wlc, rspec, preamble_type, - (DOT11_ACK_LEN + DOT11_FCS_LEN)); + (DOT11_ACK_LEN + FCS_LEN)); return dur; } @@ -7610,17 +7630,19 @@ wlc_compute_bcntsfoff(struct wlc_info *wlc, ratespec_t rspec, * and included up to, but not including, the 4 byte FCS. */ static void -wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec, - wlc_bsscfg_t *cfg, u16 *buf, int *len) +wlc_bcn_prb_template(struct wlc_info *wlc, u16 type, ratespec_t bcn_rspec, + struct wlc_bsscfg *cfg, u16 *buf, int *len) { + static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255}; cck_phy_hdr_t *plcp; - struct dot11_management_header *h; + struct ieee80211_mgmt *h; int hdr_len, body_len; ASSERT(*len >= 142); - ASSERT(type == FC_BEACON || type == FC_PROBE_RESP); + ASSERT(type == IEEE80211_STYPE_BEACON || + type == IEEE80211_STYPE_PROBE_RESP); - if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON) + if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON) hdr_len = DOT11_MAC_HDR_LEN; else hdr_len = D11_PHY_HDR_LEN + DOT11_MAC_HDR_LEN; @@ -7634,10 +7656,10 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec, plcp = (cck_phy_hdr_t *) buf; /* PLCP for Probe Response frames are filled in from core's rate table */ - if (type == FC_BEACON && !MBSS_BCN_ENAB(cfg)) { + if (type == IEEE80211_STYPE_BEACON && !MBSS_BCN_ENAB(cfg)) { /* fill in PLCP */ wlc_compute_plcp(wlc, bcn_rspec, - (DOT11_MAC_HDR_LEN + body_len + DOT11_FCS_LEN), + (DOT11_MAC_HDR_LEN + body_len + FCS_LEN), (u8 *) plcp); } @@ -7646,21 +7668,20 @@ wlc_bcn_prb_template(struct wlc_info *wlc, uint type, ratespec_t bcn_rspec, if (!SOFTBCN_ENAB(cfg)) wlc_beacon_phytxctl_txant_upd(wlc, bcn_rspec); - if (MBSS_BCN_ENAB(cfg) && type == FC_BEACON) - h = (struct dot11_management_header *)&plcp[0]; + if (MBSS_BCN_ENAB(cfg) && type == IEEE80211_STYPE_BEACON) + h = (struct ieee80211_mgmt *)&plcp[0]; else - h = (struct dot11_management_header *)&plcp[1]; + h = (struct ieee80211_mgmt *)&plcp[1]; /* fill in 802.11 header */ - h->fc = htol16((u16) type); + h->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | type); /* DUR is 0 for multicast bcn, or filled in by MAC for prb resp */ /* A1 filled in by MAC for prb resp, broadcast for bcn */ - if (type == FC_BEACON) - bcopy((const char *)ðer_bcast, (char *)&h->da, - ETH_ALEN); - bcopy((char *)&cfg->cur_etheraddr, (char *)&h->sa, ETH_ALEN); - bcopy((char *)&cfg->BSSID, (char *)&h->bssid, ETH_ALEN); + if (type == IEEE80211_STYPE_BEACON) + memcpy(&h->da, ðer_bcast, ETH_ALEN); + memcpy(&h->sa, &cfg->cur_etheraddr, ETH_ALEN); + memcpy(&h->bssid, &cfg->BSSID, ETH_ALEN); /* SEQ filled in by MAC */ @@ -7677,7 +7698,7 @@ int wlc_get_header_len() * template updated. * Otherwise, it updates the hardware template. */ -void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg) +void wlc_bss_update_beacon(struct wlc_info *wlc, struct wlc_bsscfg *cfg) { int len = BCN_TMPL_LEN; @@ -7688,26 +7709,24 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg) return; } - if (MBSS_BCN_ENAB(cfg)) { /* Optimize: Some of if/else could be combined */ - } else if (HWBCN_ENAB(cfg)) { /* Hardware beaconing for this config */ + /* Optimize: Some of if/else could be combined */ + if (!MBSS_BCN_ENAB(cfg) && HWBCN_ENAB(cfg)) { + /* Hardware beaconing for this config */ u16 bcn[BCN_TMPL_LEN / 2]; u32 both_valid = MCMD_BCN0VLD | MCMD_BCN1VLD; d11regs_t *regs = wlc->regs; - struct osl_info *osh = NULL; - - osh = wlc->osh; /* Check if both templates are in use, if so sched. an interrupt * that will call back into this routine */ - if ((R_REG(osh, ®s->maccommand) & both_valid) == both_valid) { + if ((R_REG(®s->maccommand) & both_valid) == both_valid) { /* clear any previous status */ - W_REG(osh, ®s->macintstatus, MI_BCNTPL); + W_REG(®s->macintstatus, MI_BCNTPL); } /* Check that after scheduling the interrupt both of the * templates are still busy. if not clear the int. & remask */ - if ((R_REG(osh, ®s->maccommand) & both_valid) == both_valid) { + if ((R_REG(®s->maccommand) & both_valid) == both_valid) { wlc->defmacintmask |= MI_BCNTPL; return; } @@ -7721,8 +7740,8 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg) true)); /* update the template and ucode shm */ - wlc_bcn_prb_template(wlc, FC_BEACON, wlc->bcn_rspec, cfg, bcn, - &len); + wlc_bcn_prb_template(wlc, IEEE80211_STYPE_BEACON, + wlc->bcn_rspec, cfg, bcn, &len); wlc_write_hw_bcntemplates(wlc, bcn, len, false); } } @@ -7733,7 +7752,7 @@ void wlc_bss_update_beacon(struct wlc_info *wlc, wlc_bsscfg_t *cfg) void wlc_update_beacon(struct wlc_info *wlc) { int idx; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; /* update AP or IBSS beacons */ FOREACH_BSS(wlc, idx, bsscfg) { @@ -7743,17 +7762,17 @@ void wlc_update_beacon(struct wlc_info *wlc) } /* Write ssid into shared memory */ -void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg) +void wlc_shm_ssid_upd(struct wlc_info *wlc, struct wlc_bsscfg *cfg) { u8 *ssidptr = cfg->SSID; u16 base = M_SSID; - u8 ssidbuf[DOT11_MAX_SSID_LEN]; + u8 ssidbuf[IEEE80211_MAX_SSID_LEN]; /* padding the ssid with zero and copy it into shm */ - memset(ssidbuf, 0, DOT11_MAX_SSID_LEN); - bcopy(ssidptr, ssidbuf, cfg->SSID_len); + memset(ssidbuf, 0, IEEE80211_MAX_SSID_LEN); + memcpy(ssidbuf, ssidptr, cfg->SSID_len); - wlc_copyto_shm(wlc, base, ssidbuf, DOT11_MAX_SSID_LEN); + wlc_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); if (!MBSS_BCN_ENAB(cfg)) wlc_write_shm(wlc, M_SSIDLEN, (u16) cfg->SSID_len); @@ -7762,7 +7781,7 @@ void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg) void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend) { int idx; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; /* update AP or IBSS probe responses */ FOREACH_BSS(wlc, idx, bsscfg) { @@ -7772,7 +7791,8 @@ void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend) } void -wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend) +wlc_bss_update_probe_resp(struct wlc_info *wlc, struct wlc_bsscfg *cfg, + bool suspend) { u16 prb_resp[BCN_TMPL_LEN / 2]; int len = BCN_TMPL_LEN; @@ -7781,8 +7801,8 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend) if (!MBSS_PRB_ENAB(cfg)) { /* create the probe response template */ - wlc_bcn_prb_template(wlc, FC_PROBE_RESP, 0, cfg, prb_resp, - &len); + wlc_bcn_prb_template(wlc, IEEE80211_STYPE_PROBE_RESP, 0, cfg, + prb_resp, &len); if (suspend) wlc_suspend_mac_and_wait(wlc); @@ -7802,7 +7822,7 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend) * Use the actual frame length covered by the PLCP header for the call to * wlc_mod_prb_rsp_rate_table() by subtracting the PLCP len and adding the FCS. */ - len += (-D11_PHY_HDR_LEN + DOT11_FCS_LEN); + len += (-D11_PHY_HDR_LEN + FCS_LEN); wlc_mod_prb_rsp_rate_table(wlc, (u16) len); if (suspend) @@ -7815,24 +7835,19 @@ wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, bool suspend) /* prepares pdu for transmission. returns BCM error codes */ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop) { - struct osl_info *osh; uint fifo; d11txh_t *txh; - struct dot11_header *h; + struct ieee80211_hdr *h; struct scb *scb; - u16 fc; - - osh = wlc->osh; ASSERT(pdu); txh = (d11txh_t *) (pdu->data); ASSERT(txh); - h = (struct dot11_header *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); + h = (struct ieee80211_hdr *)((u8 *) (txh + 1) + D11_PHY_HDR_LEN); ASSERT(h); - fc = ltoh16(h->fc); /* get the pkt queue info. This was put at wlc_sendctl or wlc_send for PDU */ - fifo = ltoh16(txh->TxFrameID) & TXFID_QUEUE_MASK; + fifo = le16_to_cpu(txh->TxFrameID) & TXFID_QUEUE_MASK; scb = NULL; @@ -7845,8 +7860,8 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop) return BCME_BUSY; } - if (FC_TYPE(ltoh16(txh->MacFrameControl)) != FC_TYPE_DATA) - WLCNTINCR(wlc->pub->_cnt->txctl); + if (!ieee80211_is_data(txh->MacFrameControl)) + wlc->pub->_cnt->txctl++; return 0; } @@ -7855,7 +7870,7 @@ int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifop) void wlc_reprate_init(struct wlc_info *wlc) { int i; - wlc_bsscfg_t *bsscfg; + struct wlc_bsscfg *bsscfg; FOREACH_BSS(wlc, i, bsscfg) { wlc_bsscfg_reprate_init(bsscfg); @@ -7863,7 +7878,7 @@ void wlc_reprate_init(struct wlc_info *wlc) } /* per bsscfg init tx reported rate mechanism */ -void wlc_bsscfg_reprate_init(wlc_bsscfg_t *bsscfg) +void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg) { bsscfg->txrspecidx = 0; memset((char *)bsscfg->txrspec, 0, sizeof(bsscfg->txrspec)); @@ -7949,23 +7964,6 @@ static void wlc_bss_default_init(struct wlc_info *wlc) bi->flags |= WLC_BSS_HT; } -/* Deferred event processing */ -static void wlc_process_eventq(void *arg) -{ - struct wlc_info *wlc = (struct wlc_info *) arg; - wlc_event_t *etmp; - - while ((etmp = wlc_eventq_deq(wlc->eventq))) { - /* Perform OS specific event processing */ - wl_event(wlc->wl, etmp->event.ifname, etmp); - if (etmp->data) { - kfree(etmp->data); - etmp->data = NULL; - } - wlc_event_free(wlc->eventq, etmp); - } -} - void wlc_uint64_sub(u32 *a_high, u32 *a_low, u32 b_high, u32 b_low) { @@ -8223,12 +8221,14 @@ void wlc_write_hw_bcntemplates(struct wlc_info *wlc, void *bcn, int len, void wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset, - const struct ether_addr *addr) + const u8 *addr) { wlc_bmac_set_addrmatch(wlc->hw, match_reg_offset, addr); + if (match_reg_offset == RCM_BSSID_OFFSET) + memcpy(wlc->cfg->BSSID, addr, ETH_ALEN); } -void wlc_set_rcmta(struct wlc_info *wlc, int idx, const struct ether_addr *addr) +void wlc_set_rcmta(struct wlc_info *wlc, int idx, const u8 *addr) { wlc_bmac_set_rcmta(wlc->hw, idx, addr); } @@ -8269,8 +8269,8 @@ void wlc_reset_bmac_done(struct wlc_info *wlc) void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode) { - wlc->ht_cap.cap &= ~HT_CAP_MIMO_PS_MASK; - wlc->ht_cap.cap |= (mimops_mode << HT_CAP_MIMO_PS_SHIFT); + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_SM_PS; + wlc->ht_cap.cap_info |= (mimops_mode << IEEE80211_HT_CAP_SM_PS_SHIFT); if (AP_ENAB(wlc->pub) && wlc->clk) { wlc_update_beacon(wlc); @@ -8280,7 +8280,8 @@ void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode) /* check for the particular priority flow control bit being set */ bool -wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, wlc_txq_info_t *q, int prio) +wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, struct wlc_txq_info *q, + int prio) { uint prio_mask; @@ -8295,13 +8296,13 @@ wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, wlc_txq_info_t *q, int prio) } /* propogate the flow control to all interfaces using the given tx queue */ -void wlc_txflowcontrol(struct wlc_info *wlc, wlc_txq_info_t *qi, +void wlc_txflowcontrol(struct wlc_info *wlc, struct wlc_txq_info *qi, bool on, int prio) { uint prio_bits; uint cur_bits; - WL_ERROR("%s: flow control kicks in\n", __func__); + WL_TRACE("%s: flow control kicks in\n", __func__); if (prio == ALLPRIO) { prio_bits = TXQ_STOP_FOR_PRIOFC_MASK; @@ -8338,8 +8339,8 @@ void wlc_txflowcontrol(struct wlc_info *wlc, wlc_txq_info_t *qi, } void -wlc_txflowcontrol_override(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on, - uint override) +wlc_txflowcontrol_override(struct wlc_info *wlc, struct wlc_txq_info *qi, + bool on, uint override) { uint prev_override; @@ -8387,7 +8388,7 @@ wlc_txflowcontrol_override(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on, static void wlc_txflowcontrol_reset(struct wlc_info *wlc) { - wlc_txq_info_t *qi; + struct wlc_txq_info *qi; for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) { if (qi->stopped) { @@ -8398,7 +8399,7 @@ static void wlc_txflowcontrol_reset(struct wlc_info *wlc) } static void -wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on, +wlc_txflowcontrol_signal(struct wlc_info *wlc, struct wlc_txq_info *qi, bool on, int prio) { struct wlc_if *wlcif; @@ -8409,40 +8410,38 @@ wlc_txflowcontrol_signal(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on, } } -static wlc_txq_info_t *wlc_txq_alloc(struct wlc_info *wlc, struct osl_info *osh) +static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc) { - wlc_txq_info_t *qi, *p; + struct wlc_txq_info *qi, *p; - qi = (wlc_txq_info_t *) wlc_calloc(osh, wlc->pub->unit, - sizeof(wlc_txq_info_t)); - if (qi == NULL) { - return NULL; - } - - /* Have enough room for control packets along with HI watermark */ - /* Also, add room to txq for total psq packets if all the SCBs leave PS mode */ - /* The watermark for flowcontrol to OS packets will remain the same */ - pktq_init(&qi->q, WLC_PREC_COUNT, - (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT + - wlc->pub->psq_pkts_total); - - /* add this queue to the the global list */ - p = wlc->tx_queues; - if (p == NULL) { - wlc->tx_queues = qi; - } else { - while (p->next != NULL) - p = p->next; - p->next = qi; + qi = wlc_calloc(wlc->pub->unit, sizeof(struct wlc_txq_info)); + if (qi != NULL) { + /* + * Have enough room for control packets along with HI watermark + * Also, add room to txq for total psq packets if all the SCBs + * leave PS mode. The watermark for flowcontrol to OS packets + * will remain the same + */ + pktq_init(&qi->q, WLC_PREC_COUNT, + (2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT + + wlc->pub->psq_pkts_total); + + /* add this queue to the the global list */ + p = wlc->tx_queues; + if (p == NULL) { + wlc->tx_queues = qi; + } else { + while (p->next != NULL) + p = p->next; + p->next = qi; + } } - return qi; } -static void wlc_txq_free(struct wlc_info *wlc, struct osl_info *osh, - wlc_txq_info_t *qi) +static void wlc_txq_free(struct wlc_info *wlc, struct wlc_txq_info *qi) { - wlc_txq_info_t *p; + struct wlc_txq_info *p; if (qi == NULL) return; @@ -8474,3 +8473,27 @@ void wlc_scan_stop(struct wlc_info *wlc) { wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); } + +void wlc_associate_upd(struct wlc_info *wlc, bool state) +{ + wlc->pub->associated = state; + wlc->cfg->associated = state; +} + +/* + * When a remote STA/AP is removed by Mac80211, or when it can no longer accept + * AMPDU traffic, packets pending in hardware have to be invalidated so that + * when later on hardware releases them, they can be handled appropriately. + */ +void wlc_inval_dma_pkts(struct wlc_hw_info *hw, + struct ieee80211_sta *sta, + void (*dma_callback_fn)) +{ + struct hnddma_pub *dmah; + int i; + for (i = 0; i < NFIFO; i++) { + dmah = hw->di[i]; + if (dmah != NULL) + dma_walk_packets(dmah, dma_callback_fn, sta); + } +} diff --git a/drivers/staging/brcm80211/sys/wlc_mac80211.h b/drivers/staging/brcm80211/brcmsmac/wlc_main.h index 5df996b78911..960f82cbfbc9 100644 --- a/drivers/staging/brcm80211/sys/wlc_mac80211.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_main.h @@ -17,31 +17,12 @@ #ifndef _wlc_h_ #define _wlc_h_ -#include <wlioctl.h> -#include <wlc_phy_hal.h> -#include <wlc_channel.h> -#include <wlc_bsscfg.h> -#include <wlc_scb.h> - #define MA_WINDOW_SZ 8 /* moving average window size */ #define WL_HWRXOFF 38 /* chip rx buffer offset */ #define INVCHANNEL 255 /* invalid channel */ #define MAXCOREREV 28 /* max # supported core revisions (0 .. MAXCOREREV - 1) */ #define WLC_MAXMODULES 22 /* max # wlc_module_register() calls */ -/* network protection config */ -#define WLC_PROT_G_SPEC 1 /* SPEC g protection */ -#define WLC_PROT_G_OVR 2 /* SPEC g prot override */ -#define WLC_PROT_G_USER 3 /* gmode specified by user */ -#define WLC_PROT_OVERLAP 4 /* overlap */ -#define WLC_PROT_N_USER 10 /* nmode specified by user */ -#define WLC_PROT_N_CFG 11 /* n protection */ -#define WLC_PROT_N_CFG_OVR 12 /* n protection override */ -#define WLC_PROT_N_NONGF 13 /* non-GF protection */ -#define WLC_PROT_N_NONGF_OVR 14 /* non-GF protection override */ -#define WLC_PROT_N_PAM_OVR 15 /* n preamble override */ -#define WLC_PROT_N_OBSS 16 /* non-HT OBSS present */ - #define WLC_BITSCNT(x) bcm_bitcount((u8 *)&(x), sizeof(u8)) /* Maximum wait time for a MAC suspend */ @@ -55,11 +36,11 @@ #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) /* For managing scan result lists */ -typedef struct wlc_bss_list { +struct wlc_bss_list { uint count; bool beacon; /* set for beacon, cleared for probe response */ wlc_bss_info_t *ptrs[MAXBSS]; -} wlc_bss_list_t; +}; #define SW_TIMER_MAC_STAT_UPD 30 /* periodic MAC stats update */ @@ -213,13 +194,13 @@ extern const u8 prio2fifo[]; */ #define DEVICEREMOVED(wlc) \ ((wlc->hw->clk) ? \ - ((R_REG(wlc->hw->osh, &wlc->hw->regs->maccontrol) & \ + ((R_REG(&wlc->hw->regs->maccontrol) & \ (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \ (si_deviceremoved(wlc->hw->sih))) #define WLCWLUNIT(wlc) ((wlc)->pub->unit) -typedef struct wlc_protection { +struct wlc_protection { bool _g; /* use g spec protection, driver internal */ s8 g_override; /* override for use of g spec protection */ u8 gmode_user; /* user config gmode, operating band->gmode is different */ @@ -244,10 +225,10 @@ typedef struct wlc_protection { uint ht20in40_ovlp_timeout; /* #sec until 20MHz overlapping OPMODE gone */ uint ht20in40_ibss_timeout; /* #sec until 20MHz-only HT station bcns gone */ uint non_gf_ibss_timeout; /* #sec until non-GF bcns gone */ -} wlc_protection_t; +}; /* anything affects the single/dual streams/antenna operation */ -typedef struct wlc_stf { +struct wlc_stf { u8 hw_txchain; /* HW txchain bitmap cfg */ u8 txchain; /* txchain bitmap being used */ u8 txstreams; /* number of txchains being used */ @@ -271,7 +252,7 @@ typedef struct wlc_stf { s8 ldpc; /* AUTO/ON/OFF ldpc cap supported */ u8 txcore[MAX_STREAMS_SUPPORTED + 1]; /* bitmap of selected core for each Nsts */ s8 spatial_policy; -} wlc_stf_t; +}; #define WLC_STF_SS_STBC_TX(wlc, scb) \ (((wlc)->stf->txstreams > 1) && (((wlc)->band->band_stf_stbc_tx == ON) || \ @@ -346,21 +327,18 @@ struct wlcband { u16 bcntsfoff; /* beacon tsf offset */ }; -/* generic function callback takes just one arg */ -typedef void (*cb_fn_t) (void *); - /* tx completion callback takes 3 args */ typedef void (*pkcb_fn_t) (struct wlc_info *wlc, uint txstatus, void *arg); -typedef struct pkt_cb { +struct pkt_cb { pkcb_fn_t fn; /* function to call when tx frame completes */ void *arg; /* void arg for fn */ u8 nextidx; /* index of next call back if threading */ bool entered; /* recursion check */ -} pkt_cb_t; +}; - /* module control blocks */ -typedef struct modulecb { +/* module control blocks */ +struct modulecb { char name[32]; /* module name : NULL indicates empty array member */ const bcm_iovar_t *iovars; /* iovar table */ void *hdl; /* handle passed when handler 'doiovar' is called */ @@ -371,15 +349,15 @@ typedef struct modulecb { * number of timers that could not be * freed. */ -} modulecb_t; +}; - /* dump control blocks */ -typedef struct dumpcb_s { +/* dump control blocks */ +struct dumpcb_s { const char *name; /* dump name */ dump_fn_t dump_fn; /* 'wl dump' handler */ void *dump_fn_arg; struct dumpcb_s *next; -} dumpcb_t; +}; /* virtual interface */ struct wlc_if { @@ -401,7 +379,7 @@ struct wlc_if { /* flags for the interface */ #define WLC_IF_LINKED 0x02 /* this interface is linked to a wl_if */ -typedef struct wlc_hwband { +struct wlc_hwband { int bandtype; /* WLC_BAND_2G, WLC_BAND_5G */ uint bandunit; /* bandstate[] index */ u16 mhfs[MHFMAX]; /* MHF array shadow */ @@ -416,10 +394,9 @@ typedef struct wlc_hwband { u16 radiorev; wlc_phy_t *pi; /* pointer to phy specific information */ bool abgphy_encore; -} wlc_hwband_t; +}; struct wlc_hw_info { - struct osl_info *osh; /* pointer to os handle */ bool _piomode; /* true if pio mode */ struct wlc_info *wlc; @@ -436,8 +413,8 @@ struct wlc_hw_info { u16 boardrev; /* version # of particular board */ u32 boardflags; /* Board specific flags from srom */ u32 boardflags2; /* More board flags if sromrev >= 4 */ - u32 machwcap; /* MAC capabilities (corerev >= 13) */ - u32 machwcap_backup; /* backup of machwcap (corerev >= 13) */ + u32 machwcap; /* MAC capabilities */ + u32 machwcap_backup; /* backup of machwcap */ u16 ucode_dbgsel; /* dbgsel for ucode debug(config gpio) */ si_t *sih; /* SB handle (cookie for siutils calls) */ @@ -446,8 +423,8 @@ struct wlc_hw_info { d11regs_t *regs; /* pointer to device registers */ void *physhim; /* phy shim layer handler */ void *phy_sh; /* pointer to shared phy state */ - wlc_hwband_t *band; /* pointer to active per-band state */ - wlc_hwband_t *bandstate[MAXBANDS]; /* per-band state (one per phy/radio) */ + struct wlc_hwband *band;/* pointer to active per-band state */ + struct wlc_hwband *bandstate[MAXBANDS];/* band state per phy/radio */ u16 bmac_phytxant; /* cache of high phytxant state */ bool shortslot; /* currently using 11g ShortSlot timing */ u16 SRL; /* 802.11 dot11ShortRetryLimit */ @@ -470,7 +447,7 @@ struct wlc_hw_info { uint mac_suspend_depth; /* current depth of mac_suspend levels */ u32 wake_override; /* Various conditions to force MAC to WAKE mode */ u32 mute_override; /* Prevent ucode from sending beacons */ - struct ether_addr etheraddr; /* currently configured ethernet address */ + u8 etheraddr[ETH_ALEN]; /* currently configured ethernet address */ u32 led_gpio_mask; /* LED GPIO Mask */ bool noreset; /* true= do not reset hw, used by WLC_OUT */ bool forcefastclk; /* true if the h/w is forcing the use of fast clk */ @@ -500,18 +477,17 @@ struct wlc_hw_info { * if they belong to the same flow of traffic from the device. For multi-channel * operation there are independent TX Queues for each channel. */ -typedef struct wlc_txq_info { +struct wlc_txq_info { struct wlc_txq_info *next; struct pktq q; uint stopped; /* tx flow control bits */ -} wlc_txq_info_t; +}; /* * Principal common (os-independent) software data structure. */ struct wlc_info { struct wlc_pub *pub; /* pointer to wlc public state */ - struct osl_info *osh; /* pointer to os handle */ struct wl_info *wl; /* pointer to os-specific private state */ d11regs_t *regs; /* pointer to device registers */ @@ -566,7 +542,7 @@ struct wlc_info { u32 machwcap; /* MAC capabilities, BMAC shadow */ - struct ether_addr perm_etheraddr; /* original sprom local ethernet address */ + u8 perm_etheraddr[ETH_ALEN]; /* original sprom local ethernet address */ bool bandlocked; /* disable auto multi-band switching */ bool bandinit_pending; /* track band init in auto band */ @@ -645,21 +621,19 @@ struct wlc_info { u16 tx_prec_map; /* Precedence map based on HW FIFO space */ u16 fifo2prec_map[NFIFO]; /* pointer to fifo2_prec map based on WME */ - /* BSS Configurations */ - wlc_bsscfg_t *bsscfg[WLC_MAXBSSCFG]; /* set of BSS configurations, idx 0 is default and - * always valid - */ - wlc_bsscfg_t *cfg; /* the primary bsscfg (can be AP or STA) */ + /* + * BSS Configurations set of BSS configurations, idx 0 is default and + * always valid + */ + struct wlc_bsscfg *bsscfg[WLC_MAXBSSCFG]; + struct wlc_bsscfg *cfg; /* the primary bsscfg (can be AP or STA) */ u8 stas_associated; /* count of ASSOCIATED STA bsscfgs */ u8 aps_associated; /* count of UP AP bsscfgs */ u8 block_datafifo; /* prohibit posting frames to data fifos */ bool bcmcfifo_drain; /* TX_BCMC_FIFO is set to drain */ /* tx queue */ - wlc_txq_info_t *tx_queues; /* common TX Queue list */ - - /* event */ - wlc_eventq_t *eventq; /* event queue for deferred processing */ + struct wlc_txq_info *tx_queues; /* common TX Queue list */ /* security */ wsec_key_t *wsec_keys[WSEC_MAX_KEYS]; /* dynamic key storage */ @@ -667,8 +641,8 @@ struct wlc_info { bool wsec_swkeys; /* indicates that all keys should be * treated as sw keys (used for debugging) */ - modulecb_t *modulecb; - dumpcb_t *dumpcb_head; + struct modulecb *modulecb; + struct dumpcb_s *dumpcb_head; u8 mimoft; /* SIGN or 11N */ u8 mimo_band_bwcap; /* bw cap per band type */ @@ -677,7 +651,8 @@ struct wlc_info { s8 cck_40txbw; /* 11N, cck tx b/w override when in 40MHZ mode */ s8 ofdm_40txbw; /* 11N, ofdm tx b/w override when in 40MHZ mode */ s8 mimo_40txbw; /* 11N, mimo tx b/w override when in 40MHZ mode */ - ht_cap_ie_t ht_cap; /* HT CAP IE being advertised by this node */ + /* HT CAP IE being advertised by this node: */ + struct ieee80211_ht_cap ht_cap; uint seckeys; /* 54 key table shm address */ uint tkmickeys; /* 12 TKIP MIC key table shm address */ @@ -734,12 +709,12 @@ struct wlc_info { bool ignore_bcns; /* override: ignore non shortslot bcns in a 11g network */ bool legacy_probe; /* restricts probe requests to CCK rates */ - wlc_protection_t *protection; + struct wlc_protection *protection; s8 PLCPHdr_override; /* 802.11b Preamble Type override */ - wlc_stf_t *stf; + struct wlc_stf *stf; - pkt_cb_t *pkt_callback; /* tx completion callback handlers */ + struct pkt_cb *pkt_callback; /* tx completion callback handlers */ u32 txretried; /* tx retried number in one msdu */ @@ -750,7 +725,7 @@ struct wlc_info { u32 apsd_trigger_timeout; /* timeout value for apsd_trigger_timer (in ms) * 0 == disable */ - ac_bitmap_t apsd_trigger_ac; /* Permissible Acess Category in which APSD Null + ac_bitmap_t apsd_trigger_ac; /* Permissible Access Category in which APSD Null * Trigger frames can be send */ u8 htphy_membership; /* HT PHY membership */ @@ -771,7 +746,9 @@ struct wlc_info { u16 next_bsscfg_ID; struct wlc_if *wlcif_list; /* linked list of wlc_if structs */ - wlc_txq_info_t *active_queue; /* txq for the currently active transmit context */ + struct wlc_txq_info *active_queue; /* txq for the currently active + * transmit context + */ u32 mpc_dur; /* total time (ms) in mpc mode except for the * portion since radio is turned off last time */ @@ -836,12 +813,10 @@ extern void wlc_write_hw_bcntemplates(struct wlc_info *wlc, void *bcn, int len, bool both); #if defined(BCMDBG) extern void wlc_get_rcmta(struct wlc_info *wlc, int idx, - struct ether_addr *addr); + u8 *addr); #endif extern void wlc_set_rcmta(struct wlc_info *wlc, int idx, - const struct ether_addr *addr); -extern void wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset, - const struct ether_addr *addr); + const u8 *addr); extern void wlc_read_tsf(struct wlc_info *wlc, u32 *tsf_l_ptr, u32 *tsf_h_ptr); extern void wlc_set_cwmin(struct wlc_info *wlc, u16 newmin); @@ -849,7 +824,6 @@ extern void wlc_set_cwmax(struct wlc_info *wlc, u16 newmax); extern void wlc_fifoerrors(struct wlc_info *wlc); extern void wlc_pllreq(struct wlc_info *wlc, bool set, mbool req_bit); extern void wlc_reset_bmac_done(struct wlc_info *wlc); -extern void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val); extern void wlc_hwtimer_gptimer_set(struct wlc_info *wlc, uint us); extern void wlc_hwtimer_gptimer_abort(struct wlc_info *wlc); @@ -858,6 +832,8 @@ extern void wlc_print_rxh(d11rxhdr_t *rxh); extern void wlc_print_hdrs(struct wlc_info *wlc, const char *prefix, u8 *frame, d11txh_t *txh, d11rxhdr_t *rxh, uint len); extern void wlc_print_txdesc(d11txh_t *txh); +#else +#define wlc_print_txdesc(a) #endif #if defined(BCMDBG) extern void wlc_print_dot11_mac_hdr(u8 *buf, int len); @@ -871,19 +847,20 @@ extern bool wlc_valid_rate(struct wlc_info *wlc, ratespec_t rate, int band, extern void wlc_ap_upd(struct wlc_info *wlc); /* helper functions */ -extern void wlc_shm_ssid_upd(struct wlc_info *wlc, wlc_bsscfg_t *cfg); +extern void wlc_shm_ssid_upd(struct wlc_info *wlc, struct wlc_bsscfg *cfg); extern int wlc_set_gmode(struct wlc_info *wlc, u8 gmode, bool config); extern void wlc_mac_bcn_promisc_change(struct wlc_info *wlc, bool promisc); extern void wlc_mac_bcn_promisc(struct wlc_info *wlc); extern void wlc_mac_promisc(struct wlc_info *wlc); -extern void wlc_txflowcontrol(struct wlc_info *wlc, wlc_txq_info_t *qi, bool on, - int prio); -extern void wlc_txflowcontrol_override(struct wlc_info *wlc, wlc_txq_info_t *qi, +extern void wlc_txflowcontrol(struct wlc_info *wlc, struct wlc_txq_info *qi, + bool on, int prio); +extern void wlc_txflowcontrol_override(struct wlc_info *wlc, + struct wlc_txq_info *qi, bool on, uint override); extern bool wlc_txflowcontrol_prio_isset(struct wlc_info *wlc, - wlc_txq_info_t *qi, int prio); -extern void wlc_send_q(struct wlc_info *wlc, wlc_txq_info_t *qi); + struct wlc_txq_info *qi, int prio); +extern void wlc_send_q(struct wlc_info *wlc, struct wlc_txq_info *qi); extern int wlc_prep_pdu(struct wlc_info *wlc, struct sk_buff *pdu, uint *fifo); extern u16 wlc_calc_lsig_len(struct wlc_info *wlc, ratespec_t ratespec, @@ -897,6 +874,9 @@ extern u16 wlc_compute_rtscts_dur(struct wlc_info *wlc, bool cts_only, bool ba); extern void wlc_tbtt(struct wlc_info *wlc, d11regs_t *regs); +extern void wlc_inval_dma_pkts(struct wlc_hw_info *hw, + struct ieee80211_sta *sta, + void (*dma_callback_fn)); #if defined(BCMDBG) extern void wlc_dump_ie(struct wlc_info *wlc, bcm_tlv_t *ie, @@ -905,7 +885,7 @@ extern void wlc_dump_ie(struct wlc_info *wlc, bcm_tlv_t *ie, extern bool wlc_ps_check(struct wlc_info *wlc); extern void wlc_reprate_init(struct wlc_info *wlc); -extern void wlc_bsscfg_reprate_init(wlc_bsscfg_t *bsscfg); +extern void wlc_bsscfg_reprate_init(struct wlc_bsscfg *bsscfg); extern void wlc_uint64_sub(u32 *a_high, u32 *a_low, u32 b_high, u32 b_low); extern u32 wlc_calc_tbtt_offset(u32 bi, u32 tsf_h, u32 tsf_l); @@ -924,8 +904,8 @@ extern void wlc_bss_update_beacon(struct wlc_info *wlc, struct wlc_bsscfg *bsscfg); extern void wlc_update_probe_resp(struct wlc_info *wlc, bool suspend); -extern void wlc_bss_update_probe_resp(struct wlc_info *wlc, wlc_bsscfg_t *cfg, - bool suspend); +extern void wlc_bss_update_probe_resp(struct wlc_info *wlc, + struct wlc_bsscfg *cfg, bool suspend); extern bool wlc_ismpc(struct wlc_info *wlc); extern bool wlc_is_non_delay_mpc(struct wlc_info *wlc); @@ -957,14 +937,15 @@ extern void wlc_print_ies(struct wlc_info *wlc, u8 *ies, uint ies_len); extern int wlc_set_nmode(struct wlc_info *wlc, s32 nmode); extern void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode); extern void wlc_mimops_action_ht_send(struct wlc_info *wlc, - wlc_bsscfg_t *bsscfg, u8 mimops_mode); + struct wlc_bsscfg *bsscfg, + u8 mimops_mode); extern void wlc_switch_shortslot(struct wlc_info *wlc, bool shortslot); -extern void wlc_set_bssid(wlc_bsscfg_t *cfg); -extern void wlc_edcf_setparams(wlc_bsscfg_t *cfg, bool suspend); +extern void wlc_set_bssid(struct wlc_bsscfg *cfg); +extern void wlc_edcf_setparams(struct wlc_bsscfg *cfg, bool suspend); extern void wlc_set_ratetable(struct wlc_info *wlc); -extern int wlc_set_mac(wlc_bsscfg_t *cfg); +extern int wlc_set_mac(struct wlc_bsscfg *cfg); extern void wlc_beacon_phytxctl_txant_upd(struct wlc_info *wlc, ratespec_t bcn_rate); extern void wlc_mod_prb_rsp_rate_table(struct wlc_info *wlc, uint frame_len); @@ -983,6 +964,7 @@ extern bool wlc_ps_allowed(struct wlc_info *wlc); extern bool wlc_stay_awake(struct wlc_info *wlc); extern void wlc_wme_initparams_sta(struct wlc_info *wlc, wme_param_ie_t *pe); -extern void wlc_bss_list_free(struct wlc_info *wlc, wlc_bss_list_t *bss_list); +extern void wlc_bss_list_free(struct wlc_info *wlc, + struct wlc_bss_list *bss_list); extern void wlc_ht_mimops_cap_update(struct wlc_info *wlc, u8 mimops_mode); #endif /* _wlc_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_phy_shim.c b/drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.c index 8bd4ede4c92a..96d36001f460 100644 --- a/drivers/staging/brcm80211/sys/wlc_phy_shim.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.c @@ -22,40 +22,38 @@ */ #include <linux/kernel.h> -#include <bcmdefs.h> -#include <wlc_cfg.h> #include <linux/module.h> #include <linux/pci.h> -#include <osl.h> -#include <bcmutils.h> #include <proto/802.11.h> +#include <bcmdefs.h> +#include <bcmutils.h> #include <bcmwifi.h> #include <siutils.h> -#include <bcmendian.h> #include <wlioctl.h> #include <sbconfig.h> #include <sbchipc.h> #include <pcicfg.h> -#include <sbhndpio.h> #include <sbhnddma.h> #include <hnddma.h> #include <hndpmu.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_pub.h> -#include <wlc_channel.h> -#include <bcmsrom.h> -#include <wlc_key.h> -#include <wlc_event.h> - -#include <wlc_mac80211.h> - -#include <wlc_bmac.h> -#include <wlc_phy_shim.h> -#include <wlc_phy_hal.h> -#include <wl_export.h> -#include <wl_dbg.h> + +#include "wlc_types.h" +#include "wl_dbg.h" +#include "wlc_cfg.h" +#include "d11.h" +#include "wlc_rate.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_channel.h" +#include "bcmsrom.h" +#include "wlc_key.h" +#include "wlc_bmac.h" +#include "wlc_phy_hal.h" +#include "wl_export.h" +#include "wlc_main.h" +#include "wlc_phy_shim.h" /* PHY SHIM module specific state */ struct wlc_phy_shim_info { @@ -83,9 +81,6 @@ wlc_phy_shim_info_t *wlc_phy_shim_attach(struct wlc_hw_info *wlc_hw, void wlc_phy_shim_detach(wlc_phy_shim_info_t *physhim) { - if (!physhim) - return; - kfree(physhim); } diff --git a/drivers/staging/brcm80211/sys/wlc_phy_shim.h b/drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.h index c151a5d8c693..c151a5d8c693 100644 --- a/drivers/staging/brcm80211/sys/wlc_phy_shim.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.h diff --git a/drivers/staging/brcm80211/sys/wlc_pub.h b/drivers/staging/brcm80211/brcmsmac/wlc_pub.h index aff413001b70..b956c23fa467 100644 --- a/drivers/staging/brcm80211/sys/wlc_pub.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_pub.h @@ -17,9 +17,6 @@ #ifndef _wlc_pub_h_ #define _wlc_pub_h_ -#include <wlc_types.h> -#include <wlc_scb.h> - #define WLC_NUMRATES 16 /* max # of rates in a rateset */ #define MAXMULTILIST 32 /* max # multicast addresses */ #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ @@ -134,7 +131,7 @@ struct rsn_parms { * buffer length needed for wlc_format_ssid * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. */ -#define SSID_FMT_BUF_LEN ((4 * DOT11_MAX_SSID_LEN) + 1) +#define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) #define RSN_FLAGS_SUPPORTED 0x1 /* Flag for rsn_params */ #define RSN_FLAGS_PREAUTH 0x2 /* Flag for WPA2 rsn_params */ @@ -145,27 +142,13 @@ struct rsn_parms { #define AMPDU_DEF_MPDU_DENSITY 6 /* default mpdu density (110 ==> 4us) */ /* defaults for the HT (MIMO) bss */ -#define HT_CAP ((HT_CAP_MIMO_PS_OFF << HT_CAP_MIMO_PS_SHIFT) | HT_CAP_40MHZ | \ - HT_CAP_GF | HT_CAP_MAX_AMSDU | HT_CAP_DSSS_CCK) - -/* WLC packet type is a void * */ -typedef void *wlc_pkt_t; - -/* Event data type */ -typedef struct wlc_event { - wl_event_msg_t event; /* encapsulated event */ - struct ether_addr *addr; /* used to keep a trace of the potential present of - * an address in wlc_event_msg_t - */ - int bsscfgidx; /* BSS config when needed */ - struct wl_if *wlif; /* pointer to wlif */ - void *data; /* used to hang additional data on an event */ - struct wlc_event *next; /* enables ordered list of pending events */ -} wlc_event_t; +#define HT_CAP (IEEE80211_HT_CAP_SM_PS |\ + IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_GRN_FLD |\ + IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40) /* wlc internal bss_info, wl external one is in wlioctl.h */ typedef struct wlc_bss_info { - struct ether_addr BSSID; /* network BSSID */ + u8 BSSID[ETH_ALEN]; /* network BSSID */ u16 flags; /* flags for internal attributes */ u8 SSID_len; /* the length of SSID */ u8 SSID[32]; /* SSID string */ @@ -179,8 +162,6 @@ typedef struct wlc_bss_info { u8 dtim_period; /* DTIM period */ s8 phy_noise; /* noise right after tx (in dBm) */ u16 capability; /* Capability information */ - struct dot11_bcn_prb *bcn_prb; /* beacon/probe response frame (ioctl na) */ - u16 bcn_prb_len; /* beacon/probe response frame length (ioctl na) */ u8 wme_qosinfo; /* QoS Info from WME IE; valid if WLC_BSS_WME flag set */ struct rsn_parms wpa; struct rsn_parms wpa2; @@ -260,7 +241,6 @@ struct wlc_pub { uint mac80211_state; uint unit; /* device instance number */ uint corerev; /* core revision */ - struct osl_info *osh; /* pointer to os handle */ si_t *sih; /* SB handle (cookie for siutils calls) */ char *vars; /* "environment" name=value */ bool up; /* interface up and running */ @@ -291,9 +271,9 @@ struct wlc_pub { s8 _coex; /* 20/40 MHz BSS Management AUTO, ENAB, DISABLE */ bool _priofc; /* Priority-based flowcontrol */ - struct ether_addr cur_etheraddr; /* our local ethernet address */ + u8 cur_etheraddr[ETH_ALEN]; /* our local ethernet address */ - struct ether_addr *multicast; /* ptr to list of multicast addresses */ + u8 *multicast; /* ptr to list of multicast addresses */ uint nmulticast; /* # enabled multicast addresses */ u32 wlfeatureflag; /* Flags to control sw features from registry */ @@ -330,6 +310,8 @@ struct wlc_pub { bool _lmacproto; /* lmac protocol module included and enabled */ bool phy_11ncapable; /* the PHY/HW is capable of 802.11N */ bool _ampdumac; /* mac assist ampdu enabled or not */ + + struct wl_cnt *_cnt; /* low-level counters in driver */ }; /* wl_monitor rx status per packet */ @@ -481,17 +463,24 @@ extern const u8 wme_fifo2ac[]; #define WLC_USE_COREFLAGS 0xffffffff /* invalid core flags, use the saved coreflags */ -#define WLC_UPDATE_STATS(wlc) 0 /* No stats support */ -#define WLCNTINCR(a) /* No stats support */ -#define WLCNTDECR(a) /* No stats support */ -#define WLCNTADD(a, delta) /* No stats support */ -#define WLCNTSET(a, value) /* No stats support */ -#define WLCNTVAL(a) 0 /* No stats support */ + +/* network protection config */ +#define WLC_PROT_G_SPEC 1 /* SPEC g protection */ +#define WLC_PROT_G_OVR 2 /* SPEC g prot override */ +#define WLC_PROT_G_USER 3 /* gmode specified by user */ +#define WLC_PROT_OVERLAP 4 /* overlap */ +#define WLC_PROT_N_USER 10 /* nmode specified by user */ +#define WLC_PROT_N_CFG 11 /* n protection */ +#define WLC_PROT_N_CFG_OVR 12 /* n protection override */ +#define WLC_PROT_N_NONGF 13 /* non-GF protection */ +#define WLC_PROT_N_NONGF_OVR 14 /* non-GF protection override */ +#define WLC_PROT_N_PAM_OVR 15 /* n preamble override */ +#define WLC_PROT_N_OBSS 16 /* non-HT OBSS present */ /* common functions for every port */ extern void *wlc_attach(void *wl, u16 vendor, u16 device, uint unit, - bool piomode, struct osl_info *osh, void *regsva, - uint bustype, void *btparam, uint *perr); + bool piomode, void *regsva, uint bustype, void *btparam, + uint *perr); extern uint wlc_detach(struct wlc_info *wlc); extern int wlc_up(struct wlc_info *wlc); extern uint wlc_down(struct wlc_info *wlc); @@ -521,10 +510,11 @@ extern int wlc_ioctl(struct wlc_info *wlc, int cmd, void *arg, int len, struct wlc_if *wlcif); /* helper functions */ extern void wlc_statsupd(struct wlc_info *wlc); +extern void wlc_protection_upd(struct wlc_info *wlc, uint idx, int val); extern int wlc_get_header_len(void); extern void wlc_mac_bcn_promisc_change(struct wlc_info *wlc, bool promisc); extern void wlc_set_addrmatch(struct wlc_info *wlc, int match_reg_offset, - const struct ether_addr *addr); + const u8 *addr); extern void wlc_wme_setparams(struct wlc_info *wlc, u16 aci, void *arg, bool suspend); @@ -546,6 +536,10 @@ extern u32 wlc_delta_txfunfl(struct wlc_info *wlc, int fifo); extern void wlc_rate_lookup_init(struct wlc_info *wlc, wlc_rateset_t *rateset); extern void wlc_default_rateset(struct wlc_info *wlc, wlc_rateset_t *rs); +struct ieee80211_sta; +extern void wlc_ampdu_flush(struct wlc_info *wlc, struct ieee80211_sta *sta, + u16 tid); + /* wlc_phy.c helper functions */ extern void wlc_set_ps_ctrl(struct wlc_info *wlc); extern void wlc_mctrl(struct wlc_info *wlc, u32 mask, u32 val); @@ -563,13 +557,9 @@ extern int wlc_module_register(struct wlc_pub *pub, const bcm_iovar_t *iovars, watchdog_fn_t watchdog_fn, down_fn_t down_fn); extern int wlc_module_unregister(struct wlc_pub *pub, const char *name, void *hdl); -extern void wlc_event_if(struct wlc_info *wlc, struct wlc_bsscfg *cfg, - wlc_event_t *e, const struct ether_addr *addr); extern void wlc_suspend_mac_and_wait(struct wlc_info *wlc); extern void wlc_enable_mac(struct wlc_info *wlc); -extern u16 wlc_rate_shm_offset(struct wlc_info *wlc, u8 rate); -extern u32 wlc_get_rspec_history(struct wlc_bsscfg *cfg); -extern u32 wlc_get_current_highest_rate(struct wlc_bsscfg *cfg); +extern void wlc_associate_upd(struct wlc_info *wlc, bool state); extern void wlc_scan_start(struct wlc_info *wlc); extern void wlc_scan_stop(struct wlc_info *wlc); @@ -599,20 +589,13 @@ extern int wlc_iocpichk(struct wlc_info *wlc, uint phytype); #endif /* helper functions */ -extern void wlc_getrand(struct wlc_info *wlc, u8 *buf, int len); - -struct scb; -extern void wlc_ps_on(struct wlc_info *wlc, struct scb *scb); -extern void wlc_ps_off(struct wlc_info *wlc, struct scb *scb, bool discard); +extern bool wlc_check_radio_disabled(struct wlc_info *wlc); extern bool wlc_radio_monitor_stop(struct wlc_info *wlc); #if defined(BCMDBG) extern int wlc_format_ssid(char *buf, const unsigned char ssid[], uint ssid_len); #endif -extern void wlc_pmkid_build_cand_list(struct wlc_bsscfg *cfg, bool check_SSID); -extern void wlc_pmkid_event(struct wlc_bsscfg *cfg); - #define MAXBANDS 2 /* Maximum #of bands */ /* bandstate array indices */ #define BAND_2G_INDEX 0 /* wlc->bandstate[x] index */ diff --git a/drivers/staging/brcm80211/sys/wlc_rate.c b/drivers/staging/brcm80211/brcmsmac/wlc_rate.c index ab7d0bed3c0a..0cfa36023cf1 100644 --- a/drivers/staging/brcm80211/sys/wlc_rate.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_rate.c @@ -14,22 +14,22 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/kernel.h> -#include <bcmdefs.h> -#include <wlc_cfg.h> -#include <osl.h> #include <linux/module.h> + +#include <proto/802.11.h> +#include <bcmdefs.h> #include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> #include <wlioctl.h> - -#include <sbhndpio.h> #include <sbhnddma.h> -#include <proto/802.11.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wl_dbg.h> -#include <wlc_pub.h> + +#include "wlc_types.h" +#include "d11.h" +#include "wl_dbg.h" +#include "wlc_cfg.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_rate.h" /* Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate value */ const u8 rate_info[WLC_MAXRATE + 1] = { @@ -382,7 +382,7 @@ ratespec_t BCMFASTPATH wlc_compute_rspec(d11rxhdr_t *rxh, u8 *plcp) /* copy rateset src to dst as-is (no masking or sorting) */ void wlc_rateset_copy(const wlc_rateset_t *src, wlc_rateset_t *dst) { - bcopy(src, dst, sizeof(wlc_rateset_t)); + memcpy(dst, src, sizeof(wlc_rateset_t)); } /* @@ -417,7 +417,7 @@ wlc_rateset_filter(wlc_rateset_t *src, wlc_rateset_t *dst, bool basic_only, dst->htphy_membership = src->htphy_membership; if (mcsallow && rates != WLC_RATES_CCK) - bcopy(&src->mcs[0], &dst->mcs[0], MCSSET_LEN); + memcpy(&dst->mcs[0], &src->mcs[0], MCSSET_LEN); else wlc_rateset_mcs_clear(dst); } @@ -487,7 +487,7 @@ void wlc_rateset_mcs_clear(wlc_rateset_t *rateset) void wlc_rateset_mcs_build(wlc_rateset_t *rateset, u8 txstreams) { - bcopy(&cck_ofdm_mimo_rates.mcs[0], &rateset->mcs[0], MCSSET_LEN); + memcpy(&rateset->mcs[0], &cck_ofdm_mimo_rates.mcs[0], MCSSET_LEN); wlc_rateset_mcs_upd(rateset, txstreams); } diff --git a/drivers/staging/brcm80211/sys/wlc_rate.h b/drivers/staging/brcm80211/brcmsmac/wlc_rate.h index 25ba2a423639..25ba2a423639 100644 --- a/drivers/staging/brcm80211/sys/wlc_rate.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_rate.h diff --git a/drivers/staging/brcm80211/sys/wlc_scb.h b/drivers/staging/brcm80211/brcmsmac/wlc_scb.h index fe84e993b52a..73260068898f 100644 --- a/drivers/staging/brcm80211/sys/wlc_scb.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_scb.h @@ -17,8 +17,6 @@ #ifndef _wlc_scb_h_ #define _wlc_scb_h_ -#include <proto/802.1d.h> - extern bool wlc_aggregatable(struct wlc_info *wlc, u8 tid); #define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */ @@ -58,7 +56,7 @@ struct scb { u32 flags; /* various bit flags as defined below */ u32 flags2; /* various bit flags2 as defined below */ u8 state; /* current state bitfield of auth/assoc process */ - struct ether_addr ea; /* station address */ + u8 ea[ETH_ALEN]; /* station address */ void *fragbuf[NUMPRIO]; /* defragmentation buffer per prio */ uint fragresid[NUMPRIO]; /* #bytes unused in frag buffer per prio */ diff --git a/drivers/staging/brcm80211/sys/wlc_stf.c b/drivers/staging/brcm80211/brcmsmac/wlc_stf.c index 8975b09a7438..098fd59ee153 100644 --- a/drivers/staging/brcm80211/sys/wlc_stf.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_stf.c @@ -16,35 +16,37 @@ #include <linux/kernel.h> #include <linux/module.h> -#include <wlc_cfg.h> + +#include <proto/802.11.h> + #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> -#include <proto/802.11.h> #include <wlioctl.h> #include <bcmwifi.h> -#include <sbhndpio.h> #include <sbhnddma.h> -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <wlc_channel.h> -#include <wlc_bsscfg.h> -#include <wlc_event.h> -#include <wlc_mac80211.h> -#include <wlc_scb.h> -#include <wl_export.h> -#include <wlc_bmac.h> -#include <wlc_stf.h> -#include <wl_dbg.h> + +#include "wlc_types.h" +#include "d11.h" +#include "wl_dbg.h" +#include "wlc_cfg.h" +#include "wlc_rate.h" +#include "wlc_scb.h" +#include "wlc_pub.h" +#include "wlc_key.h" +#include "phy/wlc_phy_hal.h" +#include "wlc_channel.h" +#include "wlc_main.h" +#include "wl_export.h" +#include "wlc_bmac.h" +#include "wlc_stf.h" + +#define MIN_SPATIAL_EXPANSION 0 +#define MAX_SPATIAL_EXPANSION 1 #define WLC_STF_SS_STBC_RX(wlc) (WLCISNPHY(wlc->band) && \ NREV_GT(wlc->band->phyrev, 3) && NREV_LE(wlc->band->phyrev, 6)) -static s8 wlc_stf_stbc_rx_get(struct wlc_info *wlc); static bool wlc_stf_stbc_tx_set(struct wlc_info *wlc, s32 int_val); static int wlc_stf_txcore_set(struct wlc_info *wlc, u8 Nsts, u8 val); static int wlc_stf_spatial_policy_set(struct wlc_info *wlc, int val); @@ -76,8 +78,8 @@ static void wlc_stf_stbc_rx_ht_update(struct wlc_info *wlc, int val) return; } - wlc->ht_cap.cap &= ~HT_CAP_RX_STBC_MASK; - wlc->ht_cap.cap |= (val << HT_CAP_RX_STBC_SHIFT); + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_RX_STBC; + wlc->ht_cap.cap_info |= (val << IEEE80211_HT_CAP_RX_STBC_SHIFT); if (wlc->pub->up) { wlc_update_beacon(wlc); @@ -151,11 +153,6 @@ wlc_stf_ss_algo_channel_get(struct wlc_info *wlc, u16 *ss_algo_channel, setbit(ss_algo_channel, PHY_TXC1_MODE_STBC); } -static s8 wlc_stf_stbc_rx_get(struct wlc_info *wlc) -{ - return (wlc->ht_cap.cap & HT_CAP_RX_STBC_MASK) >> HT_CAP_RX_STBC_SHIFT; -} - static bool wlc_stf_stbc_tx_set(struct wlc_info *wlc, s32 int_val) { if ((int_val != AUTO) && (int_val != OFF) && (int_val != ON)) { @@ -167,9 +164,9 @@ static bool wlc_stf_stbc_tx_set(struct wlc_info *wlc, s32 int_val) if ((int_val == OFF) || (wlc->stf->txstreams == 1) || !WLC_STBC_CAP_PHY(wlc)) - wlc->ht_cap.cap &= ~HT_CAP_TX_STBC; + wlc->ht_cap.cap_info &= ~IEEE80211_HT_CAP_TX_STBC; else - wlc->ht_cap.cap |= HT_CAP_TX_STBC; + wlc->ht_cap.cap_info |= IEEE80211_HT_CAP_TX_STBC; wlc->bandstate[BAND_2G_INDEX]->band_stf_stbc_tx = (s8) int_val; wlc->bandstate[BAND_5G_INDEX]->band_stf_stbc_tx = (s8) int_val; @@ -309,69 +306,6 @@ int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force) return BCME_OK; } -int wlc_stf_rxchain_set(struct wlc_info *wlc, s32 int_val) -{ - u8 rxchain_cnt; - u8 rxchain = (u8) int_val; - u8 mimops_mode; - u8 old_rxchain, old_rxchain_cnt; - - if (wlc->stf->rxchain == rxchain) - return BCME_OK; - - if ((rxchain & ~wlc->stf->hw_rxchain) - || !(rxchain & wlc->stf->hw_rxchain)) - return BCME_RANGE; - - rxchain_cnt = (u8) WLC_BITSCNT(rxchain); - if (WLC_STF_SS_STBC_RX(wlc)) { - if ((rxchain_cnt == 1) - && (wlc_stf_stbc_rx_get(wlc) != HT_CAP_RX_STBC_NO)) - return BCME_RANGE; - } - - if (APSTA_ENAB(wlc->pub) && (wlc->pub->associated)) - return BCME_ASSOCIATED; - - old_rxchain = wlc->stf->rxchain; - old_rxchain_cnt = wlc->stf->rxstreams; - - wlc->stf->rxchain = rxchain; - wlc->stf->rxstreams = rxchain_cnt; - - if (rxchain_cnt != old_rxchain_cnt) { - mimops_mode = - (rxchain_cnt == 1) ? HT_CAP_MIMO_PS_ON : HT_CAP_MIMO_PS_OFF; - wlc->mimops_PM = mimops_mode; - if (AP_ENAB(wlc->pub)) { - wlc_phy_stf_chain_set(wlc->band->pi, wlc->stf->txchain, - wlc->stf->rxchain); - wlc_ht_mimops_cap_update(wlc, mimops_mode); - if (wlc->pub->associated) - wlc_mimops_action_ht_send(wlc, wlc->cfg, - mimops_mode); - return BCME_OK; - } - if (wlc->pub->associated) { - if (mimops_mode == HT_CAP_MIMO_PS_OFF) { - /* if mimops is off, turn on the Rx chain first */ - wlc_phy_stf_chain_set(wlc->band->pi, - wlc->stf->txchain, - wlc->stf->rxchain); - wlc_ht_mimops_cap_update(wlc, mimops_mode); - } - } else { - wlc_phy_stf_chain_set(wlc->band->pi, wlc->stf->txchain, - wlc->stf->rxchain); - wlc_ht_mimops_cap_update(wlc, mimops_mode); - } - } else if (old_rxchain != rxchain) - wlc_phy_stf_chain_set(wlc->band->pi, wlc->stf->txchain, - wlc->stf->rxchain); - - return BCME_OK; -} - /* update wlc->stf->ss_opmode which represents the operational stf_ss mode we're using */ int wlc_stf_ss_update(struct wlc_info *wlc, struct wlcband *band) { @@ -558,7 +492,7 @@ void wlc_stf_phy_chain_calc(struct wlc_info *wlc) wlc->stf->rxstreams = (u8) WLC_BITSCNT(wlc->stf->hw_rxchain); /* initialize the txcore table */ - bcopy(txcore_default, wlc->stf->txcore, sizeof(wlc->stf->txcore)); + memcpy(wlc->stf->txcore, txcore_default, sizeof(wlc->stf->txcore)); /* default spatial_policy */ wlc->stf->spatial_policy = MIN_SPATIAL_EXPANSION; diff --git a/drivers/staging/brcm80211/sys/wlc_stf.h b/drivers/staging/brcm80211/brcmsmac/wlc_stf.h index 8de6382e620d..2b1180b128a8 100644 --- a/drivers/staging/brcm80211/sys/wlc_stf.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_stf.h @@ -17,9 +17,6 @@ #ifndef _wlc_stf_h_ #define _wlc_stf_h_ -#define MIN_SPATIAL_EXPANSION 0 -#define MAX_SPATIAL_EXPANSION 1 - extern int wlc_stf_attach(struct wlc_info *wlc); extern void wlc_stf_detach(struct wlc_info *wlc); @@ -30,7 +27,6 @@ extern void wlc_stf_ss_algo_channel_get(struct wlc_info *wlc, extern int wlc_stf_ss_update(struct wlc_info *wlc, struct wlcband *band); extern void wlc_stf_phy_txant_upd(struct wlc_info *wlc); extern int wlc_stf_txchain_set(struct wlc_info *wlc, s32 int_val, bool force); -extern int wlc_stf_rxchain_set(struct wlc_info *wlc, s32 int_val); extern bool wlc_stf_stbc_rx_set(struct wlc_info *wlc, s32 int_val); extern int wlc_stf_ant_txant_validate(struct wlc_info *wlc, s8 val); @@ -38,6 +34,5 @@ extern void wlc_stf_phy_txant_upd(struct wlc_info *wlc); extern void wlc_stf_phy_chain_calc(struct wlc_info *wlc); extern u16 wlc_stf_phytxchain_sel(struct wlc_info *wlc, ratespec_t rspec); extern u16 wlc_stf_d11hdrs_phyctl_txant(struct wlc_info *wlc, ratespec_t rspec); -extern u16 wlc_stf_spatial_expansion_get(struct wlc_info *wlc, - ratespec_t rspec); + #endif /* _wlc_stf_h_ */ diff --git a/drivers/staging/brcm80211/sys/wlc_types.h b/drivers/staging/brcm80211/brcmsmac/wlc_types.h index df6e04c6ac58..df6e04c6ac58 100644 --- a/drivers/staging/brcm80211/sys/wlc_types.h +++ b/drivers/staging/brcm80211/brcmsmac/wlc_types.h diff --git a/drivers/staging/brcm80211/include/bcmdefs.h b/drivers/staging/brcm80211/include/bcmdefs.h index 74601fc971c9..22a389e1d511 100644 --- a/drivers/staging/brcm80211/include/bcmdefs.h +++ b/drivers/staging/brcm80211/include/bcmdefs.h @@ -138,10 +138,25 @@ typedef struct { (((val) & (~(field ## _M << field ## _S))) | \ ((unsigned)(bits) << field ## _S)) +/* + * Priority definitions according 802.1D + */ +#define PRIO_8021D_NONE 2 +#define PRIO_8021D_BK 1 +#define PRIO_8021D_BE 0 +#define PRIO_8021D_EE 3 +#define PRIO_8021D_CL 4 +#define PRIO_8021D_VI 5 +#define PRIO_8021D_VO 6 +#define PRIO_8021D_NC 7 +#define MAXPRIO 7 +#define NUMPRIO (MAXPRIO + 1) + /* Max. nvram variable table size */ #define MAXSZ_NVRAM_VARS 4096 /* handle forward declaration */ struct wl_info; +struct wlc_bsscfg; #endif /* _bcmdefs_h_ */ diff --git a/drivers/staging/brcm80211/include/bcmendian.h b/drivers/staging/brcm80211/include/bcmendian.h deleted file mode 100644 index 4123aefa211c..000000000000 --- a/drivers/staging/brcm80211/include/bcmendian.h +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _BCMENDIAN_H_ -#define _BCMENDIAN_H_ - -/* Reverse the bytes in a 16-bit value */ -#define BCMSWAP16(val) \ - ((u16)((((u16)(val) & (u16)0x00ffU) << 8) | \ - (((u16)(val) & (u16)0xff00U) >> 8))) - -/* Reverse the bytes in a 32-bit value */ -#define BCMSWAP32(val) \ - ((u32)((((u32)(val) & (u32)0x000000ffU) << 24) | \ - (((u32)(val) & (u32)0x0000ff00U) << 8) | \ - (((u32)(val) & (u32)0x00ff0000U) >> 8) | \ - (((u32)(val) & (u32)0xff000000U) >> 24))) - -/* Reverse the two 16-bit halves of a 32-bit value */ -#define BCMSWAP32BY16(val) \ - ((u32)((((u32)(val) & (u32)0x0000ffffU) << 16) | \ - (((u32)(val) & (u32)0xffff0000U) >> 16))) - -/* Byte swapping macros - * Host <=> Network (Big Endian) for 16- and 32-bit values - * Host <=> Little-Endian for 16- and 32-bit values - */ -#ifndef hton16 -#ifndef IL_BIGENDIAN -#define HTON16(i) BCMSWAP16(i) -#define hton16(i) bcmswap16(i) -#define HTON32(i) BCMSWAP32(i) -#define hton32(i) bcmswap32(i) -#define NTOH16(i) BCMSWAP16(i) -#define ntoh16(i) bcmswap16(i) -#define NTOH32(i) BCMSWAP32(i) -#define ntoh32(i) bcmswap32(i) -#define LTOH16(i) (i) -#define ltoh16(i) (i) -#define LTOH32(i) (i) -#define ltoh32(i) (i) -#define HTOL16(i) (i) -#define htol16(i) (i) -#define HTOL32(i) (i) -#define htol32(i) (i) -#else /* IL_BIGENDIAN */ -#define HTON16(i) (i) -#define hton16(i) (i) -#define HTON32(i) (i) -#define hton32(i) (i) -#define NTOH16(i) (i) -#define ntoh16(i) (i) -#define NTOH32(i) (i) -#define ntoh32(i) (i) -#define LTOH16(i) BCMSWAP16(i) -#define ltoh16(i) bcmswap16(i) -#define LTOH32(i) BCMSWAP32(i) -#define ltoh32(i) bcmswap32(i) -#define HTOL16(i) BCMSWAP16(i) -#define htol16(i) bcmswap16(i) -#define HTOL32(i) BCMSWAP32(i) -#define htol32(i) bcmswap32(i) -#endif /* IL_BIGENDIAN */ -#endif /* hton16 */ - -#ifndef IL_BIGENDIAN -#define ltoh16_buf(buf, i) -#define htol16_buf(buf, i) -#else -#define ltoh16_buf(buf, i) bcmswap16_buf((u16 *)(buf), (i)) -#define htol16_buf(buf, i) bcmswap16_buf((u16 *)(buf), (i)) -#endif /* IL_BIGENDIAN */ - -/* Unaligned loads and stores in host byte order */ -#ifndef IL_BIGENDIAN -#define load32_ua(a) ltoh32_ua(a) -#define store32_ua(a, v) htol32_ua_store(v, a) -#define load16_ua(a) ltoh16_ua(a) -#define store16_ua(a, v) htol16_ua_store(v, a) -#else -#define load32_ua(a) ntoh32_ua(a) -#define store32_ua(a, v) hton32_ua_store(v, a) -#define load16_ua(a) ntoh16_ua(a) -#define store16_ua(a, v) hton16_ua_store(v, a) -#endif /* IL_BIGENDIAN */ - -#define _LTOH16_UA(cp) ((cp)[0] | ((cp)[1] << 8)) -#define _LTOH32_UA(cp) ((cp)[0] | ((cp)[1] << 8) | ((cp)[2] << 16) | ((cp)[3] << 24)) -#define _NTOH16_UA(cp) (((cp)[0] << 8) | (cp)[1]) -#define _NTOH32_UA(cp) (((cp)[0] << 24) | ((cp)[1] << 16) | ((cp)[2] << 8) | (cp)[3]) - -#define ltoh_ua(ptr) \ - (sizeof(*(ptr)) == sizeof(u8) ? *(const u8 *)(ptr) : \ - sizeof(*(ptr)) == sizeof(u16) ? _LTOH16_UA((const u8 *)(ptr)) : \ - sizeof(*(ptr)) == sizeof(u32) ? _LTOH32_UA((const u8 *)(ptr)) : \ - *(u8 *)0) - -#define ntoh_ua(ptr) \ - (sizeof(*(ptr)) == sizeof(u8) ? *(const u8 *)(ptr) : \ - sizeof(*(ptr)) == sizeof(u16) ? _NTOH16_UA((const u8 *)(ptr)) : \ - sizeof(*(ptr)) == sizeof(u32) ? _NTOH32_UA((const u8 *)(ptr)) : \ - *(u8 *)0) - -#ifdef __GNUC__ - -/* GNU macro versions avoid referencing the argument multiple times, while also - * avoiding the -fno-inline used in ROM builds. - */ - -#define bcmswap16(val) ({ \ - u16 _val = (val); \ - BCMSWAP16(_val); \ -}) - -#define bcmswap32(val) ({ \ - u32 _val = (val); \ - BCMSWAP32(_val); \ -}) - -#define bcmswap32by16(val) ({ \ - u32 _val = (val); \ - BCMSWAP32BY16(_val); \ -}) - -#define bcmswap16_buf(buf, len) ({ \ - u16 *_buf = (u16 *)(buf); \ - uint _wds = (len) / 2; \ - while (_wds--) { \ - *_buf = bcmswap16(*_buf); \ - _buf++; \ - } \ -}) - -#define htol16_ua_store(val, bytes) ({ \ - u16 _val = (val); \ - u8 *_bytes = (u8 *)(bytes); \ - _bytes[0] = _val & 0xff; \ - _bytes[1] = _val >> 8; \ -}) - -#define htol32_ua_store(val, bytes) ({ \ - u32 _val = (val); \ - u8 *_bytes = (u8 *)(bytes); \ - _bytes[0] = _val & 0xff; \ - _bytes[1] = (_val >> 8) & 0xff; \ - _bytes[2] = (_val >> 16) & 0xff; \ - _bytes[3] = _val >> 24; \ -}) - -#define hton16_ua_store(val, bytes) ({ \ - u16 _val = (val); \ - u8 *_bytes = (u8 *)(bytes); \ - _bytes[0] = _val >> 8; \ - _bytes[1] = _val & 0xff; \ -}) - -#define hton32_ua_store(val, bytes) ({ \ - u32 _val = (val); \ - u8 *_bytes = (u8 *)(bytes); \ - _bytes[0] = _val >> 24; \ - _bytes[1] = (_val >> 16) & 0xff; \ - _bytes[2] = (_val >> 8) & 0xff; \ - _bytes[3] = _val & 0xff; \ -}) - -#define ltoh16_ua(bytes) ({ \ - const u8 *_bytes = (const u8 *)(bytes); \ - _LTOH16_UA(_bytes); \ -}) - -#define ltoh32_ua(bytes) ({ \ - const u8 *_bytes = (const u8 *)(bytes); \ - _LTOH32_UA(_bytes); \ -}) - -#define ntoh16_ua(bytes) ({ \ - const u8 *_bytes = (const u8 *)(bytes); \ - _NTOH16_UA(_bytes); \ -}) - -#define ntoh32_ua(bytes) ({ \ - const u8 *_bytes = (const u8 *)(bytes); \ - _NTOH32_UA(_bytes); \ -}) - -#else /* !__GNUC__ */ - -/* Inline versions avoid referencing the argument multiple times */ -static inline u16 bcmswap16(u16 val) -{ - return BCMSWAP16(val); -} - -static inline u32 bcmswap32(u32 val) -{ - return BCMSWAP32(val); -} - -static inline u32 bcmswap32by16(u32 val) -{ - return BCMSWAP32BY16(val); -} - -/* Reverse pairs of bytes in a buffer (not for high-performance use) */ -/* buf - start of buffer of shorts to swap */ -/* len - byte length of buffer */ -static inline void bcmswap16_buf(u16 *buf, uint len) -{ - len = len / 2; - - while (len--) { - *buf = bcmswap16(*buf); - buf++; - } -} - -/* - * Store 16-bit value to unaligned little-endian byte array. - */ -static inline void htol16_ua_store(u16 val, u8 *bytes) -{ - bytes[0] = val & 0xff; - bytes[1] = val >> 8; -} - -/* - * Store 32-bit value to unaligned little-endian byte array. - */ -static inline void htol32_ua_store(u32 val, u8 *bytes) -{ - bytes[0] = val & 0xff; - bytes[1] = (val >> 8) & 0xff; - bytes[2] = (val >> 16) & 0xff; - bytes[3] = val >> 24; -} - -/* - * Store 16-bit value to unaligned network-(big-)endian byte array. - */ -static inline void hton16_ua_store(u16 val, u8 *bytes) -{ - bytes[0] = val >> 8; - bytes[1] = val & 0xff; -} - -/* - * Store 32-bit value to unaligned network-(big-)endian byte array. - */ -static inline void hton32_ua_store(u32 val, u8 *bytes) -{ - bytes[0] = val >> 24; - bytes[1] = (val >> 16) & 0xff; - bytes[2] = (val >> 8) & 0xff; - bytes[3] = val & 0xff; -} - -/* - * Load 16-bit value from unaligned little-endian byte array. - */ -static inline u16 ltoh16_ua(const void *bytes) -{ - return _LTOH16_UA((const u8 *)bytes); -} - -/* - * Load 32-bit value from unaligned little-endian byte array. - */ -static inline u32 ltoh32_ua(const void *bytes) -{ - return _LTOH32_UA((const u8 *)bytes); -} - -/* - * Load 16-bit value from unaligned big-(network-)endian byte array. - */ -static inline u16 ntoh16_ua(const void *bytes) -{ - return _NTOH16_UA((const u8 *)bytes); -} - -/* - * Load 32-bit value from unaligned big-(network-)endian byte array. - */ -static inline u32 ntoh32_ua(const void *bytes) -{ - return _NTOH32_UA((const u8 *)bytes); -} - -#endif /* !__GNUC__ */ -#endif /* !_BCMENDIAN_H_ */ diff --git a/drivers/staging/brcm80211/include/bcmnvram.h b/drivers/staging/brcm80211/include/bcmnvram.h index 63e31a4749c3..e194131a750e 100644 --- a/drivers/staging/brcm80211/include/bcmnvram.h +++ b/drivers/staging/brcm80211/include/bcmnvram.h @@ -29,12 +29,6 @@ struct nvram_header { u32 config_ncdl; /* ncdl values for memc */ }; -struct nvram_tuple { - char *name; - char *value; - struct nvram_tuple *next; -}; - /* * Get default value for an NVRAM variable */ diff --git a/drivers/staging/brcm80211/include/bcmsdh.h b/drivers/staging/brcm80211/include/bcmsdh.h index 0e1f79919c9c..3b57dc13b1de 100644 --- a/drivers/staging/brcm80211/include/bcmsdh.h +++ b/drivers/staging/brcm80211/include/bcmsdh.h @@ -17,13 +17,22 @@ #ifndef _bcmsdh_h_ #define _bcmsdh_h_ +#include <linux/skbuff.h> #define BCMSDH_ERROR_VAL 0x0001 /* Error */ #define BCMSDH_INFO_VAL 0x0002 /* Info */ extern const uint bcmsdh_msglevel; #ifdef BCMDBG -#define BCMSDH_ERROR(x) do { if ((bcmsdh_msglevel & BCMSDH_ERROR_VAL) && net_ratelimit()) printf x; } while (0) -#define BCMSDH_INFO(x) do { if ((bcmsdh_msglevel & BCMSDH_INFO_VAL) && net_ratelimit()) printf x; } while (0) +#define BCMSDH_ERROR(x) \ + do { \ + if ((bcmsdh_msglevel & BCMSDH_ERROR_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) +#define BCMSDH_INFO(x) \ + do { \ + if ((bcmsdh_msglevel & BCMSDH_INFO_VAL) && net_ratelimit()) \ + printk x; \ + } while (0) #else /* BCMDBG */ #define BCMSDH_ERROR(x) #define BCMSDH_INFO(x) @@ -40,11 +49,10 @@ typedef void (*bcmsdh_cb_fn_t) (void *); * implementation may maintain a single "default" handle (e.g. the first or * most recent one) to enable single-instance implementations to pass NULL. */ -extern bcmsdh_info_t *bcmsdh_attach(struct osl_info *osh, void *cfghdl, - void **regsva, uint irq); +extern bcmsdh_info_t *bcmsdh_attach(void *cfghdl, void **regsva, uint irq); /* Detach - freeup resources allocated in attach */ -extern int bcmsdh_detach(struct osl_info *osh, void *sdh); +extern int bcmsdh_detach(void *sdh); /* Query if SD device interrupts are enabled */ extern bool bcmsdh_intr_query(void *sdh); @@ -57,7 +65,7 @@ extern int bcmsdh_intr_disable(void *sdh); extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh); extern int bcmsdh_intr_dereg(void *sdh); -#if defined(BCMDBG) +#if defined(DHD_DEBUG) /* Query pending interrupt status from the host controller */ extern bool bcmsdh_intr_pending(void *sdh); #endif @@ -174,8 +182,7 @@ extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh); typedef struct { /* attach to device */ void *(*attach) (u16 vend_id, u16 dev_id, u16 bus, u16 slot, - u16 func, uint bustype, void *regsva, - struct osl_info *osh, void *param); + u16 func, uint bustype, void *regsva, void *param); /* detach from device */ void (*detach) (void *ch); } bcmsdh_driver_t; diff --git a/drivers/staging/brcm80211/include/bcmsrom.h b/drivers/staging/brcm80211/include/bcmsrom.h index cdcef746284f..b2dc8951c5d2 100644 --- a/drivers/staging/brcm80211/include/bcmsrom.h +++ b/drivers/staging/brcm80211/include/bcmsrom.h @@ -21,14 +21,14 @@ /* Prototypes */ extern int srom_var_init(si_t *sih, uint bus, void *curmap, - struct osl_info *osh, char **vars, uint *count); + char **vars, uint *count); -extern int srom_read(si_t *sih, uint bus, void *curmap, struct osl_info *osh, +extern int srom_read(si_t *sih, uint bus, void *curmap, uint byteoff, uint nbytes, u16 *buf, bool check_crc); /* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP * and extract from it into name=value pairs */ -extern int srom_parsecis(struct osl_info *osh, u8 **pcis, uint ciscnt, +extern int srom_parsecis(u8 **pcis, uint ciscnt, char **vars, uint *count); #endif /* _bcmsrom_h_ */ diff --git a/drivers/staging/brcm80211/include/bcmutils.h b/drivers/staging/brcm80211/include/bcmutils.h index a8f76d8199ff..fc2a2a910129 100644 --- a/drivers/staging/brcm80211/include/bcmutils.h +++ b/drivers/staging/brcm80211/include/bcmutils.h @@ -54,12 +54,12 @@ #define PKTQ_MAX_PREC 16 /* Maximum precedence levels */ #endif - typedef struct pktq_prec { + struct pktq_prec { struct sk_buff *head; /* first packet to dequeue */ struct sk_buff *tail; /* last packet to dequeue */ u16 len; /* number of queued packets */ u16 max; /* maximum number of queued packets */ - } pktq_prec_t; + }; /* multi-priority pkt queue */ struct pktq { @@ -71,28 +71,11 @@ struct pktq_prec q[PKTQ_MAX_PREC]; }; -/* simple, non-priority pkt queue */ - struct spktq { - u16 num_prec; /* number of precedences in use (always 1) */ - u16 hi_prec; /* rapid dequeue hint (>= highest non-empty prec) */ - u16 max; /* total max packets */ - u16 len; /* total number of packets */ - /* q array must be last since # of elements can be either PKTQ_MAX_PREC or 1 */ - struct pktq_prec q[1]; - }; - #define PKTQ_PREC_ITER(pq, prec) for (prec = (pq)->num_prec - 1; prec >= 0; prec--) /* fn(pkt, arg). return true if pkt belongs to if */ typedef bool(*ifpkt_cb_t) (void *, int); -/* forward definition of ether_addr structure used by some function prototypes */ - - struct ether_addr; - - extern int ether_isbcast(const void *ea); - extern int ether_isnulladdr(const void *ea); - /* operations on a specific precedence in packet queue */ #define pktq_psetmax(pq, prec, _max) ((pq)->q[prec].max = (_max)) @@ -111,12 +94,16 @@ extern struct sk_buff *pktq_penq_head(struct pktq *pq, int prec, extern struct sk_buff *pktq_pdeq(struct pktq *pq, int prec); extern struct sk_buff *pktq_pdeq_tail(struct pktq *pq, int prec); +/* packet primitives */ +extern struct sk_buff *pkt_buf_get_skb(uint len); +extern void pkt_buf_free_skb(struct sk_buff *skb); + /* Empty the queue at particular precedence level */ #ifdef BRCM_FULLMAC - extern void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, + extern void pktq_pflush(struct pktq *pq, int prec, bool dir); #else - extern void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, + extern void pktq_pflush(struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, int arg); #endif /* BRCM_FULLMAC */ @@ -144,20 +131,20 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); /* prec_out may be NULL if caller is not interested in return value */ extern struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out); #ifdef BRCM_FULLMAC - extern void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir); + extern void pktq_flush(struct pktq *pq, bool dir); #else - extern void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir, + extern void pktq_flush(struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg); #endif /* externs */ /* packet */ - extern uint pktfrombuf(struct osl_info *osh, struct sk_buff *p, + extern uint pktfrombuf(struct sk_buff *p, uint offset, int len, unsigned char *buf); - extern uint pkttotlen(struct osl_info *osh, struct sk_buff *p); + extern uint pkttotlen(struct sk_buff *p); /* ethernet address */ - extern int bcm_ether_atoe(char *p, struct ether_addr *ea); + extern int bcm_ether_atoe(char *p, u8 *ea); /* ip address */ struct ipv4_addr; @@ -167,9 +154,11 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); extern char *getvar(char *vars, const char *name); extern int getintvar(char *vars, const char *name); #ifdef BCMDBG - extern void prpkt(const char *msg, struct osl_info *osh, - struct sk_buff *p0); + extern void prpkt(const char *msg, struct sk_buff *p0); +#else +#define prpkt(a, b) #endif /* BCMDBG */ + #define bcm_perf_enable() #define bcmstats(fmt) #define bcmlog(fmt, a1, a2) @@ -369,12 +358,142 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); #define REG_MAP(pa, size) (void *)(0) #endif -/* Register operations */ -#define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v)) -#define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v)) +extern u32 g_assert_type; + +#if defined(BCMDBG_ASSERT) +#define ASSERT(exp) \ + do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0) +extern void osl_assert(char *exp, char *file, int line); +#else +#define ASSERT(exp) do {} while (0) +#endif /* defined(BCMDBG_ASSERT) */ + +/* register access macros */ +#if defined(BCMSDIO) +#ifdef BRCM_FULLMAC +#include <bcmsdh.h> +#endif +#define OSL_WRITE_REG(r, v) \ + (bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v))) +#define OSL_READ_REG(r) \ + (bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r)))) +#endif + +#if defined(BCMSDIO) +#define SELECT_BUS_WRITE(mmap_op, bus_op) bus_op +#define SELECT_BUS_READ(mmap_op, bus_op) bus_op +#else +#define SELECT_BUS_WRITE(mmap_op, bus_op) mmap_op +#define SELECT_BUS_READ(mmap_op, bus_op) mmap_op +#endif + +/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ +#define PKTBUFSZ 2048 -#define SET_REG(osh, r, mask, val) \ - W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val))) +#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) +#ifdef BRCM_FULLMAC +#include <linux/kernel.h> /* for vsn/printf's */ +#include <linux/string.h> /* for mem*, str* */ +#endif +/* bcopy's: Linux kernel doesn't provide these (anymore) */ +#define bcopy(src, dst, len) memcpy((dst), (src), (len)) + +/* register access macros */ +#ifndef IL_BIGENDIAN +#ifndef __mips__ +#define R_REG(r) (\ + SELECT_BUS_READ(sizeof(*(r)) == sizeof(u8) ? \ + readb((volatile u8*)(r)) : \ + sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \ + readl((volatile u32*)(r)), OSL_READ_REG(r)) \ +) +#else /* __mips__ */ +#define R_REG(r) (\ + SELECT_BUS_READ( \ + ({ \ + __typeof(*(r)) __osl_v; \ + __asm__ __volatile__("sync"); \ + switch (sizeof(*(r))) { \ + case sizeof(u8): \ + __osl_v = readb((volatile u8*)(r)); \ + break; \ + case sizeof(u16): \ + __osl_v = readw((volatile u16*)(r)); \ + break; \ + case sizeof(u32): \ + __osl_v = \ + readl((volatile u32*)(r)); \ + break; \ + } \ + __asm__ __volatile__("sync"); \ + __osl_v; \ + }), \ + ({ \ + __typeof(*(r)) __osl_v; \ + __asm__ __volatile__("sync"); \ + __osl_v = OSL_READ_REG(r); \ + __asm__ __volatile__("sync"); \ + __osl_v; \ + })) \ +) +#endif /* __mips__ */ + +#define W_REG(r, v) do { \ + SELECT_BUS_WRITE( \ + switch (sizeof(*(r))) { \ + case sizeof(u8): \ + writeb((u8)(v), (volatile u8*)(r)); break; \ + case sizeof(u16): \ + writew((u16)(v), (volatile u16*)(r)); break; \ + case sizeof(u32): \ + writel((u32)(v), (volatile u32*)(r)); break; \ + }, \ + (OSL_WRITE_REG(r, v))); \ + } while (0) +#else /* IL_BIGENDIAN */ +#define R_REG(r) (\ + SELECT_BUS_READ( \ + ({ \ + __typeof(*(r)) __osl_v; \ + switch (sizeof(*(r))) { \ + case sizeof(u8): \ + __osl_v = \ + readb((volatile u8*)((r)^3)); \ + break; \ + case sizeof(u16): \ + __osl_v = \ + readw((volatile u16*)((r)^2)); \ + break; \ + case sizeof(u32): \ + __osl_v = readl((volatile u32*)(r)); \ + break; \ + } \ + __osl_v; \ + }), \ + OSL_READ_REG(r)) \ +) +#define W_REG(r, v) do { \ + SELECT_BUS_WRITE( \ + switch (sizeof(*(r))) { \ + case sizeof(u8): \ + writeb((u8)(v), \ + (volatile u8*)((r)^3)); break; \ + case sizeof(u16): \ + writew((u16)(v), \ + (volatile u16*)((r)^2)); break; \ + case sizeof(u32): \ + writel((u32)(v), \ + (volatile u32*)(r)); break; \ + }, \ + (OSL_WRITE_REG(r, v))); \ + } while (0) +#endif /* IL_BIGENDIAN */ + +#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) +#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) + +#define SET_REG(r, mask, val) \ + W_REG((r), ((R_REG(r) & ~(mask)) | (val))) #ifndef setbit #ifndef NBBY /* the BSD family defines NBBY */ @@ -498,19 +617,9 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out); extern u16 bcm_qdbm_to_mw(u8 qdbm); extern u8 bcm_mw_to_qdbm(u16 mw); -/* generic datastruct to help dump routines */ - struct fielddesc { - const char *nameandfmt; - u32 offset; - u32 len; - }; - extern void bcm_binit(struct bcmstrbuf *b, char *buf, uint size); extern int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...); - typedef u32(*bcmutl_rdreg_rtn) (void *arg0, uint arg1, - u32 offset); - extern uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint len); extern uint bcm_bitcount(u8 *bitmap, uint bytelength); diff --git a/drivers/staging/brcm80211/include/bcmwifi.h b/drivers/staging/brcm80211/include/bcmwifi.h index 4067fbaacb8f..4a0f976afaa4 100644 --- a/drivers/staging/brcm80211/include/bcmwifi.h +++ b/drivers/staging/brcm80211/include/bcmwifi.h @@ -144,13 +144,6 @@ extern bool wf_chspec_malformed(chanspec_t chanspec); extern u8 wf_chspec_ctlchan(chanspec_t chspec); /* - * This function returns the chanspec that control traffic is being sent on, for legacy - * channels this is just the chanspec, for 40MHZ channels it is the upper or lowre 20MHZ - * sideband depending on the chanspec selected - */ -extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec); - -/* * Return the channel number for a given frequency and base frequency. * The returned channel number is relative to the given base frequency. * If the given base frequency is zero, a base frequency of 5 GHz is assumed for @@ -171,22 +164,4 @@ extern chanspec_t wf_chspec_ctlchspec(chanspec_t chspec); */ extern int wf_mhz2channel(uint freq, uint start_factor); -/* - * Return the center frequency in MHz of the given channel and base frequency. - * The channel number is interpreted relative to the given base frequency. - * - * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise. - * The base frequency is specified as (start_factor * 500 kHz). - * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_5_G are defined for - * 2.4 GHz and 5 GHz bands. - * The channel range of [1, 14] is only checked for a start_factor of - * WF_CHAN_FACTOR_2_4_G (4814). - * Odd start_factors produce channels on .5 MHz boundaries, in which case - * the answer is rounded down to an integral MHz. - * -1 is returned for an out of range channel. - * - * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 - */ -extern int wf_channel2mhz(uint channel, uint start_factor); - #endif /* _bcmwifi_h_ */ diff --git a/drivers/staging/brcm80211/include/hnddma.h b/drivers/staging/brcm80211/include/hnddma.h index 4c5462baf11e..5d079e77490e 100644 --- a/drivers/staging/brcm80211/include/hnddma.h +++ b/drivers/staging/brcm80211/include/hnddma.h @@ -22,6 +22,11 @@ struct hnddma_pub; #endif /* _hnddma_pub_ */ +/* map/unmap direction */ +#define DMA_TX 1 /* TX direction for DMA */ +#define DMA_RX 2 /* RX direction for DMA */ +#define BUS_SWAP32(v) (v) + /* range param for dma_getnexttxp() and dma_txreclaim */ typedef enum txd_range { HNDDMA_RANGE_ALL = 1, @@ -143,52 +148,11 @@ struct hnddma_pub { uint txnobuf; /* tx out of dma descriptors */ }; -extern struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, - si_t *sih, +extern struct hnddma_pub *dma_attach(char *name, si_t *sih, void *dmaregstx, void *dmaregsrx, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level); -#ifdef BCMDMA32 - -#define dma_detach(di) ((di)->di_fn->detach(di)) -#define dma_txreset(di) ((di)->di_fn->txreset(di)) -#define dma_rxreset(di) ((di)->di_fn->rxreset(di)) -#define dma_rxidle(di) ((di)->di_fn->rxidle(di)) -#define dma_txinit(di) ((di)->di_fn->txinit(di)) -#define dma_txenabled(di) ((di)->di_fn->txenabled(di)) -#define dma_rxinit(di) ((di)->di_fn->rxinit(di)) -#define dma_txsuspend(di) ((di)->di_fn->txsuspend(di)) -#define dma_txresume(di) ((di)->di_fn->txresume(di)) -#define dma_txsuspended(di) ((di)->di_fn->txsuspended(di)) -#define dma_txsuspendedidle(di) ((di)->di_fn->txsuspendedidle(di)) -#define dma_txfast(di, p, commit) ((di)->di_fn->txfast(di, p, commit)) -#define dma_fifoloopbackenable(di) ((di)->di_fn->fifoloopbackenable(di)) -#define dma_txstopped(di) ((di)->di_fn->txstopped(di)) -#define dma_rxstopped(di) ((di)->di_fn->rxstopped(di)) -#define dma_rxenable(di) ((di)->di_fn->rxenable(di)) -#define dma_rxenabled(di) ((di)->di_fn->rxenabled(di)) -#define dma_rx(di) ((di)->di_fn->rx(di)) -#define dma_rxfill(di) ((di)->di_fn->rxfill(di)) -#define dma_txreclaim(di, range) ((di)->di_fn->txreclaim(di, range)) -#define dma_rxreclaim(di) ((di)->di_fn->rxreclaim(di)) -#define dma_getvar(di, name) ((di)->di_fn->d_getvar(di, name)) -#define dma_getnexttxp(di, range) ((di)->di_fn->getnexttxp(di, range)) -#define dma_getnextrxp(di, forceall) ((di)->di_fn->getnextrxp(di, forceall)) -#define dma_peeknexttxp(di) ((di)->di_fn->peeknexttxp(di)) -#define dma_peeknextrxp(di) ((di)->di_fn->peeknextrxp(di)) -#define dma_rxparam_get(di, off, bufs) ((di)->di_fn->rxparam_get(di, off, bufs)) - -#define dma_txblock(di) ((di)->di_fn->txblock(di)) -#define dma_txunblock(di) ((di)->di_fn->txunblock(di)) -#define dma_txactive(di) ((di)->di_fn->txactive(di)) -#define dma_rxactive(di) ((di)->di_fn->rxactive(di)) -#define dma_txrotate(di) ((di)->di_fn->txrotate(di)) -#define dma_counterreset(di) ((di)->di_fn->counterreset(di)) -#define dma_ctrlflags(di, mask, flags) ((di)->di_fn->ctrlflags((di), (mask), (flags))) -#define dma_txpending(di) ((di)->di_fn->txpending(di)) -#define dma_txcommitted(di) ((di)->di_fn->txcommitted(di)) - -#else /* BCMDMA32 */ + extern const di_fcn_t dma64proc; #define dma_detach(di) (dma64proc.detach(di)) @@ -231,7 +195,6 @@ extern const di_fcn_t dma64proc; #define dma_txpending(di) (dma64proc.txpending(di)) #define dma_txcommitted(di) (dma64proc.txcommitted(di)) -#endif /* BCMDMA32 */ /* return addresswidth allowed * This needs to be done after SB attach but before dma attach. @@ -239,8 +202,6 @@ extern const di_fcn_t dma64proc; * This info is needed by DMA_ALLOC_CONSISTENT in dma attach */ extern uint dma_addrwidth(si_t *sih, void *dmaregs); - -/* pio helpers */ -extern void dma_txpioloopback(struct osl_info *osh, dma32regs_t *); - +void dma_walk_packets(struct hnddma_pub *dmah, void (*callback_fnc) + (void *pkt, void *arg_a), void *arg_a); #endif /* _hnddma_h_ */ diff --git a/drivers/staging/brcm80211/include/hndpmu.h b/drivers/staging/brcm80211/include/hndpmu.h index a0110e4c9ac4..3eea1f9fbc39 100644 --- a/drivers/staging/brcm80211/include/hndpmu.h +++ b/drivers/staging/brcm80211/include/hndpmu.h @@ -28,44 +28,41 @@ #define SET_LDO_VOLTAGE_LNLDO1 9 #define SET_LDO_VOLTAGE_LNLDO2_SEL 10 -extern void si_pmu_init(si_t *sih, struct osl_info *osh); -extern void si_pmu_chip_init(si_t *sih, struct osl_info *osh); -extern void si_pmu_pll_init(si_t *sih, struct osl_info *osh, u32 xtalfreq); -extern void si_pmu_res_init(si_t *sih, struct osl_info *osh); -extern void si_pmu_swreg_init(si_t *sih, struct osl_info *osh); +extern void si_pmu_init(si_t *sih); +extern void si_pmu_chip_init(si_t *sih); +extern void si_pmu_pll_init(si_t *sih, u32 xtalfreq); +extern void si_pmu_res_init(si_t *sih); +extern void si_pmu_swreg_init(si_t *sih); -extern u32 si_pmu_force_ilp(si_t *sih, struct osl_info *osh, bool force); +extern u32 si_pmu_force_ilp(si_t *sih, bool force); -extern u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh); -extern u32 si_pmu_cpu_clock(si_t *sih, struct osl_info *osh); -extern u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh); -extern u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh); -extern u32 si_pmu_ilp_clock(si_t *sih, struct osl_info *osh); +extern u32 si_pmu_si_clock(si_t *sih); +extern u32 si_pmu_cpu_clock(si_t *sih); +extern u32 si_pmu_mem_clock(si_t *sih); +extern u32 si_pmu_alp_clock(si_t *sih); +extern u32 si_pmu_ilp_clock(si_t *sih); -extern void si_pmu_set_switcher_voltage(si_t *sih, struct osl_info *osh, +extern void si_pmu_set_switcher_voltage(si_t *sih, u8 bb_voltage, u8 rf_voltage); -extern void si_pmu_set_ldo_voltage(si_t *sih, struct osl_info *osh, u8 ldo, - u8 voltage); -extern u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh); -extern void si_pmu_rcal(si_t *sih, struct osl_info *osh); +extern void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage); +extern u16 si_pmu_fast_pwrup_delay(si_t *sih); +extern void si_pmu_rcal(si_t *sih); extern void si_pmu_pllupd(si_t *sih); -extern void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid); +extern void si_pmu_spuravoid(si_t *sih, u8 spuravoid); -extern bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh); -extern u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh); +extern bool si_pmu_is_otp_powered(si_t *sih); +extern u32 si_pmu_measure_alpclk(si_t *sih); extern u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val); extern u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val); extern u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val); extern void si_pmu_pllupd(si_t *sih); -extern void si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable); +extern void si_pmu_sprom_enable(si_t *sih, bool enable); extern void si_pmu_radio_enable(si_t *sih, bool enable); -extern u32 si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, - u32 clk, u32 delay); +extern u32 si_pmu_waitforclk_on_backplane(si_t *sih, u32 clk, u32 delay); -extern void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on); -extern void si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, - u32 drivestrength); +extern void si_pmu_otp_power(si_t *sih, bool on); +extern void si_sdiod_drive_strength_init(si_t *sih, u32 drivestrength); #endif /* _hndpmu_h_ */ diff --git a/drivers/staging/brcm80211/include/nicpci.h b/drivers/staging/brcm80211/include/nicpci.h index 928818daedd7..30321eb0477e 100644 --- a/drivers/staging/brcm80211/include/nicpci.h +++ b/drivers/staging/brcm80211/include/nicpci.h @@ -45,17 +45,17 @@ #else struct sbpcieregs; -extern u8 pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, +extern u8 pcicore_find_pci_capability(void *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen); -extern uint pcie_readreg(struct osl_info *osh, struct sbpcieregs *pcieregs, +extern uint pcie_readreg(struct sbpcieregs *pcieregs, uint addrtype, uint offset); -extern uint pcie_writereg(struct osl_info *osh, struct sbpcieregs *pcieregs, +extern uint pcie_writereg(struct sbpcieregs *pcieregs, uint addrtype, uint offset, uint val); extern u8 pcie_clkreq(void *pch, u32 mask, u32 val); extern u32 pcie_lcreg(void *pch, u32 mask, u32 val); -extern void *pcicore_init(si_t *sih, struct osl_info *osh, void *regs); +extern void *pcicore_init(si_t *sih, void *pdev, void *regs); extern void pcicore_deinit(void *pch); extern void pcicore_attach(void *pch, char *pvars, int state); extern void pcicore_hwup(void *pch); @@ -70,7 +70,7 @@ extern u32 pcicore_pcieserdesreg(void *pch, u32 mdioslave, u32 offset, extern u32 pcicore_pciereg(void *pch, u32 offset, u32 mask, u32 val, uint type); -extern bool pcicore_pmecap_fast(struct osl_info *osh); +extern bool pcicore_pmecap_fast(void *pch); extern void pcicore_pmeen(void *pch); extern void pcicore_pmeclr(void *pch); extern bool pcicore_pmestat(void *pch); diff --git a/drivers/staging/brcm80211/include/osl.h b/drivers/staging/brcm80211/include/osl.h deleted file mode 100644 index b28235618d8b..000000000000 --- a/drivers/staging/brcm80211/include/osl.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _osl_h_ -#define _osl_h_ - -/* osl handle type forward declaration */ -struct osl_info { - uint pktalloced; /* Number of allocated packet buffers */ - bool mmbus; /* Bus supports memory-mapped registers */ - uint magic; - void *pdev; - uint bustype; -}; - -typedef struct osl_dmainfo osldma_t; - - -extern struct osl_info *osl_attach(void *pdev, uint bustype); -extern void osl_detach(struct osl_info *osh); - -extern u32 g_assert_type; - -#if defined(BCMDBG_ASSERT) -#define ASSERT(exp) \ - do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0) -extern void osl_assert(char *exp, char *file, int line); -#else -#define ASSERT(exp) do {} while (0) -#endif /* defined(BCMDBG_ASSERT) */ - -/* PCI device bus # and slot # */ -#define OSL_PCI_BUS(osh) osl_pci_bus(osh) -#define OSL_PCI_SLOT(osh) osl_pci_slot(osh) -extern uint osl_pci_bus(struct osl_info *osh); -extern uint osl_pci_slot(struct osl_info *osh); - -#define BUS_SWAP32(v) (v) - -extern void *osl_dma_alloc_consistent(struct osl_info *osh, uint size, - u16 align, uint *tot, unsigned long *pap); - -#ifdef BRCM_FULLMAC -#define DMA_ALLOC_CONSISTENT(osh, size, pap, dmah, alignbits) \ - osl_dma_alloc_consistent((osh), (size), (0), (tot), (pap)) -#else -#define DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \ - osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap)) -#endif /* BRCM_FULLMAC */ - -#define DMA_FREE_CONSISTENT(osh, va, size, pa, dmah) \ - osl_dma_free_consistent((osh), (void *)(va), (size), (pa)) -extern void osl_dma_free_consistent(struct osl_info *osh, void *va, - uint size, unsigned long pa); - -/* map/unmap direction */ -#define DMA_TX 1 /* TX direction for DMA */ -#define DMA_RX 2 /* RX direction for DMA */ - -/* map/unmap shared (dma-able) memory */ -#define DMA_MAP(osh, va, size, direction, p, dmah) \ - osl_dma_map((osh), (va), (size), (direction)) -#define DMA_UNMAP(osh, pa, size, direction, p, dmah) \ - osl_dma_unmap((osh), (pa), (size), (direction)) -extern uint osl_dma_map(struct osl_info *osh, void *va, uint size, - int direction); -extern void osl_dma_unmap(struct osl_info *osh, uint pa, uint size, - int direction); - -/* register access macros */ -#if defined(BCMSDIO) -#ifdef BRCM_FULLMAC -#include <bcmsdh.h> -#endif -#define OSL_WRITE_REG(osh, r, v) \ - (bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v))) -#define OSL_READ_REG(osh, r) \ - (bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r)))) -#endif - -#if defined(BCMSDIO) -#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) \ - if ((osh)->mmbus) \ - mmap_op else bus_op -#define SELECT_BUS_READ(osh, mmap_op, bus_op) \ - ((osh)->mmbus) ? mmap_op : bus_op -#else -#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) mmap_op -#define SELECT_BUS_READ(osh, mmap_op, bus_op) mmap_op -#endif - -/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */ -#define PKTBUFSZ 2048 - -#define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ)) -#define printf(fmt, args...) printk(fmt , ## args) -#ifdef BRCM_FULLMAC -#include <linux/kernel.h> /* for vsn/printf's */ -#include <linux/string.h> /* for mem*, str* */ -#endif -/* bcopy's: Linux kernel doesn't provide these (anymore) */ -#define bcopy(src, dst, len) memcpy((dst), (src), (len)) - -/* register access macros */ -#ifndef IL_BIGENDIAN -#ifndef __mips__ -#define R_REG(osh, r) (\ - SELECT_BUS_READ(osh, sizeof(*(r)) == sizeof(u8) ? \ - readb((volatile u8*)(r)) : \ - sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \ - readl((volatile u32*)(r)), OSL_READ_REG(osh, r)) \ -) -#else /* __mips__ */ -#define R_REG(osh, r) (\ - SELECT_BUS_READ(osh, \ - ({ \ - __typeof(*(r)) __osl_v; \ - __asm__ __volatile__("sync"); \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - __osl_v = readb((volatile u8*)(r)); \ - break; \ - case sizeof(u16): \ - __osl_v = readw((volatile u16*)(r)); \ - break; \ - case sizeof(u32): \ - __osl_v = \ - readl((volatile u32*)(r)); \ - break; \ - } \ - __asm__ __volatile__("sync"); \ - __osl_v; \ - }), \ - ({ \ - __typeof(*(r)) __osl_v; \ - __asm__ __volatile__("sync"); \ - __osl_v = OSL_READ_REG(osh, r); \ - __asm__ __volatile__("sync"); \ - __osl_v; \ - })) \ -) -#endif /* __mips__ */ - -#define W_REG(osh, r, v) do { \ - SELECT_BUS_WRITE(osh, \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - writeb((u8)(v), (volatile u8*)(r)); break; \ - case sizeof(u16): \ - writew((u16)(v), (volatile u16*)(r)); break; \ - case sizeof(u32): \ - writel((u32)(v), (volatile u32*)(r)); break; \ - }, \ - (OSL_WRITE_REG(osh, r, v))); \ - } while (0) -#else /* IL_BIGENDIAN */ -#define R_REG(osh, r) (\ - SELECT_BUS_READ(osh, \ - ({ \ - __typeof(*(r)) __osl_v; \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - __osl_v = \ - readb((volatile u8*)((r)^3)); \ - break; \ - case sizeof(u16): \ - __osl_v = \ - readw((volatile u16*)((r)^2)); \ - break; \ - case sizeof(u32): \ - __osl_v = readl((volatile u32*)(r)); \ - break; \ - } \ - __osl_v; \ - }), \ - OSL_READ_REG(osh, r)) \ -) -#define W_REG(osh, r, v) do { \ - SELECT_BUS_WRITE(osh, \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - writeb((u8)(v), \ - (volatile u8*)((r)^3)); break; \ - case sizeof(u16): \ - writew((u16)(v), \ - (volatile u16*)((r)^2)); break; \ - case sizeof(u32): \ - writel((u32)(v), \ - (volatile u32*)(r)); break; \ - }, \ - (OSL_WRITE_REG(osh, r, v))); \ - } while (0) -#endif /* IL_BIGENDIAN */ - -#define bcopy(src, dst, len) memcpy((dst), (src), (len)) - -/* packet primitives */ -extern struct sk_buff *pkt_buf_get_skb(struct osl_info *osh, uint len); -extern void pkt_buf_free_skb(struct osl_info *osh, struct sk_buff *skb, bool send); - -#endif /* _osl_h_ */ diff --git a/drivers/staging/brcm80211/include/packed_section_end.h b/drivers/staging/brcm80211/include/packed_section_end.h deleted file mode 100644 index 04c7d43e1286..000000000000 --- a/drivers/staging/brcm80211/include/packed_section_end.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Error check - BWL_PACKED_SECTION is defined in packed_section_start.h - * and undefined in packed_section_end.h. If it is NOT defined at this - * point, then there is a missing include of packed_section_start.h. - */ -#ifdef BWL_PACKED_SECTION -#undef BWL_PACKED_SECTION -#else -#error "BWL_PACKED_SECTION is NOT defined!" -#endif - -/* Compiler-specific directives for structure packing are declared in - * packed_section_start.h. This marks the end of the structure packing section, - * so, undef them here. - */ -#undef BWL_PRE_PACKED_STRUCT -#undef BWL_POST_PACKED_STRUCT diff --git a/drivers/staging/brcm80211/include/packed_section_start.h b/drivers/staging/brcm80211/include/packed_section_start.h deleted file mode 100644 index 60e862a0c213..000000000000 --- a/drivers/staging/brcm80211/include/packed_section_start.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* Error check - BWL_PACKED_SECTION is defined in packed_section_start.h - * and undefined in packed_section_end.h. If it is already defined at this - * point, then there is a missing include of packed_section_end.h. - */ -#ifdef BWL_PACKED_SECTION -#error "BWL_PACKED_SECTION is already defined!" -#else -#define BWL_PACKED_SECTION -#endif - -/* Declare compiler-specific directives for structure packing. */ -#if defined(__GNUC__) -#define BWL_PRE_PACKED_STRUCT -#define BWL_POST_PACKED_STRUCT __attribute__((packed)) -#elif defined(__CC_ARM) -#define BWL_PRE_PACKED_STRUCT __packed -#define BWL_POST_PACKED_STRUCT -#else -#error "Unknown compiler!" -#endif diff --git a/drivers/staging/brcm80211/include/pcicfg.h b/drivers/staging/brcm80211/include/pcicfg.h index 3a19e1d243cf..675554a1d341 100644 --- a/drivers/staging/brcm80211/include/pcicfg.h +++ b/drivers/staging/brcm80211/include/pcicfg.h @@ -388,7 +388,7 @@ typedef struct _pciconfig_cap_msi { u32 msgaddr; } pciconfig_cap_msi; -/* Data structure to define the Power managment facility +/* Data structure to define the Power management facility * Valid for PCI and PCIE configurations */ typedef struct _pciconfig_cap_pwrmgmt { @@ -465,8 +465,8 @@ typedef struct _pcie_enhanced_caphdr { #define bar0_window dev_dep[0x80 - 0x40] #define bar1_window dev_dep[0x84 - 0x40] #define sprom_control dev_dep[0x88 - 0x40] -#define PCI_BAR0_WIN 0x80 /* backplane addres space accessed by BAR0 */ -#define PCI_BAR1_WIN 0x84 /* backplane addres space accessed by BAR1 */ +#define PCI_BAR0_WIN 0x80 /* backplane address space accessed by BAR0 */ +#define PCI_BAR1_WIN 0x84 /* backplane address space accessed by BAR1 */ #define PCI_SPROM_CONTROL 0x88 /* sprom property control */ #define PCI_BAR1_CONTROL 0x8c /* BAR1 region burst control */ #define PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */ @@ -475,7 +475,7 @@ typedef struct _pcie_enhanced_caphdr { #define PCI_BACKPLANE_ADDR 0xa0 /* address an arbitrary location on the system backplane */ #define PCI_BACKPLANE_DATA 0xa4 /* data at the location specified by above address */ #define PCI_CLK_CTL_ST 0xa8 /* pci config space clock control/status (>=rev14) */ -#define PCI_BAR0_WIN2 0xac /* backplane addres space accessed by second 4KB of BAR0 */ +#define PCI_BAR0_WIN2 0xac /* backplane address space accessed by second 4KB of BAR0 */ #define PCI_GPIO_IN 0xb0 /* pci config space gpio input (>=rev3) */ #define PCI_GPIO_OUT 0xb4 /* pci config space gpio output (>=rev3) */ #define PCI_GPIO_OUTEN 0xb8 /* pci config space gpio output enable (>=rev3) */ diff --git a/drivers/staging/brcm80211/include/proto/802.11.h b/drivers/staging/brcm80211/include/proto/802.11.h index ffde19c5ac5c..374125d770b9 100644 --- a/drivers/staging/brcm80211/include/proto/802.11.h +++ b/drivers/staging/brcm80211/include/proto/802.11.h @@ -17,20 +17,16 @@ #ifndef _802_11_H_ #define _802_11_H_ -#include <proto/wpa.h> -#include <packed_section_start.h> +#include <linux/if_ether.h> #define DOT11_A3_HDR_LEN 24 #define DOT11_A4_HDR_LEN 30 #define DOT11_MAC_HDR_LEN DOT11_A3_HDR_LEN -#define DOT11_FCS_LEN 4 #define DOT11_ICV_AES_LEN 8 #define DOT11_QOS_LEN 2 #define DOT11_IV_MAX_LEN 8 -#define DOT11_MAX_SSID_LEN 32 - #define DOT11_DEFAULT_RTS_LEN 2347 #define DOT11_MIN_FRAG_LEN 256 @@ -45,23 +41,6 @@ #define DOT11_OUI_LEN 3 -BWL_PRE_PACKED_STRUCT struct dot11_header { - u16 fc; - u16 durid; - struct ether_addr a1; - struct ether_addr a2; - struct ether_addr a3; - u16 seq; - struct ether_addr a4; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct dot11_rts_frame { - u16 fc; - u16 durid; - struct ether_addr ra; - struct ether_addr ta; -} BWL_POST_PACKED_STRUCT; - #define DOT11_RTS_LEN 16 #define DOT11_CTS_LEN 10 #define DOT11_ACK_LEN 10 @@ -69,23 +48,6 @@ BWL_PRE_PACKED_STRUCT struct dot11_rts_frame { #define DOT11_BA_BITMAP_LEN 128 #define DOT11_BA_LEN 4 -BWL_PRE_PACKED_STRUCT struct dot11_management_header { - u16 fc; - u16 durid; - struct ether_addr da; - struct ether_addr sa; - struct ether_addr bssid; - u16 seq; -} BWL_POST_PACKED_STRUCT; -#define DOT11_MGMT_HDR_LEN 24 - -BWL_PRE_PACKED_STRUCT struct dot11_bcn_prb { - u32 timestamp[2]; - u16 beacon_interval; - u16 capability; -} BWL_POST_PACKED_STRUCT; -#define DOT11_BCN_PRB_LEN 12 - #define WME_OUI "\x00\x50\xf2" #define WME_VER 1 #define WME_TYPE 2 @@ -102,14 +64,14 @@ typedef u8 ac_bitmap_t; #define AC_BITMAP_ALL 0xf #define AC_BITMAP_TST(ab, ac) (((ab) & (1 << (ac))) != 0) -BWL_PRE_PACKED_STRUCT struct edcf_acparam { +struct edcf_acparam { u8 ACI; u8 ECW; u16 TXOP; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); typedef struct edcf_acparam edcf_acparam_t; -BWL_PRE_PACKED_STRUCT struct wme_param_ie { +struct wme_param_ie { u8 oui[3]; u8 type; u8 subtype; @@ -117,7 +79,7 @@ BWL_PRE_PACKED_STRUCT struct wme_param_ie { u8 qosinfo; u8 rsvd; edcf_acparam_t acparam[AC_COUNT]; -} BWL_POST_PACKED_STRUCT; +} __attribute__((packed)); typedef struct wme_param_ie wme_param_ie_t; #define WME_PARAM_IE_LEN 24 @@ -150,60 +112,14 @@ typedef struct wme_param_ie wme_param_ie_t; #define EDCF_AC_VO_TXOP_AP 0x002f -#define DOT11_OPEN_SYSTEM 0 -#define DOT11_SHARED_KEY 1 - -#define FC_TYPE_MASK 0xC -#define FC_TYPE_SHIFT 2 -#define FC_SUBTYPE_MASK 0xF0 -#define FC_SUBTYPE_SHIFT 4 -#define FC_MOREFRAG 0x400 - #define SEQNUM_SHIFT 4 #define SEQNUM_MAX 0x1000 #define FRAGNUM_MASK 0xF -#define FC_TYPE_MNG 0 -#define FC_TYPE_CTL 1 -#define FC_TYPE_DATA 2 - -#define FC_SUBTYPE_PROBE_REQ 4 -#define FC_SUBTYPE_PROBE_RESP 5 -#define FC_SUBTYPE_BEACON 8 -#define FC_SUBTYPE_PS_POLL 10 -#define FC_SUBTYPE_RTS 11 -#define FC_SUBTYPE_CTS 12 - -#define FC_SUBTYPE_ANY_QOS(s) (((s) & 8) != 0) - -#define FC_KIND_MASK (FC_TYPE_MASK | FC_SUBTYPE_MASK) - -#define FC_KIND(t, s) (((t) << FC_TYPE_SHIFT) | ((s) << FC_SUBTYPE_SHIFT)) - -#define FC_SUBTYPE(fc) (((fc) & FC_SUBTYPE_MASK) >> FC_SUBTYPE_SHIFT) -#define FC_TYPE(fc) (((fc) & FC_TYPE_MASK) >> FC_TYPE_SHIFT) - -#define FC_PROBE_REQ FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_REQ) -#define FC_PROBE_RESP FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_PROBE_RESP) -#define FC_BEACON FC_KIND(FC_TYPE_MNG, FC_SUBTYPE_BEACON) -#define FC_PS_POLL FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_PS_POLL) -#define FC_RTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_RTS) -#define FC_CTS FC_KIND(FC_TYPE_CTL, FC_SUBTYPE_CTS) - -#define TLV_LEN_OFF 1 -#define TLV_HDR_LEN 2 -#define TLV_BODY_OFF 2 - #define DOT11_MNG_RSN_ID 48 #define DOT11_MNG_WPA_ID 221 #define DOT11_MNG_VS_ID 221 -#define DOT11_CAP_ESS 0x0001 -#define DOT11_CAP_IBSS 0x0002 -#define DOT11_CAP_PRIVACY 0x0010 -#define DOT11_CAP_SHORT 0x0020 -#define DOT11_CAP_SHORTSLOT 0x0400 - #define DOT11_BSSTYPE_INFRASTRUCTURE 0 #define DOT11_BSSTYPE_ANY 2 #define DOT11_SCANTYPE_ACTIVE 0 @@ -253,43 +169,12 @@ typedef struct d11cnt { #define MCSSET_LEN 16 -BWL_PRE_PACKED_STRUCT struct ht_cap_ie { - u16 cap; - u8 params; - u8 supp_mcs[MCSSET_LEN]; - u16 ext_htcap; - u32 txbf_cap; - u8 as_cap; -} BWL_POST_PACKED_STRUCT; -typedef struct ht_cap_ie ht_cap_ie_t; - #define HT_CAP_IE_LEN 26 -#define HT_CAP_LDPC_CODING 0x0001 -#define HT_CAP_40MHZ 0x0002 -#define HT_CAP_MIMO_PS_MASK 0x000C -#define HT_CAP_MIMO_PS_SHIFT 0x0002 -#define HT_CAP_MIMO_PS_OFF 0x0003 -#define HT_CAP_MIMO_PS_ON 0x0000 -#define HT_CAP_GF 0x0010 -#define HT_CAP_SHORT_GI_20 0x0020 -#define HT_CAP_SHORT_GI_40 0x0040 -#define HT_CAP_TX_STBC 0x0080 -#define HT_CAP_RX_STBC_MASK 0x0300 -#define HT_CAP_RX_STBC_SHIFT 8 -#define HT_CAP_MAX_AMSDU 0x0800 -#define HT_CAP_DSSS_CCK 0x1000 -#define HT_CAP_40MHZ_INTOLERANT 0x4000 - #define HT_CAP_RX_STBC_NO 0x0 #define HT_CAP_RX_STBC_ONE_STREAM 0x1 -#define HT_PARAMS_RX_FACTOR_MASK 0x03 - -#define AMPDU_MAX_MPDU_DENSITY 7 -#define AMPDU_RX_FACTOR_16K 1 -#define AMPDU_RX_FACTOR_32K 2 -#define AMPDU_RX_FACTOR_64K 3 +#define AMPDU_MAX_MPDU_DENSITY IEEE80211_HT_MPDU_DENSITY_16 #define AMPDU_DELIMITER_LEN 4 @@ -308,15 +193,8 @@ typedef struct ht_cap_ie ht_cap_ie_t; #define RSN_AKM_PSK 2 #define DOT11_MAX_DEFAULT_KEYS 4 -#define DOT11_MAX_KEY_SIZE 32 #define DOT11_WPA_KEY_RSC_LEN 8 -#define WEP1_KEY_SIZE 5 -#define WEP128_KEY_SIZE 13 -#define TKIP_KEY_SIZE 32 -#define AES_KEY_SIZE 16 - #define BRCM_OUI "\x00\x10\x18" -#include <packed_section_end.h> #endif /* _802_11_H_ */ diff --git a/drivers/staging/brcm80211/include/proto/802.1d.h b/drivers/staging/brcm80211/include/proto/802.1d.h deleted file mode 100644 index 9802d8776628..000000000000 --- a/drivers/staging/brcm80211/include/proto/802.1d.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _802_1_D_ -#define _802_1_D_ - -#define PRIO_8021D_NONE 2 -#define PRIO_8021D_BK 1 -#define PRIO_8021D_BE 0 -#define PRIO_8021D_EE 3 -#define PRIO_8021D_CL 4 -#define PRIO_8021D_VI 5 -#define PRIO_8021D_VO 6 -#define PRIO_8021D_NC 7 -#define MAXPRIO 7 -#define NUMPRIO (MAXPRIO + 1) - -#define ALLPRIO -1 - -#define PRIO2PREC(prio) \ - (((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? \ - ((prio^2)) : (prio)) - -#endif /* _802_1_D_ */ diff --git a/drivers/staging/brcm80211/include/proto/bcmeth.h b/drivers/staging/brcm80211/include/proto/bcmeth.h index f7d3d8dfd3ae..e98ee654458d 100644 --- a/drivers/staging/brcm80211/include/proto/bcmeth.h +++ b/drivers/staging/brcm80211/include/proto/bcmeth.h @@ -17,8 +17,6 @@ #ifndef _BCMETH_H_ #define _BCMETH_H_ -#include <packed_section_start.h> - #define BCMILCP_SUBTYPE_RATE 1 #define BCMILCP_SUBTYPE_LINK 2 #define BCMILCP_SUBTYPE_CSA 3 @@ -35,14 +33,12 @@ #define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8 #define BCMILCP_BCM_SUBTYPEHDR_VERSION 0 -typedef BWL_PRE_PACKED_STRUCT struct bcmeth_hdr { +typedef struct bcmeth_hdr { u16 subtype; u16 length; u8 version; u8 oui[3]; u16 usr_subtype; -} BWL_POST_PACKED_STRUCT bcmeth_hdr_t; - -#include <packed_section_end.h> +} __attribute__((packed)) bcmeth_hdr_t; #endif /* _BCMETH_H_ */ diff --git a/drivers/staging/brcm80211/include/proto/bcmevent.h b/drivers/staging/brcm80211/include/proto/bcmevent.h index 865d15767a00..1b60789aef05 100644 --- a/drivers/staging/brcm80211/include/proto/bcmevent.h +++ b/drivers/staging/brcm80211/include/proto/bcmevent.h @@ -17,7 +17,7 @@ #ifndef _BCMEVENT_H_ #define _BCMEVENT_H_ -#include <packed_section_start.h> +#include <linux/if_ether.h> #define BCM_EVENT_MSG_VERSION 1 #define BCM_MSG_IFNAME_MAX 16 @@ -26,7 +26,7 @@ #define WLC_EVENT_MSG_FLUSHTXQ 0x02 #define WLC_EVENT_MSG_GROUP 0x04 -typedef BWL_PRE_PACKED_STRUCT struct { +typedef struct { u16 version; u16 flags; u32 event_type; @@ -34,16 +34,16 @@ typedef BWL_PRE_PACKED_STRUCT struct { u32 reason; u32 auth_type; u32 datalen; - struct ether_addr addr; + u8 addr[ETH_ALEN]; char ifname[BCM_MSG_IFNAME_MAX]; -} BWL_POST_PACKED_STRUCT wl_event_msg_t; +} __attribute__((packed)) wl_event_msg_t; #ifdef BRCM_FULLMAC -typedef BWL_PRE_PACKED_STRUCT struct bcm_event { - struct ether_header eth; +typedef struct bcm_event { + struct ethhdr eth; bcmeth_hdr_t bcm_hdr; wl_event_msg_t event; -} BWL_POST_PACKED_STRUCT bcm_event_t; +} __attribute__((packed)) bcm_event_t; #endif #define BCM_MSG_LEN (sizeof(bcm_event_t) - sizeof(bcmeth_hdr_t) - \ sizeof(struct ether_header)) @@ -191,14 +191,6 @@ extern const int bcmevent_names_size; #define WLC_E_SUP_SEND_FAIL 13 #define WLC_E_SUP_DEAUTH 14 -typedef struct wl_event_data_if { - u8 ifidx; - u8 opcode; - u8 reserved; - u8 bssidx; - u8 role; -} wl_event_data_if_t; - #define WLC_E_IF_ADD 1 #define WLC_E_IF_DEL 2 #define WLC_E_IF_CHANGE 3 @@ -212,6 +204,4 @@ typedef struct wl_event_data_if { #define WLC_E_LINK_ASSOC_REC 3 #define WLC_E_LINK_BSSCFG_DIS 4 -#include <packed_section_end.h> - #endif /* _BCMEVENT_H_ */ diff --git a/drivers/staging/brcm80211/include/proto/ethernet.h b/drivers/staging/brcm80211/include/proto/ethernet.h deleted file mode 100644 index 567407de020e..000000000000 --- a/drivers/staging/brcm80211/include/proto/ethernet.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _NET_ETHERNET_H_ -#define _NET_ETHERNET_H_ - -#include <linux/if_ether.h> - -#include <packed_section_start.h> - -#define ETHER_TYPE_LEN 2 -#define ETHER_CRC_LEN 4 -#define ETHER_MIN_LEN 64 -#define ETHER_MIN_DATA 46 -#define ETHER_MAX_LEN 1518 -#define ETHER_MAX_DATA 1500 - -#define ETHER_TYPE_BRCM 0x886c - -#define ETHER_DEST_OFFSET (0 * ETH_ALEN) -#define ETHER_SRC_OFFSET (1 * ETH_ALEN) -#define ETHER_TYPE_OFFSET (2 * ETH_ALEN) - -#define ETHER_IS_VALID_LEN(foo) \ - ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) - -#define ETHER_FILL_MCAST_ADDR_FROM_IP(ea, mgrp_ip) { \ - ((u8 *)ea)[0] = 0x01; \ - ((u8 *)ea)[1] = 0x00; \ - ((u8 *)ea)[2] = 0x5e; \ - ((u8 *)ea)[3] = ((mgrp_ip) >> 16) & 0x7f; \ - ((u8 *)ea)[4] = ((mgrp_ip) >> 8) & 0xff; \ - ((u8 *)ea)[5] = ((mgrp_ip) >> 0) & 0xff; \ -} - -BWL_PRE_PACKED_STRUCT struct ether_header { - u8 ether_dhost[ETH_ALEN]; - u8 ether_shost[ETH_ALEN]; - u16 ether_type; -} BWL_POST_PACKED_STRUCT; - -BWL_PRE_PACKED_STRUCT struct ether_addr { - u8 octet[ETH_ALEN]; -} BWL_POST_PACKED_STRUCT; - -#define ETHER_SET_UNICAST(ea) (((u8 *)(ea))[0] = (((u8 *)(ea))[0] & ~1)) - -static const struct ether_addr ether_bcast = { {255, 255, 255, 255, 255, 255} }; - -#define ETHER_MOVE_HDR(d, s) \ -do { \ - struct ether_header t; \ - t = *(struct ether_header *)(s); \ - *(struct ether_header *)(d) = t; \ -} while (0) - -#include <packed_section_end.h> - -#endif /* _NET_ETHERNET_H_ */ diff --git a/drivers/staging/brcm80211/include/proto/wpa.h b/drivers/staging/brcm80211/include/proto/wpa.h deleted file mode 100644 index 10c2fb62df09..000000000000 --- a/drivers/staging/brcm80211/include/proto/wpa.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _proto_wpa_h_ -#define _proto_wpa_h_ - -#include <proto/ethernet.h> - -#define WPA2_PMKID_LEN 16 -#define RSN_CAP_1_REPLAY_CNTR 0 -#define RSN_CAP_2_REPLAY_CNTRS 1 -#define RSN_CAP_4_REPLAY_CNTRS 2 -#define RSN_CAP_16_REPLAY_CNTRS 3 - -#define WPA_CAP_4_REPLAY_CNTRS RSN_CAP_4_REPLAY_CNTRS -#define WPA_CAP_16_REPLAY_CNTRS RSN_CAP_16_REPLAY_CNTRS -#define WPA_CAP_REPLAY_CNTR_SHIFT RSN_CAP_PTK_REPLAY_CNTR_SHIFT -#define WPA_CAP_REPLAY_CNTR_MASK RSN_CAP_PTK_REPLAY_CNTR_MASK - -#endif /* _proto_wpa_h_ */ diff --git a/drivers/staging/brcm80211/include/rpc_osl.h b/drivers/staging/brcm80211/include/rpc_osl.h deleted file mode 100644 index c59d9ed1397a..000000000000 --- a/drivers/staging/brcm80211/include/rpc_osl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _rpcosl_h_ -#define _rpcosl_h_ - -typedef struct rpc_osl rpc_osl_t; -extern rpc_osl_t *rpc_osl_attach(struct osl_info *osh); -extern void rpc_osl_detach(rpc_osl_t *rpc_osh); - -#define RPC_OSL_LOCK(rpc_osh) rpc_osl_lock((rpc_osh)) -#define RPC_OSL_UNLOCK(rpc_osh) rpc_osl_unlock((rpc_osh)) -#define RPC_OSL_WAIT(rpc_osh, to, ptimedout) rpc_osl_wait((rpc_osh), (to), (ptimedout)) -#define RPC_OSL_WAKE(rpc_osh) rpc_osl_wake((rpc_osh)) -extern void rpc_osl_lock(rpc_osl_t *rpc_osh); -extern void rpc_osl_unlock(rpc_osl_t *rpc_osh); -extern int rpc_osl_wait(rpc_osl_t *rpc_osh, uint ms, bool *ptimedout); -extern void rpc_osl_wake(rpc_osl_t *rpc_osh); - -#endif /* _rpcosl_h_ */ diff --git a/drivers/staging/brcm80211/include/sbhnddma.h b/drivers/staging/brcm80211/include/sbhnddma.h index 09e6d33ee579..08cb7f6e0d85 100644 --- a/drivers/staging/brcm80211/include/sbhnddma.h +++ b/drivers/staging/brcm80211/include/sbhnddma.h @@ -190,7 +190,7 @@ typedef volatile struct { } dma64dd_t; /* - * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical addresss. + * Each descriptor ring must be 8kB aligned, and fit within a contiguous 8kB physical address. */ #define D64RINGALIGN_BITS 13 #define D64MAXRINGSZ (1 << D64RINGALIGN_BITS) @@ -303,7 +303,7 @@ typedef volatile struct { #define D64_RX_FRM_STS_LEN 0x0000ffff /* frame length mask */ #define D64_RX_FRM_STS_OVFL 0x00800000 /* RxOverFlow */ -#define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1, d11corerev >= 22 */ +#define D64_RX_FRM_STS_DSCRCNT 0x0f000000 /* no. of descriptors used - 1 */ #define D64_RX_FRM_STS_DATATYPE 0xf0000000 /* core-dependent data type */ /* receive frame status */ diff --git a/drivers/staging/brcm80211/include/sbhndpio.h b/drivers/staging/brcm80211/include/sbhndpio.h deleted file mode 100644 index 9eabdb56da73..000000000000 --- a/drivers/staging/brcm80211/include/sbhndpio.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _sbhndpio_h_ -#define _sbhndpio_h_ - -/* PIO structure, - * support two PIO format: 2 bytes access and 4 bytes access - * basic FIFO register set is per channel(transmit or receive) - * a pair of channels is defined for convenience - */ - -/* 2byte-wide pio register set per channel(xmt or rcv) */ -typedef volatile struct { - u16 fifocontrol; - u16 fifodata; - u16 fifofree; /* only valid in xmt channel, not in rcv channel */ - u16 PAD; -} pio2regs_t; - -/* a pair of pio channels(tx and rx) */ -typedef volatile struct { - pio2regs_t tx; - pio2regs_t rx; -} pio2regp_t; - -/* 4byte-wide pio register set per channel(xmt or rcv) */ -typedef volatile struct { - u32 fifocontrol; - u32 fifodata; -} pio4regs_t; - -/* a pair of pio channels(tx and rx) */ -typedef volatile struct { - pio4regs_t tx; - pio4regs_t rx; -} pio4regp_t; - -#endif /* _sbhndpio_h_ */ diff --git a/drivers/staging/brcm80211/include/sbsdio.h b/drivers/staging/brcm80211/include/sbsdio.h index 6afdbbe67e19..c7facd3795a0 100644 --- a/drivers/staging/brcm80211/include/sbsdio.h +++ b/drivers/staging/brcm80211/include/sbsdio.h @@ -144,7 +144,7 @@ */ #define SBSDIO_BYTEMODE_DATALEN_MAX 64 /* sdio byte mode: maximum length of one - * data comamnd + * data command */ #define SBSDIO_CORE_ADDR_MASK 0x1FFFF /* sdio core function one address mask */ diff --git a/drivers/staging/brcm80211/include/siutils.h b/drivers/staging/brcm80211/include/siutils.h index a935092d02df..101e9a4f807d 100644 --- a/drivers/staging/brcm80211/include/siutils.h +++ b/drivers/staging/brcm80211/include/siutils.h @@ -118,8 +118,8 @@ typedef void (*gpio_handler_t) (u32 stat, void *arg); #define GPIO_CTRL_EPA_EN_MASK 0x40 /* === exported functions === */ -extern si_t *si_attach(uint pcidev, struct osl_info *osh, void *regs, - uint bustype, void *sdh, char **vars, uint *varsz); +extern si_t *si_attach(uint pcidev, void *regs, uint bustype, + void *sdh, char **vars, uint *varsz); extern void si_detach(si_t *sih); extern bool si_pci_war16165(si_t *sih); @@ -128,7 +128,6 @@ extern uint si_coreid(si_t *sih); extern uint si_flag(si_t *sih); extern uint si_coreidx(si_t *sih); extern uint si_corerev(si_t *sih); -struct osl_info *si_osh(si_t *sih); extern uint si_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val); extern void si_write_wrapperreg(si_t *sih, u32 offset, u32 val); @@ -173,10 +172,6 @@ extern void si_sdio_init(si_t *sih); #define si_eci_init(sih) (0) #define si_eci_notify_bt(sih, type, val) (0) #define si_seci(sih) 0 -static inline void *si_seci_init(si_t *sih, u8 use_seci) -{ - return NULL; -} /* OTP status */ extern bool si_is_otp_disabled(si_t *sih); @@ -192,7 +187,7 @@ extern void si_sprom_init(si_t *sih); #define SI_ERROR(args) #ifdef BCMDBG -#define SI_MSG(args) printf args +#define SI_MSG(args) printk args #else #define SI_MSG(args) #endif /* BCMDBG */ @@ -216,9 +211,8 @@ typedef struct gpioh_item { /* misc si info needed by some of the routines */ typedef struct si_info { - struct si_pub pub; /* back plane public state (must be first field) */ - struct osl_info *osh; /* osl os handle */ - void *sdh; /* bcmsdh handle */ + struct si_pub pub; /* back plane public state (must be first) */ + void *pbus; /* handle to bus (pci/sdio/..) */ uint dev_coreid; /* the core provides driver functions */ void *intr_arg; /* interrupt callback function arg */ si_intrsoff_t intrsoff_fn; /* turns chip interrupts off */ @@ -255,7 +249,7 @@ typedef struct si_info { u32 oob_router; /* oob router registers for axi */ } si_info_t; -#define SI_INFO(sih) (si_info_t *)sih +#define SI_INFO(sih) ((si_info_t *)(sih)) #define GOODCOREADDR(x, b) (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ IS_ALIGNED((x), SI_CORE_SIZE)) @@ -275,7 +269,7 @@ typedef struct si_info { /* * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts - * before after core switching to avoid invalid register accesss inside ISR. + * before after core switching to avoid invalid register access inside ISR. */ #define INTR_OFF(si, intr_val) \ if ((si)->intrsoff_fn && (si)->coreid[(si)->curidx] == (si)->dev_coreid) { \ @@ -334,9 +328,9 @@ extern void si_epa_4313war(si_t *sih); char *si_getnvramflvar(si_t *sih, const char *name); /* AMBA Interconnect exported externs */ -extern si_t *ai_attach(uint pcidev, struct osl_info *osh, void *regs, - uint bustype, void *sdh, char **vars, uint *varsz); -extern si_t *ai_kattach(struct osl_info *osh); +extern si_t *ai_attach(uint pcidev, void *regs, uint bustype, + void *sdh, char **vars, uint *varsz); +extern si_t *ai_kattach(void); extern void ai_scan(si_t *sih, void *regs, uint devid); extern uint ai_flag(si_t *sih); diff --git a/drivers/staging/brcm80211/include/spid.h b/drivers/staging/brcm80211/include/spid.h deleted file mode 100644 index e0abb8432886..000000000000 --- a/drivers/staging/brcm80211/include/spid.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _SPI_H -#define _SPI_H - -/* - * Brcm SPI Device Register Map. - * - */ - -typedef volatile struct { - u8 config; /* 0x00, len, endian, clock, speed, polarity, wakeup */ - u8 response_delay; /* 0x01, read response delay in bytes (corerev < 3) */ - u8 status_enable; /* 0x02, status-enable, intr with status, response_delay - * function selection, command/data error check - */ - u8 reset_bp; /* 0x03, reset on wlan/bt backplane reset (corerev >= 1) */ - u16 intr_reg; /* 0x04, Intr status register */ - u16 intr_en_reg; /* 0x06, Intr mask register */ - u32 status_reg; /* 0x08, RO, Status bits of last spi transfer */ - u16 f1_info_reg; /* 0x0c, RO, enabled, ready for data transfer, blocksize */ - u16 f2_info_reg; /* 0x0e, RO, enabled, ready for data transfer, blocksize */ - u16 f3_info_reg; /* 0x10, RO, enabled, ready for data transfer, blocksize */ - u32 test_read; /* 0x14, RO 0xfeedbead signature */ - u32 test_rw; /* 0x18, RW */ - u8 resp_delay_f0; /* 0x1c, read resp delay bytes for F0 (corerev >= 3) */ - u8 resp_delay_f1; /* 0x1d, read resp delay bytes for F1 (corerev >= 3) */ - u8 resp_delay_f2; /* 0x1e, read resp delay bytes for F2 (corerev >= 3) */ - u8 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 */ diff --git a/drivers/staging/brcm80211/include/wlioctl.h b/drivers/staging/brcm80211/include/wlioctl.h index 9be793c5f10c..5e2b11bcfc6f 100644 --- a/drivers/staging/brcm80211/include/wlioctl.h +++ b/drivers/staging/brcm80211/include/wlioctl.h @@ -17,7 +17,7 @@ #ifndef _wlioctl_h_ #define _wlioctl_h_ -#include <proto/ethernet.h> +#include <linux/ieee80211.h> #ifdef BRCM_FULLMAC #include <proto/bcmeth.h> #endif @@ -29,10 +29,6 @@ #define INTF_NAME_SIZ 16 #endif -/* require default structure packing */ -#define BWL_DEFAULT_PACKING -#include <packed_section_start.h> - #ifdef BRCM_FULLMAC #define WL_BSS_INFO_VERSION 108 /* current ver of wl_bss_info struct */ @@ -46,7 +42,7 @@ typedef struct wl_bss_info { u32 length; /* byte length of data in this record, * starting at version and including IEs */ - struct ether_addr BSSID; + u8 BSSID[ETH_ALEN]; u16 beacon_period; /* units are Kusec */ u16 capability; /* Capability information */ u8 SSID_len; @@ -128,7 +124,7 @@ typedef struct wl_extdscan_params { typedef struct wl_scan_params { wlc_ssid_t ssid; /* default: {0, ""} */ - struct ether_addr bssid; /* default: bcast */ + u8 bssid[ETH_ALEN]; /* default: bcast */ s8 bss_type; /* default: any, * DOT11_BSSTYPE_ANY/INFRASTRUCTURE/INDEPENDENT */ @@ -234,8 +230,8 @@ typedef struct wl_iscan_results { typedef struct wl_probe_params { wlc_ssid_t ssid; - struct ether_addr bssid; - struct ether_addr mac; + u8 bssid[ETH_ALEN]; + u8 mac[ETH_ALEN]; } wl_probe_params_t; #endif /* BRCM_FULLMAC */ @@ -262,7 +258,7 @@ typedef struct wl_u32_list { /* used for association with a specific BSSID and chanspec list */ typedef struct wl_assoc_params { - struct ether_addr bssid; /* 00:00:00:00:00:00: broadcast scan */ + u8 bssid[ETH_ALEN]; /* 00:00:00:00:00:00: broadcast scan */ s32 chanspec_num; /* 0: all available channels, * otherwise count of chanspecs in chanspec_list */ @@ -478,7 +474,7 @@ typedef struct wl_rm_rep { typedef struct wl_wsec_key { u32 index; /* key index */ u32 len; /* key length */ - u8 data[DOT11_MAX_KEY_SIZE]; /* key data */ + u8 data[WLAN_MAX_KEY_LEN]; /* key data */ u32 pad_1[18]; u32 algo; /* CRYPTO_ALGO_AES_CCM, CRYPTO_ALGO_WEP128, etc */ u32 flags; /* misc flags */ @@ -492,7 +488,7 @@ typedef struct wl_wsec_key { u16 lo; /* lower 16 bits of IV */ } rxiv; u32 pad_5[2]; - struct ether_addr ea; /* per station */ + u8 ea[ETH_ALEN]; /* per station */ } wl_wsec_key_t; #define WSEC_MIN_PSK_LEN 8 @@ -534,8 +530,8 @@ typedef struct { #define MAXPMKID 16 typedef struct _pmkid { - struct ether_addr BSSID; - u8 PMKID[WPA2_PMKID_LEN]; + u8 BSSID[ETH_ALEN]; + u8 PMKID[WLAN_PMKID_LEN]; } pmkid_t; typedef struct _pmkid_list { @@ -544,7 +540,7 @@ typedef struct _pmkid_list { } pmkid_list_t; typedef struct _pmkid_cand { - struct ether_addr BSSID; + u8 BSSID[ETH_ALEN]; u8 preauth; } pmkid_cand_t; @@ -572,7 +568,7 @@ typedef struct { /* Used to get specific STA parameters */ typedef struct { u32 val; - struct ether_addr ea; + u8 ea[ETH_ALEN]; } scb_val_t; #endif /* BRCM_FULLMAC */ @@ -586,7 +582,7 @@ typedef struct channel_info { /* For ioctls that take a list of MAC addresses */ struct maclist { uint count; /* number of MAC addresses */ - struct ether_addr ea[1]; /* variable length array of MAC addresses */ + u8 ea[1][ETH_ALEN]; /* variable length array of MAC addresses */ }; /* get pkt count struct passed through ioctl */ @@ -1266,7 +1262,7 @@ struct tsinfo_arg { #define WL_CNT_T_VERSION 7 /* current version of wl_cnt_t struct */ -typedef struct { +struct wl_cnt { u16 version; /* see definition of WL_CNT_T_VERSION */ u16 length; /* length of entire structure */ @@ -1496,7 +1492,7 @@ typedef struct { u32 rxmpdu_sgi; /* count for sgi received */ u32 txmpdu_stbc; /* count for stbc transmit */ u32 rxmpdu_stbc; /* count for stbc received */ -} wl_cnt_t; +}; #define WL_DELTA_STATS_T_VERSION 1 /* current version of wl_delta_stats_t struct */ @@ -1614,7 +1610,7 @@ struct ampdu_tid_control { /* structure for identifying ea/tid for sending addba/delba */ struct ampdu_ea_tid { - struct ether_addr ea; /* Station address */ + u8 ea[ETH_ALEN]; /* Station address */ u8 tid; /* tid */ }; /* structure for identifying retry/tid for retry_limit_tid/rr_retry_limit_tid */ @@ -1668,9 +1664,6 @@ typedef struct wl_pkt_filter_enable { #define WLC_RSSI_INVALID 0 /* invalid RSSI value */ -/* require default structure packing */ -#include <packed_section_end.h> - /* n-mode support capability */ /* 2x2 includes both 1x1 & 2x2 devices * reserved #define 2 for future when we want to separate 1x1 & 2x2 and diff --git a/drivers/staging/brcm80211/sys/d11ucode_ext.h b/drivers/staging/brcm80211/sys/d11ucode_ext.h deleted file mode 100644 index c0c0d661e00e..000000000000 --- a/drivers/staging/brcm80211/sys/d11ucode_ext.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -enum { - D11UCODE_NAMETAG_START = 0, - D11LCN0BSINITVALS24, - D11LCN0INITVALS24, - D11LCN1BSINITVALS24, - D11LCN1INITVALS24, - D11LCN2BSINITVALS24, - D11LCN2INITVALS24, - D11N0ABSINITVALS16, - D11N0BSINITVALS16, - D11N0INITVALS16, - D11UCODE_OVERSIGHT16_MIMO, - D11UCODE_OVERSIGHT16_MIMOSZ, - D11UCODE_OVERSIGHT24_LCN, - D11UCODE_OVERSIGHT24_LCNSZ, - D11UCODE_OVERSIGHT_BOMMAJOR, - D11UCODE_OVERSIGHT_BOMMINOR -}; -#define UCODE_LOADER_API_VER 0 diff --git a/drivers/staging/brcm80211/sys/wl_ucode_loader.c b/drivers/staging/brcm80211/sys/wl_ucode_loader.c deleted file mode 100644 index 23e10f3dec0d..000000000000 --- a/drivers/staging/brcm80211/sys/wl_ucode_loader.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <linux/types.h> -#include <bcmdefs.h> -#include <d11ucode_ext.h> -#include <wl_ucode.h> - - - -d11init_t *d11lcn0bsinitvals24; -d11init_t *d11lcn0initvals24; -d11init_t *d11lcn1bsinitvals24; -d11init_t *d11lcn1initvals24; -d11init_t *d11lcn2bsinitvals24; -d11init_t *d11lcn2initvals24; -d11init_t *d11n0absinitvals16; -d11init_t *d11n0bsinitvals16; -d11init_t *d11n0initvals16; -u32 *bcm43xx_16_mimo; -u32 bcm43xx_16_mimosz; -u32 *bcm43xx_24_lcn; -u32 bcm43xx_24_lcnsz; -u32 *bcm43xx_bommajor; -u32 *bcm43xx_bomminor; - -int wl_ucode_data_init(struct wl_info *wl) -{ - int rc; - rc = wl_check_firmwares(wl); - if (rc < 0) - return rc; - wl_ucode_init_buf(wl, (void **)&d11lcn0bsinitvals24, - D11LCN0BSINITVALS24); - wl_ucode_init_buf(wl, (void **)&d11lcn0initvals24, D11LCN0INITVALS24); - wl_ucode_init_buf(wl, (void **)&d11lcn1bsinitvals24, - D11LCN1BSINITVALS24); - wl_ucode_init_buf(wl, (void **)&d11lcn1initvals24, D11LCN1INITVALS24); - wl_ucode_init_buf(wl, (void **)&d11lcn2bsinitvals24, - D11LCN2BSINITVALS24); - wl_ucode_init_buf(wl, (void **)&d11lcn2initvals24, D11LCN2INITVALS24); - wl_ucode_init_buf(wl, (void **)&d11n0absinitvals16, D11N0ABSINITVALS16); - wl_ucode_init_buf(wl, (void **)&d11n0bsinitvals16, D11N0BSINITVALS16); - wl_ucode_init_buf(wl, (void **)&d11n0initvals16, D11N0INITVALS16); - wl_ucode_init_buf(wl, (void **)&bcm43xx_16_mimo, - D11UCODE_OVERSIGHT16_MIMO); - wl_ucode_init_uint(wl, &bcm43xx_16_mimosz, D11UCODE_OVERSIGHT16_MIMOSZ); - wl_ucode_init_buf(wl, (void **)&bcm43xx_24_lcn, - D11UCODE_OVERSIGHT24_LCN); - wl_ucode_init_uint(wl, &bcm43xx_24_lcnsz, D11UCODE_OVERSIGHT24_LCNSZ); - wl_ucode_init_buf(wl, (void **)&bcm43xx_bommajor, - D11UCODE_OVERSIGHT_BOMMAJOR); - wl_ucode_init_buf(wl, (void **)&bcm43xx_bomminor, - D11UCODE_OVERSIGHT_BOMMINOR); - - return 0; -} - -void wl_ucode_data_free(void) -{ - wl_ucode_free_buf((void *)d11lcn0bsinitvals24); - wl_ucode_free_buf((void *)d11lcn0initvals24); - wl_ucode_free_buf((void *)d11lcn1bsinitvals24); - wl_ucode_free_buf((void *)d11lcn1initvals24); - wl_ucode_free_buf((void *)d11lcn2bsinitvals24); - wl_ucode_free_buf((void *)d11lcn2initvals24); - wl_ucode_free_buf((void *)d11n0absinitvals16); - wl_ucode_free_buf((void *)d11n0bsinitvals16); - wl_ucode_free_buf((void *)d11n0initvals16); - wl_ucode_free_buf((void *)bcm43xx_16_mimo); - wl_ucode_free_buf((void *)bcm43xx_24_lcn); - wl_ucode_free_buf((void *)bcm43xx_bommajor); - wl_ucode_free_buf((void *)bcm43xx_bomminor); - - return; -} diff --git a/drivers/staging/brcm80211/sys/wlc_event.c b/drivers/staging/brcm80211/sys/wlc_event.c deleted file mode 100644 index dabd7094cd73..000000000000 --- a/drivers/staging/brcm80211/sys/wlc_event.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <linux/kernel.h> -#include <bcmdefs.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <osl.h> -#include <bcmutils.h> -#include <siutils.h> -#include <sbhndpio.h> -#include <sbhnddma.h> -#include <wlioctl.h> -#include <wlc_cfg.h> -#include <wlc_pub.h> -#include <wlc_key.h> -#include <wl_export.h> -#include <wlc_event.h> - -#include <d11.h> -#include <wlc_rate.h> -#include <wlc_mac80211.h> -#ifdef MSGTRACE -#include <msgtrace.h> -#endif -#include <wl_dbg.h> - -/* Local prototypes */ -static void wlc_timer_cb(void *arg); - -/* Private data structures */ -struct wlc_eventq { - wlc_event_t *head; - wlc_event_t *tail; - struct wlc_info *wlc; - void *wl; - struct wlc_pub *pub; - bool tpending; - bool workpending; - struct wl_timer *timer; - wlc_eventq_cb_t cb; - u8 event_inds_mask[broken_roundup(WLC_E_LAST, NBBY) / NBBY]; -}; - -/* - * Export functions - */ -wlc_eventq_t *wlc_eventq_attach(struct wlc_pub *pub, struct wlc_info *wlc, - void *wl, - wlc_eventq_cb_t cb) -{ - wlc_eventq_t *eq; - - eq = kzalloc(sizeof(wlc_eventq_t), GFP_ATOMIC); - if (eq == NULL) - return NULL; - - eq->cb = cb; - eq->wlc = wlc; - eq->wl = wl; - eq->pub = pub; - - eq->timer = wl_init_timer(eq->wl, wlc_timer_cb, eq, "eventq"); - if (!eq->timer) { - WL_ERROR("wl%d: wlc_eventq_attach: timer failed\n", - pub->unit); - kfree(eq); - return NULL; - } - - return eq; -} - -int wlc_eventq_detach(wlc_eventq_t *eq) -{ - /* Clean up pending events */ - wlc_eventq_down(eq); - - if (eq->timer) { - if (eq->tpending) { - wl_del_timer(eq->wl, eq->timer); - eq->tpending = false; - } - wl_free_timer(eq->wl, eq->timer); - eq->timer = NULL; - } - - ASSERT(wlc_eventq_avail(eq) == false); - kfree(eq); - return 0; -} - -int wlc_eventq_down(wlc_eventq_t *eq) -{ - int callbacks = 0; - if (eq->tpending && !eq->workpending) { - if (!wl_del_timer(eq->wl, eq->timer)) - callbacks++; - - ASSERT(wlc_eventq_avail(eq) == true); - ASSERT(eq->workpending == false); - eq->workpending = true; - if (eq->cb) - eq->cb(eq->wlc); - - ASSERT(eq->workpending == true); - eq->workpending = false; - eq->tpending = false; - } else { - ASSERT(eq->workpending || wlc_eventq_avail(eq) == false); - } - return callbacks; -} - -wlc_event_t *wlc_event_alloc(wlc_eventq_t *eq) -{ - wlc_event_t *e; - - e = kzalloc(sizeof(wlc_event_t), GFP_ATOMIC); - - if (e == NULL) - return NULL; - - return e; -} - -void wlc_event_free(wlc_eventq_t *eq, wlc_event_t *e) -{ - ASSERT(e->data == NULL); - ASSERT(e->next == NULL); - kfree(e); -} - -void wlc_eventq_enq(wlc_eventq_t *eq, wlc_event_t *e) -{ - ASSERT(e->next == NULL); - e->next = NULL; - - if (eq->tail) { - eq->tail->next = e; - eq->tail = e; - } else - eq->head = eq->tail = e; - - if (!eq->tpending) { - eq->tpending = true; - /* Use a zero-delay timer to trigger - * delayed processing of the event. - */ - wl_add_timer(eq->wl, eq->timer, 0, 0); - } -} - -wlc_event_t *wlc_eventq_deq(wlc_eventq_t *eq) -{ - wlc_event_t *e; - - e = eq->head; - if (e) { - eq->head = e->next; - e->next = NULL; - - if (eq->head == NULL) - eq->tail = eq->head; - } - return e; -} - -wlc_event_t *wlc_eventq_next(wlc_eventq_t *eq, wlc_event_t *e) -{ -#ifdef BCMDBG - wlc_event_t *etmp; - - for (etmp = eq->head; etmp; etmp = etmp->next) { - if (etmp == e) - break; - } - ASSERT(etmp != NULL); -#endif - - return e->next; -} - -int wlc_eventq_cnt(wlc_eventq_t *eq) -{ - wlc_event_t *etmp; - int cnt = 0; - - for (etmp = eq->head; etmp; etmp = etmp->next) - cnt++; - - return cnt; -} - -bool wlc_eventq_avail(wlc_eventq_t *eq) -{ - return (eq->head != NULL); -} - -/* - * Local Functions - */ -static void wlc_timer_cb(void *arg) -{ - struct wlc_eventq *eq = (struct wlc_eventq *)arg; - - ASSERT(eq->tpending == true); - ASSERT(wlc_eventq_avail(eq) == true); - ASSERT(eq->workpending == false); - eq->workpending = true; - - if (eq->cb) - eq->cb(eq->wlc); - - ASSERT(wlc_eventq_avail(eq) == false); - ASSERT(eq->tpending == true); - eq->workpending = false; - eq->tpending = false; -} diff --git a/drivers/staging/brcm80211/sys/wlc_event.h b/drivers/staging/brcm80211/sys/wlc_event.h deleted file mode 100644 index e75582dcdd93..000000000000 --- a/drivers/staging/brcm80211/sys/wlc_event.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _WLC_EVENT_H_ -#define _WLC_EVENT_H_ - -typedef struct wlc_eventq wlc_eventq_t; - -typedef void (*wlc_eventq_cb_t) (void *arg); - -extern wlc_eventq_t *wlc_eventq_attach(struct wlc_pub *pub, - struct wlc_info *wlc, - void *wl, wlc_eventq_cb_t cb); -extern int wlc_eventq_detach(wlc_eventq_t *eq); -extern int wlc_eventq_down(wlc_eventq_t *eq); -extern void wlc_event_free(wlc_eventq_t *eq, wlc_event_t *e); -extern wlc_event_t *wlc_eventq_next(wlc_eventq_t *eq, wlc_event_t *e); -extern int wlc_eventq_cnt(wlc_eventq_t *eq); -extern bool wlc_eventq_avail(wlc_eventq_t *eq); -extern wlc_event_t *wlc_eventq_deq(wlc_eventq_t *eq); -extern void wlc_eventq_enq(wlc_eventq_t *eq, wlc_event_t *e); -extern wlc_event_t *wlc_event_alloc(wlc_eventq_t *eq); - -extern int wlc_eventq_register_ind(wlc_eventq_t *eq, void *bitvect); -extern int wlc_eventq_query_ind(wlc_eventq_t *eq, void *bitvect); -extern int wlc_eventq_test_ind(wlc_eventq_t *eq, int et); -extern int wlc_eventq_set_ind(wlc_eventq_t *eq, uint et, bool on); -extern void wlc_eventq_flush(wlc_eventq_t *eq); -extern void wlc_assign_event_msg(struct wlc_info *wlc, wl_event_msg_t *msg, - const wlc_event_t *e, u8 *data, - u32 len); - -#ifdef MSGTRACE -extern void wlc_event_sendup_trace(struct wlc_info *wlc, hndrte_dev_t *bus, - u8 *hdr, u16 hdrlen, u8 *buf, - u16 buflen); -#endif - -#endif /* _WLC_EVENT_H_ */ diff --git a/drivers/staging/brcm80211/util/aiutils.c b/drivers/staging/brcm80211/util/aiutils.c index ddd2f9d64c20..570869032d88 100644 --- a/drivers/staging/brcm80211/util/aiutils.c +++ b/drivers/staging/brcm80211/util/aiutils.c @@ -18,10 +18,6 @@ #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> -#ifdef BRCM_FULLMAC -#include <linux/netdevice.h> -#endif -#include <osl.h> #include <linux/module.h> #include <linux/pci.h> #include <bcmutils.h> @@ -44,7 +40,7 @@ get_erom_ent(si_t *sih, u32 **eromptr, u32 mask, u32 match) uint inv = 0, nom = 0; while (true) { - ent = R_REG(si_osh(sih), *eromptr); + ent = R_REG(*eromptr); (*eromptr)++; if (mask == 0) @@ -118,7 +114,7 @@ void ai_scan(si_t *sih, void *regs, uint devid) chipcregs_t *cc = (chipcregs_t *) regs; u32 erombase, *eromptr, *eromlim; - erombase = R_REG(sii->osh, &cc->eromptr); + erombase = R_REG(&cc->eromptr); switch (sih->bustype) { case SI_BUS: @@ -130,14 +126,12 @@ void ai_scan(si_t *sih, void *regs, uint devid) sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE); /* Now point the window at the erom */ - pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, erombase); + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); eromptr = regs; break; -#ifdef BCMSDIO case SPI_BUS: case SDIO_BUS: -#endif /* BCMSDIO */ eromptr = (u32 *)(unsigned long)erombase; break; @@ -352,16 +346,14 @@ void *ai_setcoreidx(si_t *sih, uint coreidx) case PCI_BUS: /* point bar0 window */ - pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, addr); + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr); regs = sii->curmap; /* point bar0 2nd 4KB window */ - pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN2, wrap); + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap); break; -#ifdef BCMSDIO case SPI_BUS: case SDIO_BUS: -#endif /* BCMSDIO */ sii->curmap = regs = (void *)(unsigned long)addr; sii->curwrap = (void *)(unsigned long)wrap; break; @@ -434,7 +426,7 @@ uint ai_flag(si_t *sih) } ai = sii->curwrap; - return R_REG(sii->osh, &ai->oobselouta30) & 0x1f; + return R_REG(&ai->oobselouta30) & 0x1f; } void ai_setint(si_t *sih, int siflag) @@ -445,7 +437,7 @@ void ai_write_wrap_reg(si_t *sih, u32 offset, u32 val) { si_info_t *sii = SI_INFO(sih); u32 *w = (u32 *) sii->curwrap; - W_REG(sii->osh, w + (offset / 4), val); + W_REG(w + (offset / 4), val); return; } @@ -477,9 +469,9 @@ bool ai_iscoreup(si_t *sih) sii = SI_INFO(sih); ai = sii->curwrap; - return (((R_REG(sii->osh, &ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) == + return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) == SICF_CLOCK_EN) - && ((R_REG(sii->osh, &ai->resetctrl) & AIRC_RESET) == 0)); + && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0)); } /* @@ -560,12 +552,12 @@ uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) /* mask and set */ if (mask || val) { - w = (R_REG(sii->osh, r) & ~mask) | val; - W_REG(sii->osh, r, w); + w = (R_REG(r) & ~mask) | val; + W_REG(r, w); } /* readback */ - w = R_REG(sii->osh, r); + w = R_REG(r); if (!fast) { /* restore core index */ @@ -590,14 +582,14 @@ void ai_core_disable(si_t *sih, u32 bits) ai = sii->curwrap; /* if core is already in reset, just return */ - if (R_REG(sii->osh, &ai->resetctrl) & AIRC_RESET) + if (R_REG(&ai->resetctrl) & AIRC_RESET) return; - W_REG(sii->osh, &ai->ioctrl, bits); - dummy = R_REG(sii->osh, &ai->ioctrl); + W_REG(&ai->ioctrl, bits); + dummy = R_REG(&ai->ioctrl); udelay(10); - W_REG(sii->osh, &ai->resetctrl, AIRC_RESET); + W_REG(&ai->resetctrl, AIRC_RESET); udelay(1); } @@ -624,13 +616,13 @@ void ai_core_reset(si_t *sih, u32 bits, u32 resetbits) /* * Now do the initialization sequence. */ - W_REG(sii->osh, &ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN)); - dummy = R_REG(sii->osh, &ai->ioctrl); - W_REG(sii->osh, &ai->resetctrl, 0); + W_REG(&ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN)); + dummy = R_REG(&ai->ioctrl); + W_REG(&ai->resetctrl, 0); udelay(1); - W_REG(sii->osh, &ai->ioctrl, (bits | SICF_CLOCK_EN)); - dummy = R_REG(sii->osh, &ai->ioctrl); + W_REG(&ai->ioctrl, (bits | SICF_CLOCK_EN)); + dummy = R_REG(&ai->ioctrl); udelay(1); } @@ -654,8 +646,8 @@ void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val) ASSERT((val & ~mask) == 0); if (mask || val) { - w = ((R_REG(sii->osh, &ai->ioctrl) & ~mask) | val); - W_REG(sii->osh, &ai->ioctrl, w); + w = ((R_REG(&ai->ioctrl) & ~mask) | val); + W_REG(&ai->ioctrl, w); } } @@ -678,11 +670,11 @@ u32 ai_core_cflags(si_t *sih, u32 mask, u32 val) ASSERT((val & ~mask) == 0); if (mask || val) { - w = ((R_REG(sii->osh, &ai->ioctrl) & ~mask) | val); - W_REG(sii->osh, &ai->ioctrl, w); + w = ((R_REG(&ai->ioctrl) & ~mask) | val); + W_REG(&ai->ioctrl, w); } - return R_REG(sii->osh, &ai->ioctrl); + return R_REG(&ai->ioctrl); } u32 ai_core_sflags(si_t *sih, u32 mask, u32 val) @@ -704,10 +696,10 @@ u32 ai_core_sflags(si_t *sih, u32 mask, u32 val) ASSERT((mask & ~SISF_CORE_BITS) == 0); if (mask || val) { - w = ((R_REG(sii->osh, &ai->iostatus) & ~mask) | val); - W_REG(sii->osh, &ai->iostatus, w); + w = ((R_REG(&ai->iostatus) & ~mask) | val); + W_REG(&ai->iostatus, w); } - return R_REG(sii->osh, &ai->iostatus); + return R_REG(&ai->iostatus); } diff --git a/drivers/staging/brcm80211/util/bcmotp.c b/drivers/staging/brcm80211/util/bcmotp.c index d820e7b9e970..ba71c108b366 100644 --- a/drivers/staging/brcm80211/util/bcmotp.c +++ b/drivers/staging/brcm80211/util/bcmotp.c @@ -18,13 +18,11 @@ #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> -#include <osl.h> #include <linux/module.h> #include <linux/pci.h> #include <bcmdevs.h> #include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> #include <hndsoc.h> #include <sbchipc.h> #include <bcmotp.h> @@ -79,7 +77,6 @@ typedef struct { uint ccrev; /* chipc revision */ otp_fn_t *fn; /* OTP functions */ si_t *sih; /* Saved sb handle */ - struct osl_info *osh; #ifdef BCMIPXOTP /* IPX OTP section */ @@ -183,7 +180,7 @@ static u16 ipxotp_otpr(void *oh, chipcregs_t *cc, uint wn) ASSERT(wn < oi->wsize); ASSERT(cc != NULL); - return R_REG(oi->osh, &cc->sromotp[wn]); + return R_REG(&cc->sromotp[wn]); } static u16 ipxotp_read_bit(void *oh, chipcregs_t *cc, uint off) @@ -199,10 +196,10 @@ static u16 ipxotp_read_bit(void *oh, chipcregs_t *cc, uint off) ((OTPPOC_READ << OTPP_OC_SHIFT) & OTPP_OC_MASK) | ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) | ((col << OTPP_COL_SHIFT) & OTPP_COL_MASK); - W_REG(oi->osh, &cc->otpprog, otpp); + W_REG(&cc->otpprog, otpp); for (k = 0; - ((st = R_REG(oi->osh, &cc->otpprog)) & OTPP_START_BUSY) + ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) && (k < OTPP_TRIES); k++) ; if (k >= OTPP_TRIES) { @@ -261,9 +258,9 @@ static void _ipxotp_init(otpinfo_t *oi, chipcregs_t *cc) otpp = OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK); - W_REG(oi->osh, &cc->otpprog, otpp); + W_REG(&cc->otpprog, otpp); for (k = 0; - ((st = R_REG(oi->osh, &cc->otpprog)) & OTPP_START_BUSY) + ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) && (k < OTPP_TRIES); k++) ; if (k >= OTPP_TRIES) { @@ -271,7 +268,7 @@ static void _ipxotp_init(otpinfo_t *oi, chipcregs_t *cc) } /* Read OTP lock bits and subregion programmed indication bits */ - oi->status = R_REG(oi->osh, &cc->otpstatus); + oi->status = R_REG(&cc->otpstatus); if ((oi->sih->chip == BCM43224_CHIP_ID) || (oi->sih->chip == BCM43225_CHIP_ID)) { @@ -570,56 +567,49 @@ static int hndotp_size(void *oh) static u16 hndotp_otpr(void *oh, chipcregs_t *cc, uint wn) { +#ifdef BCMDBG otpinfo_t *oi = (otpinfo_t *) oh; - struct osl_info *osh; +#endif volatile u16 *ptr; ASSERT(wn < ((oi->size / 2) + OTP_RC_LIM_OFF)); ASSERT(cc != NULL); - osh = si_osh(oi->sih); - ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP); - return R_REG(osh, &ptr[wn]); + return R_REG(&ptr[wn]); } static u16 hndotp_otproff(void *oh, chipcregs_t *cc, int woff) { otpinfo_t *oi = (otpinfo_t *) oh; - struct osl_info *osh; volatile u16 *ptr; ASSERT(woff >= (-((int)oi->size / 2))); ASSERT(woff < OTP_LIM_OFF); ASSERT(cc != NULL); - osh = si_osh(oi->sih); - ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP); - return R_REG(osh, &ptr[(oi->size / 2) + woff]); + return R_REG(&ptr[(oi->size / 2) + woff]); } static u16 hndotp_read_bit(void *oh, chipcregs_t *cc, uint idx) { - otpinfo_t *oi = (otpinfo_t *) oh; uint k, row, col; u32 otpp, st; - struct osl_info *osh; - osh = si_osh(oi->sih); row = idx / 65; col = idx % 65; otpp = OTPP_START_BUSY | OTPP_READ | ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) | (col & OTPP_COL_MASK); - W_REG(osh, &cc->otpprog, otpp); - st = R_REG(osh, &cc->otpprog); + W_REG(&cc->otpprog, otpp); + st = R_REG(&cc->otpprog); for (k = 0; ((st & OTPP_START_BUSY) == OTPP_START_BUSY) && (k < OTPP_TRIES); k++) - st = R_REG(osh, &cc->otpprog); + st = R_REG(&cc->otpprog); if (k >= OTPP_TRIES) { return 0xffff; @@ -638,17 +628,15 @@ static void *hndotp_init(si_t *sih) otpinfo_t *oi; u32 cap = 0, clkdiv, otpdiv = 0; void *ret = NULL; - struct osl_info *osh; oi = &otpinfo; idx = si_coreidx(sih); - osh = si_osh(oi->sih); /* Check for otp */ cc = si_setcoreidx(sih, SI_CC_IDX); if (cc != NULL) { - cap = R_REG(osh, &cc->capabilities); + cap = R_REG(&cc->capabilities); if ((cap & CC_CAP_OTPSIZE) == 0) { /* Nothing there */ goto out; @@ -671,7 +659,7 @@ static void *hndotp_init(si_t *sih) if (oi->ccrev >= 18) oi->size -= ((OTP_RC0_OFF - OTP_BOUNDARY_OFF) * 2); - oi->hwprot = (int)(R_REG(osh, &cc->otpstatus) & OTPS_PROTECT); + oi->hwprot = (int)(R_REG(&cc->otpstatus) & OTPS_PROTECT); oi->boundary = -1; /* Check the region signature */ @@ -691,10 +679,10 @@ static void *hndotp_init(si_t *sih) otpdiv = 12; if (otpdiv) { - clkdiv = R_REG(osh, &cc->clkdiv); + clkdiv = R_REG(&cc->clkdiv); clkdiv = (clkdiv & ~CLKD_OTP) | (otpdiv << CLKD_OTP_SHIFT); - W_REG(osh, &cc->clkdiv, clkdiv); + W_REG(&cc->clkdiv, clkdiv); } udelay(10); @@ -818,7 +806,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len) if (offset + dsz >= *len) { goto out; } - bcopy((char *)&rawotp[i + 2], &data[offset], dsz); + memcpy(&data[offset], &rawotp[i + 2], dsz); offset += dsz; /* Remove extra null characters at the end */ while (offset > 1 && @@ -842,8 +830,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len) *len = offset; out: - if (rawotp) - kfree(rawotp); + kfree(rawotp); si_setcoreidx(oi->sih, idx); return rc; @@ -921,7 +908,6 @@ void *otp_init(si_t *sih) } oi->sih = sih; - oi->osh = si_osh(oi->sih); ret = (oi->fn->init) (sih); diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c index 19d45026a5ee..eca35b94e96c 100644 --- a/drivers/staging/brcm80211/util/bcmsrom.c +++ b/drivers/staging/brcm80211/util/bcmsrom.c @@ -17,7 +17,6 @@ #include <linux/string.h> #include <linux/etherdevice.h> #include <bcmdefs.h> -#include <osl.h> #include <linux/module.h> #include <linux/pci.h> #include <stdarg.h> @@ -25,7 +24,6 @@ #include <hndsoc.h> #include <sbchipc.h> #include <bcmdevs.h> -#include <bcmendian.h> #include <pcicfg.h> #include <siutils.h> #include <bcmsrom.h> @@ -44,7 +42,7 @@ #include <sbsdpcmdev.h> #endif -#include <proto/ethernet.h> /* for sprom content groking */ +#include <linux/if_ether.h> #define BS_ERROR(args) @@ -68,29 +66,26 @@ extern uint _varsz; #define SROM_CIS_SINGLE 1 -static int initvars_srom_si(si_t *sih, struct osl_info *osh, void *curmap, - char **vars, uint *count); -static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, - varbuf_t *b); -static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, - uint *count); +static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *count); +static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b); +static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count); static int initvars_flash_si(si_t *sih, char **vars, uint *count); #ifdef BCMSDIO -static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count); -static int sprom_cmd_sdio(struct osl_info *osh, u8 cmd); -static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data); +static int initvars_cis_sdio(char **vars, uint *count); +static int sprom_cmd_sdio(u8 cmd); +static int sprom_read_sdio(u16 addr, u16 *data); #endif /* BCMSDIO */ -static int sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, +static int sprom_read_pci(si_t *sih, u16 *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc); #if defined(BCMNVRAMR) -static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz); +static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz); #endif -static u16 srom_cc_cmd(si_t *sih, struct osl_info *osh, void *ccregs, u32 cmd, +static u16 srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd, uint wordoff, u16 data); -static int initvars_table(struct osl_info *osh, char *start, char *end, +static int initvars_table(char *start, char *end, char **vars, uint *count); -static int initvars_flash(si_t *sih, struct osl_info *osh, char **vp, +static int initvars_flash(si_t *sih, char **vp, uint len); /* Initialization of varbuf structure */ @@ -158,7 +153,7 @@ static int varbuf_append(varbuf_t *b, const char *fmt, ...) * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. */ -int srom_var_init(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, +int srom_var_init(si_t *sih, uint bustype, void *curmap, char **vars, uint *count) { uint len; @@ -175,7 +170,7 @@ int srom_var_init(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, switch (bustype) { case SI_BUS: case JTAG_BUS: - return initvars_srom_si(sih, osh, curmap, vars, count); + return initvars_srom_si(sih, curmap, vars, count); case PCI_BUS: ASSERT(curmap != NULL); @@ -186,7 +181,7 @@ int srom_var_init(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, #ifdef BCMSDIO case SDIO_BUS: - return initvars_cis_sdio(osh, vars, count); + return initvars_cis_sdio(vars, count); #endif /* BCMSDIO */ default: @@ -197,7 +192,7 @@ int srom_var_init(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, /* support only 16-bit word read from srom */ int -srom_read(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, +srom_read(si_t *sih, uint bustype, void *curmap, uint byteoff, uint nbytes, u16 *buf, bool check_crc) { uint off, nw; @@ -226,12 +221,12 @@ srom_read(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, return 1; if (sprom_read_pci - (osh, sih, srom, off, buf, nw, check_crc)) + (sih, srom, off, buf, nw, check_crc)) return 1; } #if defined(BCMNVRAMR) else { - if (otp_read_pci(osh, sih, buf, SROM_MAX)) + if (otp_read_pci(sih, buf, SROM_MAX)) return 1; } #endif @@ -241,7 +236,7 @@ srom_read(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, nw = nbytes / 2; for (i = 0; i < nw; i++) { if (sprom_read_sdio - (osh, (u16) (off + i), (u16 *) (buf + i))) + ((u16) (off + i), (u16 *) (buf + i))) return 1; } #endif /* BCMSDIO */ @@ -379,7 +374,7 @@ u8 patch_pair; /* For dongle HW, accept partial calibration parameters */ #define BCMDONGLECASE(n) -int srom_parsecis(struct osl_info *osh, u8 *pcis[], uint ciscnt, char **vars, +int srom_parsecis(u8 *pcis[], uint ciscnt, char **vars, uint *count) { char eabuf[32]; @@ -1336,8 +1331,8 @@ int srom_parsecis(struct osl_info *osh, u8 *pcis[], uint ciscnt, char **vars, u8 srev = cis[i + 1 + 70]; ASSERT(srev == 3); /* make tuple value 16-bit aligned and parse it */ - bcopy(&cis[i + 1], srom, - sizeof(srom)); + memcpy(srom, &cis[i + 1], + sizeof(srom)); _initvars_srom_pci(srev, srom, SROM3_SWRGN_OFF, &b); @@ -1399,7 +1394,7 @@ int srom_parsecis(struct osl_info *osh, u8 *pcis[], uint ciscnt, char **vars, *b.buf++ = '\0'; ASSERT(b.buf - base <= MAXSZ_NVRAM_VARS); - err = initvars_table(osh, base, b.buf, vars, count); + err = initvars_table(base, b.buf, vars, count); kfree(base); return err; @@ -1409,22 +1404,22 @@ int srom_parsecis(struct osl_info *osh, u8 *pcis[], uint ciscnt, char **vars, * not in the bus cores. */ static u16 -srom_cc_cmd(si_t *sih, struct osl_info *osh, void *ccregs, u32 cmd, +srom_cc_cmd(si_t *sih, void *ccregs, u32 cmd, uint wordoff, u16 data) { chipcregs_t *cc = (chipcregs_t *) ccregs; uint wait_cnt = 1000; if ((cmd == SRC_OP_READ) || (cmd == SRC_OP_WRITE)) { - W_REG(osh, &cc->sromaddress, wordoff * 2); + W_REG(&cc->sromaddress, wordoff * 2); if (cmd == SRC_OP_WRITE) - W_REG(osh, &cc->sromdata, data); + W_REG(&cc->sromdata, data); } - W_REG(osh, &cc->sromcontrol, SRC_START | cmd); + W_REG(&cc->sromcontrol, SRC_START | cmd); while (wait_cnt--) { - if ((R_REG(osh, &cc->sromcontrol) & SRC_BUSY) == 0) + if ((R_REG(&cc->sromcontrol) & SRC_BUSY) == 0) break; } @@ -1433,17 +1428,29 @@ srom_cc_cmd(si_t *sih, struct osl_info *osh, void *ccregs, u32 cmd, return 0xffff; } if (cmd == SRC_OP_READ) - return (u16) R_REG(osh, &cc->sromdata); + return (u16) R_REG(&cc->sromdata); else return 0xffff; } +static inline void ltoh16_buf(u16 *buf, unsigned int size) +{ + for (size /= 2; size; size--) + *(buf + size) = le16_to_cpu(*(buf + size)); +} + +static inline void htol16_buf(u16 *buf, unsigned int size) +{ + for (size /= 2; size; size--) + *(buf + size) = cpu_to_le16(*(buf + size)); +} + /* * Read in and validate sprom. * Return 0 on success, nonzero on error. */ static int -sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, uint wordoff, +sprom_read_pci(si_t *sih, u16 *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc) { int err = 0; @@ -1460,14 +1467,14 @@ sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, uint wordoff, ccregs = (void *)((u8 *) sprom - CC_SROM_OTP); buf[i] = - srom_cc_cmd(sih, osh, ccregs, SRC_OP_READ, + srom_cc_cmd(sih, ccregs, SRC_OP_READ, wordoff + i, 0); } else { if (ISSIM_ENAB(sih)) - buf[i] = R_REG(osh, &sprom[wordoff + i]); + buf[i] = R_REG(&sprom[wordoff + i]); - buf[i] = R_REG(osh, &sprom[wordoff + i]); + buf[i] = R_REG(&sprom[wordoff + i]); } } @@ -1503,7 +1510,7 @@ sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, uint wordoff, } #if defined(BCMNVRAMR) -static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz) +static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz) { u8 *otp; uint sz = OTP_SZ_MAX / 2; /* size in words */ @@ -1518,10 +1525,9 @@ static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz) err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); - bcopy(otp, buf, bufsz); + memcpy(buf, otp, bufsz); - if (otp) - kfree(otp); + kfree(otp); /* Check CRC */ if (buf[0] == 0xffff) { @@ -1551,7 +1557,7 @@ static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz) * Create variable table from memory. * Return 0 on success, nonzero on error. */ -static int initvars_table(struct osl_info *osh, char *start, char *end, +static int initvars_table(char *start, char *end, char **vars, uint *count) { int c = (int)(end - start); @@ -1562,7 +1568,7 @@ static int initvars_table(struct osl_info *osh, char *start, char *end, ASSERT(vp != NULL); if (!vp) return BCME_NOMEM; - bcopy(start, vp, c); + memcpy(vp, start, c); *vars = vp; *count = c; } else { @@ -1578,8 +1584,7 @@ static int initvars_table(struct osl_info *osh, char *start, char *end, * of the table upon enter and to the end of the table upon exit when success. * Return 0 on success, nonzero on error. */ -static int initvars_flash(si_t *sih, struct osl_info *osh, char **base, - uint len) +static int initvars_flash(si_t *sih, char **base, uint len) { char *vp = *base; char *flash; @@ -1639,7 +1644,6 @@ static int initvars_flash(si_t *sih, struct osl_info *osh, char **base, */ static int initvars_flash_si(si_t *sih, char **vars, uint *count) { - struct osl_info *osh = si_osh(sih); char *vp, *base; int err; @@ -1651,9 +1655,9 @@ static int initvars_flash_si(si_t *sih, char **vars, uint *count) if (!vp) return BCME_NOMEM; - err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS); + err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS); if (err == 0) - err = initvars_table(osh, base, vp, vars, count); + err = initvars_table(base, vp, vars, count); kfree(base); @@ -1725,16 +1729,16 @@ static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b) continue; if (flags & SRFL_ETHADDR) { - struct ether_addr ea; + u8 ea[ETH_ALEN]; - ea.octet[0] = (srom[srv->off - off] >> 8) & 0xff; - ea.octet[1] = srom[srv->off - off] & 0xff; - ea.octet[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; - ea.octet[3] = srom[srv->off + 1 - off] & 0xff; - ea.octet[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; - ea.octet[5] = srom[srv->off + 2 - off] & 0xff; + ea[0] = (srom[srv->off - off] >> 8) & 0xff; + ea[1] = srom[srv->off - off] & 0xff; + ea[2] = (srom[srv->off + 1 - off] >> 8) & 0xff; + ea[3] = srom[srv->off + 1 - off] & 0xff; + ea[4] = (srom[srv->off + 2 - off] >> 8) & 0xff; + ea[5] = srom[srv->off + 2 - off] & 0xff; - varbuf_append(b, "%s=%pM", name, ea.octet); + varbuf_append(b, "%s=%pM", name, ea); } else { ASSERT(mask_valid(srv->mask)); ASSERT(mask_width(srv->mask)); @@ -1850,7 +1854,6 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) u32 sr; varbuf_t b; char *vp, *base = NULL; - struct osl_info *osh = si_osh(sih); bool flash = false; int err = 0; @@ -1868,7 +1871,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) sromwindow = (u16 *) SROM_OFFSET(sih); if (si_is_sprom_available(sih)) { err = - sprom_read_pci(osh, sih, sromwindow, 0, srom, SROM_WORDS, + sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, true); if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || @@ -1878,7 +1881,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) && (sih->buscorerev >= 0xe)))) { /* sromrev >= 4, read more */ err = - sprom_read_pci(osh, sih, sromwindow, 0, srom, + sprom_read_pci(sih, sromwindow, 0, srom, SROM4_WORDS, true); sromrev = srom[SROM4_CRCREV] & 0xff; if (err) @@ -1896,24 +1899,29 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) } #if defined(BCMNVRAMR) /* Use OTP if SPROM not available */ - else if ((err = otp_read_pci(osh, sih, srom, SROM_MAX)) == 0) { - /* OTP only contain SROM rev8/rev9 for now */ - sromrev = srom[SROM4_CRCREV] & 0xff; - } -#endif else { - err = 1; - BS_ERROR(("Neither SPROM nor OTP has valid image\n")); + err = otp_read_pci(sih, srom, SROM_MAX); + if (err == 0) + /* OTP only contain SROM rev8/rev9 for now */ + sromrev = srom[SROM4_CRCREV] & 0xff; + else + err = 1; } +#else + else + err = 1; +#endif - /* We want internal/wltest driver to come up with default sromvars so we can - * program a blank SPROM/OTP. + /* + * We want internal/wltest driver to come up with default + * sromvars so we can program a blank SPROM/OTP. */ if (err) { char *value; u32 val; val = 0; + BS_ERROR(("Neither SPROM nor OTP has valid image\n")); value = si_getdevpathvar(sih, "sromrev"); if (value) { sromrev = (u8) simple_strtoul(value, NULL, 0); @@ -1957,7 +1965,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) /* read variables from flash */ if (flash) { - err = initvars_flash(sih, osh, &vp, MAXSZ_NVRAM_VARS); + err = initvars_flash(sih, &vp, MAXSZ_NVRAM_VARS); if (err) goto errout; goto varsdone; @@ -1976,7 +1984,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) ASSERT((vp - base) <= MAXSZ_NVRAM_VARS); varsdone: - err = initvars_table(osh, base, vp, vars, count); + err = initvars_table(base, vp, vars, count); errout: if (base) @@ -1991,7 +1999,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) * Read the SDIO cis and call parsecis to initialize the vars. * Return 0 on success, nonzero on error. */ -static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count) +static int initvars_cis_sdio(char **vars, uint *count) { u8 *cis[SBSDIO_NUM_FUNCTION + 1]; uint fn, numfn; @@ -2016,7 +2024,7 @@ static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count) } if (!rc) - rc = srom_parsecis(osh, cis, fn, vars, count); + rc = srom_parsecis(cis, fn, vars, count); while (fn-- > 0) kfree(cis[fn]); @@ -2025,7 +2033,7 @@ static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count) } /* set SDIO sprom command register */ -static int sprom_cmd_sdio(struct osl_info *osh, u8 cmd) +static int sprom_cmd_sdio(u8 cmd) { u8 status = 0; uint wait_cnt = 1000; @@ -2045,7 +2053,7 @@ static int sprom_cmd_sdio(struct osl_info *osh, u8 cmd) } /* read a word from the SDIO srom */ -static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data) +static int sprom_read_sdio(u16 addr, u16 *data) { u8 addr_l, addr_h, data_l, data_h; @@ -2059,7 +2067,7 @@ static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data) NULL); /* do read */ - if (sprom_cmd_sdio(osh, SBSDIO_SPROM_READ)) + if (sprom_cmd_sdio(SBSDIO_SPROM_READ)) return 1; /* read data */ @@ -2073,8 +2081,7 @@ static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data) } #endif /* BCMSDIO */ -static int initvars_srom_si(si_t *sih, struct osl_info *osh, void *curmap, - char **vars, uint *varsz) +static int initvars_srom_si(si_t *sih, void *curmap, char **vars, uint *varsz) { /* Search flash nvram section for srom variables */ return initvars_flash_si(sih, vars, varsz); diff --git a/drivers/staging/brcm80211/include/bcmsrom_tbl.h b/drivers/staging/brcm80211/util/bcmsrom_tbl.h index 22ae7c1c18fb..22ae7c1c18fb 100644 --- a/drivers/staging/brcm80211/include/bcmsrom_tbl.h +++ b/drivers/staging/brcm80211/util/bcmsrom_tbl.h diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index fd30cc6fb7f8..fb0bcccfda44 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -17,23 +17,65 @@ #include <linux/ctype.h> #include <linux/kernel.h> #include <linux/string.h> -#include <bcmdefs.h> -#include <stdarg.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/netdevice.h> -#include <osl.h> +#include <linux/sched.h> +#include <bcmdefs.h> +#include <stdarg.h> #include <bcmutils.h> #include <siutils.h> #include <bcmnvram.h> -#include <bcmendian.h> #include <bcmdevs.h> -#include <proto/ethernet.h> -#include <proto/802.1d.h> #include <proto/802.11.h> +/* Global ASSERT type flag */ +u32 g_assert_type; + +struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len) +{ + struct sk_buff *skb; + + skb = dev_alloc_skb(len); + if (skb) { + skb_put(skb, len); + skb->priority = 0; + } + + return skb; +} + +/* Free the driver packet. Free the tag if present */ +void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb) +{ + struct sk_buff *nskb; + int nest = 0; + + ASSERT(skb); + + /* perversion: we use skb->next to chain multi-skb packets */ + while (skb) { + nskb = skb->next; + skb->next = NULL; + + if (skb->destructor) + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if + * destructor exists + */ + dev_kfree_skb_any(skb); + else + /* can free immediately (even in_irq()) if destructor + * does not exist + */ + dev_kfree_skb(skb); + + nest++; + skb = nskb; + } +} + /* copy a buffer into a pkt buffer chain */ -uint pktfrombuf(struct osl_info *osh, struct sk_buff *p, uint offset, int len, +uint pktfrombuf(struct sk_buff *p, uint offset, int len, unsigned char *buf) { uint n, ret = 0; @@ -51,7 +93,7 @@ uint pktfrombuf(struct osl_info *osh, struct sk_buff *p, uint offset, int len, /* copy the data */ for (; p && len; p = p->next) { n = min((uint) (p->len) - offset, (uint) len); - bcopy(buf, p->data + offset, n); + memcpy(p->data + offset, buf, n); buf += n; len -= n; ret += n; @@ -61,7 +103,7 @@ uint pktfrombuf(struct osl_info *osh, struct sk_buff *p, uint offset, int len, return ret; } /* return total length of buffer chain */ -uint BCMFASTPATH pkttotlen(struct osl_info *osh, struct sk_buff *p) +uint BCMFASTPATH pkttotlen(struct sk_buff *p) { uint total; @@ -188,7 +230,7 @@ struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) } #ifdef BRCM_FULLMAC -void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir) +void pktq_pflush(struct pktq *pq, int prec, bool dir) { struct pktq_prec *q; struct sk_buff *p; @@ -198,7 +240,7 @@ void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir) while (p) { q->head = p->prev; p->prev = NULL; - pkt_buf_free_skb(osh, p, dir); + pkt_buf_free_skb(p); q->len--; pq->len--; p = q->head; @@ -207,16 +249,16 @@ void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir) q->tail = NULL; } -void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir) +void pktq_flush(struct pktq *pq, bool dir) { int prec; for (prec = 0; prec < pq->num_prec; prec++) - pktq_pflush(osh, pq, prec, dir); + pktq_pflush(pq, prec, dir); ASSERT(pq->len == 0); } #else /* !BRCM_FULLMAC */ void -pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir, +pktq_pflush(struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, int arg) { struct pktq_prec *q; @@ -232,7 +274,7 @@ pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir, else prev->prev = p->prev; p->prev = NULL; - pkt_buf_free_skb(osh, p, dir); + pkt_buf_free_skb(p); q->len--; pq->len--; p = (head ? q->head : prev->prev); @@ -248,12 +290,12 @@ pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir, } } -void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir, +void pktq_flush(struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg) { int prec; for (prec = 0; prec < pq->num_prec; prec++) - pktq_pflush(osh, pq, prec, dir, fn, arg); + pktq_pflush(pq, prec, dir, fn, arg); if (fn == NULL) ASSERT(pq->len == 0); } @@ -348,12 +390,12 @@ struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, } /* parse a xx:xx:xx:xx:xx:xx format ethernet address */ -int bcm_ether_atoe(char *p, struct ether_addr *ea) +int bcm_ether_atoe(char *p, u8 *ea) { int i = 0; for (;;) { - ea->octet[i++] = (char)simple_strtoul(p, &p, 16); + ea[i++] = (char)simple_strtoul(p, &p, 16); if (!*p++ || i == 6) break; } @@ -410,12 +452,12 @@ int getintvar(char *vars, const char *name) #if defined(BCMDBG) /* pretty hex print a pkt buffer chain */ -void prpkt(const char *msg, struct osl_info *osh, struct sk_buff *p0) +void prpkt(const char *msg, struct sk_buff *p0) { struct sk_buff *p; if (msg && (msg[0] != '\0')) - printf("%s:\n", msg); + printk(KERN_DEBUG "%s:\n", msg); for (p = p0; p; p = p->next) prhex(NULL, p->data, p->len); @@ -866,7 +908,7 @@ void prhex(const char *msg, unsigned char *buf, uint nbytes) uint i; if (msg && (msg[0] != '\0')) - printf("%s:\n", msg); + printk(KERN_DEBUG "%s:\n", msg); p = line; for (i = 0; i < nbytes; i++) { @@ -882,7 +924,7 @@ void prhex(const char *msg, unsigned char *buf, uint nbytes) } if (i % 16 == 15) { - printf("%s\n", line); /* flush line */ + printk(KERN_DEBUG "%s\n", line); /* flush line */ p = line; len = sizeof(line); } @@ -890,7 +932,7 @@ void prhex(const char *msg, unsigned char *buf, uint nbytes) /* flush last partial line */ if (p != line) - printf("%s\n", line); + printk(KERN_DEBUG "%s\n", line); } char *bcm_chipname(uint chipid, char *buf, uint len) @@ -1048,3 +1090,49 @@ int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...) return r; } +#if defined(BCMDBG_ASSERT) +void osl_assert(char *exp, char *file, int line) +{ + char tempbuf[256]; + char *basename; + + basename = strrchr(file, '/'); + /* skip the '/' */ + if (basename) + basename++; + + if (!basename) + basename = file; + + snprintf(tempbuf, 256, + "assertion \"%s\" failed: file \"%s\", line %d\n", exp, + basename, line); + + /* + * Print assert message and give it time to + * be written to /var/log/messages + */ + if (!in_interrupt()) { + const int delay = 3; + printk(KERN_ERR "%s", tempbuf); + printk(KERN_ERR "panic in %d seconds\n", delay); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(delay * HZ); + } + + switch (g_assert_type) { + case 0: + panic(KERN_ERR "%s", tempbuf); + break; + case 1: + printk(KERN_ERR "%s", tempbuf); + BUG(); + break; + case 2: + printk(KERN_ERR "%s", tempbuf); + break; + default: + break; + } +} +#endif /* defined(BCMDBG_ASSERT) */ diff --git a/drivers/staging/brcm80211/util/bcmwifi.c b/drivers/staging/brcm80211/util/bcmwifi.c index 81e54bd7a554..d82c2b29816d 100644 --- a/drivers/staging/brcm80211/util/bcmwifi.c +++ b/drivers/staging/brcm80211/util/bcmwifi.c @@ -15,10 +15,6 @@ */ #include <linux/ctype.h> #include <linux/kernel.h> -#ifdef BRCM_FULLMAC -#include <linux/netdevice.h> -#endif -#include <osl.h> #include <bcmdefs.h> #include <bcmutils.h> #include <bcmwifi.h> @@ -82,29 +78,6 @@ u8 wf_chspec_ctlchan(chanspec_t chspec) return ctl_chan; } -chanspec_t wf_chspec_ctlchspec(chanspec_t chspec) -{ - chanspec_t ctl_chspec = 0; - u8 channel; - - ASSERT(!wf_chspec_malformed(chspec)); - - /* Is there a sideband ? */ - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) { - return chspec; - } else { - if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) { - channel = UPPER_20_SB(CHSPEC_CHANNEL(chspec)); - } else { - channel = LOWER_20_SB(CHSPEC_CHANNEL(chspec)); - } - ctl_chspec = - channel | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE; - ctl_chspec |= CHSPEC_BAND(chspec); - } - return ctl_chspec; -} - /* * Return the channel number for a given frequency and base frequency. * The returned channel number is relative to the given base frequency. @@ -161,33 +134,3 @@ int wf_mhz2channel(uint freq, uint start_factor) return ch; } -/* - * Return the center frequency in MHz of the given channel and base frequency. - * The channel number is interpreted relative to the given base frequency. - * - * The valid channel range is [1, 14] in the 2.4 GHz band and [0, 200] otherwise. - * The base frequency is specified as (start_factor * 500 kHz). - * Constants WF_CHAN_FACTOR_2_4_G, WF_CHAN_FACTOR_4_G, and WF_CHAN_FACTOR_5_G - * are defined for 2.4 GHz, 4 GHz, and 5 GHz bands. - * The channel range of [1, 14] is only checked for a start_factor of - * WF_CHAN_FACTOR_2_4_G (4814 = 2407 * 2). - * Odd start_factors produce channels on .5 MHz boundaries, in which case - * the answer is rounded down to an integral MHz. - * -1 is returned for an out of range channel. - * - * Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2 - */ -int wf_channel2mhz(uint ch, uint start_factor) -{ - int freq; - - if ((start_factor == WF_CHAN_FACTOR_2_4_G && (ch < 1 || ch > 14)) || - (ch > 200)) - freq = -1; - else if ((start_factor == WF_CHAN_FACTOR_2_4_G) && (ch == 14)) - freq = 2484; - else - freq = ch * 5 + start_factor / 2; - - return freq; -} diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index d08869239d5b..8a81eb997f99 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -20,8 +20,6 @@ #include <linux/pci.h> #include <bcmdefs.h> #include <bcmdevs.h> -#include <osl.h> -#include <bcmendian.h> #include <hndsoc.h> #include <bcmutils.h> #include <siutils.h> @@ -33,6 +31,10 @@ #include <asm/addrspace.h> #endif +#ifdef BRCM_FULLMAC +#error "hnddma.c shouldn't be needed for FULLMAC" +#endif + /* debug/trace */ #ifdef BCMDBG #define DMA_ERROR(args) \ @@ -40,14 +42,14 @@ if (!(*di->msg_level & 1)) \ ; \ else \ - printf args; \ + printk args; \ } while (0) #define DMA_TRACE(args) \ do { \ if (!(*di->msg_level & 2)) \ ; \ else \ - printf args; \ + printk args; \ } while (0) #else #define DMA_ERROR(args) @@ -56,11 +58,6 @@ #define DMA_NONE(args) -#define d32txregs dregs.d32_u.txregs_32 -#define d32rxregs dregs.d32_u.rxregs_32 -#define txd32 dregs.d32_u.txd_32 -#define rxd32 dregs.d32_u.rxd_32 - #define d64txregs dregs.d64_u.txregs_64 #define d64rxregs dregs.d64_u.rxregs_64 #define txd64 dregs.d64_u.txd_64 @@ -82,20 +79,13 @@ typedef struct dma_info { uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ - void *osh; /* os handle */ - si_t *sih; /* sb handle */ + void *pbus; /* bus handle */ bool dma64; /* this dma engine is operating in 64-bit mode */ bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ union { struct { - dma32regs_t *txregs_32; /* 32-bit dma tx engine registers */ - dma32regs_t *rxregs_32; /* 32-bit dma rx engine registers */ - dma32dd_t *txd_32; /* pointer to dma32 tx descriptor ring */ - dma32dd_t *rxd_32; /* pointer to dma32 rx descriptor ring */ - } d32_u; - struct { dma64regs_t *txregs_64; /* 64-bit dma tx engine registers */ dma64regs_t *rxregs_64; /* 64-bit dma rx engine registers */ dma64dd_t *txd_64; /* pointer to dma64 tx descriptor ring */ @@ -109,7 +99,6 @@ typedef struct dma_info { u16 txin; /* index of next descriptor to reclaim */ u16 txout; /* index of next descriptor to post */ void **txp; /* pointer to parallel array of pointers to packets */ - osldma_t *tx_dmah; /* DMA TX descriptor ring handle */ hnddma_seg_map_t *txp_dmah; /* DMA MAP meta-data handle */ dmaaddr_t txdpa; /* Aligned physical address of descriptor ring */ dmaaddr_t txdpaorig; /* Original physical address of descriptor ring */ @@ -124,7 +113,6 @@ typedef struct dma_info { u16 rxin; /* index of next descriptor to reclaim */ u16 rxout; /* index of next descriptor to post */ void **rxp; /* pointer to parallel array of pointers to packets */ - osldma_t *rx_dmah; /* DMA RX descriptor ring handle */ hnddma_seg_map_t *rxp_dmah; /* DMA MAP meta-data handle */ dmaaddr_t rxdpa; /* Aligned physical address of descriptor ring */ dmaaddr_t rxdpaorig; /* Original physical address of descriptor ring */ @@ -151,25 +139,6 @@ typedef struct dma_info { bool aligndesc_4k; /* descriptor base need to be aligned or not */ } dma_info_t; -/* - * If BCMDMA32 is defined, hnddma will support both 32-bit and 64-bit DMA engines. - * Otherwise it will support only 64-bit. - * - * DMA32_ENAB indicates whether hnddma is compiled with support for 32-bit DMA engines. - * DMA64_ENAB indicates whether hnddma is compiled with support for 64-bit DMA engines. - * - * DMA64_MODE indicates whether the current DMA engine is running as 64-bit. - */ -#ifdef BCMDMA32 -#define DMA32_ENAB(di) 1 -#define DMA64_ENAB(di) 1 -#define DMA64_MODE(di) ((di)->dma64) -#else /* !BCMDMA32 */ -#define DMA32_ENAB(di) 0 -#define DMA64_ENAB(di) 1 -#define DMA64_MODE(di) 1 -#endif /* !BCMDMA32 */ - /* DMA Scatter-gather list is supported. Note this is limited to TX direction only */ #ifdef BCMDMASGLISTOSL #define DMASGLIST_ENAB true @@ -228,31 +197,9 @@ static void _dma_counterreset(dma_info_t *di); static void _dma_fifoloopbackenable(dma_info_t *di); static uint _dma_ctrlflags(dma_info_t *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); -static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, +static void *dma_ringalloc(dma_info_t *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - dmaaddr_t *descpa, osldma_t **dmah); - -/* Prototypes for 32-bit routines */ -static bool dma32_alloc(dma_info_t *di, uint direction); -static bool dma32_txreset(dma_info_t *di); -static bool dma32_rxreset(dma_info_t *di); -static bool dma32_txsuspendedidle(dma_info_t *di); -static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit); -static void *dma32_getnexttxp(dma_info_t *di, txd_range_t range); -static void *dma32_getnextrxp(dma_info_t *di, bool forceall); -static void dma32_txrotate(dma_info_t *di); -static bool dma32_rxidle(dma_info_t *di); -static void dma32_txinit(dma_info_t *di); -static bool dma32_txenabled(dma_info_t *di); -static void dma32_txsuspend(dma_info_t *di); -static void dma32_txresume(dma_info_t *di); -static bool dma32_txsuspended(dma_info_t *di); -static void dma32_txreclaim(dma_info_t *di, txd_range_t range); -static bool dma32_txstopped(dma_info_t *di); -static bool dma32_rxstopped(dma_info_t *di); -static bool dma32_rxenabled(dma_info_t *di); - -static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs); + dmaaddr_t *descpa); /* Prototypes for 64-bit routines */ static bool dma64_alloc(dma_info_t *di, uint direction); @@ -276,7 +223,7 @@ static void dma64_txreclaim(dma_info_t *di, txd_range_t range); static bool dma64_txstopped(dma_info_t *di); static bool dma64_rxstopped(dma_info_t *di); static bool dma64_rxenabled(dma_info_t *di); -static bool _dma64_addrext(struct osl_info *osh, dma64regs_t *dma64regs); +static bool _dma64_addrext(dma64regs_t *dma64regs); static inline u32 parity32(u32 data); @@ -327,54 +274,7 @@ const di_fcn_t dma64proc = { 39 }; -static const di_fcn_t dma32proc = { - (di_detach_t) _dma_detach, - (di_txinit_t) dma32_txinit, - (di_txreset_t) dma32_txreset, - (di_txenabled_t) dma32_txenabled, - (di_txsuspend_t) dma32_txsuspend, - (di_txresume_t) dma32_txresume, - (di_txsuspended_t) dma32_txsuspended, - (di_txsuspendedidle_t) dma32_txsuspendedidle, - (di_txfast_t) dma32_txfast, - NULL, - NULL, - (di_txstopped_t) dma32_txstopped, - (di_txreclaim_t) dma32_txreclaim, - (di_getnexttxp_t) dma32_getnexttxp, - (di_peeknexttxp_t) _dma_peeknexttxp, - (di_txblock_t) _dma_txblock, - (di_txunblock_t) _dma_txunblock, - (di_txactive_t) _dma_txactive, - (di_txrotate_t) dma32_txrotate, - - (di_rxinit_t) _dma_rxinit, - (di_rxreset_t) dma32_rxreset, - (di_rxidle_t) dma32_rxidle, - (di_rxstopped_t) dma32_rxstopped, - (di_rxenable_t) _dma_rxenable, - (di_rxenabled_t) dma32_rxenabled, - (di_rx_t) _dma_rx, - (di_rxfill_t) _dma_rxfill, - (di_rxreclaim_t) _dma_rxreclaim, - (di_getnextrxp_t) _dma_getnextrxp, - (di_peeknextrxp_t) _dma_peeknextrxp, - (di_rxparam_get_t) _dma_rx_param_get, - - (di_fifoloopbackenable_t) _dma_fifoloopbackenable, - (di_getvar_t) _dma_getvar, - (di_counterreset_t) _dma_counterreset, - (di_ctrlflags_t) _dma_ctrlflags, - NULL, - NULL, - NULL, - (di_rxactive_t) _dma_rxactive, - (di_txpending_t) _dma_txpending, - (di_txcommitted_t) _dma_txcommitted, - 39 -}; - -struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, +struct hnddma_pub *dma_attach(char *name, si_t *sih, void *dmaregstx, void *dmaregsrx, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level) @@ -386,7 +286,7 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, di = kzalloc(sizeof(dma_info_t), GFP_ATOMIC); if (di == NULL) { #ifdef BCMDBG - printf("dma_attach: out of memory\n"); + printk(KERN_ERR "dma_attach: out of memory\n"); #endif return NULL; } @@ -396,11 +296,7 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, /* old chips w/o sb is no longer supported */ ASSERT(sih != NULL); - if (DMA64_ENAB(di)) - di->dma64 = - ((si_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); - else - di->dma64 = 0; + di->dma64 = ((si_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); /* check arguments */ ASSERT(ISPOWEROF2(ntxd)); @@ -412,23 +308,11 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, ASSERT(dmaregstx == NULL); /* init dma reg pointer */ - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - ASSERT(ntxd <= D64MAXDD); - ASSERT(nrxd <= D64MAXDD); - di->d64txregs = (dma64regs_t *) dmaregstx; - di->d64rxregs = (dma64regs_t *) dmaregsrx; - di->hnddma.di_fn = (const di_fcn_t *)&dma64proc; - } else if (DMA32_ENAB(di)) { - ASSERT(ntxd <= D32MAXDD); - ASSERT(nrxd <= D32MAXDD); - di->d32txregs = (dma32regs_t *) dmaregstx; - di->d32rxregs = (dma32regs_t *) dmaregsrx; - di->hnddma.di_fn = (const di_fcn_t *)&dma32proc; - } else { - DMA_ERROR(("dma_attach: driver doesn't support 32-bit DMA\n")); - ASSERT(0); - goto fail; - } + ASSERT(ntxd <= D64MAXDD); + ASSERT(nrxd <= D64MAXDD); + di->d64txregs = (dma64regs_t *) dmaregstx; + di->d64rxregs = (dma64regs_t *) dmaregsrx; + di->hnddma.di_fn = (const di_fcn_t *)&dma64proc; /* Default flags (which can be changed by the driver calling dma_ctrlflags * before enable): For backwards compatibility both Rx Overflow Continue @@ -438,14 +322,17 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, di->hnddma.di_fn->ctrlflags(&di->hnddma, DMA_CTRL_ROC | DMA_CTRL_PEN, 0); - DMA_TRACE(("%s: dma_attach: %s osh %p flags 0x%x ntxd %d nrxd %d rxbufsize %d " "rxextheadroom %d nrxpost %d rxoffset %d dmaregstx %p dmaregsrx %p\n", name, (DMA64_MODE(di) ? "DMA64" : "DMA32"), osh, di->hnddma.dmactrlflags, ntxd, nrxd, rxbufsize, rxextheadroom, nrxpost, rxoffset, dmaregstx, dmaregsrx)); + DMA_TRACE(("%s: dma_attach: %s flags 0x%x ntxd %d nrxd %d " + "rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d " + "dmaregstx %p dmaregsrx %p\n", name, "DMA64", + di->hnddma.dmactrlflags, ntxd, nrxd, rxbufsize, + rxextheadroom, nrxpost, rxoffset, dmaregstx, dmaregsrx)); /* make a private copy of our callers name */ strncpy(di->name, name, MAXNAMEL); di->name[MAXNAMEL - 1] = '\0'; - di->osh = osh; - di->sih = sih; + di->pbus = ((struct si_info *)sih)->pbus; /* save tunables */ di->ntxd = (u16) ntxd; @@ -472,15 +359,9 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, di->dataoffsetlow = 0; /* for pci bus, add offset */ if (sih->bustype == PCI_BUS) { - if ((sih->buscoretype == PCIE_CORE_ID) && DMA64_MODE(di)) { - /* pcie with DMA64 */ - di->ddoffsetlow = 0; - di->ddoffsethigh = SI_PCIE_DMA_H32; - } else { - /* pci(DMA32/DMA64) or pcie with DMA32 */ - di->ddoffsetlow = SI_PCI_DMA; - di->ddoffsethigh = 0; - } + /* pcie with DMA64 */ + di->ddoffsetlow = 0; + di->ddoffsethigh = SI_PCIE_DMA_H32; di->dataoffsetlow = di->ddoffsetlow; di->dataoffsethigh = di->ddoffsethigh; } @@ -500,14 +381,11 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, /* does the descriptors need to be aligned and if yes, on 4K/8K or not */ di->aligndesc_4k = _dma_descriptor_align(di); if (di->aligndesc_4k) { - if (DMA64_MODE(di)) { - di->dmadesc_align = D64RINGALIGN_BITS; - if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) { - /* for smaller dd table, HW relax the alignment requirement */ - di->dmadesc_align = D64RINGALIGN_BITS - 1; - } - } else - di->dmadesc_align = D32RINGALIGN_BITS; + di->dmadesc_align = D64RINGALIGN_BITS; + if ((ntxd < D64MAXDD / 2) && (nrxd < D64MAXDD / 2)) { + /* for smaller dd table, HW relax alignment reqmnt */ + di->dmadesc_align = D64RINGALIGN_BITS - 1; + } } else di->dmadesc_align = 4; /* 16 byte alignment */ @@ -583,32 +461,6 @@ struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, return NULL; } -/* init the tx or rx descriptor */ -static inline void -dma32_dd_upd(dma_info_t *di, dma32dd_t *ddring, dmaaddr_t pa, uint outidx, - u32 *flags, u32 bufcount) -{ - /* dma32 uses 32-bit control to fit both flags and bufcounter */ - *flags = *flags | (bufcount & CTRL_BC_MASK); - - if ((di->dataoffsetlow == 0) || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { - W_SM(&ddring[outidx].addr, - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow)); - W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*flags)); - } else { - /* address extension */ - u32 ae; - ASSERT(di->addrext); - ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> PCI32ADDR_HIGH_SHIFT; - PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; - - *flags |= (ae << CTRL_AE_SHIFT); - W_SM(&ddring[outidx].addr, - BUS_SWAP32(PHYSADDRLO(pa) + di->dataoffsetlow)); - W_SM(&ddring[outidx].ctrl, BUS_SWAP32(*flags)); - } -} - /* Check for odd number of 1's */ static inline u32 parity32(u32 data) { @@ -669,24 +521,21 @@ dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, dmaaddr_t pa, uint outidx, } } -static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs) +static bool _dma_alloc(dma_info_t *di, uint direction) { - u32 w; - - OR_REG(osh, &dma32regs->control, XC_AE); - w = R_REG(osh, &dma32regs->control); - AND_REG(osh, &dma32regs->control, ~XC_AE); - return (w & XC_AE) == XC_AE; + return dma64_alloc(di, direction); } -static bool _dma_alloc(dma_info_t *di, uint direction) +void *dma_alloc_consistent(struct pci_dev *pdev, uint size, u16 align_bits, + uint *alloced, unsigned long *pap) { - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - return dma64_alloc(di, direction); - } else if (DMA32_ENAB(di)) { - return dma32_alloc(di, direction); - } else - ASSERT(0); + if (align_bits) { + u16 align = (1 << align_bits); + if (!IS_ALIGNED(PAGE_SIZE, align)) + size += align; + *alloced = size; + } + return pci_alloc_consistent(pdev, size, (dma_addr_t *) pap); } /* !! may be called with core in reset */ @@ -700,67 +549,45 @@ static void _dma_detach(dma_info_t *di) ASSERT(di->rxin == di->rxout); /* free dma descriptor rings */ - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - if (di->txd64) - DMA_FREE_CONSISTENT(di->osh, - ((s8 *)di->txd64 - - di->txdalign), di->txdalloc, - (di->txdpaorig), &di->tx_dmah); - if (di->rxd64) - DMA_FREE_CONSISTENT(di->osh, - ((s8 *)di->rxd64 - - di->rxdalign), di->rxdalloc, - (di->rxdpaorig), &di->rx_dmah); - } else if (DMA32_ENAB(di)) { - if (di->txd32) - DMA_FREE_CONSISTENT(di->osh, - ((s8 *)di->txd32 - - di->txdalign), di->txdalloc, - (di->txdpaorig), &di->tx_dmah); - if (di->rxd32) - DMA_FREE_CONSISTENT(di->osh, - ((s8 *)di->rxd32 - - di->rxdalign), di->rxdalloc, - (di->rxdpaorig), &di->rx_dmah); - } else - ASSERT(0); + if (di->txd64) + pci_free_consistent(di->pbus, di->txdalloc, + ((s8 *)di->txd64 - di->txdalign), + (di->txdpaorig)); + if (di->rxd64) + pci_free_consistent(di->pbus, di->rxdalloc, + ((s8 *)di->rxd64 - di->rxdalign), + (di->rxdpaorig)); /* free packet pointer vectors */ - if (di->txp) - kfree((void *)di->txp); - if (di->rxp) - kfree((void *)di->rxp); + kfree(di->txp); + kfree(di->rxp); /* free tx packet DMA handles */ - if (di->txp_dmah) - kfree(di->txp_dmah); + kfree(di->txp_dmah); /* free rx packet DMA handles */ - if (di->rxp_dmah) - kfree(di->rxp_dmah); + kfree(di->rxp_dmah); /* free our private info structure */ - kfree((void *)di); + kfree(di); } static bool _dma_descriptor_align(dma_info_t *di) { - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - u32 addrl; - - /* Check to see if the descriptors need to be aligned on 4K/8K or not */ - if (di->d64txregs != NULL) { - W_REG(di->osh, &di->d64txregs->addrlow, 0xff0); - addrl = R_REG(di->osh, &di->d64txregs->addrlow); - if (addrl != 0) - return false; - } else if (di->d64rxregs != NULL) { - W_REG(di->osh, &di->d64rxregs->addrlow, 0xff0); - addrl = R_REG(di->osh, &di->d64rxregs->addrlow); - if (addrl != 0) - return false; - } + u32 addrl; + + /* Check to see if the descriptors need to be aligned on 4K/8K or not */ + if (di->d64txregs != NULL) { + W_REG(&di->d64txregs->addrlow, 0xff0); + addrl = R_REG(&di->d64txregs->addrlow); + if (addrl != 0) + return false; + } else if (di->d64rxregs != NULL) { + W_REG(&di->d64rxregs->addrlow, 0xff0); + addrl = R_REG(&di->d64rxregs->addrlow); + if (addrl != 0) + return false; } return true; } @@ -768,133 +595,84 @@ static bool _dma_descriptor_align(dma_info_t *di) /* return true if this dma engine supports DmaExtendedAddrChanges, otherwise false */ static bool _dma_isaddrext(dma_info_t *di) { - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ - - /* not all tx or rx channel are available */ - if (di->d64txregs != NULL) { - if (!_dma64_addrext(di->osh, di->d64txregs)) { - DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have AE set\n", di->name)); - ASSERT(0); - } - return true; - } else if (di->d64rxregs != NULL) { - if (!_dma64_addrext(di->osh, di->d64rxregs)) { - DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have AE set\n", di->name)); - ASSERT(0); - } - return true; - } - return false; - } else if (DMA32_ENAB(di)) { - if (di->d32txregs) - return _dma32_addrext(di->osh, di->d32txregs); - else if (di->d32rxregs) - return _dma32_addrext(di->osh, di->d32rxregs); - } else - ASSERT(0); + /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ + /* not all tx or rx channel are available */ + if (di->d64txregs != NULL) { + if (!_dma64_addrext(di->d64txregs)) { + DMA_ERROR(("%s: _dma_isaddrext: DMA64 tx doesn't have " + "AE set\n", di->name)); + ASSERT(0); + } + return true; + } else if (di->d64rxregs != NULL) { + if (!_dma64_addrext(di->d64rxregs)) { + DMA_ERROR(("%s: _dma_isaddrext: DMA64 rx doesn't have " + "AE set\n", di->name)); + ASSERT(0); + } + return true; + } return false; } /* initialize descriptor table base address */ static void _dma_ddtable_init(dma_info_t *di, uint direction, dmaaddr_t pa) { - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - if (!di->aligndesc_4k) { - if (direction == DMA_TX) - di->xmtptrbase = PHYSADDRLO(pa); - else - di->rcvptrbase = PHYSADDRLO(pa); - } + if (!di->aligndesc_4k) { + if (direction == DMA_TX) + di->xmtptrbase = PHYSADDRLO(pa); + else + di->rcvptrbase = PHYSADDRLO(pa); + } - if ((di->ddoffsetlow == 0) - || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { - if (direction == DMA_TX) { - W_REG(di->osh, &di->d64txregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(di->osh, &di->d64txregs->addrhigh, - (PHYSADDRHI(pa) + di->ddoffsethigh)); - } else { - W_REG(di->osh, &di->d64rxregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(di->osh, &di->d64rxregs->addrhigh, - (PHYSADDRHI(pa) + di->ddoffsethigh)); - } + if ((di->ddoffsetlow == 0) + || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { + if (direction == DMA_TX) { + W_REG(&di->d64txregs->addrlow, + (PHYSADDRLO(pa) + di->ddoffsetlow)); + W_REG(&di->d64txregs->addrhigh, + (PHYSADDRHI(pa) + di->ddoffsethigh)); } else { - /* DMA64 32bits address extension */ - u32 ae; - ASSERT(di->addrext); - ASSERT(PHYSADDRHI(pa) == 0); - - /* shift the high bit(s) from pa to ae */ - ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> - PCI32ADDR_HIGH_SHIFT; - PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; - - if (direction == DMA_TX) { - W_REG(di->osh, &di->d64txregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(di->osh, &di->d64txregs->addrhigh, - di->ddoffsethigh); - SET_REG(di->osh, &di->d64txregs->control, - D64_XC_AE, (ae << D64_XC_AE_SHIFT)); - } else { - W_REG(di->osh, &di->d64rxregs->addrlow, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - W_REG(di->osh, &di->d64rxregs->addrhigh, - di->ddoffsethigh); - SET_REG(di->osh, &di->d64rxregs->control, - D64_RC_AE, (ae << D64_RC_AE_SHIFT)); - } + W_REG(&di->d64rxregs->addrlow, + (PHYSADDRLO(pa) + di->ddoffsetlow)); + W_REG(&di->d64rxregs->addrhigh, + (PHYSADDRHI(pa) + di->ddoffsethigh)); } - - } else if (DMA32_ENAB(di)) { + } else { + /* DMA64 32bits address extension */ + u32 ae; + ASSERT(di->addrext); ASSERT(PHYSADDRHI(pa) == 0); - if ((di->ddoffsetlow == 0) - || !(PHYSADDRLO(pa) & PCI32ADDR_HIGH)) { - if (direction == DMA_TX) - W_REG(di->osh, &di->d32txregs->addr, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - else - W_REG(di->osh, &di->d32rxregs->addr, - (PHYSADDRLO(pa) + di->ddoffsetlow)); + + /* shift the high bit(s) from pa to ae */ + ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> + PCI32ADDR_HIGH_SHIFT; + PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; + + if (direction == DMA_TX) { + W_REG(&di->d64txregs->addrlow, + (PHYSADDRLO(pa) + di->ddoffsetlow)); + W_REG(&di->d64txregs->addrhigh, + di->ddoffsethigh); + SET_REG(&di->d64txregs->control, + D64_XC_AE, (ae << D64_XC_AE_SHIFT)); } else { - /* dma32 address extension */ - u32 ae; - ASSERT(di->addrext); - - /* shift the high bit(s) from pa to ae */ - ae = (PHYSADDRLO(pa) & PCI32ADDR_HIGH) >> - PCI32ADDR_HIGH_SHIFT; - PHYSADDRLO(pa) &= ~PCI32ADDR_HIGH; - - if (direction == DMA_TX) { - W_REG(di->osh, &di->d32txregs->addr, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - SET_REG(di->osh, &di->d32txregs->control, XC_AE, - ae << XC_AE_SHIFT); - } else { - W_REG(di->osh, &di->d32rxregs->addr, - (PHYSADDRLO(pa) + di->ddoffsetlow)); - SET_REG(di->osh, &di->d32rxregs->control, RC_AE, - ae << RC_AE_SHIFT); - } + W_REG(&di->d64rxregs->addrlow, + (PHYSADDRLO(pa) + di->ddoffsetlow)); + W_REG(&di->d64rxregs->addrhigh, + di->ddoffsethigh); + SET_REG(&di->d64rxregs->control, + D64_RC_AE, (ae << D64_RC_AE_SHIFT)); } - } else - ASSERT(0); + } } static void _dma_fifoloopbackenable(dma_info_t *di) { DMA_TRACE(("%s: dma_fifoloopbackenable\n", di->name)); - if (DMA64_ENAB(di) && DMA64_MODE(di)) - OR_REG(di->osh, &di->d64txregs->control, D64_XC_LE); - else if (DMA32_ENAB(di)) - OR_REG(di->osh, &di->d32txregs->control, XC_LE); - else - ASSERT(0); + OR_REG(&di->d64txregs->control, D64_XC_LE); } static void _dma_rxinit(dma_info_t *di) @@ -907,62 +685,40 @@ static void _dma_rxinit(dma_info_t *di) di->rxin = di->rxout = 0; /* clear rx descriptor ring */ - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - memset((void *)di->rxd64, '\0', - (di->nrxd * sizeof(dma64dd_t))); + memset((void *)di->rxd64, '\0', + (di->nrxd * sizeof(dma64dd_t))); - /* DMA engine with out alignment requirement requires table to be inited - * before enabling the engine - */ - if (!di->aligndesc_4k) - _dma_ddtable_init(di, DMA_RX, di->rxdpa); + /* DMA engine with out alignment requirement requires table to be inited + * before enabling the engine + */ + if (!di->aligndesc_4k) + _dma_ddtable_init(di, DMA_RX, di->rxdpa); - _dma_rxenable(di); + _dma_rxenable(di); - if (di->aligndesc_4k) - _dma_ddtable_init(di, DMA_RX, di->rxdpa); - } else if (DMA32_ENAB(di)) { - memset((void *)di->rxd32, '\0', - (di->nrxd * sizeof(dma32dd_t))); - _dma_rxenable(di); + if (di->aligndesc_4k) _dma_ddtable_init(di, DMA_RX, di->rxdpa); - } else - ASSERT(0); } static void _dma_rxenable(dma_info_t *di) { uint dmactrlflags = di->hnddma.dmactrlflags; + u32 control; DMA_TRACE(("%s: dma_rxenable\n", di->name)); - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - u32 control = - (R_REG(di->osh, &di->d64rxregs->control) & D64_RC_AE) | - D64_RC_RE; - - if ((dmactrlflags & DMA_CTRL_PEN) == 0) - control |= D64_RC_PD; + control = + (R_REG(&di->d64rxregs->control) & D64_RC_AE) | + D64_RC_RE; - if (dmactrlflags & DMA_CTRL_ROC) - control |= D64_RC_OC; + if ((dmactrlflags & DMA_CTRL_PEN) == 0) + control |= D64_RC_PD; - W_REG(di->osh, &di->d64rxregs->control, - ((di->rxoffset << D64_RC_RO_SHIFT) | control)); - } else if (DMA32_ENAB(di)) { - u32 control = - (R_REG(di->osh, &di->d32rxregs->control) & RC_AE) | RC_RE; + if (dmactrlflags & DMA_CTRL_ROC) + control |= D64_RC_OC; - if ((dmactrlflags & DMA_CTRL_PEN) == 0) - control |= RC_PD; - - if (dmactrlflags & DMA_CTRL_ROC) - control |= RC_OC; - - W_REG(di->osh, &di->d32rxregs->control, - ((di->rxoffset << RC_RO_SHIFT) | control)); - } else - ASSERT(0); + W_REG(&di->d64rxregs->control, + ((di->rxoffset << D64_RC_RO_SHIFT) | control)); } static void @@ -994,7 +750,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if (head == NULL) return NULL; - len = ltoh16(*(u16 *) (head->data)); + len = le16_to_cpu(*(u16 *) (head->data)); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); #if defined(__mips__) @@ -1003,7 +759,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) while (!(len = *(u16 *) OSL_UNCACHED(head->data))) udelay(1); - *(u16 *) (head->data) = htol16((u16) len); + *(u16 *) (head->data) = cpu_to_le16((u16) len); } #endif /* defined(__mips__) */ @@ -1028,14 +784,11 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if (resid > 0) { uint cur; ASSERT(p == NULL); - cur = (DMA64_ENAB(di) && DMA64_MODE(di)) ? - B2I(((R_REG(di->osh, &di->d64rxregs->status0) & + cur = + B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, - dma64dd_t) : B2I(R_REG(di->osh, - &di->d32rxregs-> - status) & RS_CD_MASK, - dma32dd_t); + dma64dd_t); DMA_ERROR(("_dma_rx, rxin %d rxout %d, hw_curr %d\n", di->rxin, di->rxout, cur)); } @@ -1044,7 +797,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if ((di->hnddma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); - pkt_buf_free_skb(di->osh, head, false); + pkt_buf_free_skb(head); di->hnddma.rxgiants++; goto next_frame; } @@ -1092,24 +845,15 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) size to be allocated */ - p = pkt_buf_get_skb(di->osh, di->rxbufsize + extra_offset); + p = pkt_buf_get_skb(di->rxbufsize + extra_offset); if (p == NULL) { DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", di->name)); - if (i == 0) { - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - if (dma64_rxidle(di)) { - DMA_ERROR(("%s: rxfill64: ring is empty !\n", di->name)); - ring_empty = true; - } - } else if (DMA32_ENAB(di)) { - if (dma32_rxidle(di)) { - DMA_ERROR(("%s: rxfill32: ring is empty !\n", di->name)); - ring_empty = true; - } - } else - ASSERT(0); + if (i == 0 && dma64_rxidle(di)) { + DMA_ERROR(("%s: rxfill64: ring is empty !\n", + di->name)); + ring_empty = true; } di->hnddma.rxnobuf++; break; @@ -1127,8 +871,8 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) memset(&di->rxp_dmah[rxout], 0, sizeof(hnddma_seg_map_t)); - pa = DMA_MAP(di->osh, p->data, - di->rxbufsize, DMA_RX, p, &di->rxp_dmah[rxout]); + pa = pci_map_single(di->pbus, p->data, + di->rxbufsize, PCI_DMA_FROMDEVICE); ASSERT(IS_ALIGNED(PHYSADDRLO(pa), 4)); @@ -1138,34 +882,19 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) /* reset flags for each descriptor */ flags = 0; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - if (rxout == (di->nrxd - 1)) - flags = D64_CTRL1_EOT; - - dma64_dd_upd(di, di->rxd64, pa, rxout, &flags, - di->rxbufsize); - } else if (DMA32_ENAB(di)) { - if (rxout == (di->nrxd - 1)) - flags = CTRL_EOT; - - ASSERT(PHYSADDRHI(pa) == 0); - dma32_dd_upd(di, di->rxd32, pa, rxout, &flags, - di->rxbufsize); - } else - ASSERT(0); + if (rxout == (di->nrxd - 1)) + flags = D64_CTRL1_EOT; + + dma64_dd_upd(di, di->rxd64, pa, rxout, &flags, + di->rxbufsize); rxout = NEXTRXD(rxout); } di->rxout = rxout; /* update the chip lastdscr pointer */ - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - W_REG(di->osh, &di->d64rxregs->ptr, - di->rcvptrbase + I2B(rxout, dma64dd_t)); - } else if (DMA32_ENAB(di)) { - W_REG(di->osh, &di->d32rxregs->ptr, I2B(rxout, dma32dd_t)); - } else - ASSERT(0); + W_REG(&di->d64rxregs->ptr, + di->rcvptrbase + I2B(rxout, dma64dd_t)); return ring_empty; } @@ -1178,17 +907,10 @@ static void *_dma_peeknexttxp(dma_info_t *di) if (di->ntxd == 0) return NULL; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - end = - B2I(((R_REG(di->osh, &di->d64txregs->status0) & - D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, - dma64dd_t); - } else if (DMA32_ENAB(di)) { - end = - B2I(R_REG(di->osh, &di->d32txregs->status) & XS_CD_MASK, - dma32dd_t); - } else - ASSERT(0); + end = + B2I(((R_REG(&di->d64txregs->status0) & + D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, + dma64dd_t); for (i = di->txin; i != end; i = NEXTTXD(i)) if (di->txp[i]) @@ -1205,17 +927,10 @@ static void *_dma_peeknextrxp(dma_info_t *di) if (di->nrxd == 0) return NULL; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - end = - B2I(((R_REG(di->osh, &di->d64rxregs->status0) & - D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, - dma64dd_t); - } else if (DMA32_ENAB(di)) { - end = - B2I(R_REG(di->osh, &di->d32rxregs->status) & RS_CD_MASK, - dma32dd_t); - } else - ASSERT(0); + end = + B2I(((R_REG(&di->d64rxregs->status0) & + D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, + dma64dd_t); for (i = di->rxin; i != end; i = NEXTRXD(i)) if (di->rxp[i]) @@ -1231,7 +946,7 @@ static void _dma_rxreclaim(dma_info_t *di) DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); while ((p = _dma_getnextrxp(di, true))) - pkt_buf_free_skb(di->osh, p, false); + pkt_buf_free_skb(p); } static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall) @@ -1239,12 +954,7 @@ static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall) if (di->nrxd == 0) return NULL; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - return dma64_getnextrxp(di, forceall); - } else if (DMA32_ENAB(di)) { - return dma32_getnextrxp(di, forceall); - } else - ASSERT(0); + return dma64_getnextrxp(di, forceall); } static void _dma_txblock(dma_info_t *di) @@ -1266,17 +976,10 @@ static uint _dma_txpending(dma_info_t *di) { uint curr; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - curr = - B2I(((R_REG(di->osh, &di->d64txregs->status0) & - D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, - dma64dd_t); - } else if (DMA32_ENAB(di)) { - curr = - B2I(R_REG(di->osh, &di->d32txregs->status) & XS_CD_MASK, - dma32dd_t); - } else - ASSERT(0); + curr = + B2I(((R_REG(&di->d64txregs->status0) & + D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, + dma64dd_t); return NTXDACTIVE(curr, di->txout); } @@ -1289,12 +992,7 @@ static uint _dma_txcommitted(dma_info_t *di) if (txin == di->txout) return 0; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - ptr = B2I(R_REG(di->osh, &di->d64txregs->ptr), dma64dd_t); - } else if (DMA32_ENAB(di)) { - ptr = B2I(R_REG(di->osh, &di->d32txregs->ptr), dma32dd_t); - } else - ASSERT(0); + ptr = B2I(R_REG(&di->d64txregs->ptr), dma64dd_t); return NTXDACTIVE(di->txin, ptr); } @@ -1330,33 +1028,19 @@ static uint _dma_ctrlflags(dma_info_t *di, uint mask, uint flags) if (dmactrlflags & DMA_CTRL_PEN) { u32 control; - if (DMA64_ENAB(di) && DMA64_MODE(di)) { - control = R_REG(di->osh, &di->d64txregs->control); - W_REG(di->osh, &di->d64txregs->control, - control | D64_XC_PD); - if (R_REG(di->osh, &di->d64txregs->control) & D64_XC_PD) { - /* We *can* disable it so it is supported, - * restore control register - */ - W_REG(di->osh, &di->d64txregs->control, - control); - } else { - /* Not supported, don't allow it to be enabled */ - dmactrlflags &= ~DMA_CTRL_PEN; - } - } else if (DMA32_ENAB(di)) { - control = R_REG(di->osh, &di->d32txregs->control); - W_REG(di->osh, &di->d32txregs->control, - control | XC_PD); - if (R_REG(di->osh, &di->d32txregs->control) & XC_PD) { - W_REG(di->osh, &di->d32txregs->control, - control); - } else { - /* Not supported, don't allow it to be enabled */ - dmactrlflags &= ~DMA_CTRL_PEN; - } - } else - ASSERT(0); + control = R_REG(&di->d64txregs->control); + W_REG(&di->d64txregs->control, + control | D64_XC_PD); + if (R_REG(&di->d64txregs->control) & D64_XC_PD) { + /* We *can* disable it so it is supported, + * restore control register + */ + W_REG(&di->d64txregs->control, + control); + } else { + /* Not supported, don't allow it to be enabled */ + dmactrlflags &= ~DMA_CTRL_PEN; + } } di->hnddma.dmactrlflags = dmactrlflags; @@ -1375,11 +1059,6 @@ static unsigned long _dma_getvar(dma_info_t *di, const char *name) return 0; } -void dma_txpioloopback(struct osl_info *osh, dma32regs_t *regs) -{ - OR_REG(osh, ®s->control, XC_LE); -} - static u8 dma_align_sizetobits(uint size) { @@ -1398,16 +1077,16 @@ u8 dma_align_sizetobits(uint size) * descriptor ring size aligned location. This will ensure that the ring will * not cross page boundary */ -static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, +static void *dma_ringalloc(dma_info_t *di, u32 boundary, uint size, u16 *alignbits, uint *alloced, - dmaaddr_t *descpa, osldma_t **dmah) + dmaaddr_t *descpa) { void *va; u32 desc_strtaddr; u32 alignbytes = 1 << *alignbits; - va = DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced, descpa, - dmah); + va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); + if (NULL == va) return NULL; @@ -1415,569 +1094,13 @@ static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr & boundary)) { *alignbits = dma_align_sizetobits(size); - DMA_FREE_CONSISTENT(osh, va, size, *descpa, dmah); - va = DMA_ALLOC_CONSISTENT(osh, size, *alignbits, alloced, - descpa, dmah); + pci_free_consistent(di->pbus, size, va, *descpa); + va = dma_alloc_consistent(di->pbus, size, *alignbits, + alloced, descpa); } return va; } -/* 32-bit DMA functions */ - -static void dma32_txinit(dma_info_t *di) -{ - u32 control = XC_XE; - - DMA_TRACE(("%s: dma_txinit\n", di->name)); - - if (di->ntxd == 0) - return; - - di->txin = di->txout = 0; - di->hnddma.txavail = di->ntxd - 1; - - /* clear tx descriptor ring */ - memset((void *)di->txd32, '\0', (di->ntxd * sizeof(dma32dd_t))); - - if ((di->hnddma.dmactrlflags & DMA_CTRL_PEN) == 0) - control |= XC_PD; - W_REG(di->osh, &di->d32txregs->control, control); - _dma_ddtable_init(di, DMA_TX, di->txdpa); -} - -static bool dma32_txenabled(dma_info_t *di) -{ - u32 xc; - - /* If the chip is dead, it is not enabled :-) */ - xc = R_REG(di->osh, &di->d32txregs->control); - return (xc != 0xffffffff) && (xc & XC_XE); -} - -static void dma32_txsuspend(dma_info_t *di) -{ - DMA_TRACE(("%s: dma_txsuspend\n", di->name)); - - if (di->ntxd == 0) - return; - - OR_REG(di->osh, &di->d32txregs->control, XC_SE); -} - -static void dma32_txresume(dma_info_t *di) -{ - DMA_TRACE(("%s: dma_txresume\n", di->name)); - - if (di->ntxd == 0) - return; - - AND_REG(di->osh, &di->d32txregs->control, ~XC_SE); -} - -static bool dma32_txsuspended(dma_info_t *di) -{ - return (di->ntxd == 0) - || ((R_REG(di->osh, &di->d32txregs->control) & XC_SE) == XC_SE); -} - -static void dma32_txreclaim(dma_info_t *di, txd_range_t range) -{ - void *p; - - DMA_TRACE(("%s: dma_txreclaim %s\n", di->name, - (range == HNDDMA_RANGE_ALL) ? "all" : - ((range == - HNDDMA_RANGE_TRANSMITTED) ? "transmitted" : - "transfered"))); - - if (di->txin == di->txout) - return; - - while ((p = dma32_getnexttxp(di, range))) - pkt_buf_free_skb(di->osh, p, true); -} - -static bool dma32_txstopped(dma_info_t *di) -{ - return ((R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK) == - XS_XS_STOPPED); -} - -static bool dma32_rxstopped(dma_info_t *di) -{ - return ((R_REG(di->osh, &di->d32rxregs->status) & RS_RS_MASK) == - RS_RS_STOPPED); -} - -static bool dma32_alloc(dma_info_t *di, uint direction) -{ - uint size; - uint ddlen; - void *va; - uint alloced; - u16 align; - u16 align_bits; - - ddlen = sizeof(dma32dd_t); - - size = (direction == DMA_TX) ? (di->ntxd * ddlen) : (di->nrxd * ddlen); - - alloced = 0; - align_bits = di->dmadesc_align; - align = (1 << align_bits); - - if (direction == DMA_TX) { - va = dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig, &di->tx_dmah); - if (va == NULL) { - DMA_ERROR(("%s: dma_alloc: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name)); - return false; - } - - PHYSADDRHISET(di->txdpa, 0); - ASSERT(PHYSADDRHI(di->txdpaorig) == 0); - di->txd32 = (dma32dd_t *) roundup((unsigned long)va, align); - di->txdalign = - (uint) ((s8 *)di->txd32 - (s8 *) va); - - PHYSADDRLOSET(di->txdpa, - PHYSADDRLO(di->txdpaorig) + di->txdalign); - /* Make sure that alignment didn't overflow */ - ASSERT(PHYSADDRLO(di->txdpa) >= PHYSADDRLO(di->txdpaorig)); - - di->txdalloc = alloced; - ASSERT(IS_ALIGNED((unsigned long)di->txd32, align)); - } else { - va = dma_ringalloc(di->osh, D32RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig, &di->rx_dmah); - if (va == NULL) { - DMA_ERROR(("%s: dma_alloc: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name)); - return false; - } - - PHYSADDRHISET(di->rxdpa, 0); - ASSERT(PHYSADDRHI(di->rxdpaorig) == 0); - di->rxd32 = (dma32dd_t *) roundup((unsigned long)va, align); - di->rxdalign = - (uint) ((s8 *)di->rxd32 - (s8 *) va); - - PHYSADDRLOSET(di->rxdpa, - PHYSADDRLO(di->rxdpaorig) + di->rxdalign); - /* Make sure that alignment didn't overflow */ - ASSERT(PHYSADDRLO(di->rxdpa) >= PHYSADDRLO(di->rxdpaorig)); - di->rxdalloc = alloced; - ASSERT(IS_ALIGNED((unsigned long)di->rxd32, align)); - } - - return true; -} - -static bool dma32_txreset(dma_info_t *di) -{ - u32 status; - - if (di->ntxd == 0) - return true; - - /* suspend tx DMA first */ - W_REG(di->osh, &di->d32txregs->control, XC_SE); - SPINWAIT(((status = - (R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK)) - != XS_XS_DISABLED) && (status != XS_XS_IDLE) - && (status != XS_XS_STOPPED), (10000)); - - W_REG(di->osh, &di->d32txregs->control, 0); - SPINWAIT(((status = (R_REG(di->osh, - &di->d32txregs->status) & XS_XS_MASK)) != - XS_XS_DISABLED), 10000); - - /* wait for the last transaction to complete */ - udelay(300); - - return status == XS_XS_DISABLED; -} - -static bool dma32_rxidle(dma_info_t *di) -{ - DMA_TRACE(("%s: dma_rxidle\n", di->name)); - - if (di->nrxd == 0) - return true; - - return ((R_REG(di->osh, &di->d32rxregs->status) & RS_CD_MASK) == - R_REG(di->osh, &di->d32rxregs->ptr)); -} - -static bool dma32_rxreset(dma_info_t *di) -{ - u32 status; - - if (di->nrxd == 0) - return true; - - W_REG(di->osh, &di->d32rxregs->control, 0); - SPINWAIT(((status = (R_REG(di->osh, - &di->d32rxregs->status) & RS_RS_MASK)) != - RS_RS_DISABLED), 10000); - - return status == RS_RS_DISABLED; -} - -static bool dma32_rxenabled(dma_info_t *di) -{ - u32 rc; - - rc = R_REG(di->osh, &di->d32rxregs->control); - return (rc != 0xffffffff) && (rc & RC_RE); -} - -static bool dma32_txsuspendedidle(dma_info_t *di) -{ - if (di->ntxd == 0) - return true; - - if (!(R_REG(di->osh, &di->d32txregs->control) & XC_SE)) - return 0; - - if ((R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK) != XS_XS_IDLE) - return 0; - - udelay(2); - return ((R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK) == - XS_XS_IDLE); -} - -/* !! tx entry routine - * supports full 32bit dma engine buffer addressing so - * dma buffers can cross 4 Kbyte page boundaries. - * - * WARNING: call must check the return value for error. - * the error(toss frames) could be fatal and cause many subsequent hard to debug problems - */ -static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit) -{ - struct sk_buff *p, *next; - unsigned char *data; - uint len; - u16 txout; - u32 flags = 0; - dmaaddr_t pa; - - DMA_TRACE(("%s: dma_txfast\n", di->name)); - - txout = di->txout; - - /* - * Walk the chain of packet buffers - * allocating and initializing transmit descriptor entries. - */ - for (p = p0; p; p = next) { - uint nsegs, j; - hnddma_seg_map_t *map; - - data = p->data; - len = p->len; -#ifdef BCM_DMAPAD - len += PKTDMAPAD(di->osh, p); -#endif - next = p->next; - - /* return nonzero if out of tx descriptors */ - if (NEXTTXD(txout) == di->txin) - goto outoftxd; - - if (len == 0) - continue; - - if (DMASGLIST_ENAB) - memset(&di->txp_dmah[txout], 0, - sizeof(hnddma_seg_map_t)); - - /* get physical address of buffer start */ - pa = DMA_MAP(di->osh, data, len, DMA_TX, p, - &di->txp_dmah[txout]); - - if (DMASGLIST_ENAB) { - map = &di->txp_dmah[txout]; - - /* See if all the segments can be accounted for */ - if (map->nsegs > - (uint) (di->ntxd - NTXDACTIVE(di->txin, di->txout) - - 1)) - goto outoftxd; - - nsegs = map->nsegs; - } else - nsegs = 1; - - for (j = 1; j <= nsegs; j++) { - flags = 0; - if (p == p0 && j == 1) - flags |= CTRL_SOF; - - /* With a DMA segment list, Descriptor table is filled - * using the segment list instead of looping over - * buffers in multi-chain DMA. Therefore, EOF for SGLIST is when - * end of segment list is reached. - */ - if ((!DMASGLIST_ENAB && next == NULL) || - (DMASGLIST_ENAB && j == nsegs)) - flags |= (CTRL_IOC | CTRL_EOF); - if (txout == (di->ntxd - 1)) - flags |= CTRL_EOT; - - if (DMASGLIST_ENAB) { - len = map->segs[j - 1].length; - pa = map->segs[j - 1].addr; - } - ASSERT(PHYSADDRHI(pa) == 0); - - dma32_dd_upd(di, di->txd32, pa, txout, &flags, len); - ASSERT(di->txp[txout] == NULL); - - txout = NEXTTXD(txout); - } - - /* See above. No need to loop over individual buffers */ - if (DMASGLIST_ENAB) - break; - } - - /* if last txd eof not set, fix it */ - if (!(flags & CTRL_EOF)) - W_SM(&di->txd32[PREVTXD(txout)].ctrl, - BUS_SWAP32(flags | CTRL_IOC | CTRL_EOF)); - - /* save the packet */ - di->txp[PREVTXD(txout)] = p0; - - /* bump the tx descriptor index */ - di->txout = txout; - - /* kick the chip */ - if (commit) - W_REG(di->osh, &di->d32txregs->ptr, I2B(txout, dma32dd_t)); - - /* tx flow control */ - di->hnddma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; - - return 0; - - outoftxd: - DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name)); - pkt_buf_free_skb(di->osh, p0, true); - di->hnddma.txavail = 0; - di->hnddma.txnobuf++; - return -1; -} - -/* - * Reclaim next completed txd (txds if using chained buffers) in the range - * specified and return associated packet. - * If range is HNDDMA_RANGE_TRANSMITTED, reclaim descriptors that have be - * transmitted as noted by the hardware "CurrDescr" pointer. - * If range is HNDDMA_RANGE_TRANSFERED, reclaim descriptors that have be - * transfered by the DMA as noted by the hardware "ActiveDescr" pointer. - * If range is HNDDMA_RANGE_ALL, reclaim all txd(s) posted to the ring and - * return associated packet regardless of the value of hardware pointers. - */ -static void *dma32_getnexttxp(dma_info_t *di, txd_range_t range) -{ - u16 start, end, i; - u16 active_desc; - void *txp; - - DMA_TRACE(("%s: dma_getnexttxp %s\n", di->name, - (range == HNDDMA_RANGE_ALL) ? "all" : - ((range == - HNDDMA_RANGE_TRANSMITTED) ? "transmitted" : - "transfered"))); - - if (di->ntxd == 0) - return NULL; - - txp = NULL; - - start = di->txin; - if (range == HNDDMA_RANGE_ALL) - end = di->txout; - else { - dma32regs_t *dregs = di->d32txregs; - - end = - (u16) B2I(R_REG(di->osh, &dregs->status) & XS_CD_MASK, - dma32dd_t); - - if (range == HNDDMA_RANGE_TRANSFERED) { - active_desc = - (u16) ((R_REG(di->osh, &dregs->status) & - XS_AD_MASK) >> XS_AD_SHIFT); - active_desc = (u16) B2I(active_desc, dma32dd_t); - if (end != active_desc) - end = PREVTXD(active_desc); - } - } - - if ((start == 0) && (end > di->txout)) - goto bogus; - - for (i = start; i != end && !txp; i = NEXTTXD(i)) { - dmaaddr_t pa; - hnddma_seg_map_t *map = NULL; - uint size, j, nsegs; - - PHYSADDRLOSET(pa, - (BUS_SWAP32(R_SM(&di->txd32[i].addr)) - - di->dataoffsetlow)); - PHYSADDRHISET(pa, 0); - - if (DMASGLIST_ENAB) { - map = &di->txp_dmah[i]; - size = map->origsize; - nsegs = map->nsegs; - } else { - size = - (BUS_SWAP32(R_SM(&di->txd32[i].ctrl)) & - CTRL_BC_MASK); - nsegs = 1; - } - - for (j = nsegs; j > 0; j--) { - W_SM(&di->txd32[i].addr, 0xdeadbeef); - - txp = di->txp[i]; - di->txp[i] = NULL; - if (j > 1) - i = NEXTTXD(i); - } - - DMA_UNMAP(di->osh, pa, size, DMA_TX, txp, map); - } - - di->txin = i; - - /* tx flow control */ - di->hnddma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; - - return txp; - - bogus: - DMA_NONE(("dma_getnexttxp: bogus curr: start %d end %d txout %d force %d\n", start, end, di->txout, forceall)); - return NULL; -} - -static void *dma32_getnextrxp(dma_info_t *di, bool forceall) -{ - uint i, curr; - void *rxp; - dmaaddr_t pa; - /* if forcing, dma engine must be disabled */ - ASSERT(!forceall || !dma32_rxenabled(di)); - - i = di->rxin; - - /* return if no packets posted */ - if (i == di->rxout) - return NULL; - - curr = - B2I(R_REG(di->osh, &di->d32rxregs->status) & RS_CD_MASK, dma32dd_t); - - /* ignore curr if forceall */ - if (!forceall && (i == curr)) - return NULL; - - /* get the packet pointer that corresponds to the rx descriptor */ - rxp = di->rxp[i]; - ASSERT(rxp); - di->rxp[i] = NULL; - - PHYSADDRLOSET(pa, - (BUS_SWAP32(R_SM(&di->rxd32[i].addr)) - - di->dataoffsetlow)); - PHYSADDRHISET(pa, 0); - - /* clear this packet from the descriptor ring */ - DMA_UNMAP(di->osh, pa, di->rxbufsize, DMA_RX, rxp, &di->rxp_dmah[i]); - - W_SM(&di->rxd32[i].addr, 0xdeadbeef); - - di->rxin = NEXTRXD(i); - - return rxp; -} - -/* - * Rotate all active tx dma ring entries "forward" by (ActiveDescriptor - txin). - */ -static void dma32_txrotate(dma_info_t *di) -{ - u16 ad; - uint nactive; - uint rot; - u16 old, new; - u32 w; - u16 first, last; - - ASSERT(dma32_txsuspendedidle(di)); - - nactive = _dma_txactive(di); - ad = (u16) (B2I - (((R_REG(di->osh, &di->d32txregs->status) & XS_AD_MASK) - >> XS_AD_SHIFT), dma32dd_t)); - rot = TXD(ad - di->txin); - - ASSERT(rot < di->ntxd); - - /* full-ring case is a lot harder - don't worry about this */ - if (rot >= (di->ntxd - nactive)) { - DMA_ERROR(("%s: dma_txrotate: ring full - punt\n", di->name)); - return; - } - - first = di->txin; - last = PREVTXD(di->txout); - - /* move entries starting at last and moving backwards to first */ - for (old = last; old != PREVTXD(first); old = PREVTXD(old)) { - new = TXD(old + rot); - - /* - * Move the tx dma descriptor. - * EOT is set only in the last entry in the ring. - */ - w = BUS_SWAP32(R_SM(&di->txd32[old].ctrl)) & ~CTRL_EOT; - if (new == (di->ntxd - 1)) - w |= CTRL_EOT; - W_SM(&di->txd32[new].ctrl, BUS_SWAP32(w)); - W_SM(&di->txd32[new].addr, R_SM(&di->txd32[old].addr)); - - /* zap the old tx dma descriptor address field */ - W_SM(&di->txd32[old].addr, BUS_SWAP32(0xdeadbeef)); - - /* move the corresponding txp[] entry */ - ASSERT(di->txp[new] == NULL); - di->txp[new] = di->txp[old]; - - /* Move the segment map as well */ - if (DMASGLIST_ENAB) { - bcopy(&di->txp_dmah[old], &di->txp_dmah[new], - sizeof(hnddma_seg_map_t)); - memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); - } - - di->txp[old] = NULL; - } - - /* update txin and txout */ - di->txin = ad; - di->txout = TXD(di->txout + rot); - di->hnddma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; - - /* kick the chip */ - W_REG(di->osh, &di->d32txregs->ptr, I2B(di->txout, dma32dd_t)); -} - /* 64-bit DMA functions */ static void dma64_txinit(dma_info_t *di) @@ -2003,7 +1126,7 @@ static void dma64_txinit(dma_info_t *di) if ((di->hnddma.dmactrlflags & DMA_CTRL_PEN) == 0) control |= D64_XC_PD; - OR_REG(di->osh, &di->d64txregs->control, control); + OR_REG(&di->d64txregs->control, control); /* DMA engine with alignment requirement requires table to be inited * before enabling the engine @@ -2017,7 +1140,7 @@ static bool dma64_txenabled(dma_info_t *di) u32 xc; /* If the chip is dead, it is not enabled :-) */ - xc = R_REG(di->osh, &di->d64txregs->control); + xc = R_REG(&di->d64txregs->control); return (xc != 0xffffffff) && (xc & D64_XC_XE); } @@ -2028,7 +1151,7 @@ static void dma64_txsuspend(dma_info_t *di) if (di->ntxd == 0) return; - OR_REG(di->osh, &di->d64txregs->control, D64_XC_SE); + OR_REG(&di->d64txregs->control, D64_XC_SE); } static void dma64_txresume(dma_info_t *di) @@ -2038,13 +1161,13 @@ static void dma64_txresume(dma_info_t *di) if (di->ntxd == 0) return; - AND_REG(di->osh, &di->d64txregs->control, ~D64_XC_SE); + AND_REG(&di->d64txregs->control, ~D64_XC_SE); } static bool dma64_txsuspended(dma_info_t *di) { return (di->ntxd == 0) || - ((R_REG(di->osh, &di->d64txregs->control) & D64_XC_SE) == + ((R_REG(&di->d64txregs->control) & D64_XC_SE) == D64_XC_SE); } @@ -2064,19 +1187,19 @@ static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range) while ((p = dma64_getnexttxp(di, range))) { /* For unframed data, we don't have any packets to free */ if (!(di->hnddma.dmactrlflags & DMA_CTRL_UNFRAMED)) - pkt_buf_free_skb(di->osh, p, true); + pkt_buf_free_skb(p); } } static bool dma64_txstopped(dma_info_t *di) { - return ((R_REG(di->osh, &di->d64txregs->status0) & D64_XS0_XS_MASK) == + return ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_STOPPED); } static bool dma64_rxstopped(dma_info_t *di) { - return ((R_REG(di->osh, &di->d64rxregs->status0) & D64_RS0_RS_MASK) == + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK) == D64_RS0_RS_STOPPED); } @@ -2096,8 +1219,8 @@ static bool dma64_alloc(dma_info_t *di, uint direction) align = (1 << align_bits); if (direction == DMA_TX) { - va = dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, - &alloced, &di->txdpaorig, &di->tx_dmah); + va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, + &alloced, &di->txdpaorig); if (va == NULL) { DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(ntxd) failed\n", di->name)); return false; @@ -2114,8 +1237,8 @@ static bool dma64_alloc(dma_info_t *di, uint direction) di->txdalloc = alloced; ASSERT(IS_ALIGNED((unsigned long)di->txd64, align)); } else { - va = dma_ringalloc(di->osh, D64RINGALIGN, size, &align_bits, - &alloced, &di->rxdpaorig, &di->rx_dmah); + va = dma_ringalloc(di, D64RINGALIGN, size, &align_bits, + &alloced, &di->rxdpaorig); if (va == NULL) { DMA_ERROR(("%s: dma64_alloc: DMA_ALLOC_CONSISTENT(nrxd) failed\n", di->name)); return false; @@ -2144,15 +1267,15 @@ static bool dma64_txreset(dma_info_t *di) return true; /* suspend tx DMA first */ - W_REG(di->osh, &di->d64txregs->control, D64_XC_SE); + W_REG(&di->d64txregs->control, D64_XC_SE); SPINWAIT(((status = - (R_REG(di->osh, &di->d64txregs->status0) & D64_XS0_XS_MASK)) + (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED) && (status != D64_XS0_XS_IDLE) && (status != D64_XS0_XS_STOPPED), 10000); - W_REG(di->osh, &di->d64txregs->control, 0); + W_REG(&di->d64txregs->control, 0); SPINWAIT(((status = - (R_REG(di->osh, &di->d64txregs->status0) & D64_XS0_XS_MASK)) + (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED), 10000); /* wait for the last transaction to complete */ @@ -2168,8 +1291,8 @@ static bool dma64_rxidle(dma_info_t *di) if (di->nrxd == 0) return true; - return ((R_REG(di->osh, &di->d64rxregs->status0) & D64_RS0_CD_MASK) == - (R_REG(di->osh, &di->d64rxregs->ptr) & D64_RS0_CD_MASK)); + return ((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) == + (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); } static bool dma64_rxreset(dma_info_t *di) @@ -2179,9 +1302,9 @@ static bool dma64_rxreset(dma_info_t *di) if (di->nrxd == 0) return true; - W_REG(di->osh, &di->d64rxregs->control, 0); + W_REG(&di->d64rxregs->control, 0); SPINWAIT(((status = - (R_REG(di->osh, &di->d64rxregs->status0) & D64_RS0_RS_MASK)) + (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED), 10000); return status == D64_RS0_RS_DISABLED; @@ -2191,7 +1314,7 @@ static bool dma64_rxenabled(dma_info_t *di) { u32 rc; - rc = R_REG(di->osh, &di->d64rxregs->control); + rc = R_REG(&di->d64rxregs->control); return (rc != 0xffffffff) && (rc & D64_RC_RE); } @@ -2201,10 +1324,10 @@ static bool dma64_txsuspendedidle(dma_info_t *di) if (di->ntxd == 0) return true; - if (!(R_REG(di->osh, &di->d64txregs->control) & D64_XC_SE)) + if (!(R_REG(&di->d64txregs->control) & D64_XC_SE)) return 0; - if ((R_REG(di->osh, &di->d64txregs->status0) & D64_XS0_XS_MASK) == + if ((R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK) == D64_XS0_XS_IDLE) return 1; @@ -2223,12 +1346,12 @@ static void *dma64_getpos(dma_info_t *di, bool direction) if (direction == DMA_TX) { cd_offset = - R_REG(di->osh, &di->d64txregs->status0) & D64_XS0_CD_MASK; + R_REG(&di->d64txregs->status0) & D64_XS0_CD_MASK; idle = !NTXDACTIVE(di->txin, di->txout); va = di->txp[B2I(cd_offset, dma64dd_t)]; } else { cd_offset = - R_REG(di->osh, &di->d64rxregs->status0) & D64_XS0_CD_MASK; + R_REG(&di->d64rxregs->status0) & D64_XS0_CD_MASK; idle = !NRXDACTIVE(di->rxin, di->rxout); va = di->rxp[B2I(cd_offset, dma64dd_t)]; } @@ -2265,7 +1388,7 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit) if (len == 0) return 0; - pa = DMA_MAP(di->osh, buf, len, DMA_TX, NULL, &di->txp_dmah[txout]); + pa = pci_map_single(di->pbus, buf, len, PCI_DMA_TODEVICE); flags = (D64_CTRL1_SOF | D64_CTRL1_IOC | D64_CTRL1_EOF); @@ -2284,7 +1407,7 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit) /* kick the chip */ if (commit) { - W_REG(di->osh, &di->d64txregs->ptr, + W_REG(&di->d64txregs->ptr, di->xmtptrbase + I2B(txout, dma64dd_t)); } @@ -2345,8 +1468,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, memset(&di->txp_dmah[txout], 0, sizeof(hnddma_seg_map_t)); - pa = DMA_MAP(di->osh, data, len, DMA_TX, p, - &di->txp_dmah[txout]); + pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); if (DMASGLIST_ENAB) { map = &di->txp_dmah[txout]; @@ -2405,7 +1527,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, /* kick the chip */ if (commit) - W_REG(di->osh, &di->d64txregs->ptr, + W_REG(&di->d64txregs->ptr, di->xmtptrbase + I2B(txout, dma64dd_t)); /* tx flow control */ @@ -2415,7 +1537,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name)); - pkt_buf_free_skb(di->osh, p0, true); + pkt_buf_free_skb(p0); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; @@ -2456,13 +1578,13 @@ static void *BCMFASTPATH dma64_getnexttxp(dma_info_t *di, txd_range_t range) end = (u16) (B2I - (((R_REG(di->osh, &dregs->status0) & + (((R_REG(&dregs->status0) & D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, dma64dd_t)); if (range == HNDDMA_RANGE_TRANSFERED) { active_desc = - (u16) (R_REG(di->osh, &dregs->status1) & + (u16) (R_REG(&dregs->status1) & D64_XS1_AD_MASK); active_desc = (active_desc - di->xmtptrbase) & D64_XS0_CD_MASK; @@ -2508,7 +1630,7 @@ static void *BCMFASTPATH dma64_getnexttxp(dma_info_t *di, txd_range_t range) i = NEXTTXD(i); } - DMA_UNMAP(di->osh, pa, size, DMA_TX, txp, map); + pci_unmap_single(di->pbus, pa, size, PCI_DMA_TODEVICE); } di->txin = i; @@ -2539,7 +1661,7 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall) return NULL; curr = - B2I(((R_REG(di->osh, &di->d64rxregs->status0) & D64_RS0_CD_MASK) - + B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, dma64dd_t); /* ignore curr if forceall */ @@ -2559,7 +1681,7 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall) di->dataoffsethigh)); /* clear this packet from the descriptor ring */ - DMA_UNMAP(di->osh, pa, di->rxbufsize, DMA_RX, rxp, &di->rxp_dmah[i]); + pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); W_SM(&di->rxd64[i].addrlow, 0xdeadbeef); W_SM(&di->rxd64[i].addrhigh, 0xdeadbeef); @@ -2569,12 +1691,12 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall) return rxp; } -static bool _dma64_addrext(struct osl_info *osh, dma64regs_t * dma64regs) +static bool _dma64_addrext(dma64regs_t *dma64regs) { u32 w; - OR_REG(osh, &dma64regs->control, D64_XC_AE); - w = R_REG(osh, &dma64regs->control); - AND_REG(osh, &dma64regs->control, ~D64_XC_AE); + OR_REG(&dma64regs->control, D64_XC_AE); + w = R_REG(&dma64regs->control); + AND_REG(&dma64regs->control, ~D64_XC_AE); return (w & D64_XC_AE) == D64_XC_AE; } @@ -2594,7 +1716,7 @@ static void dma64_txrotate(dma_info_t *di) nactive = _dma_txactive(di); ad = (u16) (B2I - ((((R_REG(di->osh, &di->d64txregs->status1) & + ((((R_REG(&di->d64txregs->status1) & D64_XS1_AD_MASK) - di->xmtptrbase) & D64_XS1_AD_MASK), dma64dd_t)); rot = TXD(ad - di->txin); @@ -2639,8 +1761,8 @@ static void dma64_txrotate(dma_info_t *di) /* Move the map */ if (DMASGLIST_ENAB) { - bcopy(&di->txp_dmah[old], &di->txp_dmah[new], - sizeof(hnddma_seg_map_t)); + memcpy(&di->txp_dmah[new], &di->txp_dmah[old], + sizeof(hnddma_seg_map_t)); memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); } @@ -2653,17 +1775,12 @@ static void dma64_txrotate(dma_info_t *di) di->hnddma.txavail = di->ntxd - NTXDACTIVE(di->txin, di->txout) - 1; /* kick the chip */ - W_REG(di->osh, &di->d64txregs->ptr, + W_REG(&di->d64txregs->ptr, di->xmtptrbase + I2B(di->txout, dma64dd_t)); } uint dma_addrwidth(si_t *sih, void *dmaregs) { - dma32regs_t *dma32regs; - struct osl_info *osh; - - osh = si_osh(sih); - /* Perform 64-bit checks only if we want to advertise 64-bit (> 32bit) capability) */ /* DMA engine is 64-bit capable */ if ((si_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64) { @@ -2674,23 +1791,32 @@ uint dma_addrwidth(si_t *sih, void *dmaregs) ((sih->bustype == PCI_BUS) && (sih->buscoretype == PCIE_CORE_ID))) return DMADDRWIDTH_64; - - /* DMA64 is always 32-bit capable, AE is always true */ - ASSERT(_dma64_addrext(osh, (dma64regs_t *) dmaregs)); - - return DMADDRWIDTH_32; } + ASSERT(0); /* DMA hardware not supported by this driver*/ + return DMADDRWIDTH_64; +} - /* Start checking for 32-bit / 30-bit addressing */ - dma32regs = (dma32regs_t *) dmaregs; - - /* For System Backplane, PCIE bus or addrext feature, 32-bits ok */ - if ((sih->bustype == SI_BUS) || - ((sih->bustype == PCI_BUS) - && sih->buscoretype == PCIE_CORE_ID) - || (_dma32_addrext(osh, dma32regs))) - return DMADDRWIDTH_32; - - /* Fallthru */ - return DMADDRWIDTH_30; +/* + * Mac80211 initiated actions sometimes require packets in the DMA queue to be + * modified. The modified portion of the packet is not under control of the DMA + * engine. This function calls a caller-supplied function for each packet in + * the caller specified dma chain. + */ +void dma_walk_packets(struct hnddma_pub *dmah, void (*callback_fnc) + (void *pkt, void *arg_a), void *arg_a) +{ + dma_info_t *di = (dma_info_t *) dmah; + uint i = di->txin; + uint end = di->txout; + struct sk_buff *skb; + struct ieee80211_tx_info *tx_info; + + while (i != end) { + skb = (struct sk_buff *)di->txp[i]; + if (skb != NULL) { + tx_info = (struct ieee80211_tx_info *)skb->cb; + (callback_fnc)(tx_info, arg_a); + } + i = NEXTTXD(i); + } } diff --git a/drivers/staging/brcm80211/util/hndpmu.c b/drivers/staging/brcm80211/util/hndpmu.c index 6cc59a895868..59e3ede89fe7 100644 --- a/drivers/staging/brcm80211/util/hndpmu.c +++ b/drivers/staging/brcm80211/util/hndpmu.c @@ -18,11 +18,7 @@ #include <linux/string.h> #include <linux/module.h> #include <linux/pci.h> -#ifdef BRCM_FULLMAC -#include <linux/netdevice.h> -#endif #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> #include <bcmdevs.h> @@ -34,7 +30,11 @@ #define PMU_ERROR(args) #ifdef BCMDBG -#define PMU_MSG(args) printf args +#define PMU_MSG(args) printk args + +/* debug-only definitions */ +/* #define BCMDBG_FORCEHT */ +/* #define CHIPC_UART_ALWAYS_ON */ #else #define PMU_MSG(args) #endif /* BCMDBG */ @@ -45,23 +45,20 @@ #define PMU_NONE(args) /* PLL controls/clocks */ -static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, - u32 xtal); -static u32 si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); -static u32 si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); +static void si_pmu1_pllinit0(si_t *sih, chipcregs_t *cc, u32 xtal); +static u32 si_pmu1_cpuclk0(si_t *sih, chipcregs_t *cc); +static u32 si_pmu1_alpclk0(si_t *sih, chipcregs_t *cc); /* PMU resources */ static bool si_pmu_res_depfltr_bb(si_t *sih); static bool si_pmu_res_depfltr_ncb(si_t *sih); static bool si_pmu_res_depfltr_paldo(si_t *sih); static bool si_pmu_res_depfltr_npaldo(si_t *sih); -static u32 si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, - u32 rsrcs, bool all); -static uint si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, - u8 rsrc); +static u32 si_pmu_res_deps(si_t *sih, chipcregs_t *cc, u32 rsrcs, bool all); +static uint si_pmu_res_uptime(si_t *sih, chipcregs_t *cc, u8 rsrc); static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax); static void si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, - struct osl_info *osh, u8 spuravoid); + u8 spuravoid); static void si_pmu_set_4330_plldivs(si_t *sih); @@ -106,8 +103,7 @@ void si_pmu_pllupd(si_t *sih) } /* Setup switcher voltage */ -void si_pmu_set_switcher_voltage(si_t *sih, struct osl_info *osh, u8 bb_voltage, - u8 rf_voltage) +void si_pmu_set_switcher_voltage(si_t *sih, u8 bb_voltage, u8 rf_voltage) { chipcregs_t *cc; uint origidx; @@ -119,17 +115,17 @@ void si_pmu_set_switcher_voltage(si_t *sih, struct osl_info *osh, u8 bb_voltage, cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - W_REG(osh, &cc->regcontrol_addr, 0x01); - W_REG(osh, &cc->regcontrol_data, (u32) (bb_voltage & 0x1f) << 22); + W_REG(&cc->regcontrol_addr, 0x01); + W_REG(&cc->regcontrol_data, (u32) (bb_voltage & 0x1f) << 22); - W_REG(osh, &cc->regcontrol_addr, 0x00); - W_REG(osh, &cc->regcontrol_data, (u32) (rf_voltage & 0x1f) << 14); + W_REG(&cc->regcontrol_addr, 0x00); + W_REG(&cc->regcontrol_data, (u32) (rf_voltage & 0x1f) << 14); /* Return to original core */ si_setcoreidx(sih, origidx); } -void si_pmu_set_ldo_voltage(si_t *sih, struct osl_info *osh, u8 ldo, u8 voltage) +void si_pmu_set_ldo_voltage(si_t *sih, u8 ldo, u8 voltage) { u8 sr_cntl_shift = 0, rc_shift = 0, shift = 0, mask = 0; u8 addr = 0; @@ -187,7 +183,7 @@ void si_pmu_set_ldo_voltage(si_t *sih, struct osl_info *osh, u8 ldo, u8 voltage) /* d11 slow to fast clock transition time in slow clock cycles */ #define D11SCC_SLOW2FAST_TRANSITION 2 -u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) +u16 si_pmu_fast_pwrup_delay(si_t *sih) { uint delay = PMU_MAX_TRANSITION_DLY; chipcregs_t *cc; @@ -222,7 +218,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) else { u32 ilp = si_ilp_clock(sih); delay = - (si_pmu_res_uptime(sih, osh, cc, RES4329_HT_AVAIL) + + (si_pmu_res_uptime(sih, cc, RES4329_HT_AVAIL) + D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - 1) / ilp); delay = (11 * delay) / 10; @@ -237,7 +233,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) else { u32 ilp = si_ilp_clock(sih); delay = - (si_pmu_res_uptime(sih, osh, cc, RES4336_HT_AVAIL) + + (si_pmu_res_uptime(sih, cc, RES4336_HT_AVAIL) + D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - 1) / ilp); delay = (11 * delay) / 10; @@ -249,7 +245,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) else { u32 ilp = si_ilp_clock(sih); delay = - (si_pmu_res_uptime(sih, osh, cc, RES4330_HT_AVAIL) + + (si_pmu_res_uptime(sih, cc, RES4330_HT_AVAIL) + D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - 1) / ilp); delay = (11 * delay) / 10; @@ -264,7 +260,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) return (u16) delay; } -u32 si_pmu_force_ilp(si_t *sih, struct osl_info *osh, bool force) +u32 si_pmu_force_ilp(si_t *sih, bool force) { chipcregs_t *cc; uint origidx; @@ -277,12 +273,12 @@ u32 si_pmu_force_ilp(si_t *sih, struct osl_info *osh, bool force) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - oldpmucontrol = R_REG(osh, &cc->pmucontrol); + oldpmucontrol = R_REG(&cc->pmucontrol); if (force) - W_REG(osh, &cc->pmucontrol, oldpmucontrol & + W_REG(&cc->pmucontrol, oldpmucontrol & ~(PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN)); else - W_REG(osh, &cc->pmucontrol, oldpmucontrol | + W_REG(&cc->pmucontrol, oldpmucontrol | (PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN)); /* Return to original core */ @@ -682,7 +678,7 @@ static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax) } /* initialize PMU resources */ -void si_pmu_res_init(si_t *sih, struct osl_info *osh) +void si_pmu_res_init(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -777,9 +773,9 @@ void si_pmu_res_init(si_t *sih, struct osl_info *osh) PMU_MSG(("Changing rsrc %d res_updn_timer to 0x%x\n", pmu_res_updown_table[pmu_res_updown_table_sz].resnum, pmu_res_updown_table[pmu_res_updown_table_sz].updown)); - W_REG(osh, &cc->res_table_sel, + W_REG(&cc->res_table_sel, pmu_res_updown_table[pmu_res_updown_table_sz].resnum); - W_REG(osh, &cc->res_updn_timer, + W_REG(&cc->res_updn_timer, pmu_res_updown_table[pmu_res_updown_table_sz].updown); } /* Apply nvram overrides to up/down timers */ @@ -790,8 +786,8 @@ void si_pmu_res_init(si_t *sih, struct osl_info *osh) continue; PMU_MSG(("Applying %s=%s to rsrc %d res_updn_timer\n", name, val, i)); - W_REG(osh, &cc->res_table_sel, (u32) i); - W_REG(osh, &cc->res_updn_timer, + W_REG(&cc->res_table_sel, (u32) i); + W_REG(&cc->res_updn_timer, (u32) simple_strtoul(val, NULL, 0)); } @@ -806,24 +802,24 @@ void si_pmu_res_init(si_t *sih, struct osl_info *osh) if ((pmu_res_depend_table[pmu_res_depend_table_sz]. res_mask & PMURES_BIT(i)) == 0) continue; - W_REG(osh, &cc->res_table_sel, i); + W_REG(&cc->res_table_sel, i); switch (pmu_res_depend_table[pmu_res_depend_table_sz]. action) { case RES_DEPEND_SET: PMU_MSG(("Changing rsrc %d res_dep_mask to 0x%x\n", i, pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask)); - W_REG(osh, &cc->res_dep_mask, + W_REG(&cc->res_dep_mask, pmu_res_depend_table [pmu_res_depend_table_sz].depend_mask); break; case RES_DEPEND_ADD: PMU_MSG(("Adding 0x%x to rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i)); - OR_REG(osh, &cc->res_dep_mask, + OR_REG(&cc->res_dep_mask, pmu_res_depend_table [pmu_res_depend_table_sz].depend_mask); break; case RES_DEPEND_REMOVE: PMU_MSG(("Removing 0x%x from rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i)); - AND_REG(osh, &cc->res_dep_mask, + AND_REG(&cc->res_dep_mask, ~pmu_res_depend_table [pmu_res_depend_table_sz].depend_mask); break; @@ -841,8 +837,8 @@ void si_pmu_res_init(si_t *sih, struct osl_info *osh) continue; PMU_MSG(("Applying %s=%s to rsrc %d res_dep_mask\n", name, val, i)); - W_REG(osh, &cc->res_table_sel, (u32) i); - W_REG(osh, &cc->res_dep_mask, + W_REG(&cc->res_table_sel, (u32) i); + W_REG(&cc->res_dep_mask, (u32) simple_strtoul(val, NULL, 0)); } @@ -855,14 +851,14 @@ void si_pmu_res_init(si_t *sih, struct osl_info *osh) if (max_mask) { PMU_MSG(("Changing max_res_mask to 0x%x\n", max_mask)); - W_REG(osh, &cc->max_res_mask, max_mask); + W_REG(&cc->max_res_mask, max_mask); } /* Program min resource mask */ if (min_mask) { PMU_MSG(("Changing min_res_mask to 0x%x\n", min_mask)); - W_REG(osh, &cc->min_res_mask, min_mask); + W_REG(&cc->min_res_mask, min_mask); } /* Add some delay; allow resources to come up and settle. */ @@ -1183,13 +1179,13 @@ static u32 si_pmu1_pllfvco0(si_t *sih) /* query alp/xtal clock frequency */ static u32 -si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) +si_pmu1_alpclk0(si_t *sih, chipcregs_t *cc) { const pmu1_xtaltab0_t *xt; u32 xf; /* Find the frequency in the table */ - xf = (R_REG(osh, &cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> + xf = (R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> PCTL_XTALFREQ_SHIFT; for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++) if (xt->xf == xf) @@ -1208,8 +1204,7 @@ si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) * case the xtal frequency is unknown to the s/w so we need to call * si_pmu1_xtaldef0() wherever it is needed to return a default value. */ -static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, - u32 xtal) +static void si_pmu1_pllinit0(si_t *sih, chipcregs_t *cc, u32 xtal) { const pmu1_xtaltab0_t *xt; u32 tmp; @@ -1237,7 +1232,7 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, /* for 4319 bootloader already programs the PLL but bootloader does not program the PLL4 and PLL5. So Skip this check for 4319 */ - if ((((R_REG(osh, &cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> + if ((((R_REG(&cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> PCTL_XTALFREQ_SHIFT) == xt->xf) && !((sih->chip == BCM4319_CHIP_ID) || (sih->chip == BCM4330_CHIP_ID))) { @@ -1254,16 +1249,16 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, case BCM4329_CHIP_ID: /* Change the BBPLL drive strength to 8 for all channels */ buf_strength = 0x888888; - AND_REG(osh, &cc->min_res_mask, + AND_REG(&cc->min_res_mask, ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) | PMURES_BIT(RES4329_HT_AVAIL))); - AND_REG(osh, &cc->max_res_mask, + AND_REG(&cc->max_res_mask, ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) | PMURES_BIT(RES4329_HT_AVAIL))); - SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, + SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL, PMU_MAX_TRANSITION_DLY); - ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL)); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); if (xt->fref == 38400) tmp = 0x200024C0; else if (xt->fref == 37400) @@ -1272,17 +1267,16 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, tmp = 0x200024C0; else tmp = 0x200005C0; /* Chip Dflt Settings */ - W_REG(osh, &cc->pllcontrol_data, tmp); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); tmp = - R_REG(osh, - &cc->pllcontrol_data) & PMU1_PLL0_PC5_CLK_DRV_MASK; + R_REG(&cc->pllcontrol_data) & PMU1_PLL0_PC5_CLK_DRV_MASK; if ((xt->fref == 38400) || (xt->fref == 37400) || (xt->fref == 26000)) tmp |= 0x15; else tmp |= 0x25; /* Chip Dflt Settings */ - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); break; case BCM4319_CHIP_ID: @@ -1294,50 +1288,50 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, * after a delay (more than downtime for HT_AVAIL) remove the * BBPLL resource; backplane clock moves to ALP from HT. */ - AND_REG(osh, &cc->min_res_mask, + AND_REG(&cc->min_res_mask, ~(PMURES_BIT(RES4319_HT_AVAIL))); - AND_REG(osh, &cc->max_res_mask, + AND_REG(&cc->max_res_mask, ~(PMURES_BIT(RES4319_HT_AVAIL))); udelay(100); - AND_REG(osh, &cc->min_res_mask, + AND_REG(&cc->min_res_mask, ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU))); - AND_REG(osh, &cc->max_res_mask, + AND_REG(&cc->max_res_mask, ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU))); udelay(100); - SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, + SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL, PMU_MAX_TRANSITION_DLY); - ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL)); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); tmp = 0x200005c0; - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); break; case BCM4336_CHIP_ID: - AND_REG(osh, &cc->min_res_mask, + AND_REG(&cc->min_res_mask, ~(PMURES_BIT(RES4336_HT_AVAIL) | PMURES_BIT(RES4336_MACPHY_CLKAVAIL))); - AND_REG(osh, &cc->max_res_mask, + AND_REG(&cc->max_res_mask, ~(PMURES_BIT(RES4336_HT_AVAIL) | PMURES_BIT(RES4336_MACPHY_CLKAVAIL))); udelay(100); - SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, + SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL, PMU_MAX_TRANSITION_DLY); - ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); + ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL)); break; case BCM4330_CHIP_ID: - AND_REG(osh, &cc->min_res_mask, + AND_REG(&cc->min_res_mask, ~(PMURES_BIT(RES4330_HT_AVAIL) | PMURES_BIT(RES4330_MACPHY_CLKAVAIL))); - AND_REG(osh, &cc->max_res_mask, + AND_REG(&cc->max_res_mask, ~(PMURES_BIT(RES4330_HT_AVAIL) | PMURES_BIT(RES4330_MACPHY_CLKAVAIL))); udelay(100); - SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, + SPINWAIT(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL, PMU_MAX_TRANSITION_DLY); - ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); + ASSERT(!(R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL)); break; default: @@ -1347,15 +1341,15 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, PMU_MSG(("Done masking\n")); /* Write p1div and p2div to pllcontrol[0] */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - tmp = R_REG(osh, &cc->pllcontrol_data) & + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + tmp = R_REG(&cc->pllcontrol_data) & ~(PMU1_PLL0_PC0_P1DIV_MASK | PMU1_PLL0_PC0_P2DIV_MASK); tmp |= ((xt-> p1div << PMU1_PLL0_PC0_P1DIV_SHIFT) & PMU1_PLL0_PC0_P1DIV_MASK) | ((xt-> p2div << PMU1_PLL0_PC0_P2DIV_SHIFT) & PMU1_PLL0_PC0_P2DIV_MASK); - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); if ((sih->chip == BCM4330_CHIP_ID)) si_pmu_set_4330_plldivs(sih); @@ -1363,11 +1357,11 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, if ((sih->chip == BCM4329_CHIP_ID) && (sih->chiprev == 0)) { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + tmp = R_REG(&cc->pllcontrol_data); tmp = tmp & (~DOT11MAC_880MHZ_CLK_DIVISOR_MASK); tmp = tmp | DOT11MAC_880MHZ_CLK_DIVISOR_VAL; - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); } if ((sih->chip == BCM4319_CHIP_ID) || (sih->chip == BCM4336_CHIP_ID) || @@ -1377,8 +1371,8 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MASH; /* Write ndiv_int and ndiv_mode to pllcontrol[2] */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - tmp = R_REG(osh, &cc->pllcontrol_data) & + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + tmp = R_REG(&cc->pllcontrol_data) & ~(PMU1_PLL0_PC2_NDIV_INT_MASK | PMU1_PLL0_PC2_NDIV_MODE_MASK); tmp |= ((xt-> @@ -1386,26 +1380,25 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, PMU1_PLL0_PC2_NDIV_INT_MASK) | ((ndiv_mode << PMU1_PLL0_PC2_NDIV_MODE_SHIFT) & PMU1_PLL0_PC2_NDIV_MODE_MASK); - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); /* Write ndiv_frac to pllcontrol[3] */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - tmp = R_REG(osh, &cc->pllcontrol_data) & ~PMU1_PLL0_PC3_NDIV_FRAC_MASK; + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + tmp = R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC3_NDIV_FRAC_MASK; tmp |= ((xt->ndiv_frac << PMU1_PLL0_PC3_NDIV_FRAC_SHIFT) & PMU1_PLL0_PC3_NDIV_FRAC_MASK); - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); /* Write clock driving strength to pllcontrol[5] */ if (buf_strength) { PMU_MSG(("Adjusting PLL buffer drive strength: %x\n", buf_strength)); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); tmp = - R_REG(osh, - &cc->pllcontrol_data) & ~PMU1_PLL0_PC5_CLK_DRV_MASK; + R_REG(&cc->pllcontrol_data) & ~PMU1_PLL0_PC5_CLK_DRV_MASK; tmp |= (buf_strength << PMU1_PLL0_PC5_CLK_DRV_SHIFT); - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); } PMU_MSG(("Done pll\n")); @@ -1415,10 +1408,9 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, */ if ((sih->chip == BCM4319_CHIP_ID) && (xt->fref != XTAL_FREQ_30000MHZ)) { - W_REG(osh, &cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2); + W_REG(&cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2); tmp = - R_REG(osh, - &cc->chipcontrol_data) & ~CCTL_4319USB_XTAL_SEL_MASK; + R_REG(&cc->chipcontrol_data) & ~CCTL_4319USB_XTAL_SEL_MASK; if (xt->fref == XTAL_FREQ_24000MHZ) { tmp |= (CCTL_4319USB_24MHZ_PLL_SEL << @@ -1428,15 +1420,15 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, (CCTL_4319USB_48MHZ_PLL_SEL << CCTL_4319USB_XTAL_SEL_SHIFT); } - W_REG(osh, &cc->chipcontrol_data, tmp); + W_REG(&cc->chipcontrol_data, tmp); } /* Flush deferred pll control registers writes */ if (sih->pmurev >= 2) - OR_REG(osh, &cc->pmucontrol, PCTL_PLL_PLLCTL_UPD); + OR_REG(&cc->pmucontrol, PCTL_PLL_PLLCTL_UPD); /* Write XtalFreq. Set the divisor also. */ - tmp = R_REG(osh, &cc->pmucontrol) & + tmp = R_REG(&cc->pmucontrol) & ~(PCTL_ILP_DIV_MASK | PCTL_XTALFREQ_MASK); tmp |= (((((xt->fref + 127) / 128) - 1) << PCTL_ILP_DIV_SHIFT) & PCTL_ILP_DIV_MASK) | @@ -1445,16 +1437,16 @@ static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, if ((sih->chip == BCM4329_CHIP_ID) && sih->chiprev == 0) { /* clear the htstretch before clearing HTReqEn */ - AND_REG(osh, &cc->clkstretch, ~CSTRETCH_HT); + AND_REG(&cc->clkstretch, ~CSTRETCH_HT); tmp &= ~PCTL_HT_REQ_EN; } - W_REG(osh, &cc->pmucontrol, tmp); + W_REG(&cc->pmucontrol, tmp); } /* query the CPU clock frequency */ static u32 -si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) +si_pmu1_cpuclk0(si_t *sih, chipcregs_t *cc) { u32 tmp, m1div; #ifdef BCMDBG @@ -1464,30 +1456,30 @@ si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) u32 FVCO = si_pmu1_pllfvco0(sih); /* Read m1div from pllcontrol[1] */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + tmp = R_REG(&cc->pllcontrol_data); m1div = (tmp & PMU1_PLL0_PC1_M1DIV_MASK) >> PMU1_PLL0_PC1_M1DIV_SHIFT; #ifdef BCMDBG /* Read p2div/p1div from pllcontrol[0] */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + tmp = R_REG(&cc->pllcontrol_data); p2div = (tmp & PMU1_PLL0_PC0_P2DIV_MASK) >> PMU1_PLL0_PC0_P2DIV_SHIFT; p1div = (tmp & PMU1_PLL0_PC0_P1DIV_MASK) >> PMU1_PLL0_PC0_P1DIV_SHIFT; /* Calculate fvco based on xtal freq and ndiv and pdiv */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + tmp = R_REG(&cc->pllcontrol_data); ndiv_int = (tmp & PMU1_PLL0_PC2_NDIV_INT_MASK) >> PMU1_PLL0_PC2_NDIV_INT_SHIFT; - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + tmp = R_REG(&cc->pllcontrol_data); ndiv_frac = (tmp & PMU1_PLL0_PC3_NDIV_FRAC_MASK) >> PMU1_PLL0_PC3_NDIV_FRAC_SHIFT; - fref = si_pmu1_alpclk0(sih, osh, cc) / 1000; + fref = si_pmu1_alpclk0(sih, cc) / 1000; fvco = (fref * ndiv_int) << 8; fvco += (fref * (ndiv_frac >> 12)) >> 4; @@ -1508,7 +1500,7 @@ si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) } /* initialize PLL */ -void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) +void si_pmu_pll_init(si_t *sih, uint xtalfreq) { chipcregs_t *cc; uint origidx; @@ -1527,7 +1519,7 @@ void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) case BCM4329_CHIP_ID: if (xtalfreq == 0) xtalfreq = 38400; - si_pmu1_pllinit0(sih, osh, cc, xtalfreq); + si_pmu1_pllinit0(sih, cc, xtalfreq); break; case BCM4313_CHIP_ID: case BCM43224_CHIP_ID: @@ -1543,7 +1535,7 @@ void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) case BCM4319_CHIP_ID: case BCM4336_CHIP_ID: case BCM4330_CHIP_ID: - si_pmu1_pllinit0(sih, osh, cc, xtalfreq); + si_pmu1_pllinit0(sih, cc, xtalfreq); break; default: PMU_MSG(("No PLL init done for chip %s rev %d pmurev %d\n", @@ -1553,7 +1545,7 @@ void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) } #ifdef BCMDBG_FORCEHT - OR_REG(osh, &cc->clk_ctl_st, CCS_FORCEHT); + OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); #endif /* Return to original core */ @@ -1561,7 +1553,7 @@ void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) } /* query alp/xtal clock frequency */ -u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh) +u32 si_pmu_alp_clock(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -1599,7 +1591,7 @@ u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh) case BCM4336_CHIP_ID: case BCM4330_CHIP_ID: - clock = si_pmu1_alpclk0(sih, osh, cc); + clock = si_pmu1_alpclk0(sih, cc); break; case BCM5356_CHIP_ID: /* always 25Mhz */ @@ -1622,8 +1614,7 @@ u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh) * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc. */ static u32 -si_pmu5_clock(si_t *sih, struct osl_info *osh, chipcregs_t *cc, uint pll0, - uint m) { +si_pmu5_clock(si_t *sih, chipcregs_t *cc, uint pll0, uint m) { u32 tmp, div, ndiv, p1, p2, fc; if ((pll0 & 3) || (pll0 > PMU4716_MAINPLL_PLL0)) { @@ -1639,29 +1630,28 @@ si_pmu5_clock(si_t *sih, struct osl_info *osh, chipcregs_t *cc, uint pll0, if (sih->chip == BCM5357_CHIP_ID) { /* Detect failure in clock setting */ - if ((R_REG(osh, &cc->chipstatus) & 0x40000) != 0) { + if ((R_REG(&cc->chipstatus) & 0x40000) != 0) return 133 * 1000000; - } } - W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_P1P2_OFF); - (void)R_REG(osh, &cc->pllcontrol_addr); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_P1P2_OFF); + (void)R_REG(&cc->pllcontrol_addr); + tmp = R_REG(&cc->pllcontrol_data); p1 = (tmp & PMU5_PLL_P1_MASK) >> PMU5_PLL_P1_SHIFT; p2 = (tmp & PMU5_PLL_P2_MASK) >> PMU5_PLL_P2_SHIFT; - W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_M14_OFF); - (void)R_REG(osh, &cc->pllcontrol_addr); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_M14_OFF); + (void)R_REG(&cc->pllcontrol_addr); + tmp = R_REG(&cc->pllcontrol_data); div = (tmp >> ((m - 1) * PMU5_PLL_MDIV_WIDTH)) & PMU5_PLL_MDIV_MASK; - W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_NM5_OFF); - (void)R_REG(osh, &cc->pllcontrol_addr); - tmp = R_REG(osh, &cc->pllcontrol_data); + W_REG(&cc->pllcontrol_addr, pll0 + PMU5_PLL_NM5_OFF); + (void)R_REG(&cc->pllcontrol_addr); + tmp = R_REG(&cc->pllcontrol_data); ndiv = (tmp & PMU5_PLL_NDIV_MASK) >> PMU5_PLL_NDIV_SHIFT; /* Do calculation in Mhz */ - fc = si_pmu_alp_clock(sih, osh) / 1000000; + fc = si_pmu_alp_clock(sih) / 1000000; fc = (p1 * ndiv * fc) / p2; PMU_NONE(("%s: p1=%d, p2=%d, ndiv=%d(0x%x), m%d=%d; fc=%d, clock=%d\n", @@ -1675,7 +1665,7 @@ si_pmu5_clock(si_t *sih, struct osl_info *osh, chipcregs_t *cc, uint pll0, /* For designs that feed the same clock to both backplane * and CPU just return the CPU clock speed. */ -u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) +u32 si_pmu_si_clock(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -1704,19 +1694,19 @@ u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) case BCM4748_CHIP_ID: case BCM47162_CHIP_ID: clock = - si_pmu5_clock(sih, osh, cc, PMU4716_MAINPLL_PLL0, + si_pmu5_clock(sih, cc, PMU4716_MAINPLL_PLL0, PMU5_MAINPLL_SI); break; case BCM4329_CHIP_ID: if (sih->chiprev == 0) clock = 38400 * 1000; else - clock = si_pmu1_cpuclk0(sih, osh, cc); + clock = si_pmu1_cpuclk0(sih, cc); break; case BCM4319_CHIP_ID: case BCM4336_CHIP_ID: case BCM4330_CHIP_ID: - clock = si_pmu1_cpuclk0(sih, osh, cc); + clock = si_pmu1_cpuclk0(sih, cc); break; case BCM4313_CHIP_ID: /* 80MHz backplane clock */ @@ -1732,12 +1722,12 @@ u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) break; case BCM5356_CHIP_ID: clock = - si_pmu5_clock(sih, osh, cc, PMU5356_MAINPLL_PLL0, + si_pmu5_clock(sih, cc, PMU5356_MAINPLL_PLL0, PMU5_MAINPLL_SI); break; case BCM5357_CHIP_ID: clock = - si_pmu5_clock(sih, osh, cc, PMU5357_MAINPLL_PLL0, + si_pmu5_clock(sih, cc, PMU5357_MAINPLL_PLL0, PMU5_MAINPLL_SI); break; default: @@ -1754,7 +1744,7 @@ u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) } /* query CPU clock frequency */ -u32 si_pmu_cpu_clock(si_t *sih, struct osl_info *osh) +u32 si_pmu_cpu_clock(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -1787,18 +1777,18 @@ u32 si_pmu_cpu_clock(si_t *sih, struct osl_info *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - clock = si_pmu5_clock(sih, osh, cc, pll, PMU5_MAINPLL_CPU); + clock = si_pmu5_clock(sih, cc, pll, PMU5_MAINPLL_CPU); /* Return to original core */ si_setcoreidx(sih, origidx); } else - clock = si_pmu_si_clock(sih, osh); + clock = si_pmu_si_clock(sih); return clock; } /* query memory clock frequency */ -u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh) +u32 si_pmu_mem_clock(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -1831,12 +1821,12 @@ u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - clock = si_pmu5_clock(sih, osh, cc, pll, PMU5_MAINPLL_MEM); + clock = si_pmu5_clock(sih, cc, pll, PMU5_MAINPLL_MEM); /* Return to original core */ si_setcoreidx(sih, origidx); } else { - clock = si_pmu_si_clock(sih, osh); + clock = si_pmu_si_clock(sih); } return clock; @@ -1847,7 +1837,7 @@ u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh) static u32 ilpcycles_per_sec; -u32 si_pmu_ilp_clock(si_t *sih, struct osl_info *osh) +u32 si_pmu_ilp_clock(si_t *sih) { if (ISSIM_ENAB(sih)) return ILP_CLOCK; @@ -1857,9 +1847,9 @@ u32 si_pmu_ilp_clock(si_t *sih, struct osl_info *osh) u32 origidx = si_coreidx(sih); chipcregs_t *cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - start = R_REG(osh, &cc->pmutimer); + start = R_REG(&cc->pmutimer); mdelay(ILP_CALC_DUR); - end = R_REG(osh, &cc->pmutimer); + end = R_REG(&cc->pmutimer); delta = end - start; ilpcycles_per_sec = delta * (1000 / ILP_CALC_DUR); si_setcoreidx(sih, origidx); @@ -1911,8 +1901,7 @@ static const sdiod_drive_str_t sdiod_drive_strength_tab3[] = { #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) void -si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, - u32 drivestrength) { +si_sdiod_drive_strength_init(si_t *sih, u32 drivestrength) { chipcregs_t *cc; uint origidx, intr_val = 0; sdiod_drive_str_t *str_tab = NULL; @@ -1966,12 +1955,12 @@ si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, } } - W_REG(osh, &cc->chipcontrol_addr, 1); - cc_data_temp = R_REG(osh, &cc->chipcontrol_data); + W_REG(&cc->chipcontrol_addr, 1); + cc_data_temp = R_REG(&cc->chipcontrol_data); cc_data_temp &= ~str_mask; drivestrength_sel <<= str_shift; cc_data_temp |= drivestrength_sel; - W_REG(osh, &cc->chipcontrol_data, cc_data_temp); + W_REG(&cc->chipcontrol_data, cc_data_temp); PMU_MSG(("SDIO: %dmA drive strength selected, set to 0x%08x\n", drivestrength, cc_data_temp)); @@ -1982,7 +1971,7 @@ si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, } /* initialize PMU */ -void si_pmu_init(si_t *sih, struct osl_info *osh) +void si_pmu_init(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -1995,17 +1984,17 @@ void si_pmu_init(si_t *sih, struct osl_info *osh) ASSERT(cc != NULL); if (sih->pmurev == 1) - AND_REG(osh, &cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); + AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); else if (sih->pmurev >= 2) - OR_REG(osh, &cc->pmucontrol, PCTL_NOILP_ON_WAIT); + OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT); if ((sih->chip == BCM4329_CHIP_ID) && (sih->chiprev == 2)) { /* Fix for 4329b0 bad LPOM state. */ - W_REG(osh, &cc->regcontrol_addr, 2); - OR_REG(osh, &cc->regcontrol_data, 0x100); + W_REG(&cc->regcontrol_addr, 2); + OR_REG(&cc->regcontrol_data, 0x100); - W_REG(osh, &cc->regcontrol_addr, 3); - OR_REG(osh, &cc->regcontrol_data, 0x4); + W_REG(&cc->regcontrol_addr, 3); + OR_REG(&cc->regcontrol_data, 0x4); } /* Return to original core */ @@ -2014,22 +2003,21 @@ void si_pmu_init(si_t *sih, struct osl_info *osh) /* Return up time in ILP cycles for the given resource. */ static uint -si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, - u8 rsrc) { +si_pmu_res_uptime(si_t *sih, chipcregs_t *cc, u8 rsrc) { u32 deps; uint up, i, dup, dmax; u32 min_mask = 0, max_mask = 0; /* uptime of resource 'rsrc' */ - W_REG(osh, &cc->res_table_sel, rsrc); - up = (R_REG(osh, &cc->res_updn_timer) >> 8) & 0xff; + W_REG(&cc->res_table_sel, rsrc); + up = (R_REG(&cc->res_updn_timer) >> 8) & 0xff; /* direct dependancies of resource 'rsrc' */ - deps = si_pmu_res_deps(sih, osh, cc, PMURES_BIT(rsrc), false); + deps = si_pmu_res_deps(sih, cc, PMURES_BIT(rsrc), false); for (i = 0; i <= PMURES_MAX_RESNUM; i++) { if (!(deps & PMURES_BIT(i))) continue; - deps &= ~si_pmu_res_deps(sih, osh, cc, PMURES_BIT(i), true); + deps &= ~si_pmu_res_deps(sih, cc, PMURES_BIT(i), true); } si_pmu_res_masks(sih, &min_mask, &max_mask); deps &= ~min_mask; @@ -2039,7 +2027,7 @@ si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, for (i = 0; i <= PMURES_MAX_RESNUM; i++) { if (!(deps & PMURES_BIT(i))) continue; - dup = si_pmu_res_uptime(sih, osh, cc, (u8) i); + dup = si_pmu_res_uptime(sih, cc, (u8) i); if (dmax < dup) dmax = dup; } @@ -2051,7 +2039,7 @@ si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, /* Return dependancies (direct or all/indirect) for the given resources */ static u32 -si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 rsrcs, +si_pmu_res_deps(si_t *sih, chipcregs_t *cc, u32 rsrcs, bool all) { u32 deps = 0; @@ -2060,18 +2048,18 @@ si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 rsrcs, for (i = 0; i <= PMURES_MAX_RESNUM; i++) { if (!(rsrcs & PMURES_BIT(i))) continue; - W_REG(osh, &cc->res_table_sel, i); - deps |= R_REG(osh, &cc->res_dep_mask); + W_REG(&cc->res_table_sel, i); + deps |= R_REG(&cc->res_dep_mask); } return !all ? deps : (deps ? (deps | - si_pmu_res_deps(sih, osh, cc, deps, + si_pmu_res_deps(sih, cc, deps, true)) : 0); } /* power up/down OTP through PMU resources */ -void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) +void si_pmu_otp_power(si_t *sih, bool on) { chipcregs_t *cc; uint origidx; @@ -2111,7 +2099,7 @@ void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) u32 otps; /* Figure out the dependancies (exclude min_res_mask) */ - u32 deps = si_pmu_res_deps(sih, osh, cc, rsrcs, true); + u32 deps = si_pmu_res_deps(sih, cc, rsrcs, true); u32 min_mask = 0, max_mask = 0; si_pmu_res_masks(sih, &min_mask, &max_mask); deps &= ~min_mask; @@ -2119,17 +2107,17 @@ void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) if (on) { PMU_MSG(("Adding rsrc 0x%x to min_res_mask\n", rsrcs | deps)); - OR_REG(osh, &cc->min_res_mask, (rsrcs | deps)); - SPINWAIT(!(R_REG(osh, &cc->res_state) & rsrcs), + OR_REG(&cc->min_res_mask, (rsrcs | deps)); + SPINWAIT(!(R_REG(&cc->res_state) & rsrcs), PMU_MAX_TRANSITION_DLY); - ASSERT(R_REG(osh, &cc->res_state) & rsrcs); + ASSERT(R_REG(&cc->res_state) & rsrcs); } else { PMU_MSG(("Removing rsrc 0x%x from min_res_mask\n", rsrcs | deps)); - AND_REG(osh, &cc->min_res_mask, ~(rsrcs | deps)); + AND_REG(&cc->min_res_mask, ~(rsrcs | deps)); } - SPINWAIT((((otps = R_REG(osh, &cc->otpstatus)) & OTPS_READY) != + SPINWAIT((((otps = R_REG(&cc->otpstatus)) & OTPS_READY) != (on ? OTPS_READY : 0)), 100); ASSERT((otps & OTPS_READY) == (on ? OTPS_READY : 0)); if ((otps & OTPS_READY) != (on ? OTPS_READY : 0)) @@ -2141,7 +2129,7 @@ void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) si_setcoreidx(sih, origidx); } -void si_pmu_rcal(si_t *sih, struct osl_info *osh) +void si_pmu_rcal(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -2159,60 +2147,56 @@ void si_pmu_rcal(si_t *sih, struct osl_info *osh) u32 val; /* Kick RCal */ - W_REG(osh, &cc->chipcontrol_addr, 1); + W_REG(&cc->chipcontrol_addr, 1); /* Power Down RCAL Block */ - AND_REG(osh, &cc->chipcontrol_data, ~0x04); + AND_REG(&cc->chipcontrol_data, ~0x04); /* Power Up RCAL block */ - OR_REG(osh, &cc->chipcontrol_data, 0x04); + OR_REG(&cc->chipcontrol_data, 0x04); /* Wait for completion */ - SPINWAIT(0 == (R_REG(osh, &cc->chipstatus) & 0x08), + SPINWAIT(0 == (R_REG(&cc->chipstatus) & 0x08), 10 * 1000 * 1000); - ASSERT(R_REG(osh, &cc->chipstatus) & 0x08); + ASSERT(R_REG(&cc->chipstatus) & 0x08); /* Drop the LSB to convert from 5 bit code to 4 bit code */ rcal_code = - (u8) (R_REG(osh, &cc->chipstatus) >> 5) & 0x0f; + (u8) (R_REG(&cc->chipstatus) >> 5) & 0x0f; PMU_MSG(("RCal completed, status 0x%x, code 0x%x\n", - R_REG(osh, &cc->chipstatus), rcal_code)); + R_REG(&cc->chipstatus), rcal_code)); /* Write RCal code into pmu_vreg_ctrl[32:29] */ - W_REG(osh, &cc->regcontrol_addr, 0); + W_REG(&cc->regcontrol_addr, 0); val = - R_REG(osh, - &cc-> - regcontrol_data) & ~((u32) 0x07 << 29); + R_REG(&cc->regcontrol_data) & ~((u32) 0x07 << 29); val |= (u32) (rcal_code & 0x07) << 29; - W_REG(osh, &cc->regcontrol_data, val); - W_REG(osh, &cc->regcontrol_addr, 1); - val = R_REG(osh, &cc->regcontrol_data) & ~(u32) 0x01; + W_REG(&cc->regcontrol_data, val); + W_REG(&cc->regcontrol_addr, 1); + val = R_REG(&cc->regcontrol_data) & ~(u32) 0x01; val |= (u32) ((rcal_code >> 3) & 0x01); - W_REG(osh, &cc->regcontrol_data, val); + W_REG(&cc->regcontrol_data, val); /* Write RCal code into pmu_chip_ctrl[33:30] */ - W_REG(osh, &cc->chipcontrol_addr, 0); + W_REG(&cc->chipcontrol_addr, 0); val = - R_REG(osh, - &cc-> - chipcontrol_data) & ~((u32) 0x03 << 30); + R_REG(&cc->chipcontrol_data) & ~((u32) 0x03 << 30); val |= (u32) (rcal_code & 0x03) << 30; - W_REG(osh, &cc->chipcontrol_data, val); - W_REG(osh, &cc->chipcontrol_addr, 1); + W_REG(&cc->chipcontrol_data, val); + W_REG(&cc->chipcontrol_addr, 1); val = - R_REG(osh, &cc->chipcontrol_data) & ~(u32) 0x03; + R_REG(&cc->chipcontrol_data) & ~(u32) 0x03; val |= (u32) ((rcal_code >> 2) & 0x03); - W_REG(osh, &cc->chipcontrol_data, val); + W_REG(&cc->chipcontrol_data, val); /* Set override in pmu_chip_ctrl[29] */ - W_REG(osh, &cc->chipcontrol_addr, 0); - OR_REG(osh, &cc->chipcontrol_data, (0x01 << 29)); + W_REG(&cc->chipcontrol_addr, 0); + OR_REG(&cc->chipcontrol_data, (0x01 << 29)); /* Power off RCal block */ - W_REG(osh, &cc->chipcontrol_addr, 1); - AND_REG(osh, &cc->chipcontrol_data, ~0x04); + W_REG(&cc->chipcontrol_addr, 1); + AND_REG(&cc->chipcontrol_data, ~0x04); break; } @@ -2224,7 +2208,7 @@ void si_pmu_rcal(si_t *sih, struct osl_info *osh) si_setcoreidx(sih, origidx); } -void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid) +void si_pmu_spuravoid(si_t *sih, u8 spuravoid) { chipcregs_t *cc; uint origidx, intr_val; @@ -2237,23 +2221,23 @@ void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid) /* force the HT off */ if (sih->chip == BCM4336_CHIP_ID) { - tmp = R_REG(osh, &cc->max_res_mask); + tmp = R_REG(&cc->max_res_mask); tmp &= ~RES4336_HT_AVAIL; - W_REG(osh, &cc->max_res_mask, tmp); + W_REG(&cc->max_res_mask, tmp); /* wait for the ht to really go away */ - SPINWAIT(((R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL) == 0), + SPINWAIT(((R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL) == 0), 10000); - ASSERT((R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL) == 0); + ASSERT((R_REG(&cc->clk_ctl_st) & CCS_HTAVAIL) == 0); } /* update the pll changes */ - si_pmu_spuravoid_pllupdate(sih, cc, osh, spuravoid); + si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); /* enable HT back on */ if (sih->chip == BCM4336_CHIP_ID) { - tmp = R_REG(osh, &cc->max_res_mask); + tmp = R_REG(&cc->max_res_mask); tmp |= RES4336_HT_AVAIL; - W_REG(osh, &cc->max_res_mask, tmp); + W_REG(&cc->max_res_mask, tmp); } /* Return to original core */ @@ -2261,8 +2245,7 @@ void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid) } static void -si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, - u8 spuravoid) +si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, u8 spuravoid) { u32 tmp = 0; u8 phypll_offset = 0; @@ -2279,44 +2262,44 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, phypll_offset = (sih->chip == BCM5357_CHIP_ID) ? 6 : 0; /* RMW only the P1 divider */ - W_REG(osh, &cc->pllcontrol_addr, + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0 + phypll_offset); - tmp = R_REG(osh, &cc->pllcontrol_data); + tmp = R_REG(&cc->pllcontrol_data); tmp &= (~(PMU1_PLL0_PC0_P1DIV_MASK)); tmp |= (bcm5357_bcm43236_p1div[spuravoid] << PMU1_PLL0_PC0_P1DIV_SHIFT); - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); /* RMW only the int feedback divider */ - W_REG(osh, &cc->pllcontrol_addr, + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2 + phypll_offset); - tmp = R_REG(osh, &cc->pllcontrol_data); + tmp = R_REG(&cc->pllcontrol_data); tmp &= ~(PMU1_PLL0_PC2_NDIV_INT_MASK); tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << PMU1_PLL0_PC2_NDIV_INT_SHIFT; - W_REG(osh, &cc->pllcontrol_data, tmp); + W_REG(&cc->pllcontrol_data, tmp); tmp = 1 << 10; break; case BCM4331_CHIP_ID: if (spuravoid == 2) { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11500014); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x0FC00a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11500014); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x0FC00a08); } else if (spuravoid == 1) { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11500014); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x0F600a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11500014); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x0F600a08); } else { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11100014); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x03000a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11100014); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x03000a08); } tmp = 1 << 10; break; @@ -2326,47 +2309,47 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, case BCM43421_CHIP_ID: case BCM6362_CHIP_ID: if (spuravoid == 1) { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11500010); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x000C0C06); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x0F600a08); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(osh, &cc->pllcontrol_data, 0x00000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x2001E920); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888815); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11500010); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x000C0C06); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x0F600a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_data, 0x00000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x2001E920); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888815); } else { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11100010); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x000c0c06); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x03000a08); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(osh, &cc->pllcontrol_data, 0x00000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x200005c0); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888815); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11100010); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x000c0c06); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x03000a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_data, 0x00000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x200005c0); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888815); } tmp = 1 << 10; break; - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11100008); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x0c000c06); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x03000a08); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(osh, &cc->pllcontrol_data, 0x00000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x200005c0); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888855); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11100008); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x0c000c06); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x03000a08); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_data, 0x00000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x200005c0); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888855); tmp = 1 << 10; break; @@ -2375,74 +2358,74 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, case BCM4748_CHIP_ID: case BCM47162_CHIP_ID: if (spuravoid == 1) { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11500060); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x080C0C06); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x0F600000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(osh, &cc->pllcontrol_data, 0x00000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x2001E924); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888815); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11500060); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x080C0C06); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x0F600000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_data, 0x00000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x2001E924); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888815); } else { - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11100060); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x080c0c06); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x03000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(osh, &cc->pllcontrol_data, 0x00000000); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x200005c0); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888815); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11100060); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x080c0c06); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x03000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_data, 0x00000000); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x200005c0); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888815); } tmp = 3 << 9; break; case BCM4319_CHIP_ID: - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x11100070); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x1014140a); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888854); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x11100070); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x1014140a); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888854); if (spuravoid == 1) { /* spur_avoid ON, enable 41/82/164Mhz clock mode */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x05201828); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x05201828); } else { /* enable 40/80/160Mhz clock mode */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x05001828); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x05001828); } break; case BCM4336_CHIP_ID: /* Looks like these are only for default xtal freq 26MHz */ - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(osh, &cc->pllcontrol_data, 0x02100020); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); + W_REG(&cc->pllcontrol_data, 0x02100020); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(osh, &cc->pllcontrol_data, 0x0C0C0C0C); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); + W_REG(&cc->pllcontrol_data, 0x0C0C0C0C); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(osh, &cc->pllcontrol_data, 0x01240C0C); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); + W_REG(&cc->pllcontrol_data, 0x01240C0C); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(osh, &cc->pllcontrol_data, 0x202C2820); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); + W_REG(&cc->pllcontrol_data, 0x202C2820); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(osh, &cc->pllcontrol_data, 0x88888825); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); + W_REG(&cc->pllcontrol_data, 0x88888825); - W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); + W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); if (spuravoid == 1) { - W_REG(osh, &cc->pllcontrol_data, 0x00EC4EC4); + W_REG(&cc->pllcontrol_data, 0x00EC4EC4); } else { - W_REG(osh, &cc->pllcontrol_data, 0x00762762); + W_REG(&cc->pllcontrol_data, 0x00762762); } tmp = PCTL_PLL_PLLCTL_UPD; @@ -2453,11 +2436,11 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, break; } - tmp |= R_REG(osh, &cc->pmucontrol); - W_REG(osh, &cc->pmucontrol, tmp); + tmp |= R_REG(&cc->pmucontrol); + W_REG(&cc->pmucontrol, tmp); } -bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh) +bool si_pmu_is_otp_powered(si_t *sih) { uint idx; chipcregs_t *cc; @@ -2470,19 +2453,19 @@ bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh) switch (sih->chip) { case BCM4329_CHIP_ID: - st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4329_OTP_PU)) + st = (R_REG(&cc->res_state) & PMURES_BIT(RES4329_OTP_PU)) != 0; break; case BCM4319_CHIP_ID: - st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4319_OTP_PU)) + st = (R_REG(&cc->res_state) & PMURES_BIT(RES4319_OTP_PU)) != 0; break; case BCM4336_CHIP_ID: - st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4336_OTP_PU)) + st = (R_REG(&cc->res_state) & PMURES_BIT(RES4336_OTP_PU)) != 0; break; case BCM4330_CHIP_ID: - st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4330_OTP_PU)) + st = (R_REG(&cc->res_state) & PMURES_BIT(RES4330_OTP_PU)) != 0; break; @@ -2507,12 +2490,7 @@ bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh) return st; } -void -#if defined(BCMDBG) -si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) -#else -si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) -#endif +void si_pmu_sprom_enable(si_t *sih, bool enable) { chipcregs_t *cc; uint origidx; @@ -2527,7 +2505,7 @@ si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) } /* initialize PMU chip controls and other chip level stuff */ -void si_pmu_chip_init(si_t *sih, struct osl_info *osh) +void si_pmu_chip_init(si_t *sih) { uint origidx; @@ -2539,7 +2517,7 @@ void si_pmu_chip_init(si_t *sih, struct osl_info *osh) #endif /* CHIPC_UART_ALWAYS_ON */ /* Gate off SPROM clock and chip select signals */ - si_pmu_sprom_enable(sih, osh, false); + si_pmu_sprom_enable(sih, false); /* Remember original core */ origidx = si_coreidx(sih); @@ -2549,26 +2527,26 @@ void si_pmu_chip_init(si_t *sih, struct osl_info *osh) } /* initialize PMU switch/regulators */ -void si_pmu_swreg_init(si_t *sih, struct osl_info *osh) +void si_pmu_swreg_init(si_t *sih) { ASSERT(sih->cccaps & CC_CAP_PMU); switch (sih->chip) { case BCM4336_CHIP_ID: /* Reduce CLDO PWM output voltage to 1.2V */ - si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CLDO_PWM, 0xe); + si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_PWM, 0xe); /* Reduce CLDO BURST output voltage to 1.2V */ - si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CLDO_BURST, + si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CLDO_BURST, 0xe); /* Reduce LNLDO1 output voltage to 1.2V */ - si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_LNLDO1, 0xe); + si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_LNLDO1, 0xe); if (sih->chiprev == 0) si_pmu_regcontrol(sih, 2, 0x400000, 0x400000); break; case BCM4330_CHIP_ID: /* CBUCK Voltage is 1.8 by default and set that to 1.5 */ - si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CBUCK_PWM, 0); + si_pmu_set_ldo_voltage(sih, SET_LDO_VOLTAGE_CBUCK_PWM, 0); break; default: break; @@ -2593,8 +2571,7 @@ void si_pmu_radio_enable(si_t *sih, bool enable) /* Wait for a particular clock level to be on the backplane */ u32 -si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, u32 clk, - u32 delay) +si_pmu_waitforclk_on_backplane(si_t *sih, u32 clk, u32 delay) { chipcregs_t *cc; uint origidx; @@ -2607,12 +2584,12 @@ si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, u32 clk, ASSERT(cc != NULL); if (delay) - SPINWAIT(((R_REG(osh, &cc->pmustatus) & clk) != clk), delay); + SPINWAIT(((R_REG(&cc->pmustatus) & clk) != clk), delay); /* Return to original core */ si_setcoreidx(sih, origidx); - return R_REG(osh, &cc->pmustatus) & clk; + return R_REG(&cc->pmustatus) & clk; } /* @@ -2622,7 +2599,7 @@ si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, u32 clk, #define EXT_ILP_HZ 32768 -u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh) +u32 si_pmu_measure_alpclk(si_t *sih) { chipcregs_t *cc; uint origidx; @@ -2638,11 +2615,11 @@ u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - if (R_REG(osh, &cc->pmustatus) & PST_EXTLPOAVAIL) { + if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) { u32 ilp_ctr, alp_hz; /* Enable the reg to measure the freq, in case disabled before */ - W_REG(osh, &cc->pmu_xtalfreq, + W_REG(&cc->pmu_xtalfreq, 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); /* Delay for well over 4 ILP clocks */ @@ -2650,11 +2627,10 @@ u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh) /* Read the latched number of ALP ticks per 4 ILP ticks */ ilp_ctr = - R_REG(osh, - &cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; + R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; /* Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT bit to save power */ - W_REG(osh, &cc->pmu_xtalfreq, 0); + W_REG(&cc->pmu_xtalfreq, 0); /* Calculate ALP frequency */ alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4; diff --git a/drivers/staging/brcm80211/util/linux_osl.c b/drivers/staging/brcm80211/util/linux_osl.c deleted file mode 100644 index e6716e823baa..000000000000 --- a/drivers/staging/brcm80211/util/linux_osl.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2010 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <linux/delay.h> -#include <linux/fs.h> -#ifdef mips -#include <asm/paccess.h> -#endif /* mips */ -#include <bcmendian.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/netdevice.h> -#include <linux/sched.h> -#include <bcmdefs.h> -#include <osl.h> -#include <bcmutils.h> -#include <pcicfg.h> - - -#define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */ -#define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */ - -/* Global ASSERT type flag */ -u32 g_assert_type; - -struct osl_info *osl_attach(void *pdev, uint bustype) -{ - struct osl_info *osh; - - osh = kmalloc(sizeof(struct osl_info), GFP_ATOMIC); - ASSERT(osh); - - memset(osh, 0, sizeof(struct osl_info)); - - osh->magic = OS_HANDLE_MAGIC; - osh->pdev = pdev; - osh->bustype = bustype; - - switch (bustype) { - case PCI_BUS: - case SI_BUS: - case PCMCIA_BUS: - osh->mmbus = true; - break; - case JTAG_BUS: - case SDIO_BUS: - case USB_BUS: - case SPI_BUS: - case RPC_BUS: - osh->mmbus = false; - break; - default: - ASSERT(false); - break; - } - - return osh; -} - -void osl_detach(struct osl_info *osh) -{ - if (osh == NULL) - return; - - ASSERT(osh->magic == OS_HANDLE_MAGIC); - kfree(osh); -} - -struct sk_buff *BCMFASTPATH pkt_buf_get_skb(struct osl_info *osh, uint len) -{ - struct sk_buff *skb; - - skb = dev_alloc_skb(len); - if (skb) { - skb_put(skb, len); - skb->priority = 0; - - osh->pktalloced++; - } - - return skb; -} - -/* Free the driver packet. Free the tag if present */ -void BCMFASTPATH pkt_buf_free_skb(struct osl_info *osh, struct sk_buff *skb, bool send) -{ - struct sk_buff *nskb; - int nest = 0; - - ASSERT(skb); - - /* perversion: we use skb->next to chain multi-skb packets */ - while (skb) { - nskb = skb->next; - skb->next = NULL; - - if (skb->destructor) - /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if - * destructor exists - */ - dev_kfree_skb_any(skb); - else - /* can free immediately (even in_irq()) if destructor - * does not exist - */ - dev_kfree_skb(skb); - - osh->pktalloced--; - nest++; - skb = nskb; - } -} - -/* return bus # for the pci device pointed by osh->pdev */ -uint osl_pci_bus(struct osl_info *osh) -{ - ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); - - return ((struct pci_dev *)osh->pdev)->bus->number; -} - -/* return slot # for the pci device pointed by osh->pdev */ -uint osl_pci_slot(struct osl_info *osh) -{ - ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); - - return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn); -} - -void *osl_dma_alloc_consistent(struct osl_info *osh, uint size, u16 align_bits, - uint *alloced, unsigned long *pap) -{ - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - - if (align_bits) { - u16 align = (1 << align_bits); - if (!IS_ALIGNED(PAGE_SIZE, align)) - size += align; - *alloced = size; - } - return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap); -} - -void osl_dma_free_consistent(struct osl_info *osh, void *va, uint size, - unsigned long pa) -{ - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - - pci_free_consistent(osh->pdev, size, va, (dma_addr_t) pa); -} - -uint BCMFASTPATH osl_dma_map(struct osl_info *osh, void *va, uint size, - int direction) -{ - int dir; - - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - dir = (direction == DMA_TX) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE; - return pci_map_single(osh->pdev, va, size, dir); -} - -void BCMFASTPATH osl_dma_unmap(struct osl_info *osh, uint pa, uint size, - int direction) -{ - int dir; - - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - dir = (direction == DMA_TX) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE; - pci_unmap_single(osh->pdev, (u32) pa, size, dir); -} - -#if defined(BCMDBG_ASSERT) -void osl_assert(char *exp, char *file, int line) -{ - char tempbuf[256]; - char *basename; - - basename = strrchr(file, '/'); - /* skip the '/' */ - if (basename) - basename++; - - if (!basename) - basename = file; - -#ifdef BCMDBG_ASSERT - snprintf(tempbuf, 256, - "assertion \"%s\" failed: file \"%s\", line %d\n", exp, - basename, line); - - /* Print assert message and give it time to be written to /var/log/messages */ - if (!in_interrupt()) { - const int delay = 3; - printk(KERN_ERR "%s", tempbuf); - printk(KERN_ERR "panic in %d seconds\n", delay); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(delay * HZ); - } - - switch (g_assert_type) { - case 0: - panic(KERN_ERR "%s", tempbuf); - break; - case 1: - printk(KERN_ERR "%s", tempbuf); - BUG(); - break; - case 2: - printk(KERN_ERR "%s", tempbuf); - break; - default: - break; - } -#endif /* BCMDBG_ASSERT */ - -} -#endif /* defined(BCMDBG_ASSERT) */ - diff --git a/drivers/staging/brcm80211/util/nicpci.c b/drivers/staging/brcm80211/util/nicpci.c index 56e658c429a8..a1fb2f08984d 100644 --- a/drivers/staging/brcm80211/util/nicpci.c +++ b/drivers/staging/brcm80211/util/nicpci.c @@ -18,7 +18,6 @@ #include <linux/string.h> #include <linux/pci.h> #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> #include <hndsoc.h> @@ -36,7 +35,7 @@ typedef struct { } regs; /* Memory mapped register to the core */ si_t *sih; /* System interconnect handle */ - struct osl_info *osh; /* OSL handle */ + struct pci_dev *dev; u8 pciecap_lcreg_offset; /* PCIE capability LCreg offset in the config space */ bool pcie_pr42767; u8 pcie_polarity; @@ -80,7 +79,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi); /* Initialize the PCI core. It's caller's responsibility to make sure that this is done * only once */ -void *pcicore_init(si_t *sih, struct osl_info *osh, void *regs) +void *pcicore_init(si_t *sih, void *pdev, void *regs) { pcicore_info_t *pi; @@ -94,13 +93,13 @@ void *pcicore_init(si_t *sih, struct osl_info *osh, void *regs) } pi->sih = sih; - pi->osh = osh; + pi->dev = pdev; if (sih->buscoretype == PCIE_CORE_ID) { u8 cap_ptr; pi->regs.pcieregs = (sbpcieregs_t *) regs; cap_ptr = - pcicore_find_pci_capability(pi->osh, PCI_CAP_PCIECAP_ID, + pcicore_find_pci_capability(pi->dev, PCI_CAP_PCIECAP_ID, NULL, NULL); ASSERT(cap_ptr); pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET; @@ -122,7 +121,7 @@ void pcicore_deinit(void *pch) /* return cap_offset if requested capability exists in the PCI config space */ /* Note that it's caller's responsibility to make sure it's a pci bus */ u8 -pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, +pcicore_find_pci_capability(void *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen) { u8 cap_id; @@ -131,29 +130,29 @@ pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, u8 byte_val; /* check for Header type 0 */ - pci_read_config_byte(osh->pdev, PCI_CFG_HDR, &byte_val); + pci_read_config_byte(dev, PCI_CFG_HDR, &byte_val); if ((byte_val & 0x7f) != PCI_HEADER_NORMAL) goto end; /* check if the capability pointer field exists */ - pci_read_config_byte(osh->pdev, PCI_CFG_STAT, &byte_val); + pci_read_config_byte(dev, PCI_CFG_STAT, &byte_val); if (!(byte_val & PCI_CAPPTR_PRESENT)) goto end; - pci_read_config_byte(osh->pdev, PCI_CFG_CAPPTR, &cap_ptr); + pci_read_config_byte(dev, PCI_CFG_CAPPTR, &cap_ptr); /* check if the capability pointer is 0x00 */ if (cap_ptr == 0x00) goto end; /* loop thr'u the capability list and see if the pcie capabilty exists */ - pci_read_config_byte(osh->pdev, cap_ptr, &cap_id); + pci_read_config_byte(dev, cap_ptr, &cap_id); while (cap_id != req_cap_id) { - pci_read_config_byte(osh->pdev, cap_ptr + 1, &cap_ptr); + pci_read_config_byte(dev, cap_ptr + 1, &cap_ptr); if (cap_ptr == 0x00) break; - pci_read_config_byte(osh->pdev, cap_ptr, &cap_id); + pci_read_config_byte(dev, cap_ptr, &cap_id); } if (cap_id != req_cap_id) { goto end; @@ -172,7 +171,7 @@ pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, bufsize = SZPCR - cap_data; *buflen = bufsize; while (bufsize--) { - pci_read_config_byte(osh->pdev, cap_data, buf); + pci_read_config_byte(dev, cap_data, buf); cap_data++; buf++; } @@ -183,7 +182,7 @@ pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, /* ***** Register Access API */ uint -pcie_readreg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, +pcie_readreg(sbpcieregs_t *pcieregs, uint addrtype, uint offset) { uint retval = 0xFFFFFFFF; @@ -192,14 +191,14 @@ pcie_readreg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, switch (addrtype) { case PCIE_CONFIGREGS: - W_REG(osh, (&pcieregs->configaddr), offset); - (void)R_REG(osh, (&pcieregs->configaddr)); - retval = R_REG(osh, &(pcieregs->configdata)); + W_REG((&pcieregs->configaddr), offset); + (void)R_REG((&pcieregs->configaddr)); + retval = R_REG(&(pcieregs->configdata)); break; case PCIE_PCIEREGS: - W_REG(osh, &(pcieregs->pcieindaddr), offset); - (void)R_REG(osh, (&pcieregs->pcieindaddr)); - retval = R_REG(osh, &(pcieregs->pcieinddata)); + W_REG(&(pcieregs->pcieindaddr), offset); + (void)R_REG((&pcieregs->pcieindaddr)); + retval = R_REG(&(pcieregs->pcieinddata)); break; default: ASSERT(0); @@ -210,19 +209,19 @@ pcie_readreg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, } uint -pcie_writereg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, +pcie_writereg(sbpcieregs_t *pcieregs, uint addrtype, uint offset, uint val) { ASSERT(pcieregs != NULL); switch (addrtype) { case PCIE_CONFIGREGS: - W_REG(osh, (&pcieregs->configaddr), offset); - W_REG(osh, (&pcieregs->configdata), val); + W_REG((&pcieregs->configaddr), offset); + W_REG((&pcieregs->configdata), val); break; case PCIE_PCIEREGS: - W_REG(osh, (&pcieregs->pcieindaddr), offset); - W_REG(osh, (&pcieregs->pcieinddata), val); + W_REG((&pcieregs->pcieindaddr), offset); + W_REG((&pcieregs->pcieinddata), val); break; default: ASSERT(0); @@ -242,12 +241,12 @@ static bool pcie_mdiosetblock(pcicore_info_t *pi, uint blk) MDIODATA_DEVADDR_SHF) | (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) | MDIODATA_TA | (blk << 4); - W_REG(pi->osh, &pcieregs->mdiodata, mdiodata); + W_REG(&pcieregs->mdiodata, mdiodata); PR28829_DELAY(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { - if (R_REG(pi->osh, &(pcieregs->mdiocontrol)) & + if (R_REG(&(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) { break; } @@ -273,7 +272,7 @@ pcie_mdioop(pcicore_info_t *pi, uint physmedia, uint regaddr, bool write, uint pcie_serdes_spinwait = 10; /* enable mdio access to SERDES */ - W_REG(pi->osh, (&pcieregs->mdiocontrol), + W_REG((&pcieregs->mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); if (pi->sih->buscorerev >= 10) { @@ -294,22 +293,22 @@ pcie_mdioop(pcicore_info_t *pi, uint physmedia, uint regaddr, bool write, mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA | *val); - W_REG(pi->osh, &pcieregs->mdiodata, mdiodata); + W_REG(&pcieregs->mdiodata, mdiodata); PR28829_DELAY(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { - if (R_REG(pi->osh, &(pcieregs->mdiocontrol)) & + if (R_REG(&(pcieregs->mdiocontrol)) & MDIOCTL_ACCESS_DONE) { if (!write) { PR28829_DELAY(); *val = - (R_REG(pi->osh, &(pcieregs->mdiodata)) & + (R_REG(&(pcieregs->mdiodata)) & MDIODATA_MASK); } /* Disable mdio access to SERDES */ - W_REG(pi->osh, (&pcieregs->mdiocontrol), 0); + W_REG((&pcieregs->mdiocontrol), 0); return 0; } udelay(1000); @@ -318,7 +317,7 @@ pcie_mdioop(pcicore_info_t *pi, uint physmedia, uint regaddr, bool write, PCI_ERROR(("pcie_mdioop: timed out op: %d\n", write)); /* Disable mdio access to SERDES */ - W_REG(pi->osh, (&pcieregs->mdiocontrol), 0); + W_REG((&pcieregs->mdiocontrol), 0); return 1; } @@ -347,15 +346,15 @@ u8 pcie_clkreq(void *pch, u32 mask, u32 val) if (!offset) return 0; - pci_read_config_dword(pi->osh->pdev, offset, ®_val); + pci_read_config_dword(pi->dev, offset, ®_val); /* set operation */ if (mask) { if (val) reg_val |= PCIE_CLKREQ_ENAB; else reg_val &= ~PCIE_CLKREQ_ENAB; - pci_write_config_dword(pi->osh->pdev, offset, reg_val); - pci_read_config_dword(pi->osh->pdev, offset, ®_val); + pci_write_config_dword(pi->dev, offset, reg_val); + pci_read_config_dword(pi->dev, offset, ®_val); } if (reg_val & PCIE_CLKREQ_ENAB) return 1; @@ -367,19 +366,18 @@ static void pcie_extendL1timer(pcicore_info_t *pi, bool extend) { u32 w; si_t *sih = pi->sih; - struct osl_info *osh = pi->osh; sbpcieregs_t *pcieregs = pi->regs.pcieregs; if (!PCIE_PUB(sih) || sih->buscorerev < 7) return; - w = pcie_readreg(osh, pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); + w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); if (extend) w |= PCIE_ASPMTIMER_EXTEND; else w &= ~PCIE_ASPMTIMER_EXTEND; - pcie_writereg(osh, pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); - w = pcie_readreg(osh, pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); + pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); + w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); } /* centralized clkreq control policy */ @@ -432,7 +430,7 @@ static void pcie_war_polarity(pcicore_info_t *pi) if (pi->pcie_polarity != 0) return; - w = pcie_readreg(pi->osh, pi->regs.pcieregs, PCIE_PCIEREGS, + w = pcie_readreg(pi->regs.pcieregs, PCIE_PCIEREGS, PCIE_PLP_STATUSREG); /* Detect the current polarity at attach and force that polarity and @@ -464,7 +462,7 @@ static void pcie_war_aspm_clkreq(pcicore_info_t *pi) if (!ISSIM_ENAB(sih)) { reg16 = &pcieregs->sprom[SRSH_ASPM_OFFSET]; - val16 = R_REG(pi->osh, reg16); + val16 = R_REG(reg16); val16 &= ~SRSH_ASPM_ENB; if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB) @@ -474,18 +472,18 @@ static void pcie_war_aspm_clkreq(pcicore_info_t *pi) else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB) val16 |= SRSH_ASPM_L0s_ENB; - W_REG(pi->osh, reg16, val16); + W_REG(reg16, val16); - pci_read_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, + pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); w &= ~PCIE_ASPM_ENAB; w |= pi->pcie_war_aspm_ovr; - pci_write_config_dword(pi->osh->pdev, + pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); } reg16 = &pcieregs->sprom[SRSH_CLKREQ_OFFSET_REV5]; - val16 = R_REG(pi->osh, reg16); + val16 = R_REG(reg16); if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) { val16 |= SRSH_CLKREQ_ENB; @@ -493,7 +491,7 @@ static void pcie_war_aspm_clkreq(pcicore_info_t *pi) } else val16 &= ~SRSH_CLKREQ_ENB; - W_REG(pi->osh, reg16, val16); + W_REG(reg16, val16); } /* Apply the polarity determined at the start */ @@ -521,11 +519,11 @@ static void pcie_misc_config_fixup(pcicore_info_t *pi) u16 val16, *reg16; reg16 = &pcieregs->sprom[SRSH_PCIE_MISC_CONFIG]; - val16 = R_REG(pi->osh, reg16); + val16 = R_REG(reg16); if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) { val16 |= SRSH_L23READY_EXIT_NOPERST; - W_REG(pi->osh, reg16, val16); + W_REG(reg16, val16); } } @@ -544,29 +542,28 @@ static void pcie_war_noplldown(pcicore_info_t *pi) /* clear srom shadow backdoor */ reg16 = &pcieregs->sprom[SRSH_BD_OFFSET]; - W_REG(pi->osh, reg16, 0); + W_REG(reg16, 0); } /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_war_pci_setup(pcicore_info_t *pi) { si_t *sih = pi->sih; - struct osl_info *osh = pi->osh; sbpcieregs_t *pcieregs = pi->regs.pcieregs; u32 w; if ((sih->buscorerev == 0) || (sih->buscorerev == 1)) { - w = pcie_readreg(osh, pcieregs, PCIE_PCIEREGS, + w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG); w |= 0x8; - pcie_writereg(osh, pcieregs, PCIE_PCIEREGS, + pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG, w); } if (sih->buscorerev == 1) { - w = pcie_readreg(osh, pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); + w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); w |= (0x40); - pcie_writereg(osh, pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); + pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); } if (sih->buscorerev == 0) { @@ -575,11 +572,11 @@ static void pcie_war_pci_setup(pcicore_info_t *pi) pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); } else if (PCIE_ASPM(sih)) { /* Change the L1 threshold for better performance */ - w = pcie_readreg(osh, pcieregs, PCIE_PCIEREGS, + w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); w &= ~(PCIE_L1THRESHOLDTIME_MASK); w |= (PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT); - pcie_writereg(osh, pcieregs, PCIE_PCIEREGS, + pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); pcie_war_serdes(pi); @@ -668,9 +665,9 @@ void pcicore_sleep(void *pch) if (!pi || !PCIE_ASPM(pi->sih)) return; - pci_read_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, &w); + pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); w &= ~PCIE_CAP_LCREG_ASPML1; - pci_write_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, w); + pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); pi->pcie_pr42767 = false; } @@ -690,19 +687,20 @@ void pcicore_down(void *pch, int state) /* ***** Wake-on-wireless-LAN (WOWL) support functions ***** */ /* Just uses PCI config accesses to find out, when needed before sb_attach is done */ -bool pcicore_pmecap_fast(struct osl_info *osh) +bool pcicore_pmecap_fast(void *pch) { + pcicore_info_t *pi = (pcicore_info_t *) pch; u8 cap_ptr; u32 pmecap; cap_ptr = - pcicore_find_pci_capability(osh, PCI_CAP_POWERMGMTCAP_ID, NULL, + pcicore_find_pci_capability(pi->dev, PCI_CAP_POWERMGMTCAP_ID, NULL, NULL); if (!cap_ptr) return false; - pci_read_config_dword(osh->pdev, cap_ptr, &pmecap); + pci_read_config_dword(pi->dev, cap_ptr, &pmecap); return (pmecap & PME_CAP_PM_STATES) != 0; } @@ -717,7 +715,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi) if (!pi->pmecap_offset) { cap_ptr = - pcicore_find_pci_capability(pi->osh, + pcicore_find_pci_capability(pi->dev, PCI_CAP_POWERMGMTCAP_ID, NULL, NULL); if (!cap_ptr) @@ -725,7 +723,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi) pi->pmecap_offset = cap_ptr; - pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset, + pci_read_config_dword(pi->dev, pi->pmecap_offset, &pmecap); /* At least one state can generate PME */ @@ -745,10 +743,10 @@ void pcicore_pmeen(void *pch) if (!pcicore_pmecap(pi)) return; - pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET, &w); w |= (PME_CSR_PME_EN); - pci_write_config_dword(pi->osh->pdev, + pci_write_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET, w); } @@ -763,7 +761,7 @@ bool pcicore_pmestat(void *pch) if (!pcicore_pmecap(pi)) return false; - pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET, &w); return (w & PME_CSR_PME_STAT) == PME_CSR_PME_STAT; @@ -779,7 +777,7 @@ void pcicore_pmeclr(void *pch) if (!pcicore_pmecap(pi)) return; - pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + pci_read_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET, &w); PCI_ERROR(("pcicore_pci_pmeclr PMECSR : 0x%x\n", w)); @@ -787,7 +785,7 @@ void pcicore_pmeclr(void *pch) /* PMESTAT is cleared by writing 1 to it */ w &= ~(PME_CSR_PME_EN); - pci_write_config_dword(pi->osh->pdev, + pci_write_config_dword(pi->dev, pi->pmecap_offset + PME_CSR_OFFSET, w); } @@ -803,9 +801,9 @@ u32 pcie_lcreg(void *pch, u32 mask, u32 val) /* set operation */ if (mask) - pci_write_config_dword(pi->osh->pdev, offset, val); + pci_write_config_dword(pi->dev, offset, val); - pci_read_config_dword(pi->osh->pdev, offset, &tmpval); + pci_read_config_dword(pi->dev, offset, &tmpval); return tmpval; } @@ -815,11 +813,10 @@ pcicore_pciereg(void *pch, u32 offset, u32 mask, u32 val, uint type) u32 reg_val = 0; pcicore_info_t *pi = (pcicore_info_t *) pch; sbpcieregs_t *pcieregs = pi->regs.pcieregs; - struct osl_info *osh = pi->osh; if (mask) { PCI_ERROR(("PCIEREG: 0x%x writeval 0x%x\n", offset, val)); - pcie_writereg(osh, pcieregs, type, offset, val); + pcie_writereg(pcieregs, type, offset, val); } /* Should not read register 0x154 */ @@ -827,7 +824,7 @@ pcicore_pciereg(void *pch, u32 offset, u32 mask, u32 val, uint type) && type == PCIE_PCIEREGS) return reg_val; - reg_val = pcie_readreg(osh, pcieregs, type, offset); + reg_val = pcie_readreg(pcieregs, type, offset); PCI_ERROR(("PCIEREG: 0x%x readval is 0x%x\n", offset, reg_val)); return reg_val; diff --git a/drivers/staging/brcm80211/util/nvram/nvram_ro.c b/drivers/staging/brcm80211/util/nvram/nvram_ro.c index e4d41ee78e2a..a697ff10ef36 100644 --- a/drivers/staging/brcm80211/util/nvram/nvram_ro.c +++ b/drivers/staging/brcm80211/util/nvram/nvram_ro.c @@ -17,10 +17,8 @@ #include <linux/slab.h> #include <linux/string.h> #include <bcmdefs.h> -#include <osl.h> #include <bcmutils.h> #include <siutils.h> -#include <bcmendian.h> #include <bcmnvram.h> #include <sbchipc.h> #include <bcmsrom.h> @@ -49,13 +47,10 @@ static char *findvar(char *vars, char *lim, const char *name); /* copy flash to ram */ static void get_flash_nvram(si_t *sih, struct nvram_header *nvh) { - struct osl_info *osh; uint nvs, bufsz; vars_t *new; - osh = si_osh(sih); - - nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header); + nvs = R_REG(&nvh->len) - sizeof(struct nvram_header); bufsz = nvs + VARS_T_OH; new = kmalloc(bufsz, GFP_ATOMIC); @@ -70,7 +65,7 @@ static void get_flash_nvram(si_t *sih, struct nvram_header *nvh) new->next = vars; vars = new; - bcopy((char *)(&nvh[1]), new->vars, nvs); + memcpy(new->vars, &nvh[1], nvs); NVR_MSG(("%s: flash nvram @ %p, copied %d bytes to %p\n", __func__, nvh, nvs, new->vars)); @@ -195,7 +190,7 @@ int nvram_getall(char *buf, int count) len = strlen(from) + 1; if (resid < (acc + len)) return BCME_BUFTOOSHORT; - bcopy(from, to, len); + memcpy(to, from, len); acc += len; from += len; to += len; diff --git a/drivers/staging/brcm80211/include/pci_core.h b/drivers/staging/brcm80211/util/pci_core.h index 9153dcb8160e..9153dcb8160e 100644 --- a/drivers/staging/brcm80211/include/pci_core.h +++ b/drivers/staging/brcm80211/util/pci_core.h diff --git a/drivers/staging/brcm80211/include/sbpcmcia.h b/drivers/staging/brcm80211/util/sbpcmcia.h index 6b9923f551a9..6b9923f551a9 100644 --- a/drivers/staging/brcm80211/include/sbpcmcia.h +++ b/drivers/staging/brcm80211/util/sbpcmcia.h diff --git a/drivers/staging/brcm80211/include/sbsocram.h b/drivers/staging/brcm80211/util/sbsocram.h index 0cfe9852b27f..0cfe9852b27f 100644 --- a/drivers/staging/brcm80211/include/sbsocram.h +++ b/drivers/staging/brcm80211/util/sbsocram.h diff --git a/drivers/staging/brcm80211/util/sbutils.c b/drivers/staging/brcm80211/util/sbutils.c index 63c3ab1866a4..21dde8e508dd 100644 --- a/drivers/staging/brcm80211/util/sbutils.c +++ b/drivers/staging/brcm80211/util/sbutils.c @@ -19,7 +19,6 @@ #ifdef BRCM_FULLMAC #include <linux/netdevice.h> #endif -#include <osl.h> #include <bcmutils.h> #include <siutils.h> #include <bcmdevs.h> @@ -54,12 +53,12 @@ static void *_sb_setcoreidx(si_info_t *sii, uint coreidx); static u32 sb_read_sbreg(si_info_t *sii, volatile u32 *sbr) { - return R_REG(sii->osh, sbr); + return R_REG(sbr); } static void sb_write_sbreg(si_info_t *sii, volatile u32 *sbr, u32 v) { - W_REG(sii->osh, sbr, v); + W_REG(sbr, v); } uint sb_coreid(si_t *sih) @@ -178,8 +177,8 @@ uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) w = (R_SBREG(sii, r) & ~mask) | val; W_SBREG(sii, r, w); } else { - w = (R_REG(sii->osh, r) & ~mask) | val; - W_REG(sii->osh, r, w); + w = (R_REG(r) & ~mask) | val; + W_REG(r, w); } } @@ -187,7 +186,7 @@ uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) if (regoff >= SBCONFIGOFF) w = R_SBREG(sii, r); else - w = R_REG(sii->osh, r); + w = R_REG(r); if (!fast) { /* restore core index */ @@ -246,7 +245,7 @@ static uint _sb_scan(si_info_t *sii, u32 sba, void *regs, uint bus, u32 sbba, total # cores in the chip */ if (((ccrev == 4) || (ccrev >= 6))) numcores = - (R_REG(sii->osh, &cc->chipid) & CID_CC_MASK) + (R_REG(&cc->chipid) & CID_CC_MASK) >> CID_CC_SHIFT; else { /* Older chips */ @@ -368,94 +367,6 @@ static void *_sb_setcoreidx(si_info_t *sii, uint coreidx) return regs; } -/* traverse all cores to find and clear source of serror */ -static void sb_serr_clear(si_info_t *sii) -{ - sbconfig_t *sb; - uint origidx; - uint i, intr_val = 0; - void *corereg = NULL; - - INTR_OFF(sii, intr_val); - origidx = si_coreidx(&sii->pub); - - for (i = 0; i < sii->numcores; i++) { - corereg = sb_setcoreidx(&sii->pub, i); - if (NULL != corereg) { - sb = REGS2SB(corereg); - if ((R_SBREG(sii, &sb->sbtmstatehigh)) & SBTMH_SERR) { - AND_SBREG(sii, &sb->sbtmstatehigh, ~SBTMH_SERR); - SI_ERROR(("sb_serr_clear: SError core 0x%x\n", - sb_coreid(&sii->pub))); - } - } - } - - sb_setcoreidx(&sii->pub, origidx); - INTR_RESTORE(sii, intr_val); -} - -/* - * Check if any inband, outband or timeout errors has happened and clear them. - * Must be called with chip clk on ! - */ -bool sb_taclear(si_t *sih, bool details) -{ - si_info_t *sii; - sbconfig_t *sb; - uint origidx; - uint intr_val = 0; - bool rc = false; - u32 inband = 0, serror = 0, timeout = 0; - void *corereg = NULL; - volatile u32 imstate, tmstate; - - sii = SI_INFO(sih); - - if ((sii->pub.bustype == SDIO_BUS) || - (sii->pub.bustype == SPI_BUS)) { - - INTR_OFF(sii, intr_val); - origidx = si_coreidx(sih); - - corereg = si_setcore(sih, PCMCIA_CORE_ID, 0); - if (NULL == corereg) - corereg = si_setcore(sih, SDIOD_CORE_ID, 0); - if (NULL != corereg) { - sb = REGS2SB(corereg); - - imstate = R_SBREG(sii, &sb->sbimstate); - if ((imstate != 0xffffffff) - && (imstate & (SBIM_IBE | SBIM_TO))) { - AND_SBREG(sii, &sb->sbimstate, - ~(SBIM_IBE | SBIM_TO)); - /* inband = imstate & SBIM_IBE; cmd error */ - timeout = imstate & SBIM_TO; - } - tmstate = R_SBREG(sii, &sb->sbtmstatehigh); - if ((tmstate != 0xffffffff) - && (tmstate & SBTMH_INT_STATUS)) { - sb_serr_clear(sii); - serror = 1; - OR_SBREG(sii, &sb->sbtmstatelow, SBTML_INT_ACK); - AND_SBREG(sii, &sb->sbtmstatelow, - ~SBTML_INT_ACK); - } - } - - sb_setcoreidx(sih, origidx); - INTR_RESTORE(sii, intr_val); - } - - if (inband | timeout | serror) { - rc = true; - SI_ERROR(("sb_taclear: inband 0x%x, serror 0x%x, timeout " - "0x%x!\n", inband, serror, timeout)); - } - - return rc; -} - void sb_core_disable(si_t *sih, u32 bits) { si_info_t *sii; @@ -563,26 +474,3 @@ void sb_core_reset(si_t *sih, u32 bits, u32 resetbits) dummy = R_SBREG(sii, &sb->sbtmstatelow); udelay(1); } - -u32 sb_base(u32 admatch) -{ - u32 base; - uint type; - - type = admatch & SBAM_TYPE_MASK; - ASSERT(type < 3); - - base = 0; - - if (type == 0) { - base = admatch & SBAM_BASE0_MASK; - } else if (type == 1) { - ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ - base = admatch & SBAM_BASE1_MASK; - } else if (type == 2) { - ASSERT(!(admatch & SBAM_ADNEG)); /* neg not supported */ - base = admatch & SBAM_BASE2_MASK; - } - - return base; -} diff --git a/drivers/staging/brcm80211/util/siutils.c b/drivers/staging/brcm80211/util/siutils.c index b66de9b35a5a..ed168ceba5f0 100644 --- a/drivers/staging/brcm80211/util/siutils.c +++ b/drivers/staging/brcm80211/util/siutils.c @@ -18,10 +18,6 @@ #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> -#ifdef BRCM_FULLMAC -#include <linux/netdevice.h> -#endif -#include <osl.h> #include <linux/module.h> #include <linux/pci.h> #include <bcmutils.h> @@ -58,8 +54,8 @@ #endif /* local prototypes */ -static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, - void *regs, uint bustype, void *sdh, char **vars, +static si_info_t *si_doattach(si_info_t *sii, uint devid, void *regs, + uint bustype, void *sdh, char **vars, uint *varsz); static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid, void *sdh); @@ -86,7 +82,7 @@ static u32 si_gpioreservation; * vars - pointer to a pointer area for "environment" variables * varsz - pointer to int to return the size of the vars */ -si_t *si_attach(uint devid, struct osl_info *osh, void *regs, uint bustype, +si_t *si_attach(uint devid, void *regs, uint bustype, void *sdh, char **vars, uint *varsz) { si_info_t *sii; @@ -98,7 +94,7 @@ si_t *si_attach(uint devid, struct osl_info *osh, void *regs, uint bustype, return NULL; } - if (si_doattach(sii, devid, osh, regs, bustype, sdh, vars, varsz) == + if (si_doattach(sii, devid, regs, bustype, sdh, vars, varsz) == NULL) { kfree(sii); return NULL; @@ -183,19 +179,19 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, /* get chipcommon chipstatus */ if (sii->pub.ccrev >= 11) - sii->pub.chipst = R_REG(sii->osh, &cc->chipstatus); + sii->pub.chipst = R_REG(&cc->chipstatus); /* get chipcommon capabilites */ - sii->pub.cccaps = R_REG(sii->osh, &cc->capabilities); + sii->pub.cccaps = R_REG(&cc->capabilities); /* get chipcommon extended capabilities */ #ifndef BRCM_FULLMAC if (sii->pub.ccrev >= 35) - sii->pub.cccaps_ext = R_REG(sii->osh, &cc->capabilities_ext); + sii->pub.cccaps_ext = R_REG(&cc->capabilities_ext); #endif /* get pmu rev and caps */ if (sii->pub.cccaps & CC_CAP_PMU) { - sii->pub.pmucaps = R_REG(sii->osh, &cc->pmucapabilities); + sii->pub.pmucaps = R_REG(&cc->pmucapabilities); sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; } @@ -290,7 +286,7 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, if (SI_FAST(sii)) { if (!sii->pch) { sii->pch = (void *)pcicore_init( - &sii->pub, sii->osh, + &sii->pub, sii->pbus, (void *)PCIEREGS(sii)); if (sii->pch == NULL) return false; @@ -316,7 +312,7 @@ static __used void si_nvram_process(si_info_t *sii, char *pvars) switch (sii->pub.bustype) { case PCI_BUS: /* do a pci config read to get subsystem id and subvendor id */ - pci_read_config_dword(sii->osh->pdev, PCI_CFG_SVID, &w); + pci_read_config_dword(sii->pbus, PCI_CFG_SVID, &w); /* Let nvram variables override subsystem Vend/ID */ sii->pub.boardvendor = (u16)si_getdevpathintvar(&sii->pub, "boardvendor"); @@ -369,8 +365,8 @@ static __used void si_nvram_process(si_info_t *sii, char *pvars) /* this is will make Sonics calls directly, since Sonics is no longer supported in the Si abstraction */ /* this has been customized for the bcm 4329 ONLY */ #ifdef BCMSDIO -static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, - void *regs, uint bustype, void *sdh, +static si_info_t *si_doattach(si_info_t *sii, uint devid, + void *regs, uint bustype, void *pbus, char **vars, uint *varsz) { struct si_pub *sih = &sii->pub; @@ -388,15 +384,14 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, sih->buscoreidx = BADIDX; sii->curmap = regs; - sii->sdh = sdh; - sii->osh = osh; + sii->pbus = pbus; /* find Chipcommon address */ cc = (chipcregs_t *) sii->curmap; sih->bustype = bustype; /* bus/core/clk setup for register access */ - if (!si_buscore_prep(sii, bustype, devid, sdh)) { + if (!si_buscore_prep(sii, bustype, devid, pbus)) { SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n", bustype)); return NULL; @@ -407,7 +402,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, * If we add other chiptypes (or if we need to support old sdio hosts w/o chipcommon), * some way of recognizing them needs to be added here. */ - w = R_REG(osh, &cc->chipid); + w = R_REG(&cc->chipid); sih->socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT; /* Might as wll fill in chip id rev & pkg */ sih->chip = w & CID_ID_MASK; @@ -458,8 +453,8 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, if (sii->pub.ccrev >= 20) { #endif cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); - W_REG(osh, &cc->gpiopullup, 0); - W_REG(osh, &cc->gpiopulldown, 0); + W_REG(&cc->gpiopullup, 0); + W_REG(&cc->gpiopulldown, 0); sb_setcoreidx(sih, origidx); #ifdef BRCM_FULLMAC } @@ -469,15 +464,15 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, /* PMU specific initializations */ if (PMUCTL_ENAB(sih)) { u32 xtalfreq; - si_pmu_init(sih, sii->osh); - si_pmu_chip_init(sih, sii->osh); + si_pmu_init(sih); + si_pmu_chip_init(sih); xtalfreq = getintvar(pvars, "xtalfreq"); /* If xtalfreq var not available, try to measure it */ if (xtalfreq == 0) - xtalfreq = si_pmu_measure_alpclk(sih, sii->osh); - si_pmu_pll_init(sih, sii->osh, xtalfreq); - si_pmu_res_init(sih, sii->osh); - si_pmu_swreg_init(sih, sii->osh); + xtalfreq = si_pmu_measure_alpclk(sih); + si_pmu_pll_init(sih, xtalfreq); + si_pmu_res_init(sih); + si_pmu_swreg_init(sih); } /* setup the GPIO based LED powersave register */ @@ -499,8 +494,8 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, } #else /* BCMSDIO */ -static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, - void *regs, uint bustype, void *sdh, +static si_info_t *si_doattach(si_info_t *sii, uint devid, + void *regs, uint bustype, void *pbus, char **vars, uint *varsz) { struct si_pub *sih = &sii->pub; @@ -518,12 +513,11 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, sih->buscoreidx = BADIDX; sii->curmap = regs; - sii->sdh = sdh; - sii->osh = osh; + sii->pbus = pbus; /* check to see if we are a si core mimic'ing a pci core */ if (bustype == PCI_BUS) { - pci_read_config_dword(sii->osh->pdev, PCI_SPROM_CONTROL, &w); + pci_read_config_dword(sii->pbus, PCI_SPROM_CONTROL, &w); if (w == 0xffffffff) { SI_ERROR(("%s: incoming bus is PCI but it's a lie, " " switching to SI devid:0x%x\n", @@ -534,10 +528,10 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, /* find Chipcommon address */ if (bustype == PCI_BUS) { - pci_read_config_dword(sii->osh->pdev, PCI_BAR0_WIN, &savewin); + pci_read_config_dword(sii->pbus, PCI_BAR0_WIN, &savewin); if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) savewin = SI_ENUM_BASE; - pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, + pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, SI_ENUM_BASE); cc = (chipcregs_t *) regs; } else { @@ -547,7 +541,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, sih->bustype = bustype; /* bus/core/clk setup for register access */ - if (!si_buscore_prep(sii, bustype, devid, sdh)) { + if (!si_buscore_prep(sii, bustype, devid, pbus)) { SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n", bustype)); return NULL; @@ -558,7 +552,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, * If we add other chiptypes (or if we need to support old sdio hosts w/o chipcommon), * some way of recognizing them needs to be added here. */ - w = R_REG(osh, &cc->chipid); + w = R_REG(&cc->chipid); sih->socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT; /* Might as wll fill in chip id rev & pkg */ sih->chip = w & CID_ID_MASK; @@ -598,10 +592,10 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, if ((cc->chipstatus & CST43236_BP_CLK) != 0) { uint clkdiv; - clkdiv = R_REG(osh, &cc->clkdiv); + clkdiv = R_REG(&cc->clkdiv); /* otp_clk_div is even number, 120/14 < 9mhz */ clkdiv = (clkdiv & ~CLKD_OTP) | (14 << CLKD_OTP_SHIFT); - W_REG(osh, &cc->clkdiv, clkdiv); + W_REG(&cc->clkdiv, clkdiv); SI_ERROR(("%s: set clkdiv to %x\n", __func__, clkdiv)); } udelay(10); @@ -612,7 +606,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, /* Init nvram from sprom/otp if they exist */ if (srom_var_init - (&sii->pub, bustype, regs, sii->osh, vars, varsz)) { + (&sii->pub, bustype, regs, vars, varsz)) { SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } @@ -621,22 +615,22 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, /* === NVRAM, clock is ready === */ cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); - W_REG(osh, &cc->gpiopullup, 0); - W_REG(osh, &cc->gpiopulldown, 0); + W_REG(&cc->gpiopullup, 0); + W_REG(&cc->gpiopulldown, 0); si_setcoreidx(sih, origidx); /* PMU specific initializations */ if (PMUCTL_ENAB(sih)) { u32 xtalfreq; - si_pmu_init(sih, sii->osh); - si_pmu_chip_init(sih, sii->osh); + si_pmu_init(sih); + si_pmu_chip_init(sih); xtalfreq = getintvar(pvars, "xtalfreq"); /* If xtalfreq var not available, try to measure it */ if (xtalfreq == 0) - xtalfreq = si_pmu_measure_alpclk(sih, sii->osh); - si_pmu_pll_init(sih, sii->osh, xtalfreq); - si_pmu_res_init(sih, sii->osh); - si_pmu_swreg_init(sih, sii->osh); + xtalfreq = si_pmu_measure_alpclk(sih); + si_pmu_pll_init(sih, xtalfreq); + si_pmu_res_init(sih); + si_pmu_swreg_init(sih); } /* setup the GPIO based LED powersave register */ @@ -700,7 +694,7 @@ void si_detach(si_t *sih) uint idx; struct si_pub *si_local = NULL; - bcopy(&sih, &si_local, sizeof(si_t **)); + memcpy(&si_local, &sih, sizeof(si_t **)); sii = SI_INFO(sih); @@ -729,14 +723,6 @@ void si_detach(si_t *sih) kfree(sii); } -struct osl_info *si_osh(si_t *sih) -{ - si_info_t *sii; - - sii = SI_INFO(sih); - return sii->osh; -} - /* register driver interrupt disabling and restoring callback functions */ void si_register_intr_callback(si_t *sih, void *intrsoff_fn, void *intrsrestore_fn, @@ -996,7 +982,7 @@ void si_core_reset(si_t *sih, u32 bits, u32 resetbits) u32 si_alp_clock(si_t *sih) { if (PMUCTL_ENAB(sih)) - return si_pmu_alp_clock(sih, si_osh(sih)); + return si_pmu_alp_clock(sih); return ALP_CLOCK; } @@ -1004,7 +990,7 @@ u32 si_alp_clock(si_t *sih) u32 si_ilp_clock(si_t *sih) { if (PMUCTL_ENAB(sih)) - return si_pmu_ilp_clock(sih, si_osh(sih)); + return si_pmu_ilp_clock(sih); return ILP_CLOCK; } @@ -1090,7 +1076,7 @@ static uint si_slowclk_src(si_info_t *sii) if (sii->pub.ccrev < 6) { if (sii->pub.bustype == PCI_BUS) { - pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUT, + pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &val); if (val & PCI_CFG_GPIO_SCS) return SCC_SS_PCI; @@ -1098,7 +1084,7 @@ static uint si_slowclk_src(si_info_t *sii) return SCC_SS_XTAL; } else if (sii->pub.ccrev < 10) { cc = (chipcregs_t *) si_setcoreidx(&sii->pub, sii->curidx); - return R_REG(sii->osh, &cc->slow_clk_ctl) & SCC_SS_MASK; + return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; } else /* Insta-clock */ return SCC_SS_XTAL; } @@ -1112,7 +1098,7 @@ static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc) ASSERT(SI_FAST(sii) || si_coreid(&sii->pub) == CC_CORE_ID); /* shouldn't be here unless we've established the chip has dynamic clk control */ - ASSERT(R_REG(sii->osh, &cc->capabilities) & CC_CAP_PWR_CTL); + ASSERT(R_REG(&cc->capabilities) & CC_CAP_PWR_CTL); slowclk = si_slowclk_src(sii); if (sii->pub.ccrev < 6) { @@ -1124,7 +1110,7 @@ static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc) : (XTALMINFREQ / 32); } else if (sii->pub.ccrev < 10) { div = 4 * - (((R_REG(sii->osh, &cc->slow_clk_ctl) & SCC_CD_MASK) >> + (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1); if (slowclk == SCC_SS_LPO) return max_freq ? LPOMAXFREQ : LPOMINFREQ; @@ -1138,7 +1124,7 @@ static uint si_slowclk_freq(si_info_t *sii, bool max_freq, chipcregs_t *cc) ASSERT(0); } else { /* Chipc rev 10 is InstaClock */ - div = R_REG(sii->osh, &cc->system_clk_ctl) >> SYCC_CD_SHIFT; + div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT; div = 4 * (div + 1); return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div); } @@ -1168,8 +1154,8 @@ static void si_clkctl_setdelay(si_info_t *sii, void *chipcregs) pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; - W_REG(sii->osh, &cc->pll_on_delay, pll_on_delay); - W_REG(sii->osh, &cc->fref_sel_delay, fref_sel_delay); + W_REG(&cc->pll_on_delay, pll_on_delay); + W_REG(&cc->fref_sel_delay, fref_sel_delay); } /* initialize power control delay registers */ @@ -1199,7 +1185,7 @@ void si_clkctl_init(si_t *sih) /* set all Instaclk chip ILP to 1 MHz */ if (sih->ccrev >= 10) - SET_REG(sii->osh, &cc->system_clk_ctl, SYCC_CD_MASK, + SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); si_clkctl_setdelay(sii, (void *)cc); @@ -1222,7 +1208,7 @@ u16 si_clkctl_fast_pwrup_delay(si_t *sih) sii = SI_INFO(sih); if (PMUCTL_ENAB(sih)) { INTR_OFF(sii, intr_val); - fpdelay = si_pmu_fast_pwrup_delay(sih, sii->osh); + fpdelay = si_pmu_fast_pwrup_delay(sih); INTR_RESTORE(sii, intr_val); return fpdelay; } @@ -1246,7 +1232,7 @@ u16 si_clkctl_fast_pwrup_delay(si_t *sih) ASSERT(cc != NULL); slowminfreq = si_slowclk_freq(sii, false, cc); - fpdelay = (((R_REG(sii->osh, &cc->pll_on_delay) + 2) * 1000000) + + fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq; done: @@ -1277,9 +1263,9 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) if (PCIE(sii)) return -1; - pci_read_config_dword(sii->osh->pdev, PCI_GPIO_IN, &in); - pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUT, &out); - pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUTEN, &outen); + pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); + pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &out); + pci_read_config_dword(sii->pbus, PCI_GPIO_OUTEN, &outen); /* * Avoid glitching the clock if GPRS is already using it. @@ -1300,9 +1286,9 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) out |= PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->osh->pdev, + pci_write_config_dword(sii->pbus, PCI_GPIO_OUT, out); - pci_write_config_dword(sii->osh->pdev, + pci_write_config_dword(sii->pbus, PCI_GPIO_OUTEN, outen); udelay(XTAL_ON_DELAY); } @@ -1310,7 +1296,7 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) /* turn pll on */ if (what & PLL) { out &= ~PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->osh->pdev, + pci_write_config_dword(sii->pbus, PCI_GPIO_OUT, out); mdelay(2); } @@ -1319,9 +1305,9 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) out &= ~PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->osh->pdev, + pci_write_config_dword(sii->pbus, PCI_GPIO_OUT, out); - pci_write_config_dword(sii->osh->pdev, + pci_write_config_dword(sii->pbus, PCI_GPIO_OUTEN, outen); } @@ -1397,20 +1383,20 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode) if (sii->pub.ccrev < 10) { /* don't forget to force xtal back on before we clear SCC_DYN_XTAL.. */ si_clkctl_xtal(&sii->pub, XTAL, ON); - SET_REG(sii->osh, &cc->slow_clk_ctl, + SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP); } else if (sii->pub.ccrev < 20) { - OR_REG(sii->osh, &cc->system_clk_ctl, SYCC_HR); + OR_REG(&cc->system_clk_ctl, SYCC_HR); } else { - OR_REG(sii->osh, &cc->clk_ctl_st, CCS_FORCEHT); + OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); } /* wait for the PLL */ if (PMUCTL_ENAB(&sii->pub)) { u32 htavail = CCS_HTAVAIL; - SPINWAIT(((R_REG(sii->osh, &cc->clk_ctl_st) & htavail) + SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) == 0), PMU_MAX_TRANSITION_DLY); - ASSERT(R_REG(sii->osh, &cc->clk_ctl_st) & htavail); + ASSERT(R_REG(&cc->clk_ctl_st) & htavail); } else { udelay(PLL_DELAY); } @@ -1418,20 +1404,20 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode) case CLK_DYNAMIC: /* enable dynamic clock control */ if (sii->pub.ccrev < 10) { - scc = R_REG(sii->osh, &cc->slow_clk_ctl); + scc = R_REG(&cc->slow_clk_ctl); scc &= ~(SCC_FS | SCC_IP | SCC_XC); if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) scc |= SCC_XC; - W_REG(sii->osh, &cc->slow_clk_ctl, scc); + W_REG(&cc->slow_clk_ctl, scc); /* for dynamic control, we have to release our xtal_pu "force on" */ if (scc & SCC_XC) si_clkctl_xtal(&sii->pub, XTAL, OFF); } else if (sii->pub.ccrev < 20) { /* Instaclock */ - AND_REG(sii->osh, &cc->system_clk_ctl, ~SYCC_HR); + AND_REG(&cc->system_clk_ctl, ~SYCC_HR); } else { - AND_REG(sii->osh, &cc->clk_ctl_st, ~CCS_FORCEHT); + AND_REG(&cc->clk_ctl_st, ~CCS_FORCEHT); } break; @@ -1464,10 +1450,11 @@ int si_devpath(si_t *sih, char *path, int size) slen = snprintf(path, (size_t) size, "sb/%u/", si_coreidx(sih)); break; case PCI_BUS: - ASSERT((SI_INFO(sih))->osh != NULL); + ASSERT((SI_INFO(sih))->pbus != NULL); slen = snprintf(path, (size_t) size, "pci/%u/%u/", - OSL_PCI_BUS((SI_INFO(sih))->osh), - OSL_PCI_SLOT((SI_INFO(sih))->osh)); + ((struct pci_dev *)((SI_INFO(sih))->pbus))->bus->number, + PCI_SLOT( + ((struct pci_dev *)((SI_INFO(sih))->pbus))->devfn)); break; #ifdef BCMSDIO @@ -1552,7 +1539,7 @@ static __used bool si_ispcie(si_info_t *sii) return false; cap_ptr = - pcicore_find_pci_capability(sii->osh, PCI_CAP_PCIECAP_ID, NULL, + pcicore_find_pci_capability(sii->pbus, PCI_CAP_PCIECAP_ID, NULL, NULL); if (!cap_ptr) return false; @@ -1585,8 +1572,8 @@ void si_sdio_init(si_t *sih) SI_MSG(("si_sdio_init: For PCMCIA/SDIO Corerev %d, enable ints from core %d " "through SD core %d (%p)\n", sih->buscorerev, idx, sii->curidx, sdpregs)); /* enable backplane error and core interrupts */ - W_REG(sii->osh, &sdpregs->hostintmask, I_SBINT); - W_REG(sii->osh, &sdpregs->sbintmask, + W_REG(&sdpregs->hostintmask, I_SBINT); + W_REG(&sdpregs->sbintmask, (I_SB_SERR | I_SB_RESPERR | (1 << idx))); /* switch back to previous core */ @@ -1594,7 +1581,7 @@ void si_sdio_init(si_t *sih) } /* enable interrupts */ - bcmsdh_intr_enable(sii->sdh); + bcmsdh_intr_enable(sii->pbus); } #endif /* BCMSDIO */ @@ -1690,24 +1677,24 @@ void si_pci_setup(si_t *sih, uint coremask) */ if (PCIE(sii) || (PCI(sii) && ((sii->pub.buscorerev) >= 6))) { /* pci config write to set this core bit in PCIIntMask */ - pci_read_config_dword(sii->osh->pdev, PCI_INT_MASK, &w); + pci_read_config_dword(sii->pbus, PCI_INT_MASK, &w); w |= (coremask << PCI_SBIM_SHIFT); - pci_write_config_dword(sii->osh->pdev, PCI_INT_MASK, w); + pci_write_config_dword(sii->pbus, PCI_INT_MASK, w); } else { /* set sbintvec bit for our flag number */ si_setint(sih, siflag); } if (PCI(sii)) { - OR_REG(sii->osh, &pciregs->sbtopci2, + OR_REG(&pciregs->sbtopci2, (SBTOPCI_PREF | SBTOPCI_BURST)); if (sii->pub.buscorerev >= 11) { - OR_REG(sii->osh, &pciregs->sbtopci2, + OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); - w = R_REG(sii->osh, &pciregs->clkrun); - W_REG(sii->osh, &pciregs->clkrun, + w = R_REG(&pciregs->clkrun); + W_REG(&pciregs->clkrun, (w | PCI_CLKRUN_DSBL)); - w = R_REG(sii->osh, &pciregs->clkrun); + w = R_REG(&pciregs->clkrun); } /* switch back to previous core */ @@ -1749,12 +1736,12 @@ int si_pci_fixcfg(si_t *sih) reg16 = &pciregs->sprom[SRSH_PI_OFFSET]; } pciidx = si_coreidx(&sii->pub); - val16 = R_REG(sii->osh, reg16); + val16 = R_REG(reg16); if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16) pciidx) { val16 = (u16) (pciidx << SRSH_PI_SHIFT) | (val16 & ~SRSH_PI_MASK); - W_REG(sii->osh, reg16, val16); + W_REG(reg16, val16); } /* restore the original index */ @@ -1795,8 +1782,8 @@ socram_banksize(si_info_t *sii, sbsocramregs_t *regs, u8 index, ASSERT(mem_type <= SOCRAM_MEMTYPE_DEVRAM); - W_REG(sii->osh, ®s->bankidx, bankidx); - bankinfo = R_REG(sii->osh, ®s->bankinfo); + W_REG(®s->bankidx, bankidx); + bankinfo = R_REG(®s->bankinfo); banksize = SOCRAM_BANKINFO_SZBASE * ((bankinfo & SOCRAM_BANKINFO_SZMASK) + 1); return banksize; @@ -1831,7 +1818,7 @@ u32 si_socram_size(si_t *sih) if (!wasup) si_core_reset(sih, 0, 0); corerev = si_corerev(sih); - coreinfo = R_REG(sii->osh, ®s->coreinfo); + coreinfo = R_REG(®s->coreinfo); /* Calculate size from coreinfo based on rev */ if (corerev == 0) @@ -1879,22 +1866,22 @@ void si_chipcontrl_epa4331(si_t *sih, bool on) cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); - val = R_REG(sii->osh, &cc->chipcontrol); + val = R_REG(&cc->chipcontrol); if (on) { if (sih->chippkg == 9 || sih->chippkg == 0xb) { /* Ext PA Controls for 4331 12x9 Package */ - W_REG(sii->osh, &cc->chipcontrol, val | + W_REG(&cc->chipcontrol, val | (CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5)); } else { /* Ext PA Controls for 4331 12x12 Package */ - W_REG(sii->osh, &cc->chipcontrol, + W_REG(&cc->chipcontrol, val | (CCTRL4331_EXTPA_EN)); } } else { val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); - W_REG(sii->osh, &cc->chipcontrol, val); + W_REG(&cc->chipcontrol, val); } si_setcoreidx(sih, origidx); @@ -1913,8 +1900,8 @@ void si_epa_4313war(si_t *sih) cc = (chipcregs_t *) si_setcore(sih, CC_CORE_ID, 0); /* EPA Fix */ - W_REG(sii->osh, &cc->gpiocontrol, - R_REG(sii->osh, &cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK); + W_REG(&cc->gpiocontrol, + R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK); si_setcoreidx(sih, origidx); } @@ -1929,8 +1916,8 @@ bool si_deviceremoved(si_t *sih) switch (sih->bustype) { case PCI_BUS: - ASSERT(sii->osh != NULL); - pci_read_config_dword(sii->osh->pdev, PCI_CFG_VID, &w); + ASSERT(sii->pbus != NULL); + pci_read_config_dword(sii->pbus, PCI_CFG_VID, &w); if ((w & 0xFFFF) != VENDOR_BROADCOM) return true; break; @@ -1952,7 +1939,7 @@ bool si_is_sprom_available(si_t *sih) sii = SI_INFO(sih); origidx = sii->curidx; cc = si_setcoreidx(sih, SI_CC_IDX); - sromctrl = R_REG(sii->osh, &cc->sromcontrol); + sromctrl = R_REG(&cc->sromcontrol); si_setcoreidx(sih, origidx); return sromctrl & SRC_PRESENT; } @@ -2006,14 +1993,14 @@ bool si_is_otp_disabled(si_t *sih) bool si_is_otp_powered(si_t *sih) { if (PMUCTL_ENAB(sih)) - return si_pmu_is_otp_powered(sih, si_osh(sih)); + return si_pmu_is_otp_powered(sih); return true; } void si_otp_power(si_t *sih, bool on) { if (PMUCTL_ENAB(sih)) - si_pmu_otp_power(sih, si_osh(sih), on); + si_pmu_otp_power(sih, on); udelay(1000); } diff --git a/drivers/staging/brcm80211/util/siutils_priv.h b/drivers/staging/brcm80211/util/siutils_priv.h index 028461441481..a03ff617531a 100644 --- a/drivers/staging/brcm80211/util/siutils_priv.h +++ b/drivers/staging/brcm80211/util/siutils_priv.h @@ -25,8 +25,6 @@ extern uint sb_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val); extern bool sb_iscoreup(si_t *sih); void *sb_setcoreidx(si_t *sih, uint coreidx); -extern u32 sb_base(u32 admatch); extern void sb_core_reset(si_t *sih, u32 bits, u32 resetbits); extern void sb_core_disable(si_t *sih, u32 bits); -extern bool sb_taclear(si_t *sih, bool details); #endif /* _siutils_priv_h_ */ |