wifi: fix broadcom pcie wifi driver use static buf failed

PD#171351: fix broadcom pcie wifi driver use static buf failed

Change-Id: I1ce8f0d96b1e2ecd5bbd5b3f9ac805c433d548a2
Signed-off-by: libo <bo.li@amlogic.com>
This commit is contained in:
libo
2018-08-08 12:51:48 +08:00
committed by Yixun Lan
parent d439434ddc
commit 679da508da

View File

@@ -26,17 +26,25 @@
#include <linux/skbuff.h>
#include <linux/wlan_plat.h>
#include <linux/amlogic/dhd_buf.h>
#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,
@@ -52,10 +60,8 @@ enum dhd_prealloc_index {
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)
@@ -64,8 +70,8 @@ enum dhd_prealloc_index {
#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 (30 * 1024)
#define DHD_PREALLOC_MEMDUMP_RAM_SIZE (898 * 1024)
#define DHD_PREALLOC_DHD_INFO_SIZE (32 * 1024)
#define DHD_PREALLOC_MEMDUMP_RAM_SIZE (898 * 1024)
#define DHD_PREALLOC_DHD_WLFC_HANGER_SIZE (73 * 1024)
#define DHD_PREALLOC_WL_ESCAN_INFO_SIZE (66 * 1024)
#ifdef CONFIG_64BIT
@@ -73,6 +79,10 @@ enum dhd_prealloc_index {
#else
#define DHD_PREALLOC_IF_FLOW_LKUP_SIZE (20 * 1024)
#endif
#define FW_VERBOSE_RING_SIZE (256 * 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)
@@ -85,7 +95,6 @@ enum dhd_prealloc_index {
#endif /* CONFIG_64BIT */
#define WLAN_DHD_MEMDUMP_SIZE (800 * 1024)
#define DHD_SKB_1PAGE_BUFSIZE (PAGE_SIZE*1)
#define DHD_SKB_2PAGE_BUFSIZE (PAGE_SIZE*2)
#define DHD_SKB_4PAGE_BUFSIZE (PAGE_SIZE*4)
@@ -94,7 +103,6 @@ enum dhd_prealloc_index {
#define DHD_SKB_2PAGE_BUF_NUM 64
#define DHD_SKB_4PAGE_BUF_NUM 1
/* The number is defined in linux_osl.c
* WLAN_SKB_1_2PAGE_BUF_NUM => STATIC_PKT_1_2PAGE_NUM
* WLAN_SKB_BUF_NUM => STATIC_PKT_MAX_NUM
@@ -124,14 +132,17 @@ static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
void *bcmdhd_mem_prealloc(int section, unsigned long size)
{
pr_info("sectoin %d, size %ld\n", 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;
@@ -144,7 +155,7 @@ void *bcmdhd_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;
}
@@ -153,7 +164,7 @@ void *bcmdhd_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;
}
@@ -161,89 +172,91 @@ void *bcmdhd_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) is bigger than static size(%d).\n",
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) > %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) is bigger than static size(%d).\n",
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 > DHD_PREALLOC_WIPHY_ESCAN0_SIZE) {
pr_err("request DHD_PREALLOC_FW_VERBOSE_RING(%lu) is bigger than static size(%d).\n",
size, DHD_PREALLOC_WIPHY_ESCAN0_SIZE);
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 > DHD_PREALLOC_WIPHY_ESCAN0_SIZE) {
pr_err("request DHD_PREALLOC_FW_EVENT_RING(%lu) is bigger than static size(%d).\n",
size, DHD_PREALLOC_WIPHY_ESCAN0_SIZE);
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_PREALLOC_WIPHY_ESCAN0_SIZE) {
pr_err("request DHD_PREALLOC_DHD_EVENT_RING(%lu) is bigger than static size(%d).\n",
size, DHD_PREALLOC_WIPHY_ESCAN0_SIZE);
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 > DHD_PREALLOC_WIPHY_ESCAN0_SIZE) {
pr_err("request DHD_PREALLOC_NAN_EVENT_RING(%lu) is bigger than static size(%d).\n",
size, DHD_PREALLOC_WIPHY_ESCAN0_SIZE);
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 == 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",
size, DHD_PREALLOC_DHD_WLFC_HANGER_SIZE);
return NULL;
}
return wlan_static_dhd_wlfc_hanger_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",
__func__, section, size);
pr_err("failed to alloc section %d, size=%ld\n",
section, size);
return NULL;
}
@@ -258,135 +271,125 @@ int bcmdhd_init_wlan_mem(void)
wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_1PAGE_BUFSIZE);
if (!wlan_static_skb[i])
goto err_skb_alloc;
}
for (i = DHD_SKB_1PAGE_BUF_NUM; i < WLAN_SKB_1_2PAGE_BUF_NUM; i++) {
wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_2PAGE_BUFSIZE);
if (!wlan_static_skb[i])
goto err_skb_alloc;
}
#if defined(BCMDHD_SDIO)
wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_4PAGE_BUFSIZE);
if (!wlan_static_skb[i])
goto err_skb_alloc;
#endif /* BCMDHD_SDIO */
wlan_static_prot = kmalloc(DHD_PREALLOC_PROT_SIZE, GFP_KERNEL);
if (!wlan_static_prot)
goto err_mem_alloc;
#if defined(BCMDHD_SDIO)
wlan_static_rxbuf = kmalloc(DHD_PREALLOC_RXBUF_SIZE, GFP_KERNEL);
if (!wlan_static_rxbuf)
goto err_mem_alloc;
wlan_static_databuf = kmalloc(DHD_PREALLOC_DATABUF_SIZE, GFP_KERNEL);
if (!wlan_static_databuf)
goto err_mem_alloc;
#endif /* BCMDHD_SDIO */
wlan_static_osl_buf = kmalloc(DHD_PREALLOC_OSL_BUF_SIZE, GFP_KERNEL);
if (!wlan_static_osl_buf)
goto err_mem_alloc;
wlan_static_scan_buf0 = kmalloc(DHD_PREALLOC_WIPHY_ESCAN0_SIZE,
GFP_KERNEL);
if (!wlan_static_scan_buf0)
goto err_mem_alloc;
wlan_static_dhd_info_buf = kmalloc(DHD_PREALLOC_DHD_INFO_SIZE,
GFP_KERNEL);
if (!wlan_static_dhd_info_buf)
goto err_mem_alloc;
wlan_static_dhd_wlfc_info_buf = kmalloc(WLAN_DHD_WLFC_BUF_SIZE,
GFP_KERNEL);
if (!wlan_static_dhd_wlfc_info_buf)
goto err_mem_alloc;
#ifdef BCMDHD_PCIE
wlan_static_if_flow_lkup = kmalloc(DHD_PREALLOC_IF_FLOW_LKUP_SIZE,
GFP_KERNEL);
if (!wlan_static_if_flow_lkup)
goto err_mem_alloc;
#endif /* BCMDHD_PCIE */
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;
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;
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;
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;
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;
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;
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;
wlan_static_if_flow_lkup = kmalloc(DHD_PREALLOC_IF_FLOW_LKUP_SIZE,
GFP_KERNEL);
if (!wlan_static_if_flow_lkup)
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;
wlan_static_fw_verbose_ring_buf = kmalloc(
FW_VERBOSE_RING_SIZE,
GFP_KERNEL);
if (!wlan_static_fw_verbose_ring_buf)
goto err_mem_alloc;
pr_err("bcmdhd_init_wlan_mem prealloc ok\n");
wlan_static_fw_event_ring_buf = kmalloc(FW_EVENT_RING_SIZE,
GFP_KERNEL);
if (!wlan_static_fw_event_ring_buf)
goto err_mem_alloc;
wlan_static_dhd_event_ring_buf = kmalloc(DHD_EVENT_RING_SIZE,
GFP_KERNEL);
if (!wlan_static_dhd_event_ring_buf)
goto err_mem_alloc;
wlan_static_nan_event_ring_buf = kmalloc(NAN_EVENT_RING_SIZE,
GFP_KERNEL);
if (!wlan_static_nan_event_ring_buf)
goto err_mem_alloc;
pr_info("bcmdhd_init_wlan_mem prealloc ok\n");
return 0;
err_mem_alloc:
kfree(wlan_static_prot);
#if defined(BCMDHD_SDIO)
kfree(wlan_static_rxbuf);
kfree(wlan_static_databuf);
#endif /* BCMDHD_SDIO */
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_dhd_wlfc_hanger_buf);
#ifdef BCMDHD_PCIE
kfree(wlan_static_if_flow_lkup);
#endif /* BCMDHD_PCIE */
kfree(wlan_static_dhd_memdump_ram_buf);
kfree(wlan_static_dhd_wlfc_hanger_buf);
kfree(wlan_static_wl_escan_info_buf);
#ifdef BCMDHD_PCIE
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);
kfree(wlan_static_scan_buf1);
kfree(wlan_static_scan_buf0);
kfree(wlan_static_osl_buf);
kfree(wlan_static_if_flow_lkup);
#endif /* BCMDHD_PCIE */
pr_err("Failed to mem_alloc for WLAN\n");
i = WLAN_SKB_BUF_NUM;