2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 _RECV_OSDEP_C_
|
|
|
|
|
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
|
|
|
|
#include <wifi.h>
|
|
|
|
#include <recv_osdep.h>
|
|
|
|
|
|
|
|
#include <osdep_intf.h>
|
|
|
|
#include <ethernet.h>
|
|
|
|
#include <usb_ops.h>
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
/* init os related resource in struct recv_priv */
|
|
|
|
int rtw_os_recv_resource_init(struct recv_priv *precvpriv,
|
|
|
|
struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-11 03:17:11 +00:00
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
/* alloc os related resource in struct recv_frame */
|
2013-08-11 03:17:11 +00:00
|
|
|
int rtw_os_recv_resource_alloc(struct adapter *padapter,
|
2014-12-13 16:35:48 +00:00
|
|
|
struct recv_frame *precvframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-13 16:35:48 +00:00
|
|
|
precvframe->pkt_newalloc = NULL;
|
|
|
|
precvframe->pkt = NULL;
|
2013-08-11 03:17:11 +00:00
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
/* free os related resource in struct recv_frame */
|
2013-05-08 21:45:39 +00:00
|
|
|
void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
/* alloc os related resource in struct recv_buf */
|
|
|
|
int rtw_os_recvbuf_resource_alloc(struct adapter *padapter,
|
|
|
|
struct recv_buf *precvbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-11 03:17:11 +00:00
|
|
|
int res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
precvbuf->irp_pending = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
|
2013-08-11 03:17:11 +00:00
|
|
|
if (precvbuf->purb == NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
precvbuf->pskb = NULL;
|
2013-05-26 03:02:10 +00:00
|
|
|
precvbuf->reuse = false;
|
2013-08-11 03:17:11 +00:00
|
|
|
precvbuf->pallocated_buf = NULL;
|
|
|
|
precvbuf->pbuf = NULL;
|
|
|
|
precvbuf->pdata = NULL;
|
|
|
|
precvbuf->phead = NULL;
|
|
|
|
precvbuf->ptail = NULL;
|
|
|
|
precvbuf->pend = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
precvbuf->transfer_len = 0;
|
|
|
|
precvbuf->len = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
/* free os related resource in struct recv_buf */
|
|
|
|
int rtw_os_recvbuf_resource_free(struct adapter *padapter,
|
|
|
|
struct recv_buf *precvbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
usb_free_urb(precvbuf->purb);
|
2013-07-13 02:22:50 +00:00
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
union iwreq_data wrqu;
|
|
|
|
struct iw_michaelmicfailure ev;
|
2013-08-11 03:17:11 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 cur_time = 0;
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
if (psecuritypriv->last_mic_err_time == 0) {
|
2014-12-13 21:18:54 +00:00
|
|
|
psecuritypriv->last_mic_err_time = jiffies;
|
2013-08-11 03:17:11 +00:00
|
|
|
} else {
|
2014-12-13 21:18:54 +00:00
|
|
|
cur_time = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) {
|
2013-05-26 03:02:10 +00:00
|
|
|
psecuritypriv->btkip_countermeasure = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->last_mic_err_time = 0;
|
|
|
|
psecuritypriv->btkip_countermeasure_time = cur_time;
|
2013-08-11 03:17:11 +00:00
|
|
|
} else {
|
2014-12-13 21:18:54 +00:00
|
|
|
psecuritypriv->last_mic_err_time = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(&ev, 0x00, sizeof(ev));
|
2013-08-11 03:17:11 +00:00
|
|
|
if (bgroup)
|
|
|
|
ev.flags |= IW_MICFAILURE_GROUP;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-08-11 03:17:11 +00:00
|
|
|
ev.flags |= IW_MICFAILURE_PAIRWISE;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ev.src_addr.sa_family = ARPHRD_ETHER;
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(&wrqu, 0x00, sizeof(wrqu));
|
2013-08-11 03:17:11 +00:00
|
|
|
wrqu.data.length = sizeof(ev);
|
|
|
|
wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE,
|
|
|
|
&wrqu, (char *)&ev);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
void rtw_hostapd_mlme_rx(struct adapter *padapter,
|
2014-12-13 16:35:48 +00:00
|
|
|
struct recv_frame *precv_frame)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
int rtw_recv_indicatepkt(struct adapter *padapter,
|
2014-12-13 16:35:48 +00:00
|
|
|
struct recv_frame *precv_frame)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct recv_priv *precvpriv;
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_recv_queue;
|
2013-07-24 22:03:54 +00:00
|
|
|
struct sk_buff *skb;
|
2013-08-11 03:17:11 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
precvpriv = &(padapter->recvpriv);
|
|
|
|
pfree_recv_queue = &(precvpriv->free_recv_queue);
|
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
skb = precv_frame->pkt;
|
2013-07-12 06:29:15 +00:00
|
|
|
if (skb == NULL) {
|
2013-08-11 03:17:11 +00:00
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_err_,
|
|
|
|
("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto _recv_indicatepkt_drop;
|
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
|
|
|
|
("rtw_recv_indicatepkt():skb != NULL !!!\n"));
|
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
|
2014-12-13 16:35:48 +00:00
|
|
|
("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n",
|
|
|
|
precv_frame->rx_head, precv_frame->rx_data));
|
2013-08-11 03:17:11 +00:00
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
|
2014-12-13 16:35:48 +00:00
|
|
|
("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n",
|
|
|
|
precv_frame->rx_tail, precv_frame->rx_end,
|
|
|
|
precv_frame->len));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
skb->data = precv_frame->rx_data;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
skb_set_tail_pointer(skb, precv_frame->len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
skb->len = precv_frame->len;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
|
|
|
|
("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n",
|
|
|
|
skb->head, skb->data, skb_tail_pointer(skb),
|
|
|
|
skb_end_pointer(skb), skb->len));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
|
|
|
struct sk_buff *pskb2 = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2014-12-13 16:35:48 +00:00
|
|
|
struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
|
2013-05-08 21:45:39 +00:00
|
|
|
int bmcast = IS_MCAST(pattrib->dst);
|
|
|
|
|
2014-12-13 15:38:17 +00:00
|
|
|
if (memcmp(pattrib->dst, myid(&padapter->eeprompriv),
|
2013-08-11 03:17:11 +00:00
|
|
|
ETH_ALEN)) {
|
2013-05-17 21:52:06 +00:00
|
|
|
if (bmcast) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_bcmc_stainfo(padapter);
|
|
|
|
pskb2 = skb_clone(skb, GFP_ATOMIC);
|
|
|
|
} else {
|
|
|
|
psta = rtw_get_stainfo(pstapriv, pattrib->dst);
|
|
|
|
}
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
if (psta) {
|
|
|
|
struct net_device *pnetdev;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
pnetdev = (struct net_device *)padapter->pnetdev;
|
2013-05-19 04:28:07 +00:00
|
|
|
skb->dev = pnetdev;
|
2013-05-08 21:45:39 +00:00
|
|
|
skb_set_queue_mapping(skb, rtw_recv_select_queue(skb));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_xmit_entry(skb, pnetdev);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (bmcast)
|
2013-05-08 21:45:39 +00:00
|
|
|
skb = pskb2;
|
|
|
|
else
|
|
|
|
goto _recv_indicatepkt_end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rcu_read_lock();
|
2014-02-12 17:05:30 +00:00
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
|
2013-10-19 17:45:47 +00:00
|
|
|
rcu_dereference(padapter->pnetdev->rx_handler_data);
|
2014-02-12 17:05:30 +00:00
|
|
|
#else
|
|
|
|
rcu_dereference(padapter->pnetdev->br_port);
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
skb->ip_summed = CHECKSUM_NONE;
|
|
|
|
skb->dev = padapter->pnetdev;
|
|
|
|
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
|
|
|
|
|
|
|
|
netif_rx(skb);
|
|
|
|
|
|
|
|
_recv_indicatepkt_end:
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
/* pointers to NULL before rtw_free_recvframe() */
|
2014-12-13 16:35:48 +00:00
|
|
|
precv_frame->pkt = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_free_recvframe(precv_frame, pfree_recv_queue);
|
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
|
|
|
|
("\n rtw_recv_indicatepkt :after netif_rx!!!!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_recv_indicatepkt_drop:
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
/* enqueue back to free_recv_queue */
|
|
|
|
rtw_free_recvframe(precv_frame, pfree_recv_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-11 03:17:11 +00:00
|
|
|
return _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
|
|
|
|
|
|
|
precvbuf->ref_cnt--;
|
2013-08-11 03:17:11 +00:00
|
|
|
/* free skb in recv_buf */
|
2013-05-08 21:45:39 +00:00
|
|
|
dev_kfree_skb_any(precvbuf->pskb);
|
|
|
|
precvbuf->pskb = NULL;
|
2013-05-26 03:02:10 +00:00
|
|
|
precvbuf->reuse = false;
|
2013-08-11 03:17:11 +00:00
|
|
|
if (!precvbuf->irp_pending)
|
|
|
|
rtw_read_port(padapter, precvpriv->ff_hwaddr, 0,
|
|
|
|
(unsigned char *)precvbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-11 18:35:36 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static void _rtw_reordering_ctrl_timeout_handler(void *func_context)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-11 03:17:11 +00:00
|
|
|
struct recv_reorder_ctrl *preorder_ctrl;
|
|
|
|
|
|
|
|
preorder_ctrl = (struct recv_reorder_ctrl *)func_context;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_reordering_ctrl_timeout_handler(preorder_ctrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
|
|
|
|
{
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = preorder_ctrl->padapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl);
|
|
|
|
}
|