2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2013-05-19 04:28:07 +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_
|
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <recv_osdep.h>
|
|
|
|
#include <mlme_osdep.h>
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
#include <usb_ops_linux.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <wifi.h>
|
|
|
|
|
|
|
|
#include <rtl8188e_hal.h>
|
|
|
|
|
2013-07-27 01:08:39 +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,
|
2013-08-09 03:23:49 +00:00
|
|
|
(void(*)(unsigned long))rtl8188eu_recv_tasklet,
|
|
|
|
(unsigned long)padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* init recv_buf */
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&precvpriv->free_recv_buf_queue);
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
precvpriv->pallocated_recv_buf =
|
|
|
|
kzalloc(NR_RECVBUFF * sizeof(struct recv_buf), GFP_KERNEL);
|
2013-08-09 03:23:49 +00:00
|
|
|
if (precvpriv->pallocated_recv_buf == NULL) {
|
|
|
|
res = _FAIL;
|
2014-11-16 00:18:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
|
|
|
|
("alloc recv_buf fail!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
precvpriv->precv_buf = precvpriv->pallocated_recv_buf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
precvbuf = (struct recv_buf *)precvpriv->precv_buf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
for (i = 0; i < NR_RECVBUFF; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf);
|
2013-08-09 03:23:49 +00:00
|
|
|
if (res == _FAIL)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-08-09 03:23:49 +00:00
|
|
|
precvbuf->adapter = padapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF;
|
|
|
|
skb_queue_head_init(&precvpriv->rx_skb_queue);
|
|
|
|
{
|
|
|
|
int i;
|
2013-08-09 03:23:49 +00:00
|
|
|
size_t tmpaddr = 0;
|
2014-11-16 00:18:30 +00:00
|
|
|
size_t alignm = 0;
|
2013-08-09 03:23:49 +00:00
|
|
|
struct sk_buff *pskb = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
skb_queue_head_init(&precvpriv->free_recv_skb_queue);
|
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) {
|
2014-11-16 00:18:30 +00:00
|
|
|
pskb = __netdev_alloc_skb(padapter->pnetdev,
|
|
|
|
MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ,
|
|
|
|
GFP_KERNEL);
|
2013-08-09 03:23:49 +00:00
|
|
|
if (pskb) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pskb->dev = padapter->pnetdev;
|
2013-07-24 17:19:14 +00:00
|
|
|
tmpaddr = (size_t)pskb->data;
|
2014-11-16 00:18:30 +00:00
|
|
|
alignm = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
|
|
|
|
skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignm));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
skb_queue_tail(&precvpriv->free_recv_skb_queue,
|
|
|
|
pskb);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-09 03:23:49 +00:00
|
|
|
pskb = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-08-09 03:23:49 +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;
|
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
for (i = 0; i < NR_RECVBUFF; i++) {
|
2014-11-16 00:18:30 +00:00
|
|
|
usb_free_urb(precvbuf->purb);
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(precvpriv->pallocated_recv_buf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-11 05:30:22 +00:00
|
|
|
if (skb_queue_len(&precvpriv->rx_skb_queue))
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E(KERN_WARNING "rx_skb_queue not empty\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
skb_queue_purge(&precvpriv->rx_skb_queue);
|
|
|
|
|
|
|
|
|
2013-07-11 05:30:22 +00:00
|
|
|
if (skb_queue_len(&precvpriv->free_recv_skb_queue))
|
2014-11-16 00:18:30 +00:00
|
|
|
DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n",
|
|
|
|
skb_queue_len(&precvpriv->free_recv_skb_queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
skb_queue_purge(&precvpriv->free_recv_skb_queue);
|
|
|
|
}
|