#include #include #include #include #include #include #include #include #define CONFIG_BROADCOM_WIFI_RESERVED_MEM #ifdef CONFIG_BROADCOM_WIFI_RESERVED_MEM #define WLAN_STATIC_PKT_BUF 4 #define WLAN_STATIC_SCAN_BUF0 5 #define WLAN_STATIC_SCAN_BUF1 6 #define WLAN_STATIC_DHD_INFO 7 #define PREALLOC_WLAN_SEC_NUM 5 #define PREALLOC_WLAN_BUF_NUM 160 #define PREALLOC_WLAN_SECTION_HEADER 24 #define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128) #define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128) #define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512) #define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024) #define WLAN_SECTION_SIZE_7 (PREALLOC_WLAN_BUF_NUM * 128) #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 WLAN_SKB_BUF_NUM 17 static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM]; struct wlan_mem_prealloc { void *mem_ptr; unsigned long size; }; static struct wlan_mem_prealloc wlan_mem_array[PREALLOC_WLAN_SEC_NUM] = { {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)}, {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)}, {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)}, {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}, {NULL, (WLAN_SECTION_SIZE_7 + PREALLOC_WLAN_SECTION_HEADER)} }; void *wlan_static_scan_buf0; void *wlan_static_scan_buf1; void *bcmdhd_mem_prealloc(int section, unsigned long size) { if (section == WLAN_STATIC_PKT_BUF) { printk("1 %s: section=%d, wlan_static_skb=%p\n", __FUNCTION__, section, wlan_static_skb); return wlan_static_skb; } if (section == WLAN_STATIC_SCAN_BUF0) { printk("2 %s: section=%d, wlan_static_scan_buf0=%p\n", __FUNCTION__, section, wlan_static_scan_buf0); return wlan_static_scan_buf0; } if (section == WLAN_STATIC_SCAN_BUF1) { printk("3 %s: section=%d, wlan_static_scan_buf1=%p\n", __FUNCTION__, section, wlan_static_scan_buf1); return wlan_static_scan_buf1; } if (section == WLAN_STATIC_DHD_INFO) { printk("4 %s: section=%d, wlan_mem_array[4]=%p\n", __FUNCTION__, section, wlan_mem_array[4].mem_ptr); return wlan_mem_array[4].mem_ptr; } if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM)) { printk("5 %s: out of section %d\n", __FUNCTION__, section); return NULL; } if (wlan_mem_array[section].size < size) { printk("6 %s: wlan_mem_array[section].size=%d, size=%d\n", __FUNCTION__, wlan_mem_array[section].size, size); return NULL; } printk("7 %s: wlan_mem_array[section].mem_ptr=%p, size=%d\n", __FUNCTION__, wlan_mem_array[section], size); return wlan_mem_array[section].mem_ptr; } EXPORT_SYMBOL(bcmdhd_mem_prealloc); int bcmdhd_init_wlan_mem(void) { int i; int j; for (i=0; i<8; i++) { wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_1PAGE_BUFSIZE); if (!wlan_static_skb[i]) goto err_skb_alloc; printk("1 %s: wlan_static_skb[%d]=%p, size=%d\n", __FUNCTION__, i, wlan_static_skb[i], DHD_SKB_1PAGE_BUFSIZE); } for (; i<16; i++) { wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_2PAGE_BUFSIZE); if (!wlan_static_skb[i]) goto err_skb_alloc; printk("2 %s: wlan_static_skb[%d]=%p, size=%d\n", __FUNCTION__, i, wlan_static_skb[i], DHD_SKB_2PAGE_BUFSIZE); } wlan_static_skb[i] = dev_alloc_skb(DHD_SKB_4PAGE_BUFSIZE); if (!wlan_static_skb[i]) goto err_skb_alloc; printk("3 %s: wlan_static_skb[%d]=%p, size=%d\n", __FUNCTION__, i, wlan_static_skb[i], DHD_SKB_4PAGE_BUFSIZE); for (i=0; i