From: Rongjun Chen Date: Wed, 11 Oct 2017 09:34:35 +0000 (+0800) Subject: wifi: update driver to 1.579.77.41.2 (r) X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ccd15baf484ad70400c4f3394cdb1f50d19eec58;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_kernel-modules_dhd-driver.git wifi: update driver to 1.579.77.41.2 (r) PD# 151866 update wifi driver Change-Id: Iaa65eca2adedd58cd484cfc96b3f7a3c557c6e4f Signed-off-by: Rongjun Chen --- diff --git a/bcmdhd.1.579.77.41.1.cn/Makefile b/bcmdhd.1.579.77.41.1.cn/Makefile index 636497a..5788bb3 100644 --- a/bcmdhd.1.579.77.41.1.cn/Makefile +++ b/bcmdhd.1.579.77.41.1.cn/Makefile @@ -20,8 +20,8 @@ DHDCFLAGS = -Wall -Wstrict-prototypes -Dlinux -DBCMDRIVER -DSDTEST \ -DWIFI_ACT_FRAME -DARP_OFFLOAD_SUPPORT -DSUPPORT_PM2_ONLY \ -DKEEP_ALIVE -DPKT_FILTER_SUPPORT -DPNO_SUPPORT -DDHDTCPACK_SUPPRESS \ -DDHD_DONOT_FORWARD_BCMEVENT_AS_NETWORK_PKT -DRXFRAME_THREAD \ - -DTSQ_MULTIPLIER -DMFP \ - -DBCMSDIOH_TXGLOM_EXT -DWL_EXT_IAPSTA \ + -DTSQ_MULTIPLIER -DMFP \ + -DBCMSDIOH_TXGLOM_EXT -DWL_EXT_IAPSTA \ -DENABLE_INSMOD_NO_FW_LOAD \ -I$(src) -I$(src)/include @@ -117,6 +117,7 @@ DHDCFLAGS += -DWL_SUPPORT_BACKPORTED_KPATCHES DHDCFLAGS += -DESCAN_RESULT_PATCH DHDCFLAGS += -DVSDB -DWL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST DHDCFLAGS += -DWLTDLS -DMIRACAST_AMPDU_SIZE=8 +DHDCFLAGS += -DWL_VIRTUAL_APSTA endif EXTRA_CFLAGS = $(DHDCFLAGS) ifeq ($(CONFIG_BCMDHD),m) diff --git a/bcmdhd.1.579.77.41.1.cn/bcmsdh_sdmmc.c b/bcmdhd.1.579.77.41.1.cn/bcmsdh_sdmmc.c index 8cbf18a..d98411f 100644 --- a/bcmdhd.1.579.77.41.1.cn/bcmsdh_sdmmc.c +++ b/bcmdhd.1.579.77.41.1.cn/bcmsdh_sdmmc.c @@ -190,7 +190,7 @@ sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd) err_ret = sdio_enable_func(sd->func[1]); sdio_release_host(sd->func[1]); if (err_ret) { - sd_err(("bcmsdh_sdmmc: Failed to enable F1 Err: 0x%08x", err_ret)); + sd_err(("bcmsdh_sdmmc: Failed to enable F1 Err: 0x%08x\n", err_ret)); } return FALSE; @@ -1099,6 +1099,7 @@ sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func, uint add return (((err_ret == 0)&&(err_ret2 == 0)) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL); } +#ifdef BCMSDIOH_TXGLOM static SDIOH_API_RC sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func, uint addr, void *pkt) @@ -1117,11 +1118,9 @@ sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func uint32 sg_count; struct sdio_func *sdio_func = sd->func[func]; struct mmc_host *host = sdio_func->card->host; -#ifdef BCMSDIOH_TXGLOM uint8 *localbuf = NULL; uint local_plen = 0; uint pkt_len = 0; -#endif /* BCMSDIOH_TXGLOM */ struct timespec now, before; sd_trace(("%s: Enter\n", __FUNCTION__)); @@ -1139,11 +1138,9 @@ sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func pkt_offset = 0; pnext = pkt; -#ifdef BCMSDIOH_TXGLOM ttl_len = 0; sg_count = 0; if(sd->txglom_mode == SDPCM_TXGLOM_MDESC) { -#endif while (pnext != NULL) { ttl_len = 0; sg_count = 0; @@ -1231,7 +1228,6 @@ sdioh_request_packet_chain(sdioh_info_t *sd, uint fix_inc, uint write, uint func return SDIOH_API_RC_FAIL; } } -#ifdef BCMSDIOH_TXGLOM } else if(sd->txglom_mode == SDPCM_TXGLOM_CPY) { for (pnext = pkt; pnext; pnext = PKTNEXT(sd->osh, pnext)) { ttl_len += PKTLEN(sd->osh, pnext); @@ -1305,7 +1301,6 @@ txglomfail: if (localbuf) MFREE(sd->osh, localbuf, ttl_len); -#endif /* BCMSDIOH_TXGLOM */ if (sd_msglevel & SDH_COST_VAL) { getnstimeofday(&now); @@ -1316,6 +1311,7 @@ txglomfail: sd_trace(("%s: Exit\n", __FUNCTION__)); return SDIOH_API_RC_SUCCESS; } +#endif /* BCMSDIOH_TXGLOM */ static SDIOH_API_RC sdioh_buffer_tofrom_bus(sdioh_info_t *sd, uint fix_inc, uint write, uint func, @@ -1732,15 +1728,22 @@ sdioh_gpio_init(sdioh_info_t *sd) uint sdmmc_get_clock_rate(sdioh_info_t *sd) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) + return 0; +#else struct sdio_func *sdio_func = sd->func[0]; struct mmc_host *host = sdio_func->card->host; return mmc_host_clk_rate(host); +#endif } void sdmmc_set_clock_rate(sdioh_info_t *sd, uint hz) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) + return; +#else struct sdio_func *sdio_func = sd->func[0]; struct mmc_host *host = sdio_func->card->host; struct mmc_ios *ios = &host->ios; @@ -1760,6 +1763,7 @@ sdmmc_set_clock_rate(sdioh_info_t *sd, uint hz) host->ops->set_ios(host, ios); DHD_ERROR(("%s: After change: sd clock rate is %u\n", __FUNCTION__, ios->clock)); mmc_host_clk_release(host); +#endif } void diff --git a/bcmdhd.1.579.77.41.1.cn/dhd.h b/bcmdhd.1.579.77.41.1.cn/dhd.h index 99af8b3..0c46434 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd.h +++ b/bcmdhd.1.579.77.41.1.cn/dhd.h @@ -85,6 +85,10 @@ int get_scheduler_policy(struct task_struct *p); #define WL_VENDOR_EXT_SUPPORT #endif /* 3.18 > KERNEL_VER >= 3.14 || defined(CONFIG_BCMDHD_VENDOR_EXT) */ +/*#if !defined(WL_VENDOR_EXT_SUPPORT) +#undef GSCAN_SUPPORT +#endif +*/ #if defined(KEEP_ALIVE) /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */ #define KEEP_ALIVE_PERIOD 55000 @@ -106,6 +110,7 @@ enum dhd_bus_state { DHD_BUS_DATA, /* Ready for frame transfers */ DHD_BUS_SUSPEND, /* Bus has been suspended */ DHD_BUS_DOWN_IN_PROGRESS, /* Bus going Down */ + DHD_BUS_REMOVE, /* Bus has been removed */ }; /* @@ -217,7 +222,11 @@ enum dhd_bus_state { DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp)) #define DHD_BUS_CHECK_DOWN_OR_DOWN_IN_PROGRESS(dhdp) \ - ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS) + ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS || \ + (dhdp)->busstate == DHD_BUS_REMOVE) + +#define DHD_BUS_CHECK_REMOVE(dhdp) \ + ((dhdp)->busstate == DHD_BUS_REMOVE) /* Macro to print Ethernet Address as String * expects both arguements as (char *) @@ -1949,7 +1958,11 @@ extern uint dhd_force_tx_queueing; #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY #endif /* WIFI_TURNON_DELAY */ +#ifdef BCMSDIO #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 10 /* msec */ +#else +#define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 0 /* msec */ +#endif #ifndef CUSTOM_DHD_WATCHDOG_MS #define CUSTOM_DHD_WATCHDOG_MS DEFAULT_DHD_WATCHDOG_INTERVAL_MS #endif /* DEFAULT_DHD_WATCHDOG_INTERVAL_MS */ diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_common.c b/bcmdhd.1.579.77.41.1.cn/dhd_common.c index adf83c2..19a9226 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_common.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_common.c @@ -207,7 +207,7 @@ bool ap_fw_loaded = FALSE; #if defined(DHD_DEBUG) const char dhd_version[] = "Dongle Host Driver, version " EPI_VERSION_STR; #else -const char dhd_version[] = "\nDongle Host Driver, version " EPI_VERSION_STR "\nCompiled from "; +const char dhd_version[] = "\nDongle Host Driver, version " EPI_VERSION_STR; #endif char fw_version[FW_VER_STR_LEN] = "\0"; char clm_version[CLM_VER_STR_LEN] = "\0"; @@ -1171,6 +1171,7 @@ dhd_mw_list_delete(dhd_pub_t *dhd, dll_t *list_head) extern pkt_statics_t tx_statics; extern void dhdsdio_txpktstatics(void); #endif + static int dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, uint32 actionid, const char *name, void *params, int plen, void *arg, int len, int val_size) @@ -2319,13 +2320,14 @@ dhd_ioctl(dhd_pub_t * dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen) bcmstricmp((char *)buf, "pciecfgreg") && bcmstricmp((char *)buf, "devreset") && bcmstricmp((char *)buf, "sdio_suspend") && - bcmstricmp((char *)buf, "control_signal")) { + bcmstricmp((char *)buf, "control_signal")) #else if (bcmstricmp((char *)buf, "pcie_suspend") && bcmstricmp((char *)buf, "pciecfgreg") && bcmstricmp((char *)buf, "devreset") && - bcmstricmp((char *)buf, "sdio_suspend")) { + bcmstricmp((char *)buf, "sdio_suspend")) #endif /* DHD_EFI */ + { DHD_ERROR(("%s: bus is in suspend(%d)" "or suspending(0x%x) state\n", __FUNCTION__, dhd_pub->busstate, @@ -3855,6 +3857,7 @@ dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipv6addr, int idx) return retcode; } + /* * Neighbor Discover Offload: enable NDO feature * Called by ipv6 event handler when interface goes down @@ -5828,6 +5831,7 @@ fail: } } + #ifdef PCIE_FULL_DONGLE int dhd_event_logtrace_infobuf_pkt_process(dhd_pub_t *dhdp, void *pktbuf, diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_config.c b/bcmdhd.1.579.77.41.1.cn/dhd_config.c index 1e535fe..700573f 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_config.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_config.c @@ -492,8 +492,11 @@ dhd_conf_set_fw_name_by_chip(dhd_pub_t *dhd, char *fw_path) if (chiprev == BCM4339A0_CHIP_REV) strcpy(&fw_path[i+1], FW_BCM4339A0); break; - case BCM4345_CHIP_ID: case BCM43454_CHIP_ID: + if (chiprev == BCM43455C0_CHIP_REV) + strcpy(&fw_path[i+1], FW_BCM43455C0); + break; + case BCM4345_CHIP_ID: if (chiprev == BCM43455C0_CHIP_REV) strcpy(&fw_path[i+1], FW_BCM43455C0); else if (chiprev == BCM43455C5_CHIP_REV) @@ -1934,7 +1937,7 @@ dhd_conf_read_sdio_params(dhd_pub_t *dhd, char *full_param, uint len_param) printf("%s: dhd_slpauto = %d\n", __FUNCTION__, dhd_slpauto); } else if (!strncmp("kso_enable=", full_param, len_param)) { - if (!strncmp(data, "1", 1)) + if (!strncmp(data, "0", 1)) dhd_slpauto = FALSE; else dhd_slpauto = TRUE; @@ -2016,10 +2019,7 @@ dhd_conf_read_sdio_params(dhd_pub_t *dhd, char *full_param, uint len_param) printf("%s: deferred_tx_len = %d\n", __FUNCTION__, conf->deferred_tx_len); } else if (!strncmp("txctl_tmo_fix=", full_param, len_param)) { - if (!strncmp(data, "0", 1)) - conf->txctl_tmo_fix = FALSE; - else - conf->txctl_tmo_fix = TRUE; + conf->txctl_tmo_fix = (int)simple_strtol(data, NULL, 10); printf("%s: txctl_tmo_fix = %d\n", __FUNCTION__, conf->txctl_tmo_fix); } else if (!strncmp("tx_in_rx=", full_param, len_param)) { @@ -2503,7 +2503,7 @@ dhd_conf_preinit(dhd_pub_t *dhd) #endif conf->srl = -1; conf->lrl = -1; - conf->bcn_timeout = 15; + conf->bcn_timeout = 16; conf->spect = -1; conf->txbf = -1; conf->lpc = -1; @@ -2516,7 +2516,7 @@ dhd_conf_preinit(dhd_pub_t *dhd) conf->tx_max_offset = 0; conf->txglomsize = SDPCM_DEFGLOM_SIZE; conf->dhd_poll = -1; - conf->txctl_tmo_fix = TRUE; + conf->txctl_tmo_fix = 5; conf->tx_in_rx = TRUE; conf->txglom_mode = SDPCM_TXGLOM_MDESC; conf->deferred_tx_len = 0; @@ -2541,7 +2541,7 @@ dhd_conf_preinit(dhd_pub_t *dhd) conf->dhcpc_enable = -1; conf->dhcpd_enable = -1; #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) conf->tsq = 10; #else conf->tsq = 0; @@ -2574,7 +2574,7 @@ dhd_conf_preinit(dhd_pub_t *dhd) #ifdef BCMSDIO conf->dhd_txminmax = -1; conf->txinrx_thres = 128; - conf->sd_f2_blocksize = 256; + conf->sd_f2_blocksize = CUSTOM_SDIO_F2_BLKSIZE; conf->oob_enabled_later = TRUE; #ifdef CUSTOMER_HW_AMLOGIC conf->rxf_cpucore = 2; @@ -2606,7 +2606,7 @@ dhd_conf_preinit(dhd_pub_t *dhd) #endif if (conf->txglomsize > SDPCM_MAXGLOM_SIZE) conf->txglomsize = SDPCM_MAXGLOM_SIZE; - conf->deferred_tx_len = conf->txglomsize; + conf->deferred_tx_len = 0; #endif return 0; diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_config.h b/bcmdhd.1.579.77.41.1.cn/dhd_config.h index af10705..5fdd538 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_config.h +++ b/bcmdhd.1.579.77.41.1.cn/dhd_config.h @@ -149,7 +149,7 @@ typedef struct dhd_conf { int tx_max_offset; uint txglomsize; int dhd_poll; - bool txctl_tmo_fix; + int txctl_tmo_fix; bool tx_in_rx; bool txglom_mode; uint deferred_tx_len; @@ -211,6 +211,7 @@ void dhd_conf_set_nv_name_by_mac(dhd_pub_t *dhd, bcmsdh_info_t *sdh, char *nv_pa void dhd_conf_set_hw_oob_intr(bcmsdh_info_t *sdh, uint chip); #endif void dhd_conf_set_txglom_params(dhd_pub_t *dhd, bool enable); +int dhd_conf_set_blksize(bcmsdh_info_t *sdh); #endif void dhd_conf_set_fw_name_by_chip(dhd_pub_t *dhd, char *fw_path); void dhd_conf_set_clm_name_by_chip(dhd_pub_t *dhd, char *clm_path); @@ -244,7 +245,6 @@ int dhd_conf_get_disable_proptx(dhd_pub_t *dhd); #endif int dhd_conf_get_ap_mode_in_suspend(dhd_pub_t *dhd); int dhd_conf_set_ap_in_suspend(dhd_pub_t *dhd, int suspend); -int dhd_conf_set_blksize(bcmsdh_info_t *sdh); int dhd_conf_preinit(dhd_pub_t *dhd); int dhd_conf_reset(dhd_pub_t *dhd); int dhd_conf_attach(dhd_pub_t *dhd); diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_debug.c b/bcmdhd.1.579.77.41.1.cn/dhd_debug.c index c5c1e59..23e5b46 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_debug.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_debug.c @@ -1174,7 +1174,7 @@ dhd_dbg_ring_init(dhd_pub_t *dhdp, dhd_dbg_ring_t *ring, uint16 id, uint8 *name, void *buf; unsigned long flags; #ifdef CONFIG_DHD_USE_STATIC_BUF - buf = bcm_wlan_prealloc(section, ring_sz); + buf = DHD_OS_PREALLOC(dhdp, section, ring_sz); #else buf = MALLOCZ(dhdp->osh, ring_sz); #endif @@ -2041,7 +2041,12 @@ dhd_dbg_monitor_get_tx_pkts(dhd_pub_t *dhdp, void __user *user_buf, pkt_count = MIN(req_count, tx_report->status_pos); #ifdef CONFIG_COMPAT - if (is_compat_task()) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + if (in_compat_syscall()) +#else + if (is_compat_task()) +#endif + { cptr = (compat_wifi_tx_report_t *)user_buf; while ((count < pkt_count) && tx_pkt && cptr) { compat_wifi_tx_report_t *comp_ptr = compat_ptr((uintptr_t) cptr); @@ -2132,7 +2137,12 @@ dhd_dbg_monitor_get_rx_pkts(dhd_pub_t *dhdp, void __user *user_buf, pkt_count = MIN(req_count, rx_report->pkt_pos); #ifdef CONFIG_COMPAT - if (is_compat_task()) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + if (in_compat_syscall()) +#else + if (is_compat_task()) +#endif + { cptr = (compat_wifi_rx_report_t *)user_buf; while ((count < pkt_count) && rx_pkt && cptr) { compat_wifi_rx_report_t *comp_ptr = compat_ptr((uintptr_t) cptr); diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_gpio.c b/bcmdhd.1.579.77.41.1.cn/dhd_gpio.c index a438a27..78537c8 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_gpio.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_gpio.c @@ -15,6 +15,12 @@ #include #endif /* defined(BUS_POWER_RESTORE) && defined(BCMSDIO) */ + +static int gpio_wl_reg_on = -1; // WL_REG_ON is input pin of WLAN module +#ifdef CUSTOMER_OOB +static int gpio_wl_host_wake = -1; // WL_HOST_WAKE is output pin of WLAN module +#endif + #ifdef CUSTOMER_HW_AMLOGIC #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) #include @@ -28,12 +34,6 @@ extern int wifi_irq_num(void); #endif #endif - -static int gpio_wl_reg_on = -1; // WL_REG_ON is input pin of WLAN module -#ifdef CUSTOMER_OOB -static int gpio_wl_host_wake = -1; // WL_HOST_WAKE is output pin of WLAN module -#endif - static int dhd_wlan_set_power(int on #ifdef BUS_POWER_RESTORE @@ -206,14 +206,6 @@ void* bcm_wlan_prealloc(int section, unsigned long size) } #endif -//#if !defined(WL_WIRELESS_EXT) -//struct cntry_locales_custom { -// char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */ -// char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */ -// int32 custom_locale_rev; /* Custom local revisin default -1 */ -//}; -//#endif - static struct cntry_locales_custom brcm_wlan_translate_custom_table[] = { /* Table should be filled out based on custom platform regulatory requirement */ {"", "XT", 49}, /* Universal if Country code is unknown or empty */ diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_linux.c b/bcmdhd.1.579.77.41.1.cn/dhd_linux.c index 7d08eb2..6e94bfc 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_linux.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_linux.c @@ -3559,10 +3559,11 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd) } #endif /* NDO_CONFIG_SUPPORT */ #ifndef APF - if (FW_SUPPORTED(dhd, ndoe)) { + if (FW_SUPPORTED(dhd, ndoe)) #else - if (FW_SUPPORTED(dhd, ndoe) && !FW_SUPPORTED(dhd, apf)) { + if (FW_SUPPORTED(dhd, ndoe) && !FW_SUPPORTED(dhd, apf)) #endif /* APF */ + { /* enable IPv6 RA filter in firmware during suspend */ nd_ra_filter = 1; ret = dhd_iovar(dhd, 0, "nd_ra_filter_enable", @@ -3643,8 +3644,11 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd) #endif /* PASS_ALL_MCAST_PKTS */ #if defined(BCMPCIE) /* restore pre-suspend setting */ - dhd_iovar(dhd, 0, "bcn_li_dtim", (char *)&bcn_li_dtim, + ret = dhd_iovar(dhd, 0, "bcn_li_dtim", (char *)&bcn_li_dtim, sizeof(bcn_li_dtim), NULL, 0, TRUE); + if (ret < 0) { + DHD_ERROR(("%s:bcn_li_ditm fail:%d\n", __FUNCTION__, ret)); + } dhd_iovar(dhd, 0, "lpas", (char *)&lpas, sizeof(lpas), NULL, 0, TRUE); @@ -3695,10 +3699,11 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd) } #endif /* NDO_CONFIG_SUPPORT */ #ifndef APF - if (FW_SUPPORTED(dhd, ndoe)) { + if (FW_SUPPORTED(dhd, ndoe)) #else - if (FW_SUPPORTED(dhd, ndoe) && !FW_SUPPORTED(dhd, apf)) { + if (FW_SUPPORTED(dhd, ndoe) && !FW_SUPPORTED(dhd, apf)) #endif /* APF */ + { /* disable IPv6 RA filter in firmware during suspend */ nd_ra_filter = 0; ret = dhd_iovar(dhd, 0, "nd_ra_filter_enable", @@ -5062,7 +5067,7 @@ dhd_start_xmit(struct sk_buff *skb, struct net_device *net) __FUNCTION__, dhd->pub.up, dhd->pub.busstate)); netif_stop_queue(net); /* Send Event when bus down detected during data session */ - if (dhd->pub.up && !dhd->pub.hang_was_sent) { + if (dhd->pub.up && !dhd->pub.hang_was_sent && !DHD_BUS_CHECK_REMOVE(&dhd->pub)) { DHD_ERROR(("%s: Event HANG sent up\n", __FUNCTION__)); dhd->pub.hang_reason = HANG_REASON_BUS_DOWN; net_os_send_hang_message(net); @@ -6016,11 +6021,12 @@ dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *pktbuf, int numpkt, uint8 chan) ASSERT(ifidx < DHD_MAX_IFS && dhd->iflist[ifidx]); ifp = dhd->iflist[ifidx]; #ifndef PROP_TXSTATUS_VSDB - if (!(ifp && ifp->net && (ifp->net->reg_state == NETREG_REGISTERED))) { + if (!(ifp && ifp->net && (ifp->net->reg_state == NETREG_REGISTERED))) #else if (!(ifp && ifp->net && (ifp->net->reg_state == NETREG_REGISTERED) && - dhd->pub.up)) { + dhd->pub.up)) #endif /* PROP_TXSTATUS_VSDB */ + { DHD_ERROR(("%s: net device is NOT registered. drop event packet\n", __FUNCTION__)); #ifdef DHD_USE_STATIC_CTRLBUF @@ -8280,12 +8286,23 @@ dhd_open(struct net_device *net) DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__)); return -1; } - /* Init wakelock */ + } + + printf("%s: Enter %p\n", __FUNCTION__, net); +#if defined(MULTIPLE_SUPPLICANT) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1 + if (mutex_is_locked(&_dhd_sdio_mutex_lock_) != 0) { + DHD_ERROR(("%s : dhd_open: call dev open before insmod complete!\n", __FUNCTION__)); + } + mutex_lock(&_dhd_sdio_mutex_lock_); +#endif +#endif /* MULTIPLE_SUPPLICANT */ + /* Init wakelock */ + if (!dhd_download_fw_on_driverload) { if (!(dhd->dhd_state & DHD_ATTACH_STATE_WAKELOCKS_INIT)) { DHD_OS_WAKE_LOCK_INIT(dhd); dhd->dhd_state |= DHD_ATTACH_STATE_WAKELOCKS_INIT; } - #ifdef SHOW_LOGTRACE skb_queue_head_init(&dhd->evt_trace_queue); @@ -8300,15 +8317,6 @@ dhd_open(struct net_device *net) } } #endif /* SHOW_LOGTRACE */ - printf("%s: Enter %p\n", __FUNCTION__, net); -#if defined(MULTIPLE_SUPPLICANT) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1 - if (mutex_is_locked(&_dhd_sdio_mutex_lock_) != 0) { - DHD_ERROR(("%s : dhd_open: call dev open before insmod complete!\n", __FUNCTION__)); - } - mutex_lock(&_dhd_sdio_mutex_lock_); -#endif -#endif /* MULTIPLE_SUPPLICANT */ } #if defined(PREVENT_REOPEN_DURING_HANG) @@ -9387,7 +9395,7 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen) dhd_state |= DHD_ATTACH_STATE_WL_ATTACH; } #ifdef WL_ESCAN - wl_escan_attach(net, (void *)&dhd->pub); + wl_escan_attach(net, &dhd->pub); #endif /* WL_ESCAN */ #endif /* defined(WL_WIRELESS_EXT) */ @@ -12635,7 +12643,7 @@ void dhd_detach(dhd_pub_t *dhdp) wl_iw_detach(); } #ifdef WL_ESCAN - wl_escan_detach(); + wl_escan_detach(dhdp); #endif /* WL_ESCAN */ #endif /* defined(WL_WIRELESS_EXT) */ @@ -13301,6 +13309,7 @@ dhd_os_d3ack_wake(dhd_pub_t *pub) wake_up(&dhd->d3ack_wait); return 0; } + int dhd_os_busbusy_wait_negation(dhd_pub_t *pub, uint *condition) { @@ -13494,6 +13503,8 @@ dhd_os_open_image(char *filename) goto err; } + DHD_ERROR(("%s: %s (%d bytes) open success\n", __FUNCTION__, filename, size)); + err: return fp; } @@ -14187,6 +14198,7 @@ dhd_dev_get_feature_set_matrix(struct net_device *dev, int num) return ret; } + #ifdef CUSTOM_FORCE_NODFS_FLAG int dhd_dev_set_nodfs(struct net_device *dev, u32 nodfs) @@ -14448,6 +14460,7 @@ dhd_dev_pno_stop_for_ssid(struct net_device *dev) return (dhd_pno_stop_for_ssid(&dhd->pub)); } + /* Linux wrapper to call common dhd_pno_set_for_ssid */ int dhd_dev_pno_set_for_ssid(struct net_device *dev, wlc_ssid_ext_t* ssids_local, int nssid, @@ -14483,6 +14496,7 @@ dhd_dev_pno_stop_for_batch(struct net_device *dev) dhd_info_t *dhd = DHD_DEV_INFO(dev); return (dhd_pno_stop_for_batch(&dhd->pub)); } + /* Linux wrapper to call common dhd_dev_pno_set_for_batch */ int dhd_dev_pno_set_for_batch(struct net_device *dev, struct dhd_pno_batch_params *batch_params) @@ -14490,6 +14504,7 @@ dhd_dev_pno_set_for_batch(struct net_device *dev, struct dhd_pno_batch_params *b dhd_info_t *dhd = DHD_DEV_INFO(dev); return (dhd_pno_set_for_batch(&dhd->pub, batch_params)); } + /* Linux wrapper to call common dhd_dev_pno_get_for_batch */ int dhd_dev_pno_get_for_batch(struct net_device *dev, char *buf, int bufsize) @@ -14628,6 +14643,7 @@ dhd_dev_retrieve_batch_scan(struct net_device *dev) return (dhd_retreive_batch_scan_results(&dhd->pub)); } + /* Linux wrapper to call common dhd_pno_process_epno_result */ void * dhd_dev_process_epno_result(struct net_device *dev, const void *data, uint32 event, int *send_evt_bytes) @@ -14695,6 +14711,7 @@ dhd_dev_lazy_roam_enable(struct net_device *dev, uint32 enable) } return err; } + int dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev, wl_bssid_pref_cfg_t *bssid_pref, uint32 flush) @@ -14715,6 +14732,7 @@ dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev, } return err; } + int dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist, uint32 len, uint32 flush) @@ -14740,6 +14758,7 @@ dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist, } return err; } + int dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *ssid_whitelist, uint32 len, uint32 flush) @@ -14767,6 +14786,7 @@ dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *ssid_whi return err; } #endif /* GSCAN_SUPPORT */ + #if defined(GSCAN_SUPPORT) || defined(DHD_GET_VALID_CHANNELS) /* Linux wrapper to call common dhd_pno_get_gscan */ void * @@ -17475,23 +17495,21 @@ int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val) #elif (defined(BOARD_PANDA) || defined(__ARM_ARCH_7A__)) #define MEMDUMPINFO "/data/misc/wifi/.memdump.info" #else -#if defined(CONFIG_X86) -#define MEMDUMPINFO MEMDUMPINFO_LIVE -#endif +#define MEMDUMPINFO "/data/misc/wifi/.memdump.info" #endif /* CUSTOMER_HW4_DEBUG */ void dhd_get_memdump_info(dhd_pub_t *dhd) { + struct file *fp = NULL; uint32 mem_val = DUMP_MEMFILE_MAX; -#if defined(CONFIG_X86) int ret = 0; - struct file *fp = NULL; char *filepath = MEMDUMPINFO; + /* Read memdump info from the file */ fp = filp_open(filepath, O_RDONLY, 0); - if (IS_ERR(fp)) { DHD_ERROR(("%s: File [%s] doesn't exist\n", __FUNCTION__, filepath)); +#if defined(CONFIG_X86) /* Check if it is Live Brix Image */ if (strcmp(filepath, MEMDUMPINFO_LIVE) != 0) { goto done; @@ -17507,7 +17525,6 @@ void dhd_get_memdump_info(dhd_pub_t *dhd) #else /* Non Brix Android platform */ goto done; #endif /* CONFIG_X86 && OEM_ANDROID */ -#if defined(CONFIG_X86) } /* Handle success case */ @@ -17521,7 +17538,7 @@ void dhd_get_memdump_info(dhd_pub_t *dhd) mem_val = bcm_atoi((char *)&mem_val); filp_close(fp, NULL); -#endif + #ifdef DHD_INIT_DEFAULT_MEMDUMP if (mem_val == 0 || mem_val == DUMP_MEMFILE_MAX) mem_val = DUMP_MEMFILE_BUGON; @@ -17531,7 +17548,7 @@ done: #ifdef CUSTOMER_HW4_DEBUG dhd->memdump_enabled = (mem_val < DUMP_MEMFILE_MAX) ? mem_val : DUMP_DISABLED; #else - dhd->memdump_enabled = (mem_val < DUMP_MEMFILE_MAX) ? mem_val : DUMP_MEMFILE_BUGON; + dhd->memdump_enabled = (mem_val < DUMP_MEMFILE_MAX) ? mem_val : DUMP_MEMFILE; #endif /* CUSTOMER_HW4_DEBUG */ DHD_ERROR(("%s: MEMDUMP ENABLED = %d\n", __FUNCTION__, dhd->memdump_enabled)); @@ -17567,6 +17584,7 @@ void dhd_schedule_memdump(dhd_pub_t *dhdp, uint8 *buf, uint32 size) dhd_deferred_schedule_work(dhdp->info->dhd_deferred_wq, (void *)dump, DHD_WQ_WORK_SOC_RAM_DUMP, dhd_mem_dump, DHD_WQ_WORK_PRIORITY_HIGH); } + static void dhd_mem_dump(void *handle, void *event_info, u8 event) { diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_msgbuf.c b/bcmdhd.1.579.77.41.1.cn/dhd_msgbuf.c index 83b56ed..e602d24 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_msgbuf.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_msgbuf.c @@ -2283,11 +2283,11 @@ dhd_prot_attach(dhd_pub_t *dhd) /* Scratch buffer for dma rx offset */ #ifdef BCM_HOST_BUF if (dhd_dma_buf_alloc(dhd, &prot->d2h_dma_scratch_buf, - ROUNDUP(DMA_D2H_SCRATCH_BUF_LEN, 16) + DMA_HOST_BUFFER_LEN)) { + ROUNDUP(DMA_D2H_SCRATCH_BUF_LEN, 16) + DMA_HOST_BUFFER_LEN)) #else - if (dhd_dma_buf_alloc(dhd, &prot->d2h_dma_scratch_buf, DMA_D2H_SCRATCH_BUF_LEN)) { - + if (dhd_dma_buf_alloc(dhd, &prot->d2h_dma_scratch_buf, DMA_D2H_SCRATCH_BUF_LEN)) #endif /* BCM_HOST_BUF */ + { goto fail; } @@ -8314,12 +8314,14 @@ dhd_prot_debug_info_print(dhd_pub_t *dhd) PCIECFGREG_PHY_DBG_CLKREQ3, dhd_pcie_corereg_read(dhd->bus->sih, PCIECFGREG_PHY_DBG_CLKREQ3))); +#if defined(PCIE_RC_VENDOR_ID) && defined(PCIE_RC_DEVICE_ID) DHD_ERROR(("Pcie RC Error Status Val=0x%x\n", dhdpcie_rc_access_cap(dhd->bus, PCIE_EXTCAP_ID_ERR, PCIE_EXTCAP_AER_UCERR_OFFSET, TRUE, FALSE, 0))); DHD_ERROR(("RootPort PCIe linkcap=0x%08x\n", dhd_debug_get_rc_linkcap(dhd->bus))); +#endif DHD_ERROR(("\n ------- DUMPING INTR enable/disable counters ------- \r\n")); DHD_ERROR(("resume_intr_enable_count=%lu dpc_intr_enable_count=%lu\n" diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_pcie.c b/bcmdhd.1.579.77.41.1.cn/dhd_pcie.c index 48014bf..77995b5 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_pcie.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_pcie.c @@ -1116,6 +1116,27 @@ dhdpcie_advertise_bus_cleanup(dhd_pub_t *dhdp) return; } +static void +dhdpcie_advertise_bus_remove(dhd_pub_t *dhdp) +{ + unsigned long flags; + int timeleft; + + DHD_GENERAL_LOCK(dhdp, flags); + dhdp->busstate = DHD_BUS_REMOVE; + DHD_GENERAL_UNLOCK(dhdp, flags); + + timeleft = dhd_os_busbusy_wait_negation(dhdp, &dhdp->dhd_bus_busy_state); + if ((timeleft == 0) || (timeleft == 1)) { + DHD_ERROR(("%s : Timeout due to dhd_bus_busy_state=0x%x\n", + __FUNCTION__, dhdp->dhd_bus_busy_state)); + ASSERT(0); + } + + return; +} + + static void dhdpcie_bus_remove_prep(dhd_bus_t *bus) { @@ -1169,7 +1190,7 @@ dhdpcie_bus_release(dhd_bus_t *bus) ASSERT(osh); if (bus->dhd) { - dhdpcie_advertise_bus_cleanup(bus->dhd); + dhdpcie_advertise_bus_remove(bus->dhd); dongle_isolation = bus->dhd->dongle_isolation; bus->dhd->is_pcie_watchdog_reset = FALSE; dhdpcie_bus_remove_prep(bus); @@ -1763,9 +1784,10 @@ dhdpcie_download_code_file(struct dhd_bus *bus, char *pfw_path) err: if (memblock) { MFREE(bus->dhd->osh, memblock, MEMBLOCK + DHD_SDALIGN); - if (dhd_msg_level & DHD_TRACE_VAL) { - if (memptr_tmp) - MFREE(bus->dhd->osh, memptr_tmp, MEMBLOCK + DHD_SDALIGN); + if (dhd_msg_level & DHD_TRACE_VAL) { + if (memptr_tmp) + MFREE(bus->dhd->osh, memptr_tmp, MEMBLOCK + DHD_SDALIGN); + } } if (imgbuf) { @@ -3937,6 +3959,7 @@ done: return bcmerror; } + static int dhdpcie_bus_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, uint32 actionid, const char *name, void *params, int plen, void *arg, int len, int val_size) diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_pcie.h b/bcmdhd.1.579.77.41.1.cn/dhd_pcie.h index 96f8462..eb8de62 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_pcie.h +++ b/bcmdhd.1.579.77.41.1.cn/dhd_pcie.h @@ -509,8 +509,6 @@ extern void dhd_os_ib_set_device_wake(struct dhd_bus *bus, bool val); #elif defined(CONFIG_ARCH_TEGRA) #define PCIE_RC_VENDOR_ID TEGRA_PCIE_VENDOR_ID #define PCIE_RC_DEVICE_ID TEGRA_PCIE_DEVICE_ID -#else -#error "Not supported platform" #endif /* CONFIG_ARCH_EXYNOS */ #ifdef USE_EXYNOS_PCIE_RC_PMPATCH diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_pcie_linux.c b/bcmdhd.1.579.77.41.1.cn/dhd_pcie_linux.c index 44b3fe9..51664a7 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_pcie_linux.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_pcie_linux.c @@ -678,6 +678,7 @@ static int dhdpcie_suspend_host_dev(dhd_bus_t *bus) return bcmerror; } +#if defined(PCIE_RC_VENDOR_ID) && defined(PCIE_RC_DEVICE_ID) uint32 dhdpcie_rc_config_read(dhd_bus_t *bus, uint offset) { @@ -784,6 +785,7 @@ uint32 dhd_debug_get_rc_linkcap(dhd_bus_t *bus) linkcap &= PCIE_CAP_LINKCAP_LNKSPEED_MASK; return linkcap; } +#endif int dhdpcie_pci_suspend_resume(dhd_bus_t *bus, bool state) { @@ -808,10 +810,11 @@ int dhdpcie_pci_suspend_resume(dhd_bus_t *bus, bool state) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) #if defined(DHD_HANG_SEND_UP_TEST) if (bus->is_linkdown || - bus->dhd->req_hang_type == HANG_REASON_PCIE_RC_LINK_UP_FAIL) { + bus->dhd->req_hang_type == HANG_REASON_PCIE_RC_LINK_UP_FAIL) #else /* DHD_HANG_SEND_UP_TEST */ - if (bus->is_linkdown) { + if (bus->is_linkdown) #endif /* DHD_HANG_SEND_UP_TEST */ + { bus->dhd->hang_reason = HANG_REASON_PCIE_RC_LINK_UP_FAIL; dhd_os_send_hang_message(bus->dhd); } @@ -1346,7 +1349,11 @@ int dhdpcie_init(struct pci_dev *pdev) bus->is_linkdown = 0; /* Get RC Device Handle */ +#if defined(PCIE_RC_VENDOR_ID) && defined(PCIE_RC_DEVICE_ID) bus->rc_dev = pci_get_device(PCIE_RC_VENDOR_ID, PCIE_RC_DEVICE_ID, NULL); +#else + bus->rc_dev = NULL; +#endif #if defined(BCMPCIE_OOB_HOST_WAKE) && defined(CUSTOMER_HW2) && \ defined(CONFIG_ARCH_APQ8084) diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_rtt.c b/bcmdhd.1.579.77.41.1.cn/dhd_rtt.c index 95cd751..c58ca93 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_rtt.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_rtt.c @@ -75,13 +75,6 @@ static DEFINE_SPINLOCK(noti_list_lock); #define FTM_DEFAULT_CNT_40M 10 #define FTM_DEFAULT_CNT_80M 5 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) -#define ieee80211_band nl80211_band -#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ -#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ -#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS -#endif - /* convenience macros */ #define FTM_TU2MICRO(_tu) ((uint64)(_tu) << 10) #define FTM_MICRO2TU(_tu) ((uint64)(_tu) >> 10) diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_sdio.c b/bcmdhd.1.579.77.41.1.cn/dhd_sdio.c index c20bac9..1dcdd28 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_sdio.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_sdio.c @@ -720,6 +720,7 @@ static int dhd_bcmsdh_send_buffer(void *bus, uint8 *frame, uint16 len); static int dhdsdio_set_sdmode(dhd_bus_t *bus, int32 sd_mode); static int dhdsdio_sdclk(dhd_bus_t *bus, bool on); static void dhdsdio_advertise_bus_cleanup(dhd_pub_t *dhdp); +static void dhdsdio_advertise_bus_remove(dhd_pub_t *dhdp); #ifdef SUPPORT_MULTIPLE_BOARD_REV_FROM_DT int dhd_get_system_rev(void); #endif /* SUPPORT_MULTIPLE_BOARD_REV_FROM_DT */ @@ -2713,6 +2714,7 @@ dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen) uint8 doff = 0; int ret = -1; uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; + int cnt = 0; DHD_TRACE(("%s: Enter\n", __FUNCTION__)); @@ -2752,7 +2754,17 @@ dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen) /* Need to lock here to protect txseq and SDIO tx calls */ +retry: dhd_os_sdlock(bus->dhd); + if (cnt < bus->dhd->conf->txctl_tmo_fix && !TXCTLOK(bus)) { + cnt++; + dhd_os_sdunlock(bus->dhd); + OSL_SLEEP(1); + if (cnt >= (bus->dhd->conf->txctl_tmo_fix)) + DHD_ERROR(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d, last retry cnt %d\n", + __FUNCTION__, bus->tx_max, bus->tx_seq, cnt)); + goto retry; + } BUS_WAKE(bus); @@ -6736,7 +6748,7 @@ clkwait: } /* Resched the DPC if ctrl cmd is pending on bus credit */ if (bus->ctrl_frame_stat) { - if (bus->dhd->conf->txctl_tmo_fix) { + if (bus->dhd->conf->txctl_tmo_fix > 0) { set_current_state(TASK_INTERRUPTIBLE); if (!kthread_should_stop()) schedule_timeout(1); @@ -8448,8 +8460,8 @@ dhdsdio_disconnect(void *ptr) if (bus) { ASSERT(bus->dhd); - /* Advertise bus cleanup during rmmod */ - dhdsdio_advertise_bus_cleanup(bus->dhd); + /* Advertise bus remove during rmmod */ + dhdsdio_advertise_bus_remove(bus->dhd); dhdsdio_release(bus, bus->dhd->osh); } @@ -9233,6 +9245,27 @@ dhdsdio_advertise_bus_cleanup(dhd_pub_t *dhdp) return; } +static void +dhdsdio_advertise_bus_remove(dhd_pub_t *dhdp) +{ + unsigned long flags; + int timeleft; + + DHD_LINUX_GENERAL_LOCK(dhdp, flags); + dhdp->busstate = DHD_BUS_REMOVE; + DHD_LINUX_GENERAL_UNLOCK(dhdp, flags); + + timeleft = dhd_os_busbusy_wait_negation(dhdp, &dhdp->dhd_bus_busy_state); + if ((timeleft == 0) || (timeleft == 1)) { + DHD_ERROR(("%s : Timeout due to dhd_bus_busy_state=0x%x\n", + __FUNCTION__, dhdp->dhd_bus_busy_state)); + ASSERT(0); + } + + return; +} + + int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag) { diff --git a/bcmdhd.1.579.77.41.1.cn/dhd_static_buf.c b/bcmdhd.1.579.77.41.1.cn/dhd_static_buf.c index 448c30c..50573e4 100644 --- a/bcmdhd.1.579.77.41.1.cn/dhd_static_buf.c +++ b/bcmdhd.1.579.77.41.1.cn/dhd_static_buf.c @@ -24,70 +24,90 @@ #include #include #include +#include #include +#define DHD_STATIC_VERSION_STR "1.579.77.41.1" + +#define BCMDHD_SDIO +#define BCMDHD_PCIE + enum dhd_prealloc_index { DHD_PREALLOC_PROT = 0, - DHD_PREALLOC_RXBUF, - DHD_PREALLOC_DATABUF, - DHD_PREALLOC_OSL_BUF, - DHD_PREALLOC_SKB_BUF, +#if defined(BCMDHD_SDIO) + DHD_PREALLOC_RXBUF = 1, + DHD_PREALLOC_DATABUF = 2, +#endif + DHD_PREALLOC_OSL_BUF = 3, + DHD_PREALLOC_SKB_BUF = 4, DHD_PREALLOC_WIPHY_ESCAN0 = 5, DHD_PREALLOC_WIPHY_ESCAN1 = 6, DHD_PREALLOC_DHD_INFO = 7, DHD_PREALLOC_DHD_WLFC_INFO = 8, +#ifdef BCMDHD_PCIE DHD_PREALLOC_IF_FLOW_LKUP = 9, +#endif DHD_PREALLOC_MEMDUMP_BUF = 10, DHD_PREALLOC_MEMDUMP_RAM = 11, DHD_PREALLOC_DHD_WLFC_HANGER = 12, + DHD_PREALLOC_PKTID_MAP = 13, + DHD_PREALLOC_PKTID_MAP_IOCTL = 14, + DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15, + DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16, + DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17, + DHD_PREALLOC_STAT_REPORT_BUF = 18, + DHD_PREALLOC_WL_ESCAN_INFO = 19, + DHD_PREALLOC_FW_VERBOSE_RING = 20, + DHD_PREALLOC_FW_EVENT_RING = 21, + DHD_PREALLOC_DHD_EVENT_RING = 22, + DHD_PREALLOC_NAN_EVENT_RING = 23, DHD_PREALLOC_MAX }; #define STATIC_BUF_MAX_NUM 20 #define STATIC_BUF_SIZE (PAGE_SIZE*2) -#define DHD_PREALLOC_PROT_SIZE (16 * 1024) -#define DHD_PREALLOC_RXBUF_SIZE (24 * 1024) -#define DHD_PREALLOC_DATABUF_SIZE (64 * 1024) -#define DHD_PREALLOC_OSL_BUF_SIZE (STATIC_BUF_MAX_NUM * STATIC_BUF_SIZE) +#define DHD_PREALLOC_PROT_SIZE (16 * 1024) +#define DHD_PREALLOC_RXBUF_SIZE (24 * 1024) +#define DHD_PREALLOC_DATABUF_SIZE (64 * 1024) +#define DHD_PREALLOC_OSL_BUF_SIZE (STATIC_BUF_MAX_NUM * STATIC_BUF_SIZE) #define DHD_PREALLOC_WIPHY_ESCAN0_SIZE (64 * 1024) -#define DHD_PREALLOC_DHD_INFO_SIZE (24 * 1024) -#define DHD_PREALLOC_DHD_WLFC_HANGER_SIZE (64 * 1024) +#define DHD_PREALLOC_DHD_INFO_SIZE (30 * 1024) +#define DHD_PREALLOC_MEMDUMP_RAM_SIZE (770 * 1024) +#define DHD_PREALLOC_DHD_WLFC_HANGER_SIZE (73 * 1024) +#define DHD_PREALLOC_WL_ESCAN_INFO_SIZE (66 * 1024) #ifdef CONFIG_64BIT #define DHD_PREALLOC_IF_FLOW_LKUP_SIZE (20 * 1024 * 2) #else #define DHD_PREALLOC_IF_FLOW_LKUP_SIZE (20 * 1024) #endif +#define FW_VERBOSE_RING_SIZE (64 * 1024) +#define FW_EVENT_RING_SIZE (64 * 1024) +#define DHD_EVENT_RING_SIZE (64 * 1024) +#define NAN_EVENT_RING_SIZE (64 * 1024) #if defined(CONFIG_64BIT) -#define WLAN_DHD_INFO_BUF_SIZE (24 * 1024) -#define WLAN_DHD_WLFC_BUF_SIZE (64 * 1024) +#define WLAN_DHD_INFO_BUF_SIZE (24 * 1024) +#define WLAN_DHD_WLFC_BUF_SIZE (64 * 1024) #define WLAN_DHD_IF_FLOW_LKUP_SIZE (64 * 1024) #else -#define WLAN_DHD_INFO_BUF_SIZE (16 * 1024) -#define WLAN_DHD_WLFC_BUF_SIZE (24 * 1024) +#define WLAN_DHD_INFO_BUF_SIZE (16 * 1024) +#define WLAN_DHD_WLFC_BUF_SIZE (24 * 1024) #define WLAN_DHD_IF_FLOW_LKUP_SIZE (20 * 1024) #endif /* CONFIG_64BIT */ -#define WLAN_DHD_MEMDUMP_SIZE (800 * 1024) +#define WLAN_DHD_MEMDUMP_SIZE (800 * 1024) -#ifdef CONFIG_BCMDHD_PCIE #define DHD_SKB_1PAGE_BUFSIZE (PAGE_SIZE*1) #define DHD_SKB_2PAGE_BUFSIZE (PAGE_SIZE*2) #define DHD_SKB_4PAGE_BUFSIZE (PAGE_SIZE*4) -#define DHD_SKB_1PAGE_BUF_NUM 0 -#define DHD_SKB_2PAGE_BUF_NUM 64 -#define DHD_SKB_4PAGE_BUF_NUM 0 -#else -#define DHD_SKB_HDRSIZE 336 -#define DHD_SKB_1PAGE_BUFSIZE ((PAGE_SIZE*1)-DHD_SKB_HDRSIZE) -#define DHD_SKB_2PAGE_BUFSIZE ((PAGE_SIZE*2)-DHD_SKB_HDRSIZE) -#define DHD_SKB_4PAGE_BUFSIZE ((PAGE_SIZE*4)-DHD_SKB_HDRSIZE) - #define DHD_SKB_1PAGE_BUF_NUM 8 +#ifdef BCMDHD_PCIE +#define DHD_SKB_2PAGE_BUF_NUM 64 +#elif defined(BCMDHD_SDIO) #define DHD_SKB_2PAGE_BUF_NUM 8 +#endif #define DHD_SKB_4PAGE_BUF_NUM 1 -#endif /* CONFIG_BCMDHD_PCIE */ /* The number is defined in linux_osl.c * WLAN_SKB_1_2PAGE_BUF_NUM => STATIC_PKT_1_2PAGE_NUM @@ -97,30 +117,38 @@ enum dhd_prealloc_index { (DHD_SKB_2PAGE_BUF_NUM)) #define WLAN_SKB_BUF_NUM ((WLAN_SKB_1_2PAGE_BUF_NUM) + (DHD_SKB_4PAGE_BUF_NUM)) -void *wlan_static_prot = NULL; -void *wlan_static_rxbuf = NULL; -void *wlan_static_databuf = NULL; -void *wlan_static_osl_buf = NULL; -void *wlan_static_scan_buf0 = NULL; -void *wlan_static_scan_buf1 = NULL; -void *wlan_static_dhd_info_buf = NULL; -void *wlan_static_dhd_wlfc_info_buf = NULL; -void *wlan_static_if_flow_lkup = NULL; -void *wlan_static_dhd_wlfc_hanger_buf = NULL; +void *wlan_static_prot; +void *wlan_static_rxbuf; +void *wlan_static_databuf; +void *wlan_static_osl_buf; +void *wlan_static_scan_buf0; +void *wlan_static_scan_buf1; +void *wlan_static_dhd_info_buf; +void *wlan_static_dhd_wlfc_info_buf; +void *wlan_static_if_flow_lkup; +void *wlan_static_dhd_memdump_ram_buf; +void *wlan_static_dhd_wlfc_hanger_buf; +void *wlan_static_wl_escan_info_buf; +void *wlan_static_fw_verbose_ring_buf; +void *wlan_static_fw_event_ring_buf; +void *wlan_static_dhd_event_ring_buf; +void *wlan_static_nan_event_ring_buf; static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM]; -void *dhd_wlan_mem_prealloc(int section, unsigned long size) +void *bcmdhd_mem_prealloc(int section, unsigned long size) { - printk("%s: sectoin %d, %ld\n", __FUNCTION__, section, size); + pr_err("%s: sectoin %d, %ld\n", __func__, section, size); if (section == DHD_PREALLOC_PROT) return wlan_static_prot; +#if defined(BCMDHD_SDIO) if (section == DHD_PREALLOC_RXBUF) return wlan_static_rxbuf; if (section == DHD_PREALLOC_DATABUF) return wlan_static_databuf; +#endif /* BCMDHD_SDIO */ if (section == DHD_PREALLOC_SKB_BUF) return wlan_static_skb; @@ -133,7 +161,7 @@ void *dhd_wlan_mem_prealloc(int section, unsigned long size) if (section == DHD_PREALLOC_OSL_BUF) { if (size > DHD_PREALLOC_OSL_BUF_SIZE) { - pr_err("request OSL_BUF(%lu) is bigger than static size(%ld).\n", + pr_err("request OSL_BUF(%lu) > %ld\n", size, DHD_PREALLOC_OSL_BUF_SIZE); return NULL; } @@ -142,7 +170,7 @@ void *dhd_wlan_mem_prealloc(int section, unsigned long size) if (section == DHD_PREALLOC_DHD_INFO) { if (size > DHD_PREALLOC_DHD_INFO_SIZE) { - pr_err("request DHD_INFO size(%lu) is bigger than static size(%d).\n", + pr_err("request DHD_INFO size(%lu) > %d\n", size, DHD_PREALLOC_DHD_INFO_SIZE); return NULL; } @@ -150,40 +178,97 @@ void *dhd_wlan_mem_prealloc(int section, unsigned long size) } if (section == DHD_PREALLOC_DHD_WLFC_INFO) { if (size > WLAN_DHD_WLFC_BUF_SIZE) { - pr_err("request DHD_WLFC_INFO size(%lu) is bigger than static size(%d).\n", + pr_err("request DHD_WLFC_INFO size(%lu) > %d\n", size, WLAN_DHD_WLFC_BUF_SIZE); return NULL; } return wlan_static_dhd_wlfc_info_buf; } +#ifdef BCMDHD_PCIE if (section == DHD_PREALLOC_IF_FLOW_LKUP) { if (size > DHD_PREALLOC_IF_FLOW_LKUP_SIZE) { - pr_err("request DHD_IF_FLOW_LKUP size(%lu) is bigger than static size(%d).\n", + pr_err("request DHD_IF_FLOW_LKUP size(%lu) > %d\n", size, DHD_PREALLOC_IF_FLOW_LKUP_SIZE); return NULL; } return wlan_static_if_flow_lkup; } +#endif /* BCMDHD_PCIE */ + if (section == DHD_PREALLOC_MEMDUMP_RAM) { + if (size > DHD_PREALLOC_MEMDUMP_RAM_SIZE) { + pr_err("request DHD_PREALLOC_MEMDUMP_RAM_SIZE(%lu) > %d\n", + size, DHD_PREALLOC_MEMDUMP_RAM_SIZE); + return NULL; + } + + return wlan_static_dhd_memdump_ram_buf; + } if (section == DHD_PREALLOC_DHD_WLFC_HANGER) { if (size > DHD_PREALLOC_DHD_WLFC_HANGER_SIZE) { - pr_err("request DHD_WLFC_HANGER size(%lu) is bigger than static size(%d).\n", + pr_err("request DHD_WLFC_HANGER size(%lu) > %d\n", size, DHD_PREALLOC_DHD_WLFC_HANGER_SIZE); return NULL; } return wlan_static_dhd_wlfc_hanger_buf; } + if (section == DHD_PREALLOC_WL_ESCAN_INFO) { + if (size > DHD_PREALLOC_WL_ESCAN_INFO_SIZE) { + pr_err("request DHD_PREALLOC_WL_ESCAN_INFO_SIZE(%lu) > %d\n", + size, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); + return NULL; + } + + return wlan_static_wl_escan_info_buf; + } + if (section == DHD_PREALLOC_FW_VERBOSE_RING) { + if (size > FW_VERBOSE_RING_SIZE) { + pr_err("request DHD_PREALLOC_FW_VERBOSE_RING(%lu) > %d\n", + size, FW_VERBOSE_RING_SIZE); + return NULL; + } + + return wlan_static_fw_verbose_ring_buf; + } + if (section == DHD_PREALLOC_FW_EVENT_RING) { + if (size > FW_EVENT_RING_SIZE) { + pr_err("request DHD_PREALLOC_FW_EVENT_RING(%lu) > %d\n", + size, FW_EVENT_RING_SIZE); + return NULL; + } + + return wlan_static_fw_event_ring_buf; + } + if (section == DHD_PREALLOC_DHD_EVENT_RING) { + if (size > DHD_EVENT_RING_SIZE) { + pr_err("request DHD_PREALLOC_DHD_EVENT_RING(%lu) > %d\n", + size, DHD_EVENT_RING_SIZE); + return NULL; + } + + return wlan_static_dhd_event_ring_buf; + } + if (section == DHD_PREALLOC_NAN_EVENT_RING) { + if (size > NAN_EVENT_RING_SIZE) { + pr_err("request DHD_PREALLOC_NAN_EVENT_RING(%lu) > %d\n", + size, NAN_EVENT_RING_SIZE); + return NULL; + } + + return wlan_static_nan_event_ring_buf; + } if ((section < 0) || (section > DHD_PREALLOC_MAX)) pr_err("request section id(%d) is out of max index %d\n", section, DHD_PREALLOC_MAX); - pr_err("%s: failed to alloc section %d, size=%ld\n", __FUNCTION__, section, size); + pr_err("%s: failed to alloc section %d, size=%ld\n", + __func__, section, size); return NULL; } -EXPORT_SYMBOL(dhd_wlan_mem_prealloc); +EXPORT_SYMBOL(bcmdhd_mem_prealloc); -static int dhd_init_wlan_mem(void) +int bcmdhd_init_wlan_mem(void) { int i; int j; @@ -193,7 +278,8 @@ static int dhd_init_wlan_mem(void) if (!wlan_static_skb[i]) { goto err_skb_alloc; } - printk("%s: sectoin %d skb[%d], size=%ld\n", __FUNCTION__, DHD_PREALLOC_SKB_BUF, i, DHD_SKB_1PAGE_BUFSIZE); + pr_err("%s: sectoin %d skb[%d], size=%ld\n", __func__, + DHD_PREALLOC_SKB_BUF, i, DHD_SKB_1PAGE_BUFSIZE); } for (i = DHD_SKB_1PAGE_BUF_NUM; i < WLAN_SKB_1_2PAGE_BUF_NUM; i++) { @@ -201,203 +287,144 @@ static int dhd_init_wlan_mem(void) if (!wlan_static_skb[i]) { goto err_skb_alloc; } - printk("%s: sectoin %d skb[%d], size=%ld\n", __FUNCTION__, DHD_PREALLOC_SKB_BUF, i, DHD_SKB_2PAGE_BUFSIZE); + pr_err("%s: sectoin %d skb[%d], size=%ld\n", __func__, + DHD_PREALLOC_SKB_BUF, i, DHD_SKB_2PAGE_BUFSIZE); } -#if !defined(CONFIG_BCMDHD_PCIE) +#if defined(BCMDHD_SDIO) wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_4PAGE_BUFSIZE); - if (!wlan_static_skb[i]) { + if (!wlan_static_skb[i]) goto err_skb_alloc; - } -#endif /* !CONFIG_BCMDHD_PCIE */ + pr_err("%s: sectoin %d skb[%d], size=%ld\n", __func__, + DHD_PREALLOC_SKB_BUF, i, DHD_SKB_4PAGE_BUFSIZE); +#endif /* BCMDHD_SDIO */ wlan_static_prot = kmalloc(DHD_PREALLOC_PROT_SIZE, GFP_KERNEL); - if (!wlan_static_prot) { - pr_err("Failed to alloc wlan_static_prot\n"); + if (!wlan_static_prot) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_PROT, DHD_PREALLOC_PROT_SIZE); + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_PROT, DHD_PREALLOC_PROT_SIZE); -#if defined(CONFIG_BCMDHD_SDIO) +#if defined(BCMDHD_SDIO) wlan_static_rxbuf = kmalloc(DHD_PREALLOC_RXBUF_SIZE, GFP_KERNEL); - if (!wlan_static_rxbuf) { - pr_err("Failed to alloc wlan_static_rxbuf\n"); + if (!wlan_static_rxbuf) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_RXBUF, DHD_PREALLOC_RXBUF_SIZE); + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_RXBUF, DHD_PREALLOC_RXBUF_SIZE); wlan_static_databuf = kmalloc(DHD_PREALLOC_DATABUF_SIZE, GFP_KERNEL); - if (!wlan_static_databuf) { - pr_err("Failed to alloc wlan_static_databuf\n"); + if (!wlan_static_databuf) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_DATABUF, DHD_PREALLOC_DATABUF_SIZE); -#endif + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_DATABUF, DHD_PREALLOC_DATABUF_SIZE); +#endif /* BCMDHD_SDIO */ wlan_static_osl_buf = kmalloc(DHD_PREALLOC_OSL_BUF_SIZE, GFP_KERNEL); - if (!wlan_static_osl_buf) { - pr_err("Failed to alloc wlan_static_osl_buf\n"); + if (!wlan_static_osl_buf) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%ld\n", __FUNCTION__, DHD_PREALLOC_OSL_BUF, DHD_PREALLOC_OSL_BUF_SIZE); + pr_err("%s: sectoin %d, size=%ld\n", __func__, + DHD_PREALLOC_OSL_BUF, DHD_PREALLOC_OSL_BUF_SIZE); wlan_static_scan_buf0 = kmalloc(DHD_PREALLOC_WIPHY_ESCAN0_SIZE, GFP_KERNEL); - if (!wlan_static_scan_buf0) { - pr_err("Failed to alloc wlan_static_scan_buf0\n"); + if (!wlan_static_scan_buf0) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_WIPHY_ESCAN0, DHD_PREALLOC_WIPHY_ESCAN0_SIZE); + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_WIPHY_ESCAN0, DHD_PREALLOC_WIPHY_ESCAN0_SIZE); wlan_static_dhd_info_buf = kmalloc(DHD_PREALLOC_DHD_INFO_SIZE, GFP_KERNEL); - if (!wlan_static_dhd_info_buf) { - pr_err("Failed to alloc wlan_static_dhd_info_buf\n"); + if (!wlan_static_dhd_info_buf) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_DHD_INFO, DHD_PREALLOC_DHD_INFO_SIZE); + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_DHD_INFO, DHD_PREALLOC_DHD_INFO_SIZE); wlan_static_dhd_wlfc_info_buf = kmalloc(WLAN_DHD_WLFC_BUF_SIZE, GFP_KERNEL); - if (!wlan_static_dhd_wlfc_info_buf) { - pr_err("Failed to alloc wlan_static_dhd_wlfc_info_buf\n"); - goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_DHD_WLFC_INFO, WLAN_DHD_WLFC_BUF_SIZE); - - wlan_static_dhd_wlfc_hanger_buf = kmalloc(DHD_PREALLOC_DHD_WLFC_HANGER_SIZE, GFP_KERNEL); - if (!wlan_static_dhd_wlfc_hanger_buf) { - pr_err("Failed to alloc wlan_static_dhd_wlfc_hanger_buf\n"); + if (!wlan_static_dhd_wlfc_info_buf) goto err_mem_alloc; - } - printk("%s: sectoin %d, size=%d\n", __FUNCTION__, DHD_PREALLOC_DHD_WLFC_HANGER, DHD_PREALLOC_DHD_WLFC_HANGER_SIZE); + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_DHD_WLFC_INFO, WLAN_DHD_WLFC_BUF_SIZE); -#ifdef CONFIG_BCMDHD_PCIE +#ifdef BCMDHD_PCIE wlan_static_if_flow_lkup = kmalloc(DHD_PREALLOC_IF_FLOW_LKUP_SIZE, GFP_KERNEL); - if (!wlan_static_if_flow_lkup) { - pr_err("Failed to alloc wlan_static_if_flow_lkup\n"); + if (!wlan_static_if_flow_lkup) goto err_mem_alloc; - } -#endif /* CONFIG_BCMDHD_PCIE */ - - return 0; - -err_mem_alloc: +#endif /* BCMDHD_PCIE */ - if (wlan_static_prot) - kfree(wlan_static_prot); + wlan_static_dhd_memdump_ram_buf = kmalloc(DHD_PREALLOC_MEMDUMP_RAM_SIZE, GFP_KERNEL); + if (!wlan_static_dhd_memdump_ram_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_MEMDUMP_RAM, DHD_PREALLOC_MEMDUMP_RAM_SIZE); -#if defined(CONFIG_BCMDHD_SDIO) - if (wlan_static_rxbuf) - kfree(wlan_static_rxbuf); + wlan_static_dhd_wlfc_hanger_buf = kmalloc(DHD_PREALLOC_DHD_WLFC_HANGER_SIZE, GFP_KERNEL); + if (!wlan_static_dhd_wlfc_hanger_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_DHD_WLFC_HANGER, DHD_PREALLOC_DHD_WLFC_HANGER_SIZE); - if (wlan_static_databuf) - kfree(wlan_static_databuf); -#endif + wlan_static_wl_escan_info_buf = kmalloc(DHD_PREALLOC_WL_ESCAN_INFO_SIZE, GFP_KERNEL); + if (!wlan_static_wl_escan_info_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_WL_ESCAN_INFO, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); - if (wlan_static_dhd_info_buf) - kfree(wlan_static_dhd_info_buf); + wlan_static_fw_verbose_ring_buf = kmalloc( + DHD_PREALLOC_WIPHY_ESCAN0_SIZE, + GFP_KERNEL); + if (!wlan_static_fw_verbose_ring_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_FW_VERBOSE_RING, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); - if (wlan_static_dhd_wlfc_info_buf) - kfree(wlan_static_dhd_wlfc_info_buf); + wlan_static_fw_event_ring_buf = kmalloc(DHD_PREALLOC_WIPHY_ESCAN0_SIZE, GFP_KERNEL); + if (!wlan_static_fw_event_ring_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_FW_EVENT_RING, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); - if (wlan_static_dhd_wlfc_hanger_buf) - kfree(wlan_static_dhd_wlfc_hanger_buf); + wlan_static_dhd_event_ring_buf = kmalloc(DHD_PREALLOC_WIPHY_ESCAN0_SIZE, GFP_KERNEL); + if (!wlan_static_dhd_event_ring_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_DHD_EVENT_RING, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); - if (wlan_static_scan_buf1) - kfree(wlan_static_scan_buf1); + wlan_static_nan_event_ring_buf = kmalloc(DHD_PREALLOC_WIPHY_ESCAN0_SIZE, GFP_KERNEL); + if (!wlan_static_nan_event_ring_buf) + goto err_mem_alloc; + pr_err("%s: sectoin %d, size=%d\n", __func__, + DHD_PREALLOC_NAN_EVENT_RING, DHD_PREALLOC_WL_ESCAN_INFO_SIZE); - if (wlan_static_scan_buf0) - kfree(wlan_static_scan_buf0); + return 0; - if (wlan_static_osl_buf) - kfree(wlan_static_osl_buf); +err_mem_alloc: -#ifdef CONFIG_BCMDHD_PCIE - if (wlan_static_if_flow_lkup) - kfree(wlan_static_if_flow_lkup); -#endif - pr_err("Failed to mem_alloc for WLAN\n"); + kfree(wlan_static_prot); + kfree(wlan_static_rxbuf); + kfree(wlan_static_databuf); + kfree(wlan_static_osl_buf); + kfree(wlan_static_scan_buf0); + kfree(wlan_static_scan_buf1); + kfree(wlan_static_dhd_info_buf); + kfree(wlan_static_dhd_wlfc_info_buf); + kfree(wlan_static_if_flow_lkup); + kfree(wlan_static_dhd_memdump_ram_buf); + kfree(wlan_static_dhd_wlfc_hanger_buf); + kfree(wlan_static_wl_escan_info_buf); + kfree(wlan_static_fw_verbose_ring_buf); + kfree(wlan_static_fw_event_ring_buf); + kfree(wlan_static_dhd_event_ring_buf); + kfree(wlan_static_nan_event_ring_buf); + pr_err("%s: Failed to mem_alloc for WLAN\n", __func__); i = WLAN_SKB_BUF_NUM; err_skb_alloc: - pr_err("Failed to skb_alloc for WLAN\n"); - for (j = 0; j < i; j++) { + pr_err("%s: Failed to skb_alloc for WLAN\n", __func__); + for (j = 0; j < i; j++) dev_kfree_skb(wlan_static_skb[j]); - } return -ENOMEM; } - -int -bcmdhd_init_wlan_mem(void) -{ - printk(KERN_ERR "%s()\n", __FUNCTION__); - - dhd_init_wlan_mem(); - - return 0; -} - -static void -dhd_static_buf_exit(void) -{ - int i; - - printk(KERN_ERR "%s()\n", __FUNCTION__); - - for (i = 0; i < DHD_SKB_1PAGE_BUF_NUM; i++) { - if (wlan_static_skb[i]) - dev_kfree_skb(wlan_static_skb[i]); - } - - for (i = DHD_SKB_1PAGE_BUF_NUM; i < WLAN_SKB_1_2PAGE_BUF_NUM; i++) { - if (wlan_static_skb[i]) - dev_kfree_skb(wlan_static_skb[i]); - } - -#if !defined(CONFIG_BCMDHD_PCIE) - if (wlan_static_skb[i]) - dev_kfree_skb(wlan_static_skb[i]); -#endif /* !CONFIG_BCMDHD_PCIE */ - - if (wlan_static_prot) - kfree(wlan_static_prot); - -#if defined(CONFIG_BCMDHD_SDIO) - if (wlan_static_rxbuf) - kfree(wlan_static_rxbuf); - - if (wlan_static_databuf) - kfree(wlan_static_databuf); -#endif - - if (wlan_static_osl_buf) - kfree(wlan_static_osl_buf); - - if (wlan_static_scan_buf0) - kfree(wlan_static_scan_buf0); - - if (wlan_static_dhd_info_buf) - kfree(wlan_static_dhd_info_buf); - - if (wlan_static_dhd_wlfc_info_buf) - kfree(wlan_static_dhd_wlfc_info_buf); - - if (wlan_static_dhd_wlfc_hanger_buf) - kfree(wlan_static_dhd_wlfc_hanger_buf); - - if (wlan_static_scan_buf1) - kfree(wlan_static_scan_buf1); - -#ifdef CONFIG_BCMDHD_PCIE - if (wlan_static_if_flow_lkup) - kfree(wlan_static_if_flow_lkup); -#endif - return; -} - - EXPORT_SYMBOL(bcmdhd_init_wlan_mem); -#endif /* CONFIG_BROADCOM_WIFI_RESERVED_MEM */ MODULE_LICENSE("GPL"); MODULE_AUTHOR("AMLOGIC"); MODULE_DESCRIPTION("wifi device tree driver"); diff --git a/bcmdhd.1.579.77.41.1.cn/include/epivers.h b/bcmdhd.1.579.77.41.1.cn/include/epivers.h index 56a398d..4cf4c70 100644 --- a/bcmdhd.1.579.77.41.1.cn/include/epivers.h +++ b/bcmdhd.1.579.77.41.1.cn/include/epivers.h @@ -46,6 +46,6 @@ #define EPI_VERSION_DEV 1.579.77.41 /* Driver Version String, ASCII, 32 chars max */ -#define EPI_VERSION_STR "1.579.77.41.1 (r)" +#define EPI_VERSION_STR "1.579.77.41.2 (r)" #endif /* _epivers_h_ */ diff --git a/bcmdhd.1.579.77.41.1.cn/include/osl.h b/bcmdhd.1.579.77.41.1.cn/include/osl.h index d3b1161..082b301 100644 --- a/bcmdhd.1.579.77.41.1.cn/include/osl.h +++ b/bcmdhd.1.579.77.41.1.cn/include/osl.h @@ -67,9 +67,7 @@ typedef void (*osl_wreg_fn_t)(void *ctx, volatile void *reg, unsigned int val, #ifndef OR_REG #define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v)) #endif /* !OR_REG */ -#ifdef CONFIG_DHD_USE_STATIC_BUF -void* bcm_wlan_prealloc(int section, unsigned long size); -#endif + #if !defined(OSL_SYSUPTIME) #define OSL_SYSUPTIME() (0) #define OSL_SYSUPTIME_SUPPORT FALSE diff --git a/bcmdhd.1.579.77.41.1.cn/include/wlioctl.h b/bcmdhd.1.579.77.41.1.cn/include/wlioctl.h index 1e6a3a2..82c4b4f 100644 --- a/bcmdhd.1.579.77.41.1.cn/include/wlioctl.h +++ b/bcmdhd.1.579.77.41.1.cn/include/wlioctl.h @@ -11554,6 +11554,13 @@ typedef struct wl_interface_create { struct ether_addr mac_addr; /* Optional Mac address */ } wl_interface_create_t; +typedef struct wl_interface_create_v0 { + uint16 ver; /* version of this struct */ + struct ether_addr mac_addr; /* MAC address of the interface */ + char ifname[BCM_MSG_IFNAME_MAX]; /* name of interface */ + uint8 bsscfgidx; /* source bsscfg index */ +} wl_interface_info_t; + typedef struct wl_interface_create_v1 { uint16 ver; /**< version of this struct */ uint8 pad1[2]; /**< Padding bytes */ diff --git a/bcmdhd.1.579.77.41.1.cn/wl_android.c b/bcmdhd.1.579.77.41.1.cn/wl_android.c index 25b7563..42afe36 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_android.c +++ b/bcmdhd.1.579.77.41.1.cn/wl_android.c @@ -1004,7 +1004,7 @@ wl_cfg80211_get_sta_info(struct net_device *dev, char* command, int total_len) uint32 rxrtry = 0; uint32 rxmulti = 0; - WL_DBG(("%s\n", command)); + ANDROID_TRACE(("%s\n", command)); str = bcmstrtok(&pcmd, " ", NULL); if (str) { str = bcmstrtok(&pcmd, " ", NULL); @@ -1063,7 +1063,7 @@ wl_cfg80211_get_sta_info(struct net_device *dev, char* command, int total_len) "%s %s Rx_Retry_Pkts=%d Rx_BcMc_Pkts=%d CAP=%04x\n", CMD_GET_STA_INFO, str, rxrtry, rxmulti, cap); - WL_DBG(("%s", command)); + ANDROID_TRACE(("%s", command)); error: return bytes_written; @@ -2496,6 +2496,7 @@ wl_android_set_auto_channel(struct net_device *dev, const char* cmd_str, u8 *reqbuf = NULL; uint32 band = WLC_BAND_2G; uint32 buf_size; + char *pos = command; if (cmd_str) { ANDROID_INFO(("Command: %s len:%d \n", cmd_str, (int)strlen(cmd_str))); @@ -2623,7 +2624,7 @@ wl_android_set_auto_channel(struct net_device *dev, const char* cmd_str, apcs_band = (band == WLC_BAND_AUTO) ? WLC_BAND_2G : band; chosen_band = (channel <= CH_MAX_2G_CHANNEL) ? WLC_BAND_2G : WLC_BAND_5G; if (apcs_band == chosen_band) { - ANDROID_ERROR(("selected channel = %d\n", channel)); + printf("%s: selected channel = %d\n", __FUNCTION__, channel); break; } } @@ -2654,7 +2655,11 @@ done2: } if (channel) { - snprintf(command, 4, "%d", channel); + if (channel < 15) + pos += snprintf(pos, total_len, "2g="); + else + pos += snprintf(pos, total_len, "5g="); + pos += snprintf(pos, total_len, "%d", channel); ANDROID_INFO(("command result is %s \n", command)); return strlen(command); } else { @@ -2767,7 +2772,7 @@ static int wl_android_set_rmc_event(struct net_device *dev, char *command, int t /* set pid, and if the event was happened, let's send a notification through netlink */ wl_cfg80211_set_rmc_pid(dev, pid); - WL_DBG(("RMC pid=%d\n", pid)); + ANDROID_TRACE(("RMC pid=%d\n", pid)); return err; } @@ -3474,7 +3479,7 @@ wl_netlink_send_msg(int pid, int type, int seq, const void *data, size_t size) /* netlink_unicast() takes ownership of the skb and frees it itself. */ ret = netlink_unicast(nl_sk, skb, pid, 0); - WL_DBG(("netlink_unicast() pid=%d, ret=%d\n", pid, ret)); + ANDROID_TRACE(("netlink_unicast() pid=%d, ret=%d\n", pid, ret)); nlmsg_failure: return ret; @@ -3631,7 +3636,7 @@ static int wl_android_get_link_status(struct net_device *dev, char *command, } if (i == ETHER_ADDR_LEN) { - WL_DBG(("No BSSID\n")); + ANDROID_TRACE(("No BSSID\n")); return -1; } @@ -3721,7 +3726,7 @@ static int wl_android_get_link_status(struct net_device *dev, char *command, } } - WL_DBG(("%s:result=%d, stf=%d, single_stream=%d, mcs map=%d\n", + ANDROID_TRACE(("%s:result=%d, stf=%d, single_stream=%d, mcs map=%d\n", __FUNCTION__, result, stf, single_stream, nss)); bytes_written = sprintf(command, "%s %d", CMD_GET_LINK_STATUS, result); @@ -3786,7 +3791,7 @@ wl_android_murx_bfe_cap(struct net_device *dev, int val) sizeof(wl_reassoc_params_t))) < 0) { ANDROID_ERROR(("reassoc failed err:%d \n", err)); } else { - WL_DBG(("reassoc issued successfully\n")); + ANDROID_TRACE(("reassoc issued successfully\n")); } return err; @@ -3823,7 +3828,7 @@ wl_android_set_ap_beaconrate(struct net_device *dev, char *command) return -EINVAL; ifname = token; - WL_DBG(("rate %d, ifacename %s\n", rate, ifname)); + ANDROID_TRACE(("rate %d, ifacename %s\n", rate, ifname)); err = wl_set_ap_beacon_rate(dev, rate, ifname); if (unlikely(err)) { @@ -3852,7 +3857,7 @@ int wl_android_get_ap_basicrate(struct net_device *dev, char *command, int total return -EINVAL; ifname = token; - WL_DBG(("ifacename %s\n", ifname)); + ANDROID_TRACE(("ifacename %s\n", ifname)); bytes_written = wl_get_ap_basic_rate(dev, command, ifname, total_len); if (bytes_written < 1) { @@ -3886,7 +3891,7 @@ wl_android_get_ap_rps(struct net_device *dev, char *command, int total_len) return -EINVAL; ifname = token; - WL_DBG(("ifacename %s\n", ifname)); + ANDROID_TRACE(("ifacename %s\n", ifname)); bytes_written = wl_get_ap_rps(dev, command, ifname, total_len); if (bytes_written < 1) { @@ -3926,7 +3931,7 @@ wl_android_set_ap_rps(struct net_device *dev, char *command, int total_len) return -EINVAL; ifname = token; - WL_DBG(("enable %d, ifacename %s\n", enable, ifname)); + ANDROID_TRACE(("enable %d, ifacename %s\n", enable, ifname)); err = wl_set_ap_rps(dev, enable? TRUE: FALSE, ifname); if (unlikely(err)) { @@ -3983,7 +3988,7 @@ wl_android_set_ap_rps_params(struct net_device *dev, char *command, int total_le return -EINVAL; ifname = token; - WL_DBG(("pps %d, level %d, quiettime %d, sta_assoc_check %d, " + ANDROID_TRACE(("pps %d, level %d, quiettime %d, sta_assoc_check %d, " "ifacename %s\n", rps.pps, rps.level, rps.quiet_time, rps.sta_assoc_check, ifname)); @@ -4053,17 +4058,17 @@ wl_android_get_rssi_per_ant(struct net_device *dev, char *command, int total_len } /* Parse the results */ - WL_DBG(("ifname %s, version %d, count %d, mimo rssi %d\n", + ANDROID_TRACE(("ifname %s, version %d, count %d, mimo rssi %d\n", ifname, rssi_ant_mimo.version, rssi_ant_mimo.count, mimo_rssi)); if (mimo_rssi) { - WL_DBG(("MIMO RSSI: %d\n", rssi_ant_mimo.rssi_sum)); + ANDROID_TRACE(("MIMO RSSI: %d\n", rssi_ant_mimo.rssi_sum)); bytes_written = snprintf(command, total_len, "%s MIMO %d", CMD_GET_RSSI_PER_ANT, rssi_ant_mimo.rssi_sum); } else { int cnt; bytes_written = snprintf(command, total_len, "%s PER_ANT ", CMD_GET_RSSI_PER_ANT); for (cnt = 0; cnt < rssi_ant_mimo.count; cnt++) { - WL_DBG(("RSSI[%d]: %d\n", cnt, rssi_ant_mimo.rssi_ant[cnt])); + ANDROID_TRACE(("RSSI[%d]: %d\n", cnt, rssi_ant_mimo.rssi_ant[cnt])); bytes_written = snprintf(command, total_len, "%d ", rssi_ant_mimo.rssi_ant[cnt]); } @@ -4112,7 +4117,7 @@ wl_android_set_rssi_logging(struct net_device *dev, char *command, int total_len } set_param.time_threshold = bcm_atoi(token); - WL_DBG(("enable %d, RSSI threshold %d, Time threshold %d\n", set_param.enable, + ANDROID_TRACE(("enable %d, RSSI threshold %d, Time threshold %d\n", set_param.enable, set_param.rssi_threshold, set_param.time_threshold)); err = wl_set_rssi_logging(dev, (void *)&set_param); @@ -4138,29 +4143,29 @@ wl_android_get_rssi_logging(struct net_device *dev, char *command, int total_len return BCME_ERROR; } - WL_DBG(("report_count %d, enable %d, rssi_threshold %d, time_threshold %d\n", + ANDROID_TRACE(("report_count %d, enable %d, rssi_threshold %d, time_threshold %d\n", get_param.report_count, get_param.enable, get_param.rssi_threshold, get_param.time_threshold)); /* Parse the parameter */ if (!get_param.enable) { - WL_DBG(("RSSI LOGGING: Feature is disables\n")); + ANDROID_TRACE(("RSSI LOGGING: Feature is disables\n")); bytes_written = snprintf(command, total_len, "%s FEATURE DISABLED\n", CMD_GET_RSSI_LOGGING); } else if (get_param.enable & (RSSILOG_FLAG_FEATURE_SW | RSSILOG_FLAG_REPORT_READY)) { if (!get_param.report_count) { - WL_DBG(("[PASS] RSSI difference across antennas is within" + ANDROID_TRACE(("[PASS] RSSI difference across antennas is within" " threshold limits\n")); bytes_written = snprintf(command, total_len, "%s PASS\n", CMD_GET_RSSI_LOGGING); } else { - WL_DBG(("[FAIL] RSSI difference across antennas found " + ANDROID_TRACE(("[FAIL] RSSI difference across antennas found " "to be greater than %3d dB\n", get_param.rssi_threshold)); - WL_DBG(("[FAIL] RSSI difference check have failed for " + ANDROID_TRACE(("[FAIL] RSSI difference check have failed for " "%d out of %d times\n", get_param.report_count, get_param.time_threshold)); - WL_DBG(("[FAIL] RSSI difference is being monitored once " + ANDROID_TRACE(("[FAIL] RSSI difference is being monitored once " "per second, for a %d secs window\n", get_param.time_threshold)); bytes_written = snprintf(command, total_len, "%s FAIL - RSSI Threshold " "%d dBm for %d out of %d times\n", CMD_GET_RSSI_LOGGING, @@ -4168,7 +4173,7 @@ wl_android_get_rssi_logging(struct net_device *dev, char *command, int total_len get_param.time_threshold); } } else { - WL_DBG(("[BUSY] Reprot is not ready\n")); + ANDROID_TRACE(("[BUSY] Reprot is not ready\n")); bytes_written = snprintf(command, total_len, "%s BUSY - NOT READY\n", CMD_GET_RSSI_LOGGING); } @@ -4802,6 +4807,7 @@ wl_handle_private_cmd(struct net_device *net, char *command, u32 cmd_len) else if (strnicmp(command, CMD_MAXDTIM_IN_SUSPEND, strlen(CMD_MAXDTIM_IN_SUSPEND)) == 0) { bytes_written = wl_android_set_max_dtim(net, command, priv_cmd.total_len); } +#ifdef WL_CFG80211 else if (strnicmp(command, CMD_SETBAND, strlen(CMD_SETBAND)) == 0) { #ifdef DISABLE_SETBAND bytes_written = BCME_DISABLED; @@ -4813,6 +4819,7 @@ wl_handle_private_cmd(struct net_device *net, char *command, u32 cmd_len) bytes_written = wl_cfg80211_set_if_band(net, band); #endif /* DISABLE_SETBAND */ } +#endif else if (strnicmp(command, CMD_GETBAND, strlen(CMD_GETBAND)) == 0) { bytes_written = wl_android_get_band(net, command, priv_cmd.total_len); } diff --git a/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.c b/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.c index 9d64099..1a3bcb7 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.c +++ b/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.c @@ -920,13 +920,6 @@ struct chan_info { #define CFG80211_PUT_BSS(wiphy, bss) cfg80211_put_bss(bss); #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) -#define ieee80211_band nl80211_band -#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ -#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ -#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS -#endif - #define CHAN2G(_channel, _freq, _flags) { \ .band = IEEE80211_BAND_2GHZ, \ .center_freq = (_freq), \ @@ -1178,11 +1171,13 @@ wl_chspec_from_legacy(chanspec_t legacy_chspec) chspec |= WL_CHANSPEC_CTL_SB_U; } } + if (wf_chspec_malformed(chspec)) { WL_ERR(("wl_chspec_from_legacy: output chanspec (0x%04X) malformed\n", chspec)); return INVCHANSPEC; } + return chspec; } @@ -1286,6 +1281,7 @@ wl_chspec_driver_to_host(chanspec_t chanspec) if (ioctl_version == 1) { chanspec = wl_chspec_from_legacy(chanspec); } + return chanspec; } @@ -3723,6 +3719,7 @@ wl_cfg80211_interface_ops(struct bcm_cfg80211 *cfg, &iface_v3, sizeof(wl_interface_create_v3_t), ioctl_buf, sizeof(ioctl_buf), NULL); } else { +#if 0 /* On any other error, attempt with iovar version 2 */ WL_DBG(("interface_create version 2. get_ver:%d\n", ret)); iface.ver = WL_INTERFACE_CREATE_VER_2; @@ -3734,6 +3731,7 @@ wl_cfg80211_interface_ops(struct bcm_cfg80211 *cfg, ret = wldev_iovar_getbuf(ndev, "interface_create", &iface, sizeof(struct wl_interface_create_v2), ioctl_buf, sizeof(ioctl_buf), NULL); +#endif } if (unlikely(ret)) { @@ -14082,10 +14080,11 @@ static void wl_scan_timeout(unsigned long data) struct wl_bss_info *bi = NULL; s32 i; u32 channel; -/*#if defined(DHD_DEBUG) && defined(DHD_FW_COREDUMP) +#if 0 dhd_pub_t *dhdp = (dhd_pub_t *)(cfg->pub); uint32 prev_memdump_mode = dhdp->memdump_enabled; -#endif*/ /* DHD_DEBUG && DHD_FW_COREDUMP */ +#endif /* DHD_DEBUG && DHD_FW_COREDUMP */ + if (!(cfg->scan_request)) { WL_ERR(("timer expired but no scan request\n")); return; @@ -14096,6 +14095,7 @@ static void wl_scan_timeout(unsigned long data) WL_ERR(("bss_list is null. Didn't receive any partial scan results\n")); } else { WL_ERR(("scanned AP count (%d)\n", bss_list->count)); + bi = next_bss(bss_list, bi); for_each_bss(bss_list, bi, i) { if (bi != NULL && &(bi->chanspec) != NULL && (bi->SSID)) { @@ -14111,6 +14111,7 @@ static void wl_scan_timeout(unsigned long data) } } } + #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) if (cfg->scan_request->dev) wdev = cfg->scan_request->dev->ieee80211_ptr; @@ -14123,17 +14124,17 @@ static void wl_scan_timeout(unsigned long data) return; } ndev = wdev_to_wlc_ndev(wdev, cfg); + bzero(&msg, sizeof(wl_event_msg_t)); WL_ERR(("timer expired\n")); -/*#if defined(DHD_DEBUG) && defined(DHD_FW_COREDUMP) +#if 0 if (dhdp->memdump_enabled) { dhdp->memdump_enabled = DUMP_MEMFILE; dhdp->memdump_type = DUMP_TYPE_SCAN_TIMEOUT; dhd_bus_mem_dump(dhdp); dhdp->memdump_enabled = prev_memdump_mode; } -#endif*/ - /* DHD_DEBUG && DHD_FW_COREDUMP */ +#endif /* DHD_DEBUG && DHD_FW_COREDUMP */ msg.event_type = hton32(WLC_E_ESCAN_RESULT); msg.status = hton32(WLC_E_STATUS_TIMEOUT); msg.reason = 0xFFFFFFFF; @@ -14142,6 +14143,7 @@ static void wl_scan_timeout(unsigned long data) if (!wl_scan_timeout_dbg_enabled) wl_scan_timeout_dbg_set(); #endif /* CUSTOMER_HW4_DEBUG */ + // terence 20130729: workaround to fix out of memory in firmware // if (dhd_conf_get_chip(dhd_get_pub(ndev)) == BCM43362_CHIP_ID) { // WL_ERR(("Send hang event\n")); @@ -15181,7 +15183,7 @@ static s32 wl_notifier_change_state(struct bcm_cfg80211 *cfg, struct net_info *_ wl_cfg80211_update_power_mode(_net_info->ndev); } #ifdef RTT_SUPPORT - } + } #endif /* RTT_SUPPORT */ } wl_cfg80211_concurrent_roam(cfg, 0); @@ -16380,9 +16382,6 @@ static s32 __wl_cfg80211_down(struct bcm_cfg80211 *cfg) unsigned long flags; struct net_info *iter, *next; struct net_device *ndev = bcmcfg_to_prmry_ndev(cfg); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) - struct cfg80211_scan_info info; -#endif #if defined(WL_CFG80211) && (defined(WL_ENABLE_P2P_IF) || \ defined(WL_NEW_CFG_PRIVCMD_SUPPORT)) && !defined(PLATFORM_SLP) struct net_device *p2p_net = cfg->p2p_net; @@ -16392,6 +16391,10 @@ static s32 __wl_cfg80211_down(struct bcm_cfg80211 *cfg) dhd_pub_t *dhd = (dhd_pub_t *)(cfg->pub); #endif #endif /* PROP_TXSTATUS_VSDB */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) + struct cfg80211_scan_info info; +#endif + WL_DBG(("In\n")); /* Check if cfg80211 interface is already down */ @@ -17376,27 +17379,25 @@ done: } static bool -wl_cfg80211_valid_chanspec_p2p(chanspec_t chanspec) +wl_cfg80211_valid_channel_p2p(int channel) { bool valid = false; - char chanbuf[CHANSPEC_STR_LEN]; /* channel 1 to 14 */ - if ((chanspec >= 0x2b01) && (chanspec <= 0x2b0e)) { + if ((channel >= 1) && (channel <= 14)) { valid = true; } /* channel 36 to 48 */ - else if ((chanspec >= 0x1b24) && (chanspec <= 0x1b30)) { + else if ((channel >= 36) && (channel <= 48)) { valid = true; } /* channel 149 to 161 */ - else if ((chanspec >= 0x1b95) && (chanspec <= 0x1ba1)) { + else if ((channel >= 149) && (channel <= 161)) { valid = true; } else { valid = false; - WL_INFORM(("invalid P2P chanspec, chanspec = %s\n", - wf_chspec_ntoa_ex(chanspec, chanbuf))); + WL_INFORM(("invalid P2P chanspec, channel = %d\n", channel)); } return valid; @@ -17461,7 +17462,7 @@ wl_cfg80211_get_chanspecs_5g(struct net_device *ndev, void *buf, s32 buflen) } if (CHANNEL_IS_RADAR(channel) || - !(wl_cfg80211_valid_chanspec_p2p(chanspec))) { + !(wl_cfg80211_valid_channel_p2p(CHSPEC_CHANNEL(chanspec)))) { continue; } else { list->element[j] = list->element[i]; @@ -17486,7 +17487,7 @@ wl_cfg80211_get_best_channel(struct net_device *ndev, void *buf, int buflen, uint chip; /* Start auto channel selection scan. */ - ret = wldev_ioctl_set(ndev, WLC_START_CHANNEL_SEL, NULL, 0); + ret = wldev_ioctl_set(ndev, WLC_START_CHANNEL_SEL, buf, buflen); if (ret < 0) { WL_ERR(("can't start auto channel scan, error = %d\n", ret)); *channel = 0; @@ -17508,7 +17509,7 @@ wl_cfg80211_get_best_channel(struct net_device *ndev, void *buf, int buflen, chanspec = wl_chspec_driver_to_host(chosen); printf("selected chanspec = 0x%x\n", chanspec); ctl_chan = wf_chspec_ctlchan(chanspec); - printf("selected ctl_chan = 0x%x\n", ctl_chan); + printf("selected ctl_chan = %d\n", ctl_chan); *channel = (u16)(ctl_chan & 0x00FF); } else *channel = (u16)(chosen & 0x00FF); @@ -17524,6 +17525,7 @@ wl_cfg80211_get_best_channel(struct net_device *ndev, void *buf, int buflen, *channel = 0; ret = BCME_ERROR; } + WL_INFORM(("selected channel = %d\n", *channel)); done: return ret; @@ -17591,17 +17593,19 @@ wl_cfg80211_get_best_channels(struct net_device *dev, char* cmd, int total_len) } if (CHANNEL_IS_2G(channel)) { +#if 0 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(WL_COMPAT_WIRELESS) channel = ieee80211_channel_to_frequency(channel); #else channel = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); +#endif #endif } else { WL_ERR(("invalid 2.4GHz channel, channel = %d\n", channel)); channel = 0; } + pos += snprintf(pos, total_len, "2g=%d ", channel); } - pos += snprintf(pos, total_len, "%04d ", channel); if (band_cur != WLC_BAND_2G) { // terence 20140120: fix for some chipsets only return 2.4GHz channel (4330b2/43341b0/4339a0) @@ -17625,17 +17629,12 @@ wl_cfg80211_get_best_channels(struct net_device *dev, char* cmd, int total_len) } if (CHANNEL_IS_5G(channel)) { - channel = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ); - } else { - WL_ERR(("invalid 5GHz channel, channel = %d\n", channel)); - channel = 0; - } - - if (CHANNEL_IS_5G(channel)) { +#if 0 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && !defined(WL_COMPAT_WIRELESS) channel = ieee80211_channel_to_frequency(channel); #else channel = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ); +#endif #endif } else { WL_ERR(("invalid 5GHz channel, channel = %d\n", channel)); @@ -17645,11 +17644,8 @@ wl_cfg80211_get_best_channels(struct net_device *dev, char* cmd, int total_len) ret = wldev_ioctl(dev, WLC_SET_BAND, &band_cur, sizeof(band_cur), true); if (ret < 0) WL_ERR(("WLC_SET_BAND error %d\n", ret)); + pos += snprintf(pos, total_len, "5g=%d ", channel); } - pos += snprintf(pos, total_len, "%04d ", channel); - - /* Set overall best channel same as 5GHz best channel. */ - pos += snprintf(pos, total_len, "%04d ", channel); done: if (NULL != buf) { @@ -17662,7 +17658,7 @@ done: WL_ERR(("can't restore auto channel scan state, error = %d\n", ret)); } - printf("%s: channel %s\n", __FUNCTION__, cmd); + printf("%s: %s\n", __FUNCTION__, cmd); return (pos - cmd); } diff --git a/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.h b/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.h index f002166..9d06534 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.h +++ b/bcmdhd.1.579.77.41.1.cn/wl_cfg80211.h @@ -199,6 +199,12 @@ do { \ #define WL_PNO(x) #define WL_SD(x) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) +#define ieee80211_band nl80211_band +#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ +#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ +#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS +#endif #define WL_SCAN_RETRY_MAX 3 #define WL_NUM_PMKIDS_MAX MAXPMKID diff --git a/bcmdhd.1.579.77.41.1.cn/wl_cfgvendor.c b/bcmdhd.1.579.77.41.1.cn/wl_cfgvendor.c index 9bf7084..8806a5f 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_cfgvendor.c +++ b/bcmdhd.1.579.77.41.1.cn/wl_cfgvendor.c @@ -252,7 +252,7 @@ wl_cfgvendor_set_country(struct wiphy *wiphy, int err = BCME_ERROR, rem, type; char country_code[WLC_CNTRY_BUF_SZ] = {0}; const struct nlattr *iter; - + WL_ERR(("enter wl_cfgvendor_set_country: \n")); nla_for_each_attr(iter, data, len, rem) { type = nla_type(iter); switch (type) { @@ -267,6 +267,7 @@ wl_cfgvendor_set_country(struct wiphy *wiphy, } err = wldev_set_country(wdev->netdev, country_code, true, true, -1); + WL_ERR(("Set country code ret:%d\n", err)); if (err < 0) { WL_ERR(("Set country failed ret:%d\n", err)); } @@ -2203,7 +2204,11 @@ static int wl_cfgvendor_lstats_get_info(struct wiphy *wiphy, wlc_rev_info_t revinfo; #ifdef CONFIG_COMPAT compat_wifi_iface_stat compat_iface; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + int compat_task_state = in_compat_syscall(); +#else int compat_task_state = is_compat_task(); +#endif #endif /* CONFIG_COMPAT */ WL_INFORM(("%s: Enter \n", __func__)); @@ -2563,7 +2568,12 @@ wl_cfgvendor_dbg_get_mem_dump(struct wiphy *wiphy, goto free_mem; } #ifdef CONFIG_COMPAT - if (is_compat_task()) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + if (in_compat_syscall()) +#else + if (is_compat_task()) +#endif + { void * usr_ptr = compat_ptr((uintptr_t) user_buf); ret = copy_to_user(usr_ptr, mem_buf, buf_len); if (ret) { @@ -2737,9 +2747,9 @@ static int wl_cfgvendor_dbg_get_feature(struct wiphy *wiphy, ret = wl_cfgvendor_send_cmd_reply(wiphy, bcmcfg_to_prmry_ndev(cfg), &supported_features, sizeof(supported_features)); if (ret < 0) { - WL_ERR(("wl_cfgvendor_send_cmd_reply failed ret:%d\n", ret)); - goto exit; - } + WL_ERR(("wl_cfgvendor_send_cmd_reply failed ret:%d\n", ret)); + goto exit; + } exit: return ret; } diff --git a/bcmdhd.1.579.77.41.1.cn/wl_escan.c b/bcmdhd.1.579.77.41.1.cn/wl_escan.c index d6425b9..f9be063 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_escan.c +++ b/bcmdhd.1.579.77.41.1.cn/wl_escan.c @@ -4,6 +4,9 @@ #include #include #include +#include +#include + #include #include #include @@ -1393,7 +1396,7 @@ err: return err; } -void wl_escan_detach(void) +void wl_escan_detach(dhd_pub_t *dhdp) { struct wl_escan_info *escan = g_escan; @@ -1410,14 +1413,12 @@ void wl_escan_detach(void) kfree(escan->escan_ioctl_buf); escan->escan_ioctl_buf = NULL; } -#ifndef CONFIG_DHD_USE_STATIC_BUF - kfree(escan); -#endif + DHD_OS_PREFREE(dhdp, escan, sizeof(struct wl_escan_info)); g_escan = NULL; } int -wl_escan_attach(struct net_device *dev, void * dhdp) +wl_escan_attach(struct net_device *dev, dhd_pub_t *dhdp) { struct wl_escan_info *escan = NULL; @@ -1425,11 +1426,7 @@ wl_escan_attach(struct net_device *dev, void * dhdp) if (!dev) return 0; -#ifdef CONFIG_DHD_USE_STATIC_BUF - escan = bcm_wlan_prealloc(DHD_PREALLOC_WL_ESCAN_INFO, sizeof(struct wl_escan_info)); -#else - escan = kmalloc(sizeof(struct wl_escan_info), GFP_KERNEL); -#endif + escan = (wl_escan_info_t *)DHD_OS_PREALLOC(dhdp, DHD_PREALLOC_WL_ESCAN_INFO, sizeof(struct wl_escan_info)); if (!escan) return -ENOMEM; memset(escan, 0, sizeof(struct wl_escan_info)); @@ -1452,7 +1449,7 @@ wl_escan_attach(struct net_device *dev, void * dhdp) return 0; err: - wl_escan_detach(); + wl_escan_detach(dhdp); return -ENOMEM; } diff --git a/bcmdhd.1.579.77.41.1.cn/wl_escan.h b/bcmdhd.1.579.77.41.1.cn/wl_escan.h index 6be090a..04255d4 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_escan.h +++ b/bcmdhd.1.579.77.41.1.cn/wl_escan.h @@ -68,8 +68,8 @@ int wl_escan_set_scan( ); int wl_escan_get_scan(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra); -int wl_escan_attach(struct net_device *dev, void * dhdp); -void wl_escan_detach(void); +int wl_escan_attach(struct net_device *dev, dhd_pub_t *dhdp); +void wl_escan_detach(dhd_pub_t *dhdp); #endif /* _wl_escan_ */ diff --git a/bcmdhd.1.579.77.41.1.cn/wl_iw.c b/bcmdhd.1.579.77.41.1.cn/wl_iw.c index b7161be..a817c01 100644 --- a/bcmdhd.1.579.77.41.1.cn/wl_iw.c +++ b/bcmdhd.1.579.77.41.1.cn/wl_iw.c @@ -599,9 +599,9 @@ wl_iw_set_freq( fwrq->m /= 10; } /* handle 4.9GHz frequencies as Japan 4 GHz based channelization */ - if (fwrq->m > 4000 && fwrq->m < 5000) { - sf = WF_CHAN_FACTOR_4_G; /* start factor for 4 GHz */ - } + if (fwrq->m > 4000 && fwrq->m < 5000) { + sf = WF_CHAN_FACTOR_4_G; /* start factor for 4 GHz */ + } chan = wf_mhz2channel(fwrq->m, sf); } WL_ERROR(("%s: chan=%d\n", __FUNCTION__, chan));