2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2014-12-19 06:59:46 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _RTL8188EU_RECV_C_
|
2014-12-17 04:09:56 +00:00
|
|
|
#include <drv_conf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <recv_osdep.h>
|
|
|
|
#include <mlme_osdep.h>
|
|
|
|
#include <ip.h>
|
|
|
|
#include <if_ether.h>
|
|
|
|
#include <ethernet.h>
|
|
|
|
|
|
|
|
#include <usb_ops.h>
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <wifi.h>
|
2014-12-17 04:09:56 +00:00
|
|
|
#include <circ_buf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
#include <rtl8188e_hal.h>
|
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->transfer_len = 0;
|
|
|
|
|
|
|
|
precvbuf->len = 0;
|
|
|
|
|
|
|
|
precvbuf->ref_cnt = 0;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (precvbuf->pbuf)
|
2014-12-17 04:09:56 +00:00
|
|
|
{
|
|
|
|
precvbuf->pdata = precvbuf->phead = precvbuf->ptail = precvbuf->pbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ;
|
|
|
|
}
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
int rtl8188eu_init_recv_priv(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
|
|
|
int i, res = _SUCCESS;
|
|
|
|
struct recv_buf *precvbuf;
|
|
|
|
|
|
|
|
tasklet_init(&precvpriv->recv_tasklet,
|
2014-12-17 04:09:56 +00:00
|
|
|
(void(*)(unsigned long))rtl8188eu_recv_tasklet,
|
|
|
|
(unsigned long)padapter);
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_INTERRUPT_IN_PIPE
|
|
|
|
precvpriv->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (precvpriv->int_in_urb == NULL) {
|
2014-12-17 04:09:56 +00:00
|
|
|
res= _FAIL;
|
|
|
|
DBG_8192C("alloc_urb for interrupt in endpoint fail !!!!\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
precvpriv->int_in_buf = rtw_zmalloc(INTERRUPT_MSG_FORMAT_LEN);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (precvpriv->int_in_buf == NULL) {
|
2014-12-17 04:09:56 +00:00
|
|
|
res= _FAIL;
|
|
|
|
DBG_8192C("alloc_mem for interrupt in endpoint fail !!!!\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 00:51:33 +00:00
|
|
|
/* init recv_buf */
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&precvpriv->free_recv_buf_queue);
|
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF *sizeof(struct recv_buf) + 4);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (precvpriv->pallocated_recv_buf== NULL) {
|
2014-12-17 04:09:56 +00:00
|
|
|
res= _FAIL;
|
|
|
|
RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("alloc recv_buf fail!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF *sizeof(struct recv_buf) + 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
precvbuf = (struct recv_buf*)precvpriv->precv_buf;
|
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i < NR_RECVBUFF ; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&precvbuf->list);
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2015-03-05 20:42:30 +00:00
|
|
|
spin_lock_init(&precvbuf->recvbuf_lock);
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->alloc_sz = MAX_RECVBUF_SZ;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (res==_FAIL)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->ref_cnt = 0;
|
2014-12-17 04:09:56 +00:00
|
|
|
precvbuf->adapter =padapter;
|
|
|
|
|
|
|
|
|
2018-08-30 18:19:58 +00:00
|
|
|
/* rtw_list_insert_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue); */
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf++;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
skb_queue_head_init(&precvpriv->rx_skb_queue);
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
2014-12-17 04:09:56 +00:00
|
|
|
SIZE_PTR tmpaddr=0;
|
|
|
|
SIZE_PTR alignment=0;
|
2015-08-15 18:31:56 +00:00
|
|
|
struct sk_buff *pskb= NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
skb_queue_head_init(&precvpriv->free_recv_skb_queue);
|
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i<NR_PREALLOC_RECV_SKB; i++)
|
2014-12-17 04:09:56 +00:00
|
|
|
{
|
|
|
|
pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pskb)
|
2014-12-17 04:09:56 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pskb->dev = padapter->pnetdev;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
|
|
|
tmpaddr = (SIZE_PTR)pskb->data;
|
2013-05-08 21:45:39 +00:00
|
|
|
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
|
|
|
|
skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
|
|
|
|
|
|
|
|
skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
|
|
|
|
}
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2015-08-15 18:31:56 +00:00
|
|
|
pskb= NULL;
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 04:09:56 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtl8188eu_free_recv_priv (struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct recv_buf *precvbuf;
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
|
|
|
|
|
|
|
precvbuf = (struct recv_buf *)precvpriv->precv_buf;
|
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i < NR_RECVBUFF ; i++)
|
2014-12-17 04:09:56 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_recvbuf_resource_free(padapter, precvbuf);
|
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (precvpriv->pallocated_recv_buf)
|
2014-12-17 04:09:56 +00:00
|
|
|
rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF *sizeof(struct recv_buf) + 4);
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_INTERRUPT_IN_PIPE
|
2015-08-15 18:02:34 +00:00
|
|
|
if (precvpriv->int_in_urb)
|
2014-12-17 04:09:56 +00:00
|
|
|
usb_free_urb(precvpriv->int_in_urb);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (precvpriv->int_in_buf)
|
2014-12-17 04:09:56 +00:00
|
|
|
rtw_mfree(precvpriv->int_in_buf, INTERRUPT_MSG_FORMAT_LEN);
|
2015-02-20 00:51:33 +00:00
|
|
|
#endif/* CONFIG_USB_INTERRUPT_IN_PIPE */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
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);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 04:09:56 +00:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
rtw_skb_queue_purge(&precvpriv->free_recv_skb_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|