/* * Free recv private variable of hardware dependent * 1. recv buf * 2. recv tasklet * */ void rtl8723bs_free_recv_priv(PADAPTER padapter) { u32 i, n; struct recv_priv *precvpriv; struct recv_buf *precvbuf; precvpriv = &padapter->recvpriv; /* 3 1. kill tasklet */ tasklet_kill(&precvpriv->recv_tasklet); /* 3 2. free all recv buffers */ precvbuf = (struct recv_buf*)precvpriv->precv_buf; if (precvbuf) { n = NR_RECVBUFF; precvpriv->free_recv_buf_queue_cnt = 0; for (i = 0; i < n ; i++) { list_del_init(&precvbuf->list); rtw_os_recvbuf_resource_free(padapter, precvbuf); precvbuf++; } precvpriv->precv_buf = NULL; } if (precvpriv->pallocated_recv_buf) { n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; kfree(precvpriv->pallocated_recv_buf); precvpriv->pallocated_recv_buf = NULL; } }
/* * Free recv private variable of hardware dependent * 1. recv buf * 2. recv tasklet * */ void rtl8723as_free_recv_priv(PADAPTER padapter) { u32 i, n; struct recv_priv *precvpriv; struct recv_buf *precvbuf; precvpriv = &padapter->recvpriv; //3 1. kill tasklet #ifdef PLATFORM_LINUX tasklet_kill(&precvpriv->recv_tasklet); #endif //3 2. free all recv buffers precvbuf = (struct recv_buf*)precvpriv->precv_buf; if (precvbuf) { n = NR_RECVBUFF; precvpriv->free_recv_buf_queue_cnt = 0; for (i = 0; i < n ; i++) { rtw_list_delete(&precvbuf->list); rtw_os_recvbuf_resource_free(padapter, precvbuf); freerecvbuf(precvbuf); precvbuf++; } precvpriv->precv_buf = NULL; } if (precvpriv->pallocated_recv_buf) { n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; rtw_mfree(precvpriv->pallocated_recv_buf, n); precvpriv->pallocated_recv_buf = NULL; } }
void rtl8188eu_free_recv_priv (_adapter *padapter) { int i; struct recv_buf *precvbuf; struct recv_priv *precvpriv = &padapter->recvpriv; precvbuf = (struct recv_buf *)precvpriv->precv_buf; for(i=0; i < NR_RECVBUFF ; i++) { rtw_os_recvbuf_resource_free(padapter, precvbuf); precvbuf++; } if(precvpriv->pallocated_recv_buf) rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF *sizeof(struct recv_buf) + 4); #ifdef CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX if(precvpriv->int_in_urb) { usb_free_urb(precvpriv->int_in_urb); } #endif//PLATFORM_LINUX if(precvpriv->int_in_buf) rtw_mfree(precvpriv->int_in_buf, INTERRUPT_MSG_FORMAT_LEN); #endif//CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX if (skb_queue_len(&precvpriv->rx_skb_queue)) { DBG_8192C(KERN_WARNING "rx_skb_queue not empty\n"); } skb_queue_purge(&precvpriv->rx_skb_queue); #ifdef CONFIG_PREALLOC_RECV_SKB if (skb_queue_len(&precvpriv->free_recv_skb_queue)) { DBG_8192C(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); } skb_queue_purge(&precvpriv->free_recv_skb_queue); #endif #endif }
/* * Initialize recv private variable for hardware dependent * 1. recv buf * 2. recv tasklet * */ s32 rtl8723as_init_recv_priv(PADAPTER padapter) { s32 res; u32 i, n; struct recv_priv *precvpriv; struct recv_buf *precvbuf; res = _SUCCESS; precvpriv = &padapter->recvpriv; //3 1. init recv buffer _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; precvpriv->pallocated_recv_buf = rtw_zmalloc(n); if (precvpriv->pallocated_recv_buf == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; } precvpriv->precv_buf = (u8*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); // init each recv buffer precvbuf = (struct recv_buf*)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { res = initrecvbuf(precvbuf, padapter); if (res == _FAIL) break; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) { freerecvbuf(precvbuf); break; } #ifdef CONFIG_SDIO_RX_COPY if (precvbuf->pskb == NULL) { SIZE_PTR tmpaddr=0; SIZE_PTR alignment=0; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) // http://www.mail-archive.com/[email protected]/msg17214.html precvbuf->pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #else precvbuf->pskb = netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #endif if(precvbuf->pskb) { precvbuf->pskb->dev = padapter->pnetdev; tmpaddr = (SIZE_PTR)precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); } if (precvbuf->pskb == NULL) { DBG_871X("%s: alloc_skb fail!\n", __FUNCTION__); } } #endif rtw_list_insert_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = i; if (res == _FAIL) goto initbuferror; //3 2. init tasklet #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))rtl8723as_recv_tasklet, (unsigned long)padapter); #endif goto exit; initbuferror: precvbuf = (struct recv_buf*)precvpriv->precv_buf; if (precvbuf) { n = precvpriv->free_recv_buf_queue_cnt; precvpriv->free_recv_buf_queue_cnt = 0; for (i = 0; i < n ; i++) { rtw_list_delete(&precvbuf->list); rtw_os_recvbuf_resource_free(padapter, precvbuf); freerecvbuf(precvbuf); precvbuf++; } precvpriv->precv_buf = NULL; } if (precvpriv->pallocated_recv_buf) { n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; rtw_mfree(precvpriv->pallocated_recv_buf, n); precvpriv->pallocated_recv_buf = NULL; } exit: return res; }
/* * Initialize recv private variable for hardware dependent * 1. recv buf * 2. recv tasklet * */ s32 rtl8723as_init_recv_priv(PADAPTER padapter) { s32 res; u32 i, n; struct recv_priv *precvpriv; struct recv_buf *precvbuf; res = _SUCCESS; precvpriv = &padapter->recvpriv; //3 1. init recv buffer _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; precvpriv->pallocated_recv_buf = rtw_zmalloc(n); if (precvpriv->pallocated_recv_buf == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; } precvpriv->precv_buf = (u8*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); // init each recv buffer precvbuf = (struct recv_buf*)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { res = initrecvbuf(precvbuf, padapter); if (res == _FAIL) break; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) { freerecvbuf(precvbuf); break; } rtw_list_insert_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = i; if (res == _FAIL) goto initbuferror; //3 2. init tasklet #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))rtl8723as_recv_tasklet, (unsigned long)padapter); #endif goto exit; initbuferror: precvbuf = (struct recv_buf*)precvpriv->precv_buf; if (precvbuf) { n = precvpriv->free_recv_buf_queue_cnt; precvpriv->free_recv_buf_queue_cnt = 0; for (i = 0; i < n ; i++) { rtw_list_delete(&precvbuf->list); rtw_os_recvbuf_resource_free(padapter, precvbuf); freerecvbuf(precvbuf); precvbuf++; } precvpriv->precv_buf = NULL; } if (precvpriv->pallocated_recv_buf) { n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; rtw_mfree(precvpriv->pallocated_recv_buf, n); precvpriv->pallocated_recv_buf = NULL; } exit: return res; }
/* * Initialize recv private variable for hardware dependent * 1. recv buf * 2. recv tasklet * */ s32 rtl8723bs_init_recv_priv(PADAPTER padapter) { s32 res; u32 i, n; struct recv_priv *precvpriv; struct recv_buf *precvbuf; res = _SUCCESS; precvpriv = &padapter->recvpriv; /* 3 1. init recv buffer */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; precvpriv->pallocated_recv_buf = rtw_zmalloc(n); if (precvpriv->pallocated_recv_buf == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; } precvpriv->precv_buf = (u8*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); /* init each recv buffer */ precvbuf = (struct recv_buf*)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { res = initrecvbuf(precvbuf, padapter); if (res == _FAIL) break; if (precvbuf->pskb == NULL) { SIZE_PTR tmpaddr =0; SIZE_PTR alignment =0; precvbuf->pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); if (precvbuf->pskb) { precvbuf->pskb->dev = padapter->pnetdev; tmpaddr = (SIZE_PTR)precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); } if (precvbuf->pskb == NULL) { DBG_871X("%s: alloc_skb fail!\n", __FUNCTION__); } } list_add_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = i; if (res == _FAIL) goto initbuferror; /* 3 2. init tasklet */ tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))rtl8723bs_recv_tasklet, (unsigned long)padapter); goto exit; initbuferror: precvbuf = (struct recv_buf*)precvpriv->precv_buf; if (precvbuf) { n = precvpriv->free_recv_buf_queue_cnt; precvpriv->free_recv_buf_queue_cnt = 0; for (i = 0; i < n ; i++) { list_del_init(&precvbuf->list); rtw_os_recvbuf_resource_free(padapter, precvbuf); precvbuf++; } precvpriv->precv_buf = NULL; } if (precvpriv->pallocated_recv_buf) { n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; kfree(precvpriv->pallocated_recv_buf); precvpriv->pallocated_recv_buf = NULL; } exit: return res; }
void usb_free_recv_priv (_adapter *padapter, u16 ini_in_buf_sz) { int i; struct recv_buf *precvbuf; struct recv_priv *precvpriv = &padapter->recvpriv; precvbuf = (struct recv_buf *)precvpriv->precv_buf; for(i=0; i < NR_RECVBUFF ; i++) { rtw_os_recvbuf_resource_free(padapter, precvbuf); precvbuf++; } if(precvpriv->pallocated_recv_buf) rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF *sizeof(struct recv_buf) + 4); #ifdef CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX if(precvpriv->int_in_urb) { usb_free_urb(precvpriv->int_in_urb); } #endif if(precvpriv->int_in_buf) rtw_mfree(precvpriv->int_in_buf, ini_in_buf_sz); #endif /* CONFIG_USB_INTERRUPT_IN_PIPE */ #ifdef PLATFORM_LINUX if (skb_queue_len(&precvpriv->rx_skb_queue)) { DBG_8192C(KERN_WARNING "rx_skb_queue not empty\n"); } rtw_skb_queue_purge(&precvpriv->rx_skb_queue); if (skb_queue_len(&precvpriv->free_recv_skb_queue)) { DBG_8192C(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); } #if !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX) #if defined(CONFIG_PREALLOC_RECV_SKB) && defined(CONFIG_PREALLOC_RX_SKB_BUFFER) { struct sk_buff *skb; while ((skb = skb_dequeue(&precvpriv->free_recv_skb_queue)) != NULL) { if (rtw_free_skb_premem(skb) != 0) rtw_skb_free(skb); } } #else rtw_skb_queue_purge(&precvpriv->free_recv_skb_queue); #endif /* defined(CONFIG_PREALLOC_RX_SKB_BUFFER) && defined(CONFIG_PREALLOC_RECV_SKB) */ #endif /* !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX) */ #endif /* PLATFORM_LINUX */ #ifdef PLATFORM_FREEBSD struct sk_buff *pskb; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { rtw_skb_free(pskb); } #if !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX) rtw_skb_queue_purge(&precvpriv->free_recv_skb_queue); #endif #ifdef CONFIG_RX_INDICATE_QUEUE struct mbuf *m; for (;;) { IF_DEQUEUE(&precvpriv->rx_indicate_queue, m); if (m == NULL) break; m_freem(m); } mtx_destroy(&precvpriv->rx_indicate_queue.ifq_mtx); #endif /* CONFIG_RX_INDICATE_QUEUE */ #endif /* PLATFORM_FREEBSD */ }