int dhd_prot_attach(dhd_pub_t *dhd) { dhd_prot_t *cdc; #ifndef DHD_USE_STATIC_BUF if (!(cdc = (dhd_prot_t *)MALLOC(dhd->osh, sizeof(dhd_prot_t)))) { DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__)); goto fail; } #else if (!(cdc = (dhd_prot_t *)dhd_os_prealloc(DHD_PREALLOC_PROT, sizeof(dhd_prot_t)))) { DHD_ERROR(("%s: kmalloc failed\n", __FUNCTION__)); goto fail; } #endif /* DHD_USE_STATIC_BUF */ memset(cdc, 0, sizeof(dhd_prot_t)); /* ensure that the msg buf directly follows the cdc msg struct */ if ((uintptr)(&cdc->msg + 1) != (uintptr)cdc->buf) { DHD_ERROR(("dhd_prot_t is not correctly defined\n")); goto fail; } dhd->prot = cdc; #ifdef BDC dhd->hdrlen += BDC_HEADER_LEN; #endif dhd->maxctl = WLC_IOCTL_MAXLEN + sizeof(cdc_ioctl_t) + ROUND_UP_MARGIN; return 0; fail: #ifndef DHD_USE_STATIC_BUF if (cdc != NULL) MFREE(dhd->osh, cdc, sizeof(dhd_prot_t)); #endif return BCME_NOMEM; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; osh = kmalloc(sizeof(osl_t), GFP_ATOMIC); ASSERT(osh); /* LGE_CHANGE_S, [[email protected]], 2010-04-22, WBT Fix */ // WBT Fix TD# 37025, 37026 if ( ! osh ) return NULL; /* LGE_CHANGE_S, [[email protected]], 2010-04-22, WBT Fix */ bzero(osh, sizeof(osl_t)); /* Check that error map has the right number of entries in it */ ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; atomic_set(&osh->malloced, 0); osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: case RPC_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #ifdef DHD_USE_STATIC_BUF if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { printk("can not alloc static buf!\n"); } else printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); sema_init(&bcm_static_buf->static_sem, 1); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++) bcm_static_skb->pkt_use[i] = 0; sema_init(&bcm_static_skb->osl_pkt_sem, 1); } #endif /* DHD_USE_STATIC_BUF */ return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) gfp_t flags; flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL; osh = kmalloc(sizeof(osl_t), flags); #else osh = kmalloc(sizeof(osl_t), GFP_ATOMIC); #endif ASSERT(osh); bzero(osh, sizeof(osl_t)); ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; atomic_set(&osh->malloced, 0); osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: case RPC_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #if defined(DHD_USE_STATIC_BUF) if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(osh, 3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { printk("can not alloc static buf!\n"); } else printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); sema_init(&bcm_static_buf->static_sem, 1); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(osh, 4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *) * 16); for (i = 0; i < STATIC_PKT_MAX_NUM * 2; i++) bcm_static_skb->pkt_use[i] = 0; sema_init(&bcm_static_skb->osl_pkt_sem, 1); } #endif return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; osh = kmalloc(sizeof(osl_t), GFP_ATOMIC); ASSERT(osh); bzero(osh, sizeof(osl_t)); ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; osh->malloced = 0; osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #ifdef DHD_USE_STATIC_BUF if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { OSL_MSG_ERROR(("osl_attach: can not alloc static buf!\n")); } else OSL_MSG_INFO(("osl_attach: alloc static buf at %x!\n", (unsigned int)bcm_static_buf)); init_MUTEX(&bcm_static_buf->static_sem); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; #ifndef CUSTOMER_HW_SAMSUNG void *skb_buff_ptr = 0; #endif bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); #ifdef CUSTOMER_HW_SAMSUNG for (i = 0; i < MAX_STATIC_PKT_NUM; i++) { bcm_static_skb->skb_4k[i] = dev_alloc_skb(DHD_SKB_1PAGE_BUFSIZE); if (bcm_static_skb->skb_4k[i] == NULL) { OSL_MSG_ERROR(("osl_attach: 4K memory allocation failure. idx=%d\n", i)); goto err; } } for (i = 0; i < MAX_STATIC_PKT_NUM; i++) { bcm_static_skb->skb_8k[i] = dev_alloc_skb_kernel(DHD_SKB_2PAGE_BUFSIZE); if (bcm_static_skb->skb_8k[i] == NULL) { OSL_MSG_ERROR(("osl_attach: 8K memory allocation failure. idx=%d\n", i)); goto err; } } bcm_static_skb->skb_16k = dev_alloc_skb_kernel(DHD_SKB_4PAGE_BUFSIZE); if (bcm_static_skb->skb_16k == NULL) { OSL_MSG_ERROR(("osl_attach: 16K memory allocation failure. idx=%d\n", i)); goto err; } #else skb_buff_ptr = dhd_os_prealloc(4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); #endif /* CUSTOMER_HW_SAMSUNG */ for (i = 0; i < MAX_STATIC_PKT_NUM*2+1; i++) bcm_static_skb->pkt_use[i] = 0; init_MUTEX(&bcm_static_skb->osl_pkt_sem); } #endif return osh; err: kfree(osh); return 0; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; if(!(osh = kmalloc(sizeof(osl_t), GFP_ATOMIC))){ ASSERT(osh); return NULL; } bzero(osh, sizeof(osl_t)); ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; osh->malloced = 0; osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #ifdef DHD_USE_STATIC_BUF if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { printk("can not alloc static buf!\n"); } else { printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); init_MUTEX(&bcm_static_buf->static_sem); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } } #ifdef USE_STATIC_SKB if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++) bcm_static_skb->pkt_use[i] = 0; init_MUTEX(&bcm_static_skb->osl_pkt_sem); } #endif /* USE_STATIC_SKB */ #endif return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; if (!(osh = kmalloc(sizeof(osl_t), GFP_ATOMIC))) return osh; ASSERT(osh); bzero(osh, sizeof(osl_t)); ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; atomic_set(&osh->malloced, 0); osh->failed = 0; osh->dbgmem_list = NULL; spin_lock_init(&(osh->dbgmem_lock)); osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: case RPC_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #if defined(CONFIG_DHD_USE_STATIC_BUF) if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(osh, 3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { ; } else ; sema_init(&bcm_static_buf->static_sem, 1); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(osh, 4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)* (STATIC_PKT_MAX_NUM * 2 + STATIC_PKT_4PAGE_NUM)); for (i = 0; i < (STATIC_PKT_MAX_NUM * 2 + STATIC_PKT_4PAGE_NUM); i++) bcm_static_skb->pkt_use[i] = 0; sema_init(&bcm_static_skb->osl_pkt_sem, 1); } #endif spin_lock_init(&(osh->pktalloc_lock)); return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; gfp_t flags; flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL; osh = kmalloc(sizeof(osl_t), flags); ASSERT(osh); #ifdef HTC_KlocWork if(osh == NULL) { myprintf("[HTCKW] osl_attach: osh == NULL\n"); return NULL; } #endif bzero(osh, sizeof(osl_t)); ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; osh->malloced = 0; osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #ifdef DHD_USE_STATIC_BUF if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { myprintf("can not alloc static buf!\n"); #ifdef HTC_KlocWork return NULL; #endif } else { /* myprintf("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); */ } mutex_init(&bcm_static_buf->static_sem); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(4, 0); #ifdef HTC_KlocWork if(skb_buff_ptr != NULL) #endif bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++) bcm_static_skb->pkt_use[i] = 0; mutex_init(&bcm_static_skb->osl_pkt_sem); } #endif return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; osh = kmalloc(sizeof(osl_t), GFP_ATOMIC); ASSERT(osh); bzero(osh, sizeof(osl_t)); /* Check that error map has the right number of entries in it */ ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; atomic_set(&osh->malloced, 0); osh->failed = 0; osh->dbgmem_list = NULL; spin_lock_init(&(osh->dbgmem_lock)); osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: case RPC_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #if defined(DHD_USE_STATIC_BUF) if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(osh, 3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { printk("can not alloc static buf!\n"); } else printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); sema_init(&bcm_static_buf->static_sem, 1); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(osh, 4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); for (i = 0; i < STATIC_PKT_MAX_NUM * 2; i++) bcm_static_skb->pkt_use[i] = 0; sema_init(&bcm_static_skb->osl_pkt_sem, 1); } #endif /* DHD_USE_STATIC_BUF */ spin_lock_init(&(osh->pktalloc_lock)); #ifdef BCMDBG if (pkttag) { struct sk_buff *skb; BCM_REFERENCE(skb); ASSERT(OSL_PKTTAG_SZ <= sizeof(skb->cb)); } #endif return osh; }
osl_t * osl_attach(void *pdev, uint bustype, bool pkttag) { osl_t *osh; gfp_t flags; flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL; osh = kzalloc(sizeof(osl_t), flags); ASSERT(osh); if (!osh) { return NULL; } ASSERT(ABS(BCME_LAST) == (ARRAYSIZE(linuxbcmerrormap) - 1)); osh->magic = OS_HANDLE_MAGIC; osh->malloced = 0; osh->failed = 0; osh->dbgmem_list = NULL; osh->pdev = pdev; osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: osh->pub.mmbus = TRUE; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: osh->pub.mmbus = FALSE; break; default: ASSERT(FALSE); break; } #ifdef DHD_USE_STATIC_BUF /* BEGIN: 0005533 [email protected] 2010-03-27 */ /* MOD 0005533: [WLAN] Fixing WBT issues on Wi-Fi driver */ /* WBT Fix TD# 248396, 248397 */ if (!bcm_static_buf) { if (!(bcm_static_buf = (bcm_static_buf_t *)dhd_os_prealloc(3, STATIC_BUF_SIZE+ STATIC_BUF_TOTAL_LEN))) { printk("can not alloc static buf!\n"); } else { printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); init_MUTEX(&bcm_static_buf->static_sem); bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE; } } /* END: 0005533 [email protected] 2010-03-27 */ #ifdef USE_STATIC_SKB if (!bcm_static_skb) { int i; void *skb_buff_ptr = 0; bcm_static_skb = (bcm_static_pkt_t *)((char *)bcm_static_buf + 2048); skb_buff_ptr = dhd_os_prealloc(4, 0); bcopy(skb_buff_ptr, bcm_static_skb, sizeof(struct sk_buff *)*16); for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++) bcm_static_skb->pkt_use[i] = 0; init_MUTEX(&bcm_static_skb->osl_pkt_sem); } #endif /* USE_STATIC_SKB */ #endif return osh; }