2013-05-08 21:45:39 +00:00
/******************************************************************************
*
* Copyright ( c ) 2007 - 2012 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 _RTW_RECV_C_
2014-12-11 21:15:04 +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>
2015-01-30 03:41:53 +00:00
# include <usb_osintf.h>
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_BT_COEXIST
# include <rtl8723a_hal.h>
# endif
# include <wifi.h>
# include <circ_buf.h>
2013-09-06 10:09:58 +00:00
2013-05-08 21:45:39 +00:00
void rtw_signal_stat_timer_hdl ( RTW_TIMER_HDL_ARGS ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
void _rtw_init_sta_recv_priv ( struct sta_recv_priv * psta_recvpriv )
{
2014-12-01 22:31:15 +00:00
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-02-19 20:58:09 +00:00
memset ( ( u8 * ) psta_recvpriv , 0 , sizeof ( struct sta_recv_priv ) ) ;
2013-05-08 21:45:39 +00:00
2015-03-05 20:42:30 +00:00
spin_lock_init ( & psta_recvpriv - > lock ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
_rtw_init_queue ( & psta_recvpriv - > defrag_q ) ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
sint _rtw_init_recv_priv ( struct recv_priv * precvpriv , struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
sint i ;
2013-05-08 21:45:39 +00:00
union recv_frame * precvframe ;
2015-08-15 18:19:16 +00:00
sint res = _SUCCESS ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
/* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */
2014-12-11 21:15:04 +00:00
2015-03-05 20:42:30 +00:00
spin_lock_init ( & precvpriv - > lock ) ;
2013-05-08 21:45:39 +00:00
_rtw_init_queue ( & precvpriv - > free_recv_queue ) ;
_rtw_init_queue ( & precvpriv - > recv_pending_queue ) ;
_rtw_init_queue ( & precvpriv - > uc_swdec_pending_queue ) ;
precvpriv - > adapter = padapter ;
precvpriv - > free_recvframe_cnt = NR_RECVFRAME ;
rtw_os_recv_resource_init ( precvpriv , padapter ) ;
precvpriv - > pallocated_frame_buf = rtw_zvmalloc ( NR_RECVFRAME * sizeof ( union recv_frame ) + RXFRAME_ALIGN_SZ ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:24:16 +00:00
if ( precvpriv - > pallocated_frame_buf = = NULL ) {
2015-08-15 18:19:16 +00:00
res = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
precvpriv - > precv_frame_buf = ( u8 * ) N_BYTE_ALIGMENT ( ( SIZE_PTR ) ( precvpriv - > pallocated_frame_buf ) , RXFRAME_ALIGN_SZ ) ;
2015-02-19 21:34:32 +00:00
/* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */
/* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
precvframe = ( union recv_frame * ) precvpriv - > precv_frame_buf ;
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
for ( i = 0 ; i < NR_RECVFRAME ; i + + )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
_rtw_init_listhead ( & ( precvframe - > u . list ) ) ;
rtw_list_insert_tail ( & ( precvframe - > u . list ) , & ( precvpriv - > free_recv_queue . queue ) ) ;
res = rtw_os_recv_resource_alloc ( padapter , precvframe ) ;
precvframe - > u . hdr . len = 0 ;
2014-12-11 21:15:04 +00:00
precvframe - > u . hdr . adapter = padapter ;
2013-05-08 21:45:39 +00:00
precvframe + + ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
precvpriv - > rx_pending_cnt = 1 ;
2013-05-08 21:45:39 +00:00
_rtw_init_sema ( & precvpriv - > allrxreturnevt , 0 ) ;
res = rtw_hal_init_recv_priv ( padapter ) ;
_init_timer ( & precvpriv - > signal_stat_timer , padapter - > pnetdev , RTW_TIMER_HDL_NAME ( signal_stat ) , padapter ) ;
2015-02-19 21:34:32 +00:00
precvpriv - > signal_stat_sampling_interval = 1000 ; /* ms */
2013-05-08 21:45:39 +00:00
rtw_set_signal_stat_timer ( precvpriv ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
exit :
return res ;
}
void _rtw_free_recv_priv ( struct recv_priv * precvpriv )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = precvpriv - > adapter ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
rtw_free_uc_swdec_pending_queue ( padapter ) ;
rtw_os_recv_resource_free ( precvpriv ) ;
2015-08-15 18:02:34 +00:00
if ( precvpriv - > pallocated_frame_buf ) {
2013-05-08 21:45:39 +00:00
rtw_vmfree ( precvpriv - > pallocated_frame_buf , NR_RECVFRAME * sizeof ( union recv_frame ) + RXFRAME_ALIGN_SZ ) ;
}
rtw_hal_free_recv_priv ( padapter ) ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-03-16 13:54:18 +00:00
union recv_frame * _rtw_alloc_recvframe ( struct __queue * pfree_recv_queue )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
union recv_frame * precvframe ;
2015-03-16 13:54:18 +00:00
struct list_head * plist , * phead ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv ;
2015-01-26 22:20:25 +00:00
;
2014-12-01 22:31:15 +00:00
2015-08-15 18:02:34 +00:00
if ( _rtw_queue_empty ( pfree_recv_queue ) = = true )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
precvframe = NULL ;
2014-12-11 21:15:04 +00:00
}
else
{
2013-05-08 21:45:39 +00:00
phead = get_list_head ( pfree_recv_queue ) ;
plist = get_next ( phead ) ;
precvframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
rtw_list_delete ( & precvframe - > u . hdr . list ) ;
2015-08-15 18:19:16 +00:00
padapter = precvframe - > u . hdr . adapter ;
2015-08-15 18:24:16 +00:00
if ( padapter ! = NULL ) {
2015-08-15 18:19:16 +00:00
precvpriv = & padapter - > recvpriv ;
2015-08-15 18:02:34 +00:00
if ( pfree_recv_queue = = & precvpriv - > free_recv_queue )
2013-05-08 21:45:39 +00:00
precvpriv - > free_recvframe_cnt - - ;
}
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return precvframe ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-03-16 13:54:18 +00:00
union recv_frame * rtw_alloc_recvframe ( struct __queue * pfree_recv_queue )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2013-05-08 21:45:39 +00:00
union recv_frame * precvframe ;
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pfree_recv_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
precvframe = _rtw_alloc_recvframe ( pfree_recv_queue ) ;
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & pfree_recv_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
return precvframe ;
}
void rtw_init_recvframe ( union recv_frame * precvframe , struct recv_priv * precvpriv )
{
/* Perry: This can be removed */
_rtw_init_listhead ( & precvframe - > u . hdr . list ) ;
2015-08-15 18:19:16 +00:00
precvframe - > u . hdr . len = 0 ;
2013-05-08 21:45:39 +00:00
}
2015-03-16 13:54:18 +00:00
int rtw_free_recvframe ( union recv_frame * precvframe , struct __queue * pfree_recv_queue )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2015-08-15 18:19:16 +00:00
struct adapter * padapter = precvframe - > u . hdr . adapter ;
2014-12-11 21:15:04 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( precvframe - > u . hdr . pkt ) {
2015-02-19 21:34:32 +00:00
rtw_skb_free ( precvframe - > u . hdr . pkt ) ; /* free skb by driver */
2013-05-08 21:45:39 +00:00
precvframe - > u . hdr . pkt = NULL ;
}
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & pfree_recv_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
rtw_list_delete ( & ( precvframe - > u . hdr . list ) ) ;
precvframe - > u . hdr . len = 0 ;
rtw_list_insert_tail ( & ( precvframe - > u . hdr . list ) , get_list_head ( pfree_recv_queue ) ) ;
2015-08-15 18:24:16 +00:00
if ( padapter ! = NULL ) {
2015-08-15 18:02:34 +00:00
if ( pfree_recv_queue = = & precvpriv - > free_recv_queue )
2013-05-08 21:45:39 +00:00
precvpriv - > free_recvframe_cnt + + ;
}
2015-03-10 16:18:03 +00:00
spin_unlock_bh ( & pfree_recv_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
}
2015-03-16 13:54:18 +00:00
sint _rtw_enqueue_recvframe ( union recv_frame * precvframe , struct __queue * queue )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
struct adapter * padapter = precvframe - > u . hdr . adapter ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* _rtw_init_listhead(&(precvframe->u.hdr.list)); */
2013-05-08 21:45:39 +00:00
rtw_list_delete ( & ( precvframe - > u . hdr . list ) ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
rtw_list_insert_tail ( & ( precvframe - > u . hdr . list ) , get_list_head ( queue ) ) ;
if ( padapter ! = NULL ) {
if ( queue = = & precvpriv - > free_recv_queue )
precvpriv - > free_recvframe_cnt + + ;
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
}
2015-03-16 13:54:18 +00:00
sint rtw_enqueue_recvframe ( union recv_frame * precvframe , struct __queue * queue )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
sint ret ;
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & queue - > lock ) ;
2013-05-08 21:45:39 +00:00
ret = _rtw_enqueue_recvframe ( precvframe , queue ) ;
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & queue - > lock ) ;
2013-05-08 21:45:39 +00:00
return ret ;
}
/*
caller : defrag ; recvframe_chk_defrag in recv_thread ( passive )
pframequeue : defrag_queue : will be accessed in recv_thread ( passive )
using spinlock to protect
*/
2015-03-16 13:54:18 +00:00
void rtw_free_recvframe_queue ( struct __queue * pframequeue , struct __queue * pfree_recv_queue )
2013-05-08 21:45:39 +00:00
{
2014-12-19 06:59:46 +00:00
union recv_frame * precvframe ;
2015-03-16 13:54:18 +00:00
struct list_head * plist , * phead ;
2013-05-08 21:45:39 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
_rtw_spinlock ( & pframequeue - > lock ) ;
2013-05-08 21:45:39 +00:00
phead = get_list_head ( pframequeue ) ;
plist = get_next ( phead ) ;
2015-08-15 18:04:12 +00:00
while ( rtw_end_of_queue_search ( phead , plist ) = = false )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
precvframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
plist = get_next ( plist ) ;
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
}
2014-12-11 21:15:04 +00:00
_rtw_spinunlock ( & pframequeue - > lock ) ;
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
u32 rtw_free_uc_swdec_pending_queue ( struct adapter * adapter )
2013-05-08 21:45:39 +00:00
{
u32 cnt = 0 ;
union recv_frame * pending_frame ;
2015-08-15 18:19:16 +00:00
while ( ( pending_frame = rtw_alloc_recvframe ( & adapter - > recvpriv . uc_swdec_pending_queue ) ) ) {
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( pending_frame , & adapter - > recvpriv . free_recv_queue ) ;
cnt + + ;
}
2014-12-11 21:15:04 +00:00
if ( cnt )
DBG_871X ( FUNC_ADPT_FMT " dequeue %d \n " , FUNC_ADPT_ARG ( adapter ) , cnt ) ;
2013-05-08 21:45:39 +00:00
return cnt ;
}
2014-12-11 21:15:04 +00:00
2015-03-16 13:54:18 +00:00
sint rtw_enqueue_recvbuf_to_head ( struct recv_buf * precvbuf , struct __queue * queue )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-11 21:15:04 +00:00
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & queue - > lock ) ;
2013-05-08 21:45:39 +00:00
rtw_list_delete ( & precvbuf - > list ) ;
rtw_list_insert_head ( & precvbuf - > list , get_list_head ( queue ) ) ;
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & queue - > lock ) ;
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
}
2015-03-16 13:54:18 +00:00
sint rtw_enqueue_recvbuf ( struct recv_buf * precvbuf , struct __queue * queue )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2014-12-11 21:15:04 +00:00
_enter_critical_ex ( & queue - > lock , & irqL ) ;
2013-05-08 21:45:39 +00:00
rtw_list_delete ( & precvbuf - > list ) ;
rtw_list_insert_tail ( & precvbuf - > list , get_list_head ( queue ) ) ;
2014-12-11 21:15:04 +00:00
_exit_critical_ex ( & queue - > lock , & irqL ) ;
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2015-03-16 13:54:18 +00:00
struct recv_buf * rtw_dequeue_recvbuf ( struct __queue * queue )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
2013-05-08 21:45:39 +00:00
struct recv_buf * precvbuf ;
2015-03-16 13:54:18 +00:00
struct list_head * plist , * phead ;
2014-12-11 21:15:04 +00:00
_enter_critical_ex ( & queue - > lock , & irqL ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( _rtw_queue_empty ( queue ) = = true )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
precvbuf = NULL ;
2014-12-11 21:15:04 +00:00
}
else
{
2013-05-08 21:45:39 +00:00
phead = get_list_head ( queue ) ;
plist = get_next ( phead ) ;
precvbuf = LIST_CONTAINOR ( plist , struct recv_buf , list ) ;
rtw_list_delete ( & precvbuf - > list ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
_exit_critical_ex ( & queue - > lock , & irqL ) ;
2013-05-08 21:45:39 +00:00
return precvbuf ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
sint recvframe_chkmic ( struct adapter * adapter , union recv_frame * precvframe ) ;
2015-08-15 18:24:16 +00:00
sint recvframe_chkmic ( struct adapter * adapter , union recv_frame * precvframe ) {
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
sint i , res = _SUCCESS ;
2013-05-08 21:45:39 +00:00
u32 datalen ;
u8 miccode [ 8 ] ;
2015-08-15 18:19:16 +00:00
u8 bmic_err = false , brpt_micerror = true ;
2014-12-11 21:15:04 +00:00
u8 * pframe , * payload , * pframemic ;
2013-05-08 21:45:39 +00:00
u8 * mickey ;
2015-08-15 18:19:16 +00:00
/* u8 *iv, rxdata_key_idx =0; */
2013-05-08 21:45:39 +00:00
struct sta_info * stainfo ;
2015-08-15 18:19:16 +00:00
struct rx_pkt_attrib * prxattrib = & precvframe - > u . hdr . attrib ;
struct security_priv * psecuritypriv = & adapter - > securitypriv ;
2013-05-08 21:45:39 +00:00
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
struct mlme_ext_info * pmlmeinfo = & ( pmlmeext - > mlmext_info ) ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
stainfo = rtw_get_stainfo ( & adapter - > stapriv , & prxattrib - > ta [ 0 ] ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( prxattrib - > encrypt = = _TKIP_ )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n recvframe_chkmic:prxattrib->encrypt ==_TKIP_ \n " ) ) ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n recvframe_chkmic:da =0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n " ,
prxattrib - > ra [ 0 ] , prxattrib - > ra [ 1 ] , prxattrib - > ra [ 2 ] , prxattrib - > ra [ 3 ] , prxattrib - > ra [ 4 ] , prxattrib - > ra [ 5 ] ) ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* calculate mic code */
2015-08-15 18:02:34 +00:00
if ( stainfo ! = NULL )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( IS_MCAST ( prxattrib - > ra ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
/* mickey =&psecuritypriv->dot118021XGrprxmickey.skey[0]; */
2015-02-19 21:34:32 +00:00
/* iv = precvframe->u.hdr.rx_data+prxattrib->hdrlen; */
/* rxdata_key_idx =( ((iv[3])>>6)&0x3) ; */
2015-08-15 18:19:16 +00:00
mickey = & psecuritypriv - > dot118021XGrprxmickey [ prxattrib - > key_index ] . skey [ 0 ] ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n recvframe_chkmic: bcmc key \n " ) ) ;
/* DBG_871X("\n recvframe_chkmic: bcmc key psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv key_id(%d)\n", */
/* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
if ( psecuritypriv - > binstallGrpkey = = false )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
res = _FAIL ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n recvframe_chkmic:didn't install group key!!!!!!!!!! \n " ) ) ;
2014-12-11 21:15:04 +00:00
DBG_871X ( " \n recvframe_chkmic:didn't install group key!!!!!!!!!! \n " ) ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-11 21:15:04 +00:00
}
else {
2015-08-15 18:19:16 +00:00
mickey = & stainfo - > dot11tkiprxmickey . skey [ 0 ] ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n recvframe_chkmic: unicast key \n " ) ) ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
datalen = precvframe - > u . hdr . len - prxattrib - > hdrlen - prxattrib - > iv_len - prxattrib - > icv_len - 8 ; /* icv_len included the mic code */
pframe = precvframe - > u . hdr . rx_data ;
payload = pframe + prxattrib - > hdrlen + prxattrib - > iv_len ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n prxattrib->iv_len =%d prxattrib->icv_len =%d \n " , prxattrib - > iv_len , prxattrib - > icv_len ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
rtw_seccalctkipmic ( mickey , pframe , payload , datalen , & miccode [ 0 ] , ( unsigned char ) prxattrib - > priority ) ; /* care the length of the data */
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
pframemic = payload + datalen ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
bmic_err = false ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < 8 ; i + + ) {
if ( miccode [ i ] ! = * ( pframemic + i ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x) " , i , miccode [ i ] , i , * ( pframemic + i ) ) ) ;
bmic_err = true ;
2013-05-08 21:45:39 +00:00
}
}
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( bmic_err = = true ) {
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n *(pframemic-8)-*(pframemic-1) =0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n " ,
2014-12-11 21:15:04 +00:00
* ( pframemic - 8 ) , * ( pframemic - 7 ) , * ( pframemic - 6 ) , * ( pframemic - 5 ) , * ( pframemic - 4 ) , * ( pframemic - 3 ) , * ( pframemic - 2 ) , * ( pframemic - 1 ) ) ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n *(pframemic-16)-*(pframemic-9) =0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n " ,
2014-12-11 21:15:04 +00:00
* ( pframemic - 16 ) , * ( pframemic - 15 ) , * ( pframemic - 14 ) , * ( pframemic - 13 ) , * ( pframemic - 12 ) , * ( pframemic - 11 ) , * ( pframemic - 10 ) , * ( pframemic - 9 ) ) ) ;
2013-05-08 21:45:39 +00:00
{
uint i ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n ======demp packet (len =%d) ====== \n " , precvframe - > u . hdr . len ) ) ;
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < precvframe - > u . hdr . len ; i = i + 8 ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x " ,
2014-12-11 21:15:04 +00:00
* ( precvframe - > u . hdr . rx_data + i ) , * ( precvframe - > u . hdr . rx_data + i + 1 ) ,
* ( precvframe - > u . hdr . rx_data + i + 2 ) , * ( precvframe - > u . hdr . rx_data + i + 3 ) ,
* ( precvframe - > u . hdr . rx_data + i + 4 ) , * ( precvframe - > u . hdr . rx_data + i + 5 ) ,
* ( precvframe - > u . hdr . rx_data + i + 6 ) , * ( precvframe - > u . hdr . rx_data + i + 7 ) ) ) ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n ======demp packet end [len =%d]====== \n " , precvframe - > u . hdr . len ) ) ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " \n hrdlen =%d, \n " , prxattrib - > hdrlen ) ) ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " ra =0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x psecuritypriv->binstallGrpkey =%d " ,
prxattrib - > ra [ 0 ] , prxattrib - > ra [ 1 ] , prxattrib - > ra [ 2 ] ,
prxattrib - > ra [ 3 ] , prxattrib - > ra [ 4 ] , prxattrib - > ra [ 5 ] , psecuritypriv - > binstallGrpkey ) ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* double check key_index for some timing issue , */
/* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
2015-08-15 18:19:16 +00:00
if ( ( IS_MCAST ( prxattrib - > ra ) = = true ) & & ( prxattrib - > key_index ! = pmlmeinfo - > key_index ) )
2014-12-29 02:13:24 +00:00
brpt_micerror = false ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ( prxattrib - > bdecrypted = = true ) & & ( brpt_micerror = = true ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
rtw_handle_tkip_mic_err ( adapter , ( u8 ) IS_MCAST ( prxattrib - > ra ) ) ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " mic error :prxattrib->bdecrypted =%d " , prxattrib - > bdecrypted ) ) ;
DBG_871X ( " mic error :prxattrib->bdecrypted =%d \n " , prxattrib - > bdecrypted ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
else
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " mic error :prxattrib->bdecrypted =%d " , prxattrib - > bdecrypted ) ) ;
DBG_871X ( " mic error :prxattrib->bdecrypted =%d \n " , prxattrib - > bdecrypted ) ;
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:19:16 +00:00
res = _FAIL ;
2014-12-11 21:15:04 +00:00
}
else {
2015-02-19 21:34:32 +00:00
/* mic checked ok */
2015-08-15 18:24:16 +00:00
if ( ( psecuritypriv - > bcheck_grpkey = = false ) & & ( IS_MCAST ( prxattrib - > ra ) = = true ) ) {
2014-12-29 02:13:24 +00:00
psecuritypriv - > bcheck_grpkey = true ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " psecuritypriv->bcheck_grpkey =true " ) ) ;
2013-05-08 21:45:39 +00:00
}
}
2014-12-11 21:15:04 +00:00
}
else
{
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvframe_chkmic: rtw_get_stainfo == NULL!!! \n " ) ) ;
2013-05-08 21:45:39 +00:00
}
recvframe_pull_tail ( precvframe , 8 ) ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return res ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
/* decrypt and set the ivlen, icvlen of the recv_frame */
static union recv_frame * decryptor ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
struct rx_pkt_attrib * prxattrib = & precv_frame - > u . hdr . attrib ;
2015-08-15 18:19:16 +00:00
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
union recv_frame * return_packet = precv_frame ;
u32 res = _SUCCESS ;
2014-12-01 22:31:15 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " prxstat->decrypted =%x prxattrib->encrypt = 0x%03x \n " , prxattrib - > bdecrypted , prxattrib - > encrypt ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( prxattrib - > encrypt > 0 ) {
2013-05-08 21:45:39 +00:00
u8 * iv = precv_frame - > u . hdr . rx_data + prxattrib - > hdrlen ;
2014-12-11 21:15:04 +00:00
prxattrib - > key_index = ( ( ( iv [ 3 ] ) > > 6 ) & 0x3 ) ;
2015-08-15 18:02:34 +00:00
if ( prxattrib - > key_index > WEP_KEYS )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:00:19 +00:00
DBG_871X ( " prxattrib->key_index(%d) > WEP_KEYS \n " , prxattrib - > key_index ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
switch ( prxattrib - > encrypt ) {
2014-12-11 21:15:04 +00:00
case _WEP40_ :
case _WEP104_ :
prxattrib - > key_index = psecuritypriv - > dot11PrivacyKeyIndex ;
break ;
2014-12-19 06:59:46 +00:00
case _TKIP_ :
case _AES_ :
2014-12-11 21:15:04 +00:00
default :
prxattrib - > key_index = psecuritypriv - > dot118021XGrpKeyid ;
break ;
2014-12-19 06:59:46 +00:00
}
}
2014-12-11 21:15:04 +00:00
}
2013-08-01 02:43:28 +00:00
2015-08-15 18:22:58 +00:00
if ( ( prxattrib - > encrypt > 0 ) & & ( ( prxattrib - > bdecrypted = = 0 ) | | ( psecuritypriv - > sw_decrypt = = true ) ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
psecuritypriv - > hw_decrypted = false ;
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DECRYPTOR
DBG_871X ( " prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d \n "
2015-08-15 18:19:16 +00:00
, prxattrib - > bdecrypted , prxattrib - > encrypt , psecuritypriv - > hw_decrypted ) ;
2014-12-11 21:15:04 +00:00
# endif
2013-05-08 21:45:39 +00:00
2015-08-15 18:24:16 +00:00
switch ( prxattrib - > encrypt ) {
2013-05-08 21:45:39 +00:00
case _WEP40_ :
case _WEP104_ :
rtw_wep_decrypt ( padapter , ( u8 * ) precv_frame ) ;
break ;
case _TKIP_ :
res = rtw_tkip_decrypt ( padapter , ( u8 * ) precv_frame ) ;
break ;
case _AES_ :
2014-12-11 21:15:04 +00:00
res = rtw_aes_decrypt ( padapter , ( u8 * ) precv_frame ) ;
2013-05-08 21:45:39 +00:00
break ;
2014-12-11 21:15:04 +00:00
default :
break ;
}
}
2015-08-15 18:19:16 +00:00
else if ( prxattrib - > bdecrypted = = 1
2014-12-11 21:15:04 +00:00
& & prxattrib - > encrypt > 0
2015-08-15 18:19:16 +00:00
& & ( psecuritypriv - > busetkipkey = = 1 | | prxattrib - > encrypt ! = _TKIP_ )
2014-12-11 21:15:04 +00:00
)
{
2015-08-15 18:19:16 +00:00
psecuritypriv - > hw_decrypted = true ;
2014-12-29 02:00:11 +00:00
# ifdef DBG_RX_DECRYPTOR
DBG_871X ( " prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d \n "
2015-08-15 18:19:16 +00:00
, prxattrib - > bdecrypted , prxattrib - > encrypt , psecuritypriv - > hw_decrypted ) ;
2014-12-29 02:00:11 +00:00
# endif
} else {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DECRYPTOR
DBG_871X ( " prxstat->bdecrypted:%d, prxattrib->encrypt:%d, psecuritypriv->hw_decrypted:%d \n "
2015-08-15 18:19:16 +00:00
, prxattrib - > bdecrypted , prxattrib - > encrypt , psecuritypriv - > hw_decrypted ) ;
2014-12-11 21:15:04 +00:00
# endif
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( res = = _FAIL )
2014-12-11 21:15:04 +00:00
{
2014-12-19 06:59:46 +00:00
rtw_free_recvframe ( return_packet , & padapter - > recvpriv . free_recv_queue ) ;
2013-05-08 21:45:39 +00:00
return_packet = NULL ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
else {
2014-12-29 02:13:24 +00:00
prxattrib - > bdecrypted = true ;
2013-05-08 21:45:39 +00:00
}
return return_packet ;
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
/* set the security information in the recv_frame */
2015-08-15 18:19:16 +00:00
static union recv_frame * portctrl ( struct adapter * adapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
u8 * psta_addr , * ptr ;
2013-05-08 21:45:39 +00:00
uint auth_alg ;
struct recv_frame_hdr * pfhdr ;
struct sta_info * psta ;
2014-12-11 21:15:04 +00:00
struct sta_priv * pstapriv ;
2013-05-08 21:45:39 +00:00
union recv_frame * prtnframe ;
2015-08-15 18:19:16 +00:00
u16 ether_type = 0 ;
2015-02-19 21:34:32 +00:00
u16 eapol_type = 0x888e ; /* for Funia BD's WPA issue */
2013-05-08 21:45:39 +00:00
struct rx_pkt_attrib * pattrib ;
2015-01-28 05:14:58 +00:00
__be16 be_tmp ;
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
pstapriv = & adapter - > stapriv ;
auth_alg = adapter - > securitypriv . dot11AuthAlgrthm ;
ptr = get_recvframe_data ( precv_frame ) ;
pfhdr = & precv_frame - > u . hdr ;
pattrib = & pfhdr - > attrib ;
psta_addr = pattrib - > ta ;
prtnframe = NULL ;
2014-11-20 06:12:27 +00:00
psta = rtw_get_stainfo ( pstapriv , psta_addr ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " ########portctrl:adapter->securitypriv.dot11AuthAlgrthm =%d \n " , adapter - > securitypriv . dot11AuthAlgrthm ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
if ( auth_alg = = 2 )
2014-12-11 21:15:04 +00:00
{
if ( ( psta ! = NULL ) & & ( psta - > ieee8021x_blocked ) )
{
2015-02-19 21:34:32 +00:00
/* blocked */
/* only accept EAPOL frame */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " ########portctrl:psta->ieee8021x_blocked ==1 \n " ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* get ether_type */
2015-08-15 18:19:16 +00:00
ptr = ptr + pfhdr - > attrib . hdrlen + pfhdr - > attrib . iv_len + LLC_HEADER_SIZE ;
2015-01-28 05:14:58 +00:00
memcpy ( & be_tmp , ptr , 2 ) ;
2015-08-15 18:19:16 +00:00
ether_type = ntohs ( be_tmp ) ;
2014-12-11 21:15:04 +00:00
if ( ether_type = = eapol_type ) {
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2014-12-11 21:15:04 +00:00
}
else {
2015-02-19 21:34:32 +00:00
/* free this frame */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precv_frame , & adapter - > recvpriv . free_recv_queue ) ;
2015-08-15 18:19:16 +00:00
prtnframe = NULL ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
}
else
{
2015-02-19 21:34:32 +00:00
/* allowed */
/* check decryption status, and decrypt the frame if needed */
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " ########portctrl:psta->ieee8021x_blocked == 0 \n " ) ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " portctrl:precv_frame->hdr.attrib.privacy =%x \n " , precv_frame - > u . hdr . attrib . privacy ) ) ;
2013-05-08 21:45:39 +00:00
if ( pattrib - > bdecrypted = = 0 )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " portctrl:prxstat->decrypted =%x \n " , pattrib - > bdecrypted ) ) ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2015-02-19 21:34:32 +00:00
/* check is the EAPOL frame or not (Rekey) */
2015-08-15 18:24:16 +00:00
if ( ether_type = = eapol_type ) {
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " ########portctrl:ether_type == 0x888e \n " ) ) ;
2015-02-19 21:34:32 +00:00
/* check Rekey */
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2014-12-11 21:15:04 +00:00
}
else {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " ########portctrl:ether_type =0x%04x \n " , ether_type ) ) ;
2013-05-08 21:45:39 +00:00
}
}
2014-12-11 21:15:04 +00:00
}
else
{
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2013-05-08 21:45:39 +00:00
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return prtnframe ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
sint recv_decache ( union recv_frame * precv_frame , u8 bretry , struct stainfo_rxcache * prxcache ) ;
sint recv_decache ( union recv_frame * precv_frame , u8 bretry , struct stainfo_rxcache * prxcache )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
sint tid = precv_frame - > u . hdr . attrib . priority ;
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
u16 seq_ctrl = ( ( precv_frame - > u . hdr . attrib . seq_num & 0xffff ) < < 4 ) |
2013-05-08 21:45:39 +00:00
( precv_frame - > u . hdr . attrib . frag_num & 0xf ) ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( tid > 15 )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " recv_decache, (tid>15)! seq_ctrl =0x%x, tid =0x%x \n " , seq_ctrl , tid ) ) ;
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
2015-08-15 18:02:34 +00:00
if ( 1 ) /* if (bretry) */
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( seq_ctrl = = prxcache - > tid_rxseq [ tid ] )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " recv_decache, seq_ctrl =0x%x, tid =0x%x, tid_rxseq =0x%x \n " , seq_ctrl , tid , prxcache - > tid_rxseq [ tid ] ) ) ;
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
}
prxcache - > tid_rxseq [ tid ] = seq_ctrl ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
void process_pwrbit_data ( struct adapter * padapter , union recv_frame * precv_frame ) ;
void process_pwrbit_data ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_AP_MODE
2013-05-08 21:45:39 +00:00
unsigned char pwrbit ;
u8 * ptr = precv_frame - > u . hdr . rx_data ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_priv * pstapriv = & padapter - > stapriv ;
2015-08-15 18:19:16 +00:00
struct sta_info * psta = NULL ;
2013-05-08 21:45:39 +00:00
psta = rtw_get_stainfo ( pstapriv , pattrib - > src ) ;
pwrbit = GetPwrMgt ( ptr ) ;
2015-08-15 18:02:34 +00:00
if ( psta )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( pwrbit )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( ! ( psta - > state & WIFI_SLEEP_STATE ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* psta->state |= WIFI_SLEEP_STATE; */
/* pstapriv->sta_dz_bitmap |= BIT(psta->aid); */
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
stop_sta_xmit ( padapter , psta ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
/* DBG_871X("to sleep, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */
2014-12-11 21:15:04 +00:00
}
}
else
{
2015-08-15 18:02:34 +00:00
if ( psta - > state & WIFI_SLEEP_STATE )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* psta->state ^= WIFI_SLEEP_STATE; */
/* pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); */
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
wakeup_sta_to_xmit ( padapter , psta ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
/* DBG_871X("to wakeup, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
# endif
}
2014-12-17 23:13:53 +00:00
void process_wmmps_data ( struct adapter * padapter , union recv_frame * precv_frame ) ;
void process_wmmps_data ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2014-12-19 06:59:46 +00:00
# ifdef CONFIG_AP_MODE
2013-05-08 21:45:39 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_priv * pstapriv = & padapter - > stapriv ;
2015-08-15 18:19:16 +00:00
struct sta_info * psta = NULL ;
2013-05-08 21:45:39 +00:00
psta = rtw_get_stainfo ( pstapriv , pattrib - > src ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( ! psta ) return ;
2013-05-19 04:28:07 +00:00
2015-08-15 18:02:34 +00:00
if ( ! psta - > qos_option )
2013-05-08 21:45:39 +00:00
return ;
2015-08-15 18:02:34 +00:00
if ( ! ( psta - > qos_info & 0xf ) )
2013-05-08 21:45:39 +00:00
return ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( psta - > state & WIFI_SLEEP_STATE )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
u8 wmmps_ac = 0 ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:05:44 +00:00
switch ( pattrib - > priority )
2014-12-11 21:15:04 +00:00
{
case 1 :
case 2 :
wmmps_ac = psta - > uapsd_bk & BIT ( 1 ) ;
break ;
case 4 :
case 5 :
wmmps_ac = psta - > uapsd_vi & BIT ( 1 ) ;
break ;
case 6 :
case 7 :
wmmps_ac = psta - > uapsd_vo & BIT ( 1 ) ;
break ;
case 0 :
case 3 :
default :
wmmps_ac = psta - > uapsd_be & BIT ( 1 ) ;
2014-12-19 06:59:46 +00:00
break ;
2014-12-11 21:15:04 +00:00
}
2013-05-19 04:28:07 +00:00
2015-08-15 18:02:34 +00:00
if ( wmmps_ac )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( psta - > sleepq_ac_len > 0 )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* process received triggered frame */
2014-12-11 21:15:04 +00:00
xmit_delivery_enabled_frames ( padapter , psta ) ;
}
else
{
2015-02-19 21:34:32 +00:00
/* issue one qos null frame with More data bit = 0 and the EOSP bit set (=1) */
2014-12-11 21:15:04 +00:00
issue_qos_nulldata ( padapter , psta - > hwaddr , ( u16 ) pattrib - > priority , 0 , 0 ) ;
}
}
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
2013-05-19 04:28:07 +00:00
2014-12-19 06:59:46 +00:00
# endif
2014-12-11 21:15:04 +00:00
}
2015-08-15 04:04:53 +00:00
static void count_rx_stats ( struct adapter * padapter , union recv_frame * prframe , struct sta_info * sta )
2013-05-08 21:45:39 +00:00
{
int sz ;
struct sta_info * psta = NULL ;
struct stainfo_stats * pstats = NULL ;
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2013-05-08 21:45:39 +00:00
sz = get_recvframe_len ( prframe ) ;
precvpriv - > rx_bytes + = sz ;
padapter - > mlmepriv . LinkDetectInfo . NumRxOkInPeriod + + ;
2015-08-15 18:24:16 +00:00
if ( ( ! MacAddr_isBcst ( pattrib - > dst ) ) & & ( ! IS_MCAST ( pattrib - > dst ) ) ) {
2013-05-08 21:45:39 +00:00
padapter - > mlmepriv . LinkDetectInfo . NumRxUnicastOkInPeriod + + ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( sta )
2013-05-08 21:45:39 +00:00
psta = sta ;
else
psta = prframe - > u . hdr . psta ;
2015-08-15 18:02:34 +00:00
if ( psta )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pstats = & psta - > sta_stats ;
pstats - > rx_data_pkts + + ;
pstats - > rx_bytes + = sz ;
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
sint sta2sta_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2013-05-08 21:45:39 +00:00
union recv_frame * precv_frame ,
2014-12-11 21:15:04 +00:00
struct sta_info * * psta
2013-05-08 21:45:39 +00:00
) ;
2014-12-11 21:15:04 +00:00
sint sta2sta_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2014-12-11 21:15:04 +00:00
union recv_frame * precv_frame ,
struct sta_info * * psta
)
2013-05-08 21:45:39 +00:00
{
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
sint ret = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2014-12-19 06:59:46 +00:00
struct sta_priv * pstapriv = & adapter - > stapriv ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2013-05-08 21:45:39 +00:00
u8 * mybssid = get_bssid ( pmlmepriv ) ;
u8 * myhwaddr = myid ( & adapter - > eeprompriv ) ;
2014-12-11 21:15:04 +00:00
u8 * sta_addr = NULL ;
sint bmcast = IS_MCAST ( pattrib - > dst ) ;
2014-12-29 02:13:24 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) = = true ) | |
( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = true ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* filter packets that SA is myself or multicast or broadcast */
2015-08-15 18:24:16 +00:00
if ( _rtw_memcmp ( myhwaddr , pattrib - > src , ETH_ALEN ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " SA ==myself \n " ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:24:16 +00:00
if ( ( ! _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) ) & & ( ! bmcast ) ) {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:02:34 +00:00
if ( _rtw_memcmp ( pattrib - > bssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
2014-12-11 21:15:04 +00:00
_rtw_memcmp ( mybssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) ) {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-07-12 01:13:07 +00:00
goto exit ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
sta_addr = pattrib - > src ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:02:34 +00:00
else if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
{
2015-02-19 21:34:32 +00:00
/* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */
2015-08-15 18:02:34 +00:00
if ( ! _rtw_memcmp ( pattrib - > bssid , pattrib - > src , ETH_ALEN ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " bssid != TA under STATION_MODE; drop pkt \n " ) ) ;
ret = _FAIL ;
2014-12-11 21:15:04 +00:00
goto exit ;
2015-03-10 16:18:03 +00:00
}
sta_addr = pattrib - > bssid ;
2014-12-11 21:15:04 +00:00
}
}
2015-08-15 18:02:34 +00:00
else if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
if ( bmcast )
{
2015-02-19 21:34:32 +00:00
/* For AP mode, if DA == MCAST, then BSSID should be also MCAST */
2015-08-15 18:24:16 +00:00
if ( ! IS_MCAST ( pattrib - > bssid ) ) {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2014-12-11 21:15:04 +00:00
goto exit ;
}
}
2015-02-19 21:34:32 +00:00
else /* not mc-frame */
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */
2015-08-15 18:02:34 +00:00
if ( ! _rtw_memcmp ( pattrib - > bssid , pattrib - > dst , ETH_ALEN ) ) {
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2014-12-11 21:15:04 +00:00
goto exit ;
}
sta_addr = pattrib - > src ;
}
}
2015-08-15 18:02:34 +00:00
else if ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , GetAddr2Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ra , pattrib - > dst , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pattrib - > src , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
sta_addr = mybssid ;
}
else
{
ret = _FAIL ;
}
2015-08-15 18:02:34 +00:00
if ( bmcast )
2014-12-11 21:15:04 +00:00
* psta = rtw_get_bcmc_stainfo ( adapter ) ;
else
2015-02-19 21:34:32 +00:00
* psta = rtw_get_stainfo ( pstapriv , sta_addr ) ; /* get ap_info */
2014-12-11 21:15:04 +00:00
if ( * psta = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " can't get psta under sta2sta_data_frame ; drop pkt \n " ) ) ;
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
exit :
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
sint ap2sta_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2013-05-08 21:45:39 +00:00
union recv_frame * precv_frame ,
2014-12-11 21:15:04 +00:00
struct sta_info * * psta ) ;
sint ap2sta_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2014-12-11 21:15:04 +00:00
union recv_frame * precv_frame ,
struct sta_info * * psta )
2013-05-08 21:45:39 +00:00
{
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
sint ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
struct sta_priv * pstapriv = & adapter - > stapriv ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2013-05-08 21:45:39 +00:00
u8 * mybssid = get_bssid ( pmlmepriv ) ;
u8 * myhwaddr = myid ( & adapter - > eeprompriv ) ;
2014-12-11 21:15:04 +00:00
sint bmcast = IS_MCAST ( pattrib - > dst ) ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = true )
& & ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true
| | check_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) = = true )
2014-12-11 21:15:04 +00:00
)
{
2015-02-19 21:34:32 +00:00
/* filter packets that SA is myself or multicast or broadcast */
2015-08-15 18:24:16 +00:00
if ( _rtw_memcmp ( myhwaddr , pattrib - > src , ETH_ALEN ) ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " SA ==myself \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
2015-08-15 18:19:16 +00:00
DBG_871X ( " DBG_RX_DROP_FRAME %s SA = " MAC_FMT " , myhwaddr = " MAC_FMT " \n " ,
2014-12-11 21:15:04 +00:00
__FUNCTION__ , MAC_ARG ( pattrib - > src ) , MAC_ARG ( myhwaddr ) ) ;
2014-12-19 06:59:46 +00:00
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* da should be for me */
2015-08-15 18:02:34 +00:00
if ( ( ! _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) ) & & ( ! bmcast ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ ,
( " ap2sta_data_frame: compare DA fail; DA = " MAC_FMT " \n " , MAC_ARG ( pattrib - > dst ) ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
2015-08-15 18:19:16 +00:00
DBG_871X ( " DBG_RX_DROP_FRAME %s DA = " MAC_FMT " \n " , __func__ , MAC_ARG ( pattrib - > dst ) ) ;
2014-12-11 21:15:04 +00:00
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2013-08-01 02:43:28 +00:00
2015-02-19 21:34:32 +00:00
/* check BSSID */
2015-08-15 18:02:34 +00:00
if ( _rtw_memcmp ( pattrib - > bssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
2014-12-11 21:15:04 +00:00
_rtw_memcmp ( mybssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ ,
( " ap2sta_data_frame: compare BSSID fail ; BSSID = " MAC_FMT " \n " , MAC_ARG ( pattrib - > bssid ) ) ) ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " mybssid = " MAC_FMT " \n " , MAC_ARG ( mybssid ) ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
2015-08-15 18:19:16 +00:00
DBG_871X ( " DBG_RX_DROP_FRAME %s BSSID = " MAC_FMT " , mybssid = " MAC_FMT " \n " ,
2014-12-11 21:15:04 +00:00
__FUNCTION__ , MAC_ARG ( pattrib - > bssid ) , MAC_ARG ( mybssid ) ) ;
DBG_871X ( " this adapter = %d, buddy adapter = %d \n " , adapter - > adapter_type , adapter - > pbuddy_adapter - > adapter_type ) ;
# endif
2015-08-15 18:02:34 +00:00
if ( ! bmcast )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
DBG_871X ( " issue_deauth to the nonassociated ap = " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > bssid ) ) ;
2013-05-08 21:45:39 +00:00
issue_deauth ( adapter , pattrib - > bssid , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
}
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:02:34 +00:00
if ( bmcast )
2013-05-08 21:45:39 +00:00
* psta = rtw_get_bcmc_stainfo ( adapter ) ;
else
2015-02-19 21:34:32 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > bssid ) ; /* get ap_info */
2013-05-08 21:45:39 +00:00
if ( * psta = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " ap2sta: can't get psta under STATION_MODE ; drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s can't get psta under STATION_MODE ; drop pkt \n " , __FUNCTION__ ) ;
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 21:34:32 +00:00
/* if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { */
/* */
2013-05-08 21:45:39 +00:00
if ( GetFrameSubType ( ptr ) & BIT ( 6 ) ) {
/* No data, will not indicate to upper layer, temporily count it here */
count_rx_stats ( adapter , precv_frame , * psta ) ;
ret = RTW_RX_HANDLED ;
goto exit ;
}
2014-12-11 21:15:04 +00:00
}
2014-12-29 02:13:24 +00:00
else if ( ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = true ) & &
( check_fwstate ( pmlmepriv , _FW_LINKED ) = = true ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , GetAddr2Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ra , pattrib - > dst , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pattrib - > src , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* */
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > bssid , mybssid , ETH_ALEN ) ;
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > bssid ) ; /* get sta_info */
2013-05-08 21:45:39 +00:00
if ( * psta = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " can't get psta under MP_MODE ; drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s can't get psta under WIFI_MP_STATE ; drop pkt \n " , __FUNCTION__ ) ;
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-11 21:15:04 +00:00
}
2014-12-29 02:13:24 +00:00
else if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
/* Special case */
ret = RTW_RX_HANDLED ;
goto exit ;
2014-12-11 21:15:04 +00:00
}
else
{
2015-08-15 18:02:34 +00:00
if ( _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) & & ( ! bmcast ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > bssid ) ; /* get sta_info */
2014-12-11 21:15:04 +00:00
if ( * psta = = NULL )
{
2015-08-15 18:19:16 +00:00
DBG_871X ( " issue_deauth to the ap = " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > bssid ) ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
issue_deauth ( adapter , pattrib - > bssid , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
}
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s fw_state:0x%x \n " , __FUNCTION__ , get_fwstate ( pmlmepriv ) ) ;
# endif
2013-05-08 21:45:39 +00:00
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
sint sta2ap_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2014-12-11 21:15:04 +00:00
union recv_frame * precv_frame ,
struct sta_info * * psta ) ;
sint sta2ap_data_frame (
2014-12-17 23:13:53 +00:00
struct adapter * adapter ,
2014-12-11 21:15:04 +00:00
union recv_frame * precv_frame ,
struct sta_info * * psta )
2013-05-08 21:45:39 +00:00
{
2013-10-19 17:45:47 +00:00
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2014-12-19 06:59:46 +00:00
struct sta_priv * pstapriv = & adapter - > stapriv ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2014-12-19 06:59:46 +00:00
unsigned char * mybssid = get_bssid ( pmlmepriv ) ;
2015-08-15 18:19:16 +00:00
sint ret = _SUCCESS ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = true )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
/* For AP mode, RA =BSSID, TX =STA(SRC_ADDR), A3 =DST_ADDR */
2015-08-15 18:02:34 +00:00
if ( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
* psta = rtw_get_stainfo ( pstapriv , pattrib - > src ) ;
2014-12-11 21:15:04 +00:00
if ( * psta = = NULL )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " can't get psta under AP_MODE; drop pkt \n " ) ) ;
DBG_871X ( " issue_deauth to sta = " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > src ) ) ;
2013-05-08 21:45:39 +00:00
issue_deauth ( adapter , pattrib - > src , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
ret = RTW_RX_HANDLED ;
goto exit ;
}
process_pwrbit_data ( adapter , precv_frame ) ;
if ( ( GetFrameSubType ( ptr ) & WIFI_QOS_DATA_TYPE ) = = WIFI_QOS_DATA_TYPE ) {
process_wmmps_data ( adapter , precv_frame ) ;
}
if ( GetFrameSubType ( ptr ) & BIT ( 6 ) ) {
/* No data, will not indicate to upper layer, temporily count it here */
count_rx_stats ( adapter , precv_frame , * psta ) ;
ret = RTW_RX_HANDLED ;
goto exit ;
}
2014-12-11 21:15:04 +00:00
}
else {
2013-05-08 21:45:39 +00:00
u8 * myhwaddr = myid ( & adapter - > eeprompriv ) ;
if ( ! _rtw_memcmp ( pattrib - > ra , myhwaddr , ETH_ALEN ) ) {
ret = RTW_RX_HANDLED ;
goto exit ;
}
2015-08-15 18:19:16 +00:00
DBG_871X ( " issue_deauth to sta = " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > src ) ) ;
2013-05-08 21:45:39 +00:00
issue_deauth ( adapter , pattrib - > src , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
ret = RTW_RX_HANDLED ;
goto exit ;
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
sint validate_recv_ctrl_frame ( struct adapter * padapter , union recv_frame * precv_frame ) ;
sint validate_recv_ctrl_frame ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_AP_MODE
2013-05-08 21:45:39 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_priv * pstapriv = & padapter - > stapriv ;
u8 * pframe = precv_frame - > u . hdr . rx_data ;
2015-02-19 21:34:32 +00:00
/* uint len = precv_frame->u.hdr.len; */
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* DBG_871X("+validate_recv_ctrl_frame\n"); */
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
if ( GetFrameType ( pframe ) ! = WIFI_CTRL_TYPE )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
return _FAIL ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* receive the frames that ra(a1) is my address */
2013-05-08 21:45:39 +00:00
if ( ! _rtw_memcmp ( GetAddr1Ptr ( pframe ) , myid ( & padapter - > eeprompriv ) , ETH_ALEN ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
return _FAIL ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* only handle ps-poll */
2015-08-15 18:02:34 +00:00
if ( GetFrameSubType ( pframe ) = = WIFI_PSPOLL )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
u16 aid ;
2015-08-15 18:19:16 +00:00
u8 wmmps_ac = 0 ;
struct sta_info * psta = NULL ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
aid = GetAid ( pframe ) ;
psta = rtw_get_stainfo ( pstapriv , GetAddr2Ptr ( pframe ) ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:22:58 +00:00
if ( ( psta = = NULL ) | | ( psta - > aid ! = aid ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
return _FAIL ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* for rx pkt statistics */
2013-05-08 21:45:39 +00:00
psta - > sta_stats . rx_ctrl_pkts + + ;
2015-08-15 18:05:44 +00:00
switch ( pattrib - > priority )
2014-12-11 21:15:04 +00:00
{
case 1 :
case 2 :
wmmps_ac = psta - > uapsd_bk & BIT ( 0 ) ;
break ;
case 4 :
case 5 :
wmmps_ac = psta - > uapsd_vi & BIT ( 0 ) ;
break ;
case 6 :
case 7 :
wmmps_ac = psta - > uapsd_vo & BIT ( 0 ) ;
break ;
case 0 :
case 3 :
default :
wmmps_ac = psta - > uapsd_be & BIT ( 0 ) ;
2014-12-19 06:59:46 +00:00
break ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:02:34 +00:00
if ( wmmps_ac )
2013-05-08 21:45:39 +00:00
return _FAIL ;
2015-08-15 18:02:34 +00:00
if ( psta - > state & WIFI_STA_ALIVE_CHK_STATE )
2014-12-19 06:59:46 +00:00
{
2014-12-11 21:15:04 +00:00
DBG_871X ( " %s alive check-rx ps-poll \n " , __func__ ) ;
2013-05-08 21:45:39 +00:00
psta - > expire_to = pstapriv - > expire_to ;
psta - > state ^ = WIFI_STA_ALIVE_CHK_STATE ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( ( psta - > state & WIFI_SLEEP_STATE ) & & ( pstapriv - > sta_dz_bitmap & BIT ( psta - > aid ) ) )
2014-12-11 21:15:04 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irqL ;
struct list_head * xmitframe_plist , * xmitframe_phead ;
2015-08-15 18:19:16 +00:00
struct xmit_frame * pxmitframe = NULL ;
2014-11-20 06:12:27 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
/* spin_lock_bh(&psta->sleep_q.lock); */
spin_lock_bh ( & pxmitpriv - > lock ) ;
2013-05-08 21:45:39 +00:00
xmitframe_phead = get_list_head ( & psta - > sleep_q ) ;
xmitframe_plist = get_next ( xmitframe_phead ) ;
2014-12-29 02:13:24 +00:00
if ( ( rtw_end_of_queue_search ( xmitframe_phead , xmitframe_plist ) ) = = false )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
pxmitframe = LIST_CONTAINOR ( xmitframe_plist , struct xmit_frame , list ) ;
xmitframe_plist = get_next ( xmitframe_plist ) ;
rtw_list_delete ( & pxmitframe - > list ) ;
psta - > sleepq_len - - ;
2015-08-15 18:02:34 +00:00
if ( psta - > sleepq_len > 0 )
2013-05-08 21:45:39 +00:00
pxmitframe - > attrib . mdata = 1 ;
2014-12-11 21:15:04 +00:00
else
2013-05-08 21:45:39 +00:00
pxmitframe - > attrib . mdata = 0 ;
pxmitframe - > attrib . triggered = 1 ;
2015-08-15 18:19:16 +00:00
/* DBG_871X("handling ps-poll, q_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */
2014-12-11 21:15:04 +00:00
2014-11-20 06:12:27 +00:00
rtw_hal_xmitframe_enqueue ( padapter , pxmitframe ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:22:58 +00:00
if ( psta - > sleepq_len = = 0 )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pstapriv - > tim_bitmap & = ~ BIT ( psta - > aid ) ;
2015-02-19 21:34:32 +00:00
/* upate BCN for TIM IE */
/* update_BCNTIM(padapter); */
2014-12-29 02:13:24 +00:00
update_beacon ( padapter , _TIM_IE_ , NULL , false ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2015-03-06 17:54:48 +00:00
/* spin_unlock_bh(&psta->sleep_q.lock); */
spin_unlock_bh ( & pxmitpriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
else
{
2015-03-06 17:54:48 +00:00
/* spin_unlock_bh(&psta->sleep_q.lock); */
spin_unlock_bh ( & pxmitpriv - > lock ) ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* DBG_871X("no buffered packets to xmit\n"); */
2015-08-15 18:02:34 +00:00
if ( pstapriv - > tim_bitmap & BIT ( psta - > aid ) )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:22:58 +00:00
if ( psta - > sleepq_len = = 0 )
2014-12-11 21:15:04 +00:00
{
DBG_871X ( " no buffered packets to xmit \n " ) ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
2013-05-08 21:45:39 +00:00
issue_nulldata ( padapter , psta - > hwaddr , 0 , 0 , 0 ) ;
}
2014-12-11 21:15:04 +00:00
else
{
2015-08-15 18:19:16 +00:00
DBG_871X ( " error!psta->sleepq_len =%d \n " , psta - > sleepq_len ) ;
psta - > sleepq_len = 0 ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
pstapriv - > tim_bitmap & = ~ BIT ( psta - > aid ) ;
2013-05-19 04:28:07 +00:00
2015-02-19 21:34:32 +00:00
/* upate BCN for TIM IE */
/* update_BCNTIM(padapter); */
2014-12-29 02:13:24 +00:00
update_beacon ( padapter , _TIM_IE_ , NULL , false ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
# endif
return _FAIL ;
2014-12-11 21:15:04 +00:00
}
2013-07-26 22:56:14 +00:00
2014-12-17 23:13:53 +00:00
union recv_frame * recvframe_chk_defrag ( struct adapter * padapter , union recv_frame * precv_frame ) ;
sint validate_recv_mgnt_frame ( struct adapter * padapter , union recv_frame * precv_frame ) ;
sint validate_recv_mgnt_frame ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2015-02-19 21:34:32 +00:00
/* struct mlme_priv *pmlmepriv = &padapter->mlmepriv; */
2013-10-19 17:45:47 +00:00
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " +validate_recv_mgnt_frame \n " ) ) ;
precv_frame = recvframe_chk_defrag ( padapter , precv_frame ) ;
if ( precv_frame = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " %s: fragment packet \n " , __FUNCTION__ ) ) ;
2013-05-08 21:45:39 +00:00
return _SUCCESS ;
}
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* for rx pkt statistics */
2014-12-11 21:15:04 +00:00
struct sta_info * psta = rtw_get_stainfo ( & padapter - > stapriv , GetAddr2Ptr ( precv_frame - > u . hdr . rx_data ) ) ;
if ( psta ) {
psta - > sta_stats . rx_mgnt_pkts + + ;
if ( GetFrameSubType ( precv_frame - > u . hdr . rx_data ) = = WIFI_BEACON )
psta - > sta_stats . rx_beacon_pkts + + ;
else if ( GetFrameSubType ( precv_frame - > u . hdr . rx_data ) = = WIFI_PROBEREQ )
psta - > sta_stats . rx_probereq_pkts + + ;
else if ( GetFrameSubType ( precv_frame - > u . hdr . rx_data ) = = WIFI_PROBERSP ) {
2014-12-29 02:13:24 +00:00
if ( _rtw_memcmp ( padapter - > eeprompriv . mac_addr , GetAddr1Ptr ( precv_frame - > u . hdr . rx_data ) , ETH_ALEN ) = = true )
2014-12-11 21:15:04 +00:00
psta - > sta_stats . rx_probersp_pkts + + ;
else if ( is_broadcast_mac_addr ( GetAddr1Ptr ( precv_frame - > u . hdr . rx_data ) )
| | is_multicast_mac_addr ( GetAddr1Ptr ( precv_frame - > u . hdr . rx_data ) ) )
psta - > sta_stats . rx_probersp_bm_pkts + + ;
2014-12-19 06:59:46 +00:00
else
2014-12-11 21:15:04 +00:00
psta - > sta_stats . rx_probersp_uo_pkts + + ;
}
2013-05-08 21:45:39 +00:00
}
}
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_INTEL_PROXIM
2015-08-15 18:19:16 +00:00
if ( padapter - > proximity . proxim_on = = true )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct recv_stat * prxstat = ( struct recv_stat * ) precv_frame - > u . hdr . rx_head ;
2014-12-11 21:15:04 +00:00
u8 * pda , * psa , * pbssid , * ptr ;
2015-08-15 18:19:16 +00:00
ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
pda = get_da ( ptr ) ;
psa = get_sa ( ptr ) ;
pbssid = get_hdr_bssid ( ptr ) ;
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > dst , pda , ETH_ALEN ) ;
memcpy ( pattrib - > src , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > bssid , pbssid , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:05:44 +00:00
switch ( pattrib - > to_fr_ds )
2014-12-11 21:15:04 +00:00
{
case 0 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
break ;
case 1 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pbssid , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
break ;
case 2 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pbssid , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
break ;
case 3 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , GetAddr2Ptr ( ptr ) , ETH_ALEN ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " case 3 \n " ) ) ;
2014-12-11 21:15:04 +00:00
break ;
default :
break ;
2014-12-19 06:59:46 +00:00
}
2015-08-15 18:19:16 +00:00
pattrib - > priority = 0 ;
pattrib - > hdrlen = pattrib - > to_fr_ds = = 3 ? 30 : 24 ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
padapter - > proximity . proxim_rx ( padapter , precv_frame ) ;
2014-12-11 21:15:04 +00:00
}
# endif
2013-05-08 21:45:39 +00:00
mgt_dispatcher ( padapter , precv_frame ) ;
return _SUCCESS ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
sint validate_recv_data_frame ( struct adapter * adapter , union recv_frame * precv_frame ) ;
sint validate_recv_data_frame ( struct adapter * adapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
u8 bretry ;
u8 * psa , * pda , * pbssid ;
struct sta_info * psta = NULL ;
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2014-12-19 06:59:46 +00:00
struct sta_priv * pstapriv = & adapter - > stapriv ;
struct security_priv * psecuritypriv = & adapter - > securitypriv ;
2014-12-11 21:15:04 +00:00
sint ret = _SUCCESS ;
2013-05-08 21:45:39 +00:00
bretry = GetRetry ( ptr ) ;
pda = get_da ( ptr ) ;
psa = get_sa ( ptr ) ;
pbssid = get_hdr_bssid ( ptr ) ;
2015-08-15 18:24:16 +00:00
if ( pbssid = = NULL ) {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s pbssid == NULL \n " , __func__ ) ;
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > dst , pda , ETH_ALEN ) ;
memcpy ( pattrib - > src , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > bssid , pbssid , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:05:44 +00:00
switch ( pattrib - > to_fr_ds )
2014-12-11 21:15:04 +00:00
{
case 0 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
ret = sta2sta_data_frame ( adapter , precv_frame , & psta ) ;
break ;
case 1 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pbssid , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
ret = ap2sta_data_frame ( adapter , precv_frame , & psta ) ;
break ;
case 2 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , pbssid , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
ret = sta2ap_data_frame ( adapter , precv_frame , & psta ) ;
break ;
case 3 :
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , GetAddr2Ptr ( ptr ) , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
ret = _FAIL ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " case 3 \n " ) ) ;
2014-12-11 21:15:04 +00:00
break ;
default :
ret = _FAIL ;
break ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:24:16 +00:00
if ( ret = = _FAIL ) {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s case:%d, res:%d \n " , __FUNCTION__ , pattrib - > to_fr_ds , ret ) ;
# endif
2013-05-08 21:45:39 +00:00
goto exit ;
} else if ( ret = = RTW_RX_HANDLED ) {
goto exit ;
}
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( psta = = NULL ) {
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " after to_fr_ds_chk; psta == NULL \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s psta == NULL \n " , __func__ ) ;
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* psta->rssi = prxcmd->rssi; */
2015-08-15 18:19:16 +00:00
/* psta->signal_quality = prxcmd->sq; */
2013-05-08 21:45:39 +00:00
precv_frame - > u . hdr . psta = psta ;
2014-12-19 06:59:46 +00:00
2013-05-19 04:28:07 +00:00
2015-08-15 18:19:16 +00:00
pattrib - > amsdu = 0 ;
2013-05-08 21:45:39 +00:00
pattrib - > ack_policy = 0 ;
2015-02-19 21:34:32 +00:00
/* parsing QC field */
2015-08-15 18:02:34 +00:00
if ( pattrib - > qos = = 1 )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pattrib - > priority = GetPriority ( ( ptr + 24 ) ) ;
pattrib - > ack_policy = GetAckpolicy ( ( ptr + 24 ) ) ;
pattrib - > amsdu = GetAMsdu ( ( ptr + 24 ) ) ;
2015-08-15 18:19:16 +00:00
pattrib - > hdrlen = pattrib - > to_fr_ds = = 3 ? 32 : 26 ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( pattrib - > priority ! = 0 & & pattrib - > priority ! = 3 )
2014-12-11 21:15:04 +00:00
{
2014-12-29 02:13:24 +00:00
adapter - > recvpriv . bIsAnyNonBEPkts = true ;
2014-12-11 21:15:04 +00:00
}
}
else
{
2015-08-15 18:19:16 +00:00
pattrib - > priority = 0 ;
pattrib - > hdrlen = pattrib - > to_fr_ds = = 3 ? 30 : 24 ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( pattrib - > order ) /* HT-CTRL 11n */
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pattrib - > hdrlen + = 4 ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
precv_frame - > u . hdr . preorder_ctrl = & psta - > recvreorder_ctrl [ pattrib - > priority ] ;
2015-02-19 21:34:32 +00:00
/* decache, drop duplicate recv packets */
2015-08-15 18:02:34 +00:00
if ( recv_decache ( precv_frame , bretry , & psta - > sta_recvpriv . rxcache ) = = _FAIL )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " decache : drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s recv_decache return _FAIL \n " , __func__ ) ;
# endif
2015-08-15 18:19:16 +00:00
ret = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
2015-08-15 18:24:16 +00:00
if ( pattrib - > privacy ) {
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " validate_recv_data_frame:pattrib->privacy =%x \n " , pattrib - > privacy ) ) ;
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x)) =%d^^^^^^^^^^^^^^^6 \n " , pattrib - > ra [ 0 ] , IS_MCAST ( pattrib - > ra ) ) ) ;
2013-05-08 21:45:39 +00:00
GET_ENCRY_ALGO ( psecuritypriv , psta , pattrib - > encrypt , IS_MCAST ( pattrib - > ra ) ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n pattrib->encrypt =%d \n " , pattrib - > encrypt ) ) ;
2013-05-08 21:45:39 +00:00
SET_ICE_IV_LEN ( pattrib - > iv_len , pattrib - > icv_len , pattrib - > encrypt ) ;
2014-12-11 21:15:04 +00:00
}
else
{
2013-05-08 21:45:39 +00:00
pattrib - > encrypt = 0 ;
2014-12-11 21:15:04 +00:00
pattrib - > iv_len = pattrib - > icv_len = 0 ;
2013-05-08 21:45:39 +00:00
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_IEEE80211W
2014-12-17 23:13:53 +00:00
static sint validate_80211w_mgmt ( struct adapter * adapter , union recv_frame * precv_frame )
2014-12-11 21:15:04 +00:00
{
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
u8 * ptr = precv_frame - > u . hdr . rx_data ;
u8 type ;
u8 subtype ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
type = GetFrameType ( ptr ) ;
2015-02-19 21:34:32 +00:00
subtype = GetFrameSubType ( ptr ) ; /* bit(7)~bit(2) */
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* only support station mode */
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) & & check_fwstate ( pmlmepriv , _FW_LINKED )
2014-12-29 02:13:24 +00:00
& & adapter - > securitypriv . binstallBIPkey = = true )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* unicast management frame decrypt */
2015-08-15 18:02:34 +00:00
if ( pattrib - > privacy & & ! ( IS_MCAST ( GetAddr1Ptr ( ptr ) ) ) & &
2014-12-11 21:15:04 +00:00
( subtype = = WIFI_DEAUTH | | subtype = = WIFI_DISASSOC | | subtype = = WIFI_ACTION ) )
{
u8 * ppp , * mgmt_DATA ;
2015-08-15 18:19:16 +00:00
u32 data_len = 0 ;
2014-12-11 21:15:04 +00:00
ppp = GetAddr2Ptr ( ptr ) ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
pattrib - > bdecrypted = 0 ;
pattrib - > encrypt = _AES_ ;
pattrib - > hdrlen = sizeof ( struct rtw_ieee80211_hdr_3addr ) ;
2015-02-19 21:34:32 +00:00
/* set iv and icv length */
2014-12-11 21:15:04 +00:00
SET_ICE_IV_LEN ( pattrib - > iv_len , pattrib - > icv_len , pattrib - > encrypt ) ;
2015-02-19 20:50:04 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , GetAddr2Ptr ( ptr ) , ETH_ALEN ) ;
2015-02-19 21:34:32 +00:00
/* actual management data frame body */
2014-12-11 21:15:04 +00:00
data_len = pattrib - > pkt_len - pattrib - > hdrlen - pattrib - > iv_len - pattrib - > icv_len ;
mgmt_DATA = rtw_zmalloc ( data_len ) ;
2015-08-15 18:02:34 +00:00
if ( mgmt_DATA = = NULL )
2014-12-11 21:15:04 +00:00
{
DBG_871X ( " %s mgmt allocate fail !!!!!!!!! \n " , __FUNCTION__ ) ;
goto validate_80211w_fail ;
}
2015-02-19 21:34:32 +00:00
/*/* dump the packet content before decrypt */
2014-12-11 21:15:04 +00:00
{
int pp ;
printk ( " pattrib->pktlen = %d => " , pattrib - > pkt_len ) ;
2015-08-15 18:19:16 +00:00
for ( pp = 0 ; pp < pattrib - > pkt_len ; pp + + )
2014-12-11 21:15:04 +00:00
printk ( " %02x " , ptr [ pp ] ) ;
printk ( " \n " ) ;
} */
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
precv_frame = decryptor ( adapter , precv_frame ) ;
2015-02-19 21:34:32 +00:00
/* save actual management data frame body */
2015-02-19 20:50:04 +00:00
memcpy ( mgmt_DATA , ptr + pattrib - > hdrlen + pattrib - > iv_len , data_len ) ;
2015-02-19 21:34:32 +00:00
/* overwrite the iv field */
2015-02-19 20:50:04 +00:00
memcpy ( ptr + pattrib - > hdrlen , mgmt_DATA , data_len ) ;
2015-02-19 21:34:32 +00:00
/* remove the iv and icv length */
2014-12-11 21:15:04 +00:00
pattrib - > pkt_len = pattrib - > pkt_len - pattrib - > iv_len - pattrib - > icv_len ;
rtw_mfree ( mgmt_DATA , data_len ) ;
2015-02-19 21:34:32 +00:00
/*/* print packet content after decryption */
2014-12-11 21:15:04 +00:00
{
int pp ;
printk ( " after decryption pattrib->pktlen = %d @@=> " , pattrib - > pkt_len ) ;
2015-08-15 18:19:16 +00:00
for ( pp = 0 ; pp < pattrib - > pkt_len ; pp + + )
2014-12-11 21:15:04 +00:00
printk ( " %02x " , ptr [ pp ] ) ;
printk ( " \n " ) ;
} */
2015-08-15 18:02:34 +00:00
if ( ! precv_frame )
2014-12-11 21:15:04 +00:00
{
DBG_871X ( " %s mgmt descrypt fail !!!!!!!!! \n " , __FUNCTION__ ) ;
goto validate_80211w_fail ;
}
}
2015-08-15 18:02:34 +00:00
else if ( IS_MCAST ( GetAddr1Ptr ( ptr ) ) & &
2014-12-11 21:15:04 +00:00
( subtype = = WIFI_DEAUTH | | subtype = = WIFI_DISASSOC ) )
{
sint BIP_ret = _SUCCESS ;
2015-02-19 21:34:32 +00:00
/* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */
2014-12-11 21:15:04 +00:00
BIP_ret = rtw_BIP_verify ( adapter , ( u8 * ) precv_frame ) ;
2015-08-15 18:02:34 +00:00
if ( BIP_ret = = _FAIL )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* DBG_871X("802.11w BIP verify fail\n"); */
2014-12-11 21:15:04 +00:00
goto validate_80211w_fail ;
}
2015-08-15 18:02:34 +00:00
else if ( BIP_ret = = RTW_RX_HANDLED )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* DBG_871X("802.11w recv none protected packet\n"); */
/* issue sa query request */
2014-12-11 21:15:04 +00:00
issue_action_SA_Query ( adapter , NULL , 0 , 0 ) ;
goto validate_80211w_fail ;
}
2015-02-19 21:34:32 +00:00
} /* 802.11w protect */
2014-12-11 21:15:04 +00:00
else
{
2015-08-15 18:02:34 +00:00
if ( subtype = = WIFI_ACTION )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* according 802.11-2012 standard, these five types are not robust types */
2015-08-15 18:02:34 +00:00
if ( ptr [ WLAN_HDR_A3_LEN ] ! = RTW_WLAN_CATEGORY_PUBLIC & &
2014-12-11 21:15:04 +00:00
ptr [ WLAN_HDR_A3_LEN ] ! = RTW_WLAN_CATEGORY_HT & &
ptr [ WLAN_HDR_A3_LEN ] ! = RTW_WLAN_CATEGORY_UNPROTECTED_WNM & &
ptr [ WLAN_HDR_A3_LEN ] ! = RTW_WLAN_CATEGORY_SELF_PROTECTED & &
ptr [ WLAN_HDR_A3_LEN ] ! = RTW_WLAN_CATEGORY_P2P )
{
2015-08-15 18:19:16 +00:00
DBG_871X ( " action frame category =%d should robust \n " , ptr [ WLAN_HDR_A3_LEN ] ) ;
2014-12-11 21:15:04 +00:00
goto validate_80211w_fail ;
}
}
2015-08-15 18:02:34 +00:00
else if ( subtype = = WIFI_DEAUTH | | subtype = = WIFI_DISASSOC )
2014-12-11 21:15:04 +00:00
{
DBG_871X ( " 802.11w recv none protected packet \n " ) ;
2015-02-19 21:34:32 +00:00
/* issue sa query request */
2014-12-11 21:15:04 +00:00
issue_action_SA_Query ( adapter , NULL , 0 , 0 ) ;
goto validate_80211w_fail ;
}
}
}
return _SUCCESS ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
validate_80211w_fail :
return _FAIL ;
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
# endif /* CONFIG_IEEE80211W */
2014-12-11 21:15:04 +00:00
2014-12-17 23:13:53 +00:00
sint validate_recv_frame ( struct adapter * adapter , union recv_frame * precv_frame ) ;
sint validate_recv_frame ( struct adapter * adapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
2015-02-19 21:34:32 +00:00
/* shall check frame subtype, to / from ds, da, bssid */
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* then call check if rx seq/frag. duplicated. */
2013-05-08 21:45:39 +00:00
u8 type ;
u8 subtype ;
2014-12-11 21:15:04 +00:00
sint retval = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2015-03-10 16:18:03 +00:00
u8 bDumpRxPkt ;
2013-05-08 21:45:39 +00:00
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2014-12-11 21:15:04 +00:00
u8 ver = ( unsigned char ) ( * ptr ) & 0x3 ;
2015-03-01 17:00:26 +00:00
# ifdef CONFIG_AP_MODE
2013-05-08 21:45:39 +00:00
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
2014-12-11 21:15:04 +00:00
# endif
2013-05-08 21:45:39 +00:00
2015-03-01 17:00:26 +00:00
# ifdef CONFIG_AP_MODE
2013-05-08 21:45:39 +00:00
if ( pmlmeext - > sitesurvey_res . state = = SCAN_PROCESS ) {
int ch_set_idx = rtw_ch_set_search_ch ( pmlmeext - > channel_set , rtw_get_oper_ch ( adapter ) ) ;
if ( ch_set_idx > = 0 )
pmlmeext - > channel_set [ ch_set_idx ] . rx_count + + ;
}
2014-12-11 21:15:04 +00:00
# endif
2015-02-19 21:34:32 +00:00
/* add version chk */
2015-08-15 18:24:16 +00:00
if ( ver ! = 0 ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " validate_recv_data_frame fail! (ver!=0) \n " ) ) ;
retval = _FAIL ;
2013-05-08 21:45:39 +00:00
goto exit ;
}
type = GetFrameType ( ptr ) ;
2015-02-19 21:34:32 +00:00
subtype = GetFrameSubType ( ptr ) ; /* bit(7)~bit(2) */
2013-05-08 21:45:39 +00:00
pattrib - > to_fr_ds = get_tofr_ds ( ptr ) ;
pattrib - > frag_num = GetFragNum ( ptr ) ;
pattrib - > seq_num = GetSequence ( ptr ) ;
pattrib - > pw_save = GetPwrMgt ( ptr ) ;
pattrib - > mfrag = GetMFrag ( ptr ) ;
pattrib - > mdata = GetMData ( ptr ) ;
pattrib - > privacy = GetPrivacy ( ptr ) ;
pattrib - > order = GetOrder ( ptr ) ;
rtw_hal_get_def_var ( adapter , HAL_DEF_DBG_DUMP_RXPKT , & ( bDumpRxPkt ) ) ;
2015-08-15 18:24:16 +00:00
if ( bDumpRxPkt = = 1 ) { /* dump all rx packets */
2013-05-08 21:45:39 +00:00
int i ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
for ( i = 0 ; i < 64 ; i = i + 8 )
2014-12-11 21:15:04 +00:00
DBG_871X ( " %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X: \n " , * ( ptr + i ) ,
* ( ptr + i + 1 ) , * ( ptr + i + 2 ) , * ( ptr + i + 3 ) , * ( ptr + i + 4 ) , * ( ptr + i + 5 ) , * ( ptr + i + 6 ) , * ( ptr + i + 7 ) ) ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:24:16 +00:00
else if ( bDumpRxPkt = = 2 ) {
if ( type = = WIFI_MGT_TYPE ) {
2013-05-08 21:45:39 +00:00
int i ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
for ( i = 0 ; i < 64 ; i = i + 8 )
2014-12-11 21:15:04 +00:00
DBG_871X ( " %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X: \n " , * ( ptr + i ) ,
* ( ptr + i + 1 ) , * ( ptr + i + 2 ) , * ( ptr + i + 3 ) , * ( ptr + i + 4 ) , * ( ptr + i + 5 ) , * ( ptr + i + 6 ) , * ( ptr + i + 7 ) ) ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:24:16 +00:00
else if ( bDumpRxPkt = = 3 ) {
if ( type = = WIFI_DATA_TYPE ) {
2013-05-08 21:45:39 +00:00
int i ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:19:16 +00:00
for ( i = 0 ; i < 64 ; i = i + 8 )
2014-12-11 21:15:04 +00:00
DBG_871X ( " %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X: \n " , * ( ptr + i ) ,
* ( ptr + i + 1 ) , * ( ptr + i + 2 ) , * ( ptr + i + 3 ) , * ( ptr + i + 4 ) , * ( ptr + i + 5 ) , * ( ptr + i + 6 ) , * ( ptr + i + 7 ) ) ;
2015-08-15 18:00:19 +00:00
DBG_871X ( " ############################# \n " ) ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
switch ( type )
{
2015-02-19 21:34:32 +00:00
case WIFI_MGT_TYPE : /* mgnt */
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_IEEE80211W
2015-08-15 18:02:34 +00:00
if ( validate_80211w_mgmt ( adapter , precv_frame ) = = _FAIL )
2014-12-11 21:15:04 +00:00
{
retval = _FAIL ;
break ;
}
2015-02-19 21:34:32 +00:00
# endif /* CONFIG_IEEE80211W */
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
retval = validate_recv_mgnt_frame ( adapter , precv_frame ) ;
if ( retval = = _FAIL )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " validate_recv_mgnt_frame fail \n " ) ) ;
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
retval = _FAIL ; /* only data frame return _SUCCESS */
2014-12-11 21:15:04 +00:00
break ;
2015-02-19 21:34:32 +00:00
case WIFI_CTRL_TYPE : /* ctrl */
2014-12-11 21:15:04 +00:00
retval = validate_recv_ctrl_frame ( adapter , precv_frame ) ;
if ( retval = = _FAIL )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " validate_recv_ctrl_frame fail \n " ) ) ;
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
retval = _FAIL ; /* only data frame return _SUCCESS */
2014-12-11 21:15:04 +00:00
break ;
2015-02-19 21:34:32 +00:00
case WIFI_DATA_TYPE : /* data */
2014-12-11 21:15:04 +00:00
rtw_led_control ( adapter , LED_CTL_RX ) ;
pattrib - > qos = ( subtype & BIT ( 7 ) ) ? 1 : 0 ;
retval = validate_recv_data_frame ( adapter , precv_frame ) ;
if ( retval = = _FAIL )
{
struct recv_priv * precvpriv = & adapter - > recvpriv ;
2015-08-15 18:19:16 +00:00
/* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */
2014-12-11 21:15:04 +00:00
precvpriv - > rx_drop + + ;
}
break ;
default :
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " validate_recv_data_frame fail! type =0x%x \n " , type ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
2015-08-15 18:19:16 +00:00
DBG_871X ( " DBG_RX_DROP_FRAME validate_recv_data_frame fail! type =0x%x \n " , type ) ;
2014-12-11 21:15:04 +00:00
# endif
retval = _FAIL ;
break ;
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
return retval ;
}
2015-02-19 21:34:32 +00:00
/* remove the wlanhdr and add the eth_hdr */
2014-12-11 21:15:04 +00:00
2015-08-15 04:04:53 +00:00
static sint wlanhdr_to_ethhdr ( union recv_frame * precvframe )
2013-05-08 21:45:39 +00:00
{
2014-12-11 21:15:04 +00:00
sint rmv_len ;
2013-05-08 21:45:39 +00:00
u16 eth_type , len ;
u8 bsnaphdr ;
u8 * psnap_type ;
struct ieee80211_snap_hdr * psnap ;
2015-01-28 05:14:58 +00:00
__be16 be_tmp ;
2015-08-15 18:19:16 +00:00
sint ret = _SUCCESS ;
2014-12-17 23:13:53 +00:00
struct adapter * adapter = precvframe - > u . hdr . adapter ;
2013-05-08 21:45:39 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2015-02-19 21:34:32 +00:00
u8 * ptr = get_recvframe_data ( precvframe ) ; /* point to frame_ctrl field */
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
2013-05-08 21:45:39 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:24:16 +00:00
if ( pattrib - > encrypt ) {
2014-12-19 06:59:46 +00:00
recvframe_pull_tail ( precvframe , pattrib - > icv_len ) ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
psnap = ( struct ieee80211_snap_hdr * ) ( ptr + pattrib - > hdrlen + pattrib - > iv_len ) ;
psnap_type = ptr + pattrib - > hdrlen + pattrib - > iv_len + SNAP_SIZE ;
2013-05-08 21:45:39 +00:00
/* convert hdr + possible LLC headers into Ethernet header */
2015-02-19 21:34:32 +00:00
/* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
2015-08-15 18:02:34 +00:00
if ( ( _rtw_memcmp ( psnap , rtw_rfc1042_header , SNAP_SIZE ) & &
2014-12-29 02:13:24 +00:00
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_IPX , 2 ) = = false ) & &
2015-08-15 18:19:16 +00:00
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_APPLETALK_AARP , 2 ) = = false ) ) | |
2015-02-19 21:34:32 +00:00
/* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
2015-08-15 18:24:16 +00:00
_rtw_memcmp ( psnap , rtw_bridge_tunnel_header , SNAP_SIZE ) ) {
2013-05-08 21:45:39 +00:00
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
2014-12-29 02:13:24 +00:00
bsnaphdr = true ;
2014-12-11 21:15:04 +00:00
}
else {
2013-05-08 21:45:39 +00:00
/* Leave Ethernet header part of hdr and full payload */
2014-12-29 02:13:24 +00:00
bsnaphdr = false ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
rmv_len = pattrib - > hdrlen + pattrib - > iv_len + ( bsnaphdr ? SNAP_SIZE : 0 ) ;
2013-05-08 21:45:39 +00:00
len = precvframe - > u . hdr . len - rmv_len ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " \n ===pattrib->hdrlen: %x, pattrib->iv_len:%x === \n \n " , pattrib - > hdrlen , pattrib - > iv_len ) ) ;
2013-05-08 21:45:39 +00:00
2015-01-28 05:14:58 +00:00
memcpy ( & be_tmp , ptr + rmv_len , 2 ) ;
2015-08-15 18:19:16 +00:00
eth_type = ntohs ( be_tmp ) ; /* pattrib->ether_type */
2013-05-08 21:45:39 +00:00
pattrib - > eth_type = eth_type ;
2014-12-29 02:13:24 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = true ) )
2014-12-11 21:15:04 +00:00
{
2014-12-19 06:59:46 +00:00
ptr + = rmv_len ;
2013-05-08 21:45:39 +00:00
* ptr = 0x87 ;
* ( ptr + 1 ) = 0x12 ;
eth_type = 0x8712 ;
2015-02-19 21:34:32 +00:00
/* append rx status for mp test packets */
2013-05-08 21:45:39 +00:00
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + 2 ) - 24 ) ;
2015-01-28 05:14:58 +00:00
memcpy ( ptr , get_rxmem ( precvframe ) , 24 ) ;
2014-12-11 21:15:04 +00:00
ptr + = 24 ;
}
else {
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + ( bsnaphdr ? 2 : 0 ) ) ) ;
}
2015-02-19 20:50:04 +00:00
memcpy ( ptr , pattrib - > dst , ETH_ALEN ) ;
memcpy ( ptr + ETH_ALEN , pattrib - > src , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( ! bsnaphdr ) {
2015-01-28 05:14:58 +00:00
be_tmp = htons ( len ) ;
2015-02-19 20:50:04 +00:00
memcpy ( ptr + 12 , & be_tmp , 2 ) ;
2014-12-11 21:15:04 +00:00
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
return ret ;
}
2015-02-19 21:34:32 +00:00
/* perform defrag */
2015-03-16 13:54:18 +00:00
static union recv_frame * recvframe_defrag ( struct adapter * adapter , struct __queue * defrag_q )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
struct list_head * plist , * phead ;
2015-08-15 18:19:16 +00:00
u8 * data , wlanhdr_offset ;
2013-05-08 21:45:39 +00:00
u8 curfragnum ;
2014-12-11 21:15:04 +00:00
struct recv_frame_hdr * pfhdr , * pnfhdr ;
union recv_frame * prframe , * pnextrframe ;
2015-03-16 13:54:18 +00:00
struct __queue * pfree_recv_queue ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
curfragnum = 0 ;
pfree_recv_queue = & adapter - > recvpriv . free_recv_queue ;
2013-05-08 21:45:39 +00:00
phead = get_list_head ( defrag_q ) ;
plist = get_next ( phead ) ;
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2015-08-15 18:19:16 +00:00
pfhdr = & prframe - > u . hdr ;
2013-05-08 21:45:39 +00:00
rtw_list_delete ( & ( prframe - > u . list ) ) ;
2015-08-15 18:02:34 +00:00
if ( curfragnum ! = pfhdr - > attrib . frag_num )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* the first fragment number must be 0 */
/* free the whole queue */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
return NULL ;
}
curfragnum + + ;
2015-08-15 18:19:16 +00:00
plist = get_list_head ( defrag_q ) ;
2013-05-08 21:45:39 +00:00
plist = get_next ( plist ) ;
2015-08-15 18:19:16 +00:00
data = get_recvframe_data ( prframe ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:04:12 +00:00
while ( rtw_end_of_queue_search ( phead , plist ) = = false )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pnextrframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2015-08-15 18:19:16 +00:00
pnfhdr = & pnextrframe - > u . hdr ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* check the fragment sequence (2nd ~n fragment frame) */
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( curfragnum ! = pnfhdr - > attrib . frag_num )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* the fragment number must be increasing (after decache) */
/* release the defrag_q & prframe */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
return NULL ;
}
curfragnum + + ;
2015-02-19 21:34:32 +00:00
/* copy the 2nd~n fragment frame's payload to the first fragment */
/* get the 2nd~last fragment frame's payload */
2013-05-08 21:45:39 +00:00
wlanhdr_offset = pnfhdr - > attrib . hdrlen + pnfhdr - > attrib . iv_len ;
recvframe_pull ( pnextrframe , wlanhdr_offset ) ;
2015-02-19 21:34:32 +00:00
/* append to first fragment frame's tail (if privacy frame, pull the ICV) */
2013-05-08 21:45:39 +00:00
recvframe_pull_tail ( prframe , pfhdr - > attrib . icv_len ) ;
2015-02-19 21:34:32 +00:00
/* memcpy */
2015-02-19 20:50:04 +00:00
memcpy ( pfhdr - > rx_tail , pnfhdr - > rx_data , pnfhdr - > len ) ;
2013-05-08 21:45:39 +00:00
recvframe_put ( prframe , pnfhdr - > len ) ;
2015-08-15 18:19:16 +00:00
pfhdr - > attrib . icv_len = pnfhdr - > attrib . icv_len ;
2013-05-08 21:45:39 +00:00
plist = get_next ( plist ) ;
2014-12-11 21:15:04 +00:00
} ;
2015-02-19 21:34:32 +00:00
/* free the defrag_q queue and return the prframe */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " Performance defrag!!!!! \n " ) ) ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
return prframe ;
}
2015-02-19 21:34:32 +00:00
/* check if need to defrag, if needed queue the frame to defrag_q */
2014-12-17 23:13:53 +00:00
union recv_frame * recvframe_chk_defrag ( struct adapter * padapter , union recv_frame * precv_frame )
2013-05-08 21:45:39 +00:00
{
u8 ismfrag ;
u8 fragnum ;
u8 * psta_addr ;
struct recv_frame_hdr * pfhdr ;
struct sta_info * psta ;
struct sta_priv * pstapriv ;
2015-03-16 13:54:18 +00:00
struct list_head * phead ;
2013-05-08 21:45:39 +00:00
union recv_frame * prtnframe = NULL ;
2015-03-16 13:54:18 +00:00
struct __queue * pfree_recv_queue , * pdefrag_q ;
2013-05-08 21:45:39 +00:00
pstapriv = & padapter - > stapriv ;
pfhdr = & precv_frame - > u . hdr ;
pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
2015-02-19 21:34:32 +00:00
/* need to define struct of wlan header frame ctrl */
2013-05-08 21:45:39 +00:00
ismfrag = pfhdr - > attrib . mfrag ;
fragnum = pfhdr - > attrib . frag_num ;
psta_addr = pfhdr - > attrib . ta ;
psta = rtw_get_stainfo ( pstapriv , psta_addr ) ;
2014-12-11 21:15:04 +00:00
if ( psta = = NULL )
{
2013-05-08 21:45:39 +00:00
u8 type = GetFrameType ( pfhdr - > rx_data ) ;
if ( type ! = WIFI_DATA_TYPE ) {
psta = rtw_get_bcmc_stainfo ( padapter ) ;
pdefrag_q = & psta - > sta_recvpriv . defrag_q ;
2014-12-11 21:15:04 +00:00
} else
2013-05-08 21:45:39 +00:00
pdefrag_q = NULL ;
2013-08-01 02:43:28 +00:00
}
2014-12-11 21:15:04 +00:00
else
pdefrag_q = & psta - > sta_recvpriv . defrag_q ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:22:58 +00:00
if ( ( ismfrag = = 0 ) & & ( fragnum = = 0 ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
prtnframe = precv_frame ; /* isn't a fragment frame */
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
if ( ismfrag = = 1 )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* 0~(n-1) fragment frame */
/* enqueue to defraf_g */
2015-08-15 18:02:34 +00:00
if ( pdefrag_q ! = NULL )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:22:58 +00:00
if ( fragnum = = 0 )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* the first fragment */
2015-08-15 18:02:34 +00:00
if ( _rtw_queue_empty ( pdefrag_q ) = = false )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* free current defrag_q */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe_queue ( pdefrag_q , pfree_recv_queue ) ;
}
}
2015-02-19 21:34:32 +00:00
/* Then enqueue the 0~(n-1) fragment into the defrag_q */
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* _rtw_spinlock(&pdefrag_q->lock); */
2013-05-08 21:45:39 +00:00
phead = get_list_head ( pdefrag_q ) ;
rtw_list_insert_tail ( & pfhdr - > list , phead ) ;
2015-02-19 21:34:32 +00:00
/* _rtw_spinunlock(&pdefrag_q->lock); */
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " Enqueuq: ismfrag = %d, fragnum = %d \n " , ismfrag , fragnum ) ) ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
prtnframe = NULL ;
2014-12-11 21:15:04 +00:00
}
else
{
2015-02-19 21:34:32 +00:00
/* can't find this ta's defrag_queue, so free this recv_frame */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precv_frame , pfree_recv_queue ) ;
2015-08-15 18:19:16 +00:00
prtnframe = NULL ;
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d \n " , ismfrag , fragnum ) ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:22:58 +00:00
if ( ( ismfrag = = 0 ) & & ( fragnum ! = 0 ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* the last fragment frame */
/* enqueue the last fragment */
2015-08-15 18:02:34 +00:00
if ( pdefrag_q ! = NULL )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* _rtw_spinlock(&pdefrag_q->lock); */
2013-05-08 21:45:39 +00:00
phead = get_list_head ( pdefrag_q ) ;
2015-08-15 18:19:16 +00:00
rtw_list_insert_tail ( & pfhdr - > list , phead ) ;
2015-02-19 21:34:32 +00:00
/* _rtw_spinunlock(&pdefrag_q->lock); */
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* call recvframe_defrag to defrag */
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " defrag: ismfrag = %d, fragnum = %d \n " , ismfrag , fragnum ) ) ;
2013-05-08 21:45:39 +00:00
precv_frame = recvframe_defrag ( padapter , pdefrag_q ) ;
2015-08-15 18:19:16 +00:00
prtnframe = precv_frame ;
2014-12-11 21:15:04 +00:00
}
else
{
2015-02-19 21:34:32 +00:00
/* can't find this ta's defrag_queue, so free this recv_frame */
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precv_frame , pfree_recv_queue ) ;
2015-08-15 18:19:16 +00:00
prtnframe = NULL ;
2015-08-15 18:22:58 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d \n " , ismfrag , fragnum ) ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( ( prtnframe ! = NULL ) & & ( prtnframe - > u . hdr . attrib . privacy ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* after defrag we must check tkip mic code */
2015-08-15 18:19:16 +00:00
if ( recvframe_chkmic ( padapter , prtnframe ) = = _FAIL )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvframe_chkmic(padapter, prtnframe) ==_FAIL \n " ) ) ;
rtw_free_recvframe ( prtnframe , pfree_recv_queue ) ;
prtnframe = NULL ;
2013-05-08 21:45:39 +00:00
}
}
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return prtnframe ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
# define ENDIAN_FREE 1
2015-08-15 04:04:53 +00:00
static int amsdu_to_msdu ( struct adapter * padapter , union recv_frame * prframe )
2013-05-08 21:45:39 +00:00
{
int a_len , padding_len ;
2014-12-19 06:59:46 +00:00
u16 eth_type , nSubframe_Length ;
2013-05-08 21:45:39 +00:00
u8 nr_subframes , i ;
unsigned char * pdata ;
struct rx_pkt_attrib * pattrib ;
unsigned char * data_ptr ;
2015-03-16 13:54:18 +00:00
struct sk_buff * sub_skb , * subframes [ MAX_SUBFRAME_COUNT ] ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-03-16 13:54:18 +00:00
struct __queue * pfree_recv_queue = & ( precvpriv - > free_recv_queue ) ;
2013-05-08 21:45:39 +00:00
int ret = _SUCCESS ;
nr_subframes = 0 ;
2014-12-11 21:15:04 +00:00
pattrib = & prframe - > u . hdr . attrib ;
recvframe_pull ( prframe , prframe - > u . hdr . attrib . hdrlen ) ;
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( prframe - > u . hdr . attrib . iv_len > 0 )
2014-12-11 21:15:04 +00:00
{
recvframe_pull ( prframe , prframe - > u . hdr . attrib . iv_len ) ;
}
a_len = prframe - > u . hdr . len ;
pdata = prframe - > u . hdr . rx_data ;
2015-08-15 18:04:12 +00:00
while ( a_len > ETH_HLEN ) {
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
/* Offset 12 denote 2 mac address */
# ifdef ENDIAN_FREE
2015-02-19 21:34:32 +00:00
/* nSubframe_Length = ntohs(*((u16*)(pdata + 12))); */
2014-12-11 21:15:04 +00:00
nSubframe_Length = RTW_GET_BE16 ( pdata + 12 ) ;
2015-02-19 21:34:32 +00:00
# else /* ENDIAN_FREE */
2014-12-11 21:15:04 +00:00
nSubframe_Length = * ( ( u16 * ) ( pdata + 12 ) ) ;
2015-08-15 18:19:16 +00:00
/* m ==>change the length order */
2014-12-11 21:15:04 +00:00
nSubframe_Length = ( nSubframe_Length > > 8 ) + ( nSubframe_Length < < 8 ) ;
2015-02-19 21:34:32 +00:00
/* ntohs(nSubframe_Length); */
# endif /* ENDIAN_FREE */
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( a_len < ( ETHERNET_HEADER_SIZE + nSubframe_Length ) ) {
2015-08-15 18:19:16 +00:00
DBG_871X ( " nRemain_Length is %d and nSubframe_Length is : %d \n " , a_len , nSubframe_Length ) ;
2014-12-11 21:15:04 +00:00
goto exit ;
}
/* move the data point to data content */
pdata + = ETH_HLEN ;
a_len - = ETH_HLEN ;
/* Allocate new skb for releasing to upper layer */
sub_skb = rtw_skb_alloc ( nSubframe_Length + 12 ) ;
2015-08-15 18:02:34 +00:00
if ( sub_skb ) {
2014-12-11 21:15:04 +00:00
skb_reserve ( sub_skb , 12 ) ;
data_ptr = ( u8 * ) skb_put ( sub_skb , nSubframe_Length ) ;
2015-02-19 20:50:04 +00:00
memcpy ( data_ptr , pdata , nSubframe_Length ) ;
2015-03-03 21:18:07 +00:00
} else {
2014-12-11 21:15:04 +00:00
sub_skb = rtw_skb_clone ( prframe - > u . hdr . pkt ) ;
2015-08-15 18:02:34 +00:00
if ( sub_skb )
2014-12-11 21:15:04 +00:00
{
sub_skb - > data = pdata ;
sub_skb - > len = nSubframe_Length ;
skb_set_tail_pointer ( sub_skb , nSubframe_Length ) ;
}
else
{
2015-08-15 18:19:16 +00:00
DBG_871X ( " rtw_skb_clone() Fail!!! , nr_subframes = %d \n " , nr_subframes ) ;
2014-12-11 21:15:04 +00:00
break ;
}
}
2015-02-19 21:34:32 +00:00
/* sub_skb->dev = padapter->pnetdev; */
2014-12-11 21:15:04 +00:00
subframes [ nr_subframes + + ] = sub_skb ;
2015-08-15 18:02:34 +00:00
if ( nr_subframes > = MAX_SUBFRAME_COUNT ) {
2014-12-11 21:15:04 +00:00
DBG_871X ( " ParseSubframe(): Too many Subframes! Packets dropped! \n " ) ;
break ;
}
pdata + = nSubframe_Length ;
a_len - = nSubframe_Length ;
2015-08-15 18:02:34 +00:00
if ( a_len ! = 0 ) {
2014-12-11 21:15:04 +00:00
padding_len = 4 - ( ( nSubframe_Length + ETH_HLEN ) & ( 4 - 1 ) ) ;
2015-08-15 18:02:34 +00:00
if ( padding_len = = 4 ) {
2014-12-11 21:15:04 +00:00
padding_len = 0 ;
}
2015-08-15 18:02:34 +00:00
if ( a_len < padding_len ) {
2014-12-11 21:15:04 +00:00
goto exit ;
}
pdata + = padding_len ;
a_len - = padding_len ;
}
}
2015-08-15 18:24:16 +00:00
for ( i = 0 ; i < nr_subframes ; i + + ) {
2014-12-11 21:15:04 +00:00
sub_skb = subframes [ i ] ;
/* convert hdr + possible LLC headers into Ethernet header */
# ifdef ENDIAN_FREE
2015-02-19 21:34:32 +00:00
/* eth_type = ntohs(*(u16*)&sub_skb->data[6]); */
2014-12-11 21:15:04 +00:00
eth_type = RTW_GET_BE16 ( & sub_skb - > data [ 6 ] ) ;
2015-02-19 21:34:32 +00:00
# else /* ENDIAN_FREE */
2014-12-11 21:15:04 +00:00
eth_type = ( sub_skb - > data [ 6 ] < < 8 ) | sub_skb - > data [ 7 ] ;
2015-02-19 21:34:32 +00:00
# endif /* ENDIAN_FREE */
2014-12-11 21:15:04 +00:00
if ( sub_skb - > len > = 8 & &
( ( _rtw_memcmp ( sub_skb - > data , rtw_rfc1042_header , SNAP_SIZE ) & &
eth_type ! = ETH_P_AARP & & eth_type ! = ETH_P_IPX ) | |
_rtw_memcmp ( sub_skb - > data , rtw_bridge_tunnel_header , SNAP_SIZE ) ) ) {
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
skb_pull ( sub_skb , SNAP_SIZE ) ;
2015-02-19 20:50:04 +00:00
memcpy ( skb_push ( sub_skb , ETH_ALEN ) , pattrib - > src , ETH_ALEN ) ;
memcpy ( skb_push ( sub_skb , ETH_ALEN ) , pattrib - > dst , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
} else {
2015-01-28 05:14:58 +00:00
__be16 len ;
2014-12-11 21:15:04 +00:00
/* Leave Ethernet header part of hdr and full payload */
len = htons ( sub_skb - > len ) ;
2015-01-28 05:14:58 +00:00
memcpy ( skb_push ( sub_skb , 2 ) , & len , 2 ) ;
memcpy ( skb_push ( sub_skb , ETH_ALEN ) , pattrib - > src , ETH_ALEN ) ;
memcpy ( skb_push ( sub_skb , ETH_ALEN ) , pattrib - > dst , ETH_ALEN ) ;
2014-12-11 21:15:04 +00:00
}
/* Indicat the packets to upper layer */
2015-03-10 16:18:03 +00:00
{
2015-02-19 21:34:32 +00:00
/* memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); */
2014-12-11 21:15:04 +00:00
# ifdef CONFIG_BR_EXT
2015-02-19 21:34:32 +00:00
/* Insert NAT2.5 RX here! */
2014-12-11 21:15:04 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
void * br_port = NULL ;
# if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
br_port = padapter - > pnetdev - > br_port ;
2015-02-19 21:34:32 +00:00
# else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
2014-12-11 21:15:04 +00:00
rcu_read_lock ( ) ;
br_port = rcu_dereference ( padapter - > pnetdev - > rx_handler_data ) ;
rcu_read_unlock ( ) ;
2015-02-19 21:34:32 +00:00
# endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( br_port & & ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE | WIFI_ADHOC_STATE ) = = true ) )
2014-12-11 21:15:04 +00:00
{
if ( nat25_handle_frame ( padapter , sub_skb ) = = - 1 ) {
2015-02-19 21:34:32 +00:00
/* priv->ext_stats.rx_data_drops++; */
/* DEBUG_ERR("RX DROP: nat25_handle_frame fail!\n"); */
/* return FAIL; */
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* bypass this frame to upper layer!! */
2014-12-19 06:59:46 +00:00
}
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
# endif /* CONFIG_BR_EXT */
2014-12-11 21:15:04 +00:00
sub_skb - > protocol = eth_type_trans ( sub_skb , padapter - > pnetdev ) ;
sub_skb - > dev = padapter - > pnetdev ;
sub_skb - > ip_summed = CHECKSUM_NONE ;
rtw_netif_rx ( padapter - > pnetdev , sub_skb ) ;
}
}
exit :
2015-08-15 18:19:16 +00:00
prframe - > u . hdr . len = 0 ;
2015-02-19 21:34:32 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ; /* free this recv_frame */
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
return ret ;
2013-05-08 21:45:39 +00:00
}
2015-01-30 03:41:53 +00:00
static int check_indicate_seq ( struct recv_reorder_ctrl * preorder_ctrl , u16 seq_num )
2013-05-08 21:45:39 +00:00
{
u8 wsize = preorder_ctrl - > wsize_b ;
2015-02-19 21:34:32 +00:00
u16 wend = ( preorder_ctrl - > indicate_seq + wsize - 1 ) & 0xFFF ; /* 4096; */
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* Rx Reorder initialize condition. */
2013-05-08 21:45:39 +00:00
if ( preorder_ctrl - > indicate_seq = = 0xFFFF )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = seq_num ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d init IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , seq_num ) ;
# endif
2015-08-15 18:19:16 +00:00
/* DbgPrint("check_indicate_seq, 1st->indicate_seq =%d\n", precvpriv->indicate_seq); */
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
/* DbgPrint("enter->check_indicate_seq(): IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* Drop out the packet which SeqNum is smaller than WinStart */
2015-08-15 18:02:34 +00:00
if ( SN_LESS ( seq_num , preorder_ctrl - > indicate_seq ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
2014-12-19 06:59:46 +00:00
DBG_871X ( " %s IndicateSeq: %d > NewSeq: %d \n " , __FUNCTION__ ,
2014-12-11 21:15:04 +00:00
preorder_ctrl - > indicate_seq , seq_num ) ;
# endif
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
return false ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* */
/* Sliding window manipulation. Conditions includes: */
/* 1. Incoming SeqNum is equal to WinStart =>Window shift 1 */
/* 2. Incoming SeqNum is larger than the WinEnd => Window shift N */
/* */
2015-08-15 18:02:34 +00:00
if ( SN_EQUAL ( seq_num , preorder_ctrl - > indicate_seq ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) & 0xFFF ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d SN_EQUAL IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , seq_num ) ;
# endif
}
2015-08-15 18:02:34 +00:00
else if ( SN_LESS ( wend , seq_num ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */
/* DbgPrint("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* boundary situation, when seq_num cross 0xFFF */
2015-08-15 18:02:34 +00:00
if ( seq_num > = ( wsize - 1 ) )
2014-12-11 21:15:04 +00:00
preorder_ctrl - > indicate_seq = seq_num + 1 - wsize ;
2013-05-08 21:45:39 +00:00
else
preorder_ctrl - > indicate_seq = 0xFFF - ( wsize - ( seq_num + 1 ) ) + 1 ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d SN_LESS(wend, seq_num) IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , seq_num ) ;
# endif
2013-05-08 21:45:39 +00:00
}
2015-02-19 21:34:32 +00:00
/* DbgPrint("exit->check_indicate_seq(): IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
return true ;
2013-05-08 21:45:39 +00:00
}
int enqueue_reorder_recvframe ( struct recv_reorder_ctrl * preorder_ctrl , union recv_frame * prframe ) ;
int enqueue_reorder_recvframe ( struct recv_reorder_ctrl * preorder_ctrl , union recv_frame * prframe )
{
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
2015-03-16 13:54:18 +00:00
struct __queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
struct list_head * phead , * plist ;
2013-05-08 21:45:39 +00:00
union recv_frame * pnextrframe ;
struct rx_pkt_attrib * pnextattrib ;
phead = get_list_head ( ppending_recvframe_queue ) ;
plist = get_next ( phead ) ;
2015-08-15 18:04:12 +00:00
while ( rtw_end_of_queue_search ( phead , plist ) = = false )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
pnextrframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
pnextattrib = & pnextrframe - > u . hdr . attrib ;
2015-08-15 18:02:34 +00:00
if ( SN_LESS ( pnextattrib - > seq_num , pattrib - > seq_num ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
plist = get_next ( plist ) ;
2014-12-11 21:15:04 +00:00
}
2015-08-15 18:02:34 +00:00
else if ( SN_EQUAL ( pnextattrib - > seq_num , pattrib - > seq_num ) )
2014-12-11 21:15:04 +00:00
{
2014-12-29 02:13:24 +00:00
return false ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
else
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
break ;
2014-12-11 21:15:04 +00:00
}
2013-05-08 21:45:39 +00:00
}
rtw_list_delete ( & ( prframe - > u . hdr . list ) ) ;
rtw_list_insert_tail ( & ( prframe - > u . hdr . list ) , plist ) ;
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
return true ;
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
int recv_indicatepkts_in_order ( struct adapter * padapter , struct recv_reorder_ctrl * preorder_ctrl , int bforced ) ;
int recv_indicatepkts_in_order ( struct adapter * padapter , struct recv_reorder_ctrl * preorder_ctrl , int bforced )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
/* unsigned long irql; */
2015-02-19 21:34:32 +00:00
/* u8 bcancelled; */
2015-03-16 13:54:18 +00:00
struct list_head * phead , * plist ;
2013-05-08 21:45:39 +00:00
union recv_frame * prframe ;
struct rx_pkt_attrib * pattrib ;
2015-02-19 21:34:32 +00:00
/* u8 index = 0; */
2014-12-29 02:13:24 +00:00
int bPktInBuf = false ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-03-16 13:54:18 +00:00
struct __queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* DbgPrint("+recv_indicatepkts_in_order\n"); */
2014-12-11 21:15:04 +00:00
2015-03-06 17:54:48 +00:00
/* _enter_critical_ex(&ppending_recvframe_queue->lock); */
2015-02-19 21:34:32 +00:00
/* _rtw_spinlock_ex(&ppending_recvframe_queue->lock); */
2014-12-11 21:15:04 +00:00
2014-12-19 06:59:46 +00:00
phead = get_list_head ( ppending_recvframe_queue ) ;
2013-05-08 21:45:39 +00:00
plist = get_next ( phead ) ;
2015-02-19 21:34:32 +00:00
/* Handling some condition for forced indicate case. */
2015-08-15 18:19:16 +00:00
if ( bforced = = true )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( rtw_is_list_empty ( phead ) )
2014-12-11 21:15:04 +00:00
{
2015-03-06 17:54:48 +00:00
/* _exit_critical_ex(&ppending_recvframe_queue->lock); */
2015-02-19 21:34:32 +00:00
/* _rtw_spinunlock_ex(&ppending_recvframe_queue->lock); */
2014-12-29 02:13:24 +00:00
return true ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2015-03-10 16:18:03 +00:00
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2014-12-19 06:59:46 +00:00
pattrib = & prframe - > u . hdr . attrib ;
preorder_ctrl - > indicate_seq = pattrib - > seq_num ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
2013-05-08 21:45:39 +00:00
}
2015-02-19 21:34:32 +00:00
/* Prepare indication list and indication. */
/* Check if there is any packet need indicate. */
2015-08-15 18:04:12 +00:00
while ( ! rtw_is_list_empty ( phead ) )
2014-12-11 21:15:04 +00:00
{
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
pattrib = & prframe - > u . hdr . attrib ;
2015-08-15 18:02:34 +00:00
if ( ! SN_LESS ( preorder_ctrl - > indicate_seq , pattrib - > seq_num ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ ,
2015-08-15 18:19:16 +00:00
( " recv_indicatepkts_in_order: indicate =%d seq =%d amsdu =%d \n " ,
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq , pattrib - > seq_num , pattrib - > amsdu ) ) ;
plist = get_next ( plist ) ;
rtw_list_delete ( & ( prframe - > u . hdr . list ) ) ;
2015-08-15 18:02:34 +00:00
if ( SN_EQUAL ( preorder_ctrl - > indicate_seq , pattrib - > seq_num ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) & 0xFFF ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
}
2015-02-19 21:34:32 +00:00
/* Set this as a lock to make sure that only one thread is indicating packet. */
/* pTS->RxIndicateState = RXTS_INDICATE_PROCESSING; */
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* Indicate packets */
2015-08-15 18:00:19 +00:00
/* RT_ASSERT((index<=REORDER_WIN_SIZE), ("RxReorderIndicatePacket(): Rx Reorder buffer full!!\n")); */
2013-05-08 21:45:39 +00:00
2015-02-19 21:34:32 +00:00
/* indicate this recv_frame */
2015-08-15 18:19:16 +00:00
/* DbgPrint("recv_indicatepkts_in_order, indicate_seq =%d, seq_num =%d\n", precvpriv->indicate_seq, pattrib->seq_num); */
2015-08-15 18:02:34 +00:00
if ( ! pattrib - > amsdu )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
/* DBG_871X("recv_indicatepkts_in_order, amsdu!=1, indicate_seq =%d, seq_num =%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num); */
2014-12-11 21:15:04 +00:00
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = false ) & &
( padapter - > bSurpriseRemoved = = false ) )
2014-12-11 21:15:04 +00:00
{
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
rtw_recv_indicatepkt ( padapter , prframe ) ; /* indicate this recv_frame */
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
}
}
2015-08-15 18:19:16 +00:00
else if ( pattrib - > amsdu = = 1 )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( amsdu_to_msdu ( padapter , prframe ) ! = _SUCCESS )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( prframe , & precvpriv - > free_recv_queue ) ;
2014-12-11 21:15:04 +00:00
}
}
else
{
2015-02-19 21:34:32 +00:00
/* error condition; */
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* Update local variables. */
2014-12-29 02:13:24 +00:00
bPktInBuf = false ;
2014-12-11 21:15:04 +00:00
}
else
{
2014-12-29 02:13:24 +00:00
bPktInBuf = true ;
2013-05-08 21:45:39 +00:00
break ;
}
}
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* return true; */
2013-05-08 21:45:39 +00:00
return bPktInBuf ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-01-30 03:41:53 +00:00
static int recv_indicatepkt_reorder ( struct adapter * padapter , union recv_frame * prframe )
2013-05-08 21:45:39 +00:00
{
2015-03-16 13:54:18 +00:00
unsigned long irql ;
2013-05-08 21:45:39 +00:00
int retval = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
struct recv_reorder_ctrl * preorder_ctrl = prframe - > u . hdr . preorder_ctrl ;
2015-03-16 13:54:18 +00:00
struct __queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( ! pattrib - > amsdu ) {
2015-02-19 21:34:32 +00:00
/* s1. */
2013-05-08 21:45:39 +00:00
wlanhdr_to_ethhdr ( prframe ) ;
2015-01-30 03:41:53 +00:00
if ( pattrib - > qos ! = 1 ) {
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = false ) & &
2015-01-30 03:41:53 +00:00
( padapter - > bSurpriseRemoved = = false ) ) {
2014-12-11 21:15:04 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " @@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt \n " ) ) ;
2013-05-08 21:45:39 +00:00
rtw_recv_indicatepkt ( padapter , prframe ) ;
return _SUCCESS ;
2014-12-11 21:15:04 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s pattrib->qos !=1 \n " , __FUNCTION__ ) ;
# endif
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
2015-01-30 03:41:53 +00:00
if ( preorder_ctrl - > enable = = false ) {
2015-02-19 21:34:32 +00:00
/* indicate this recv_frame */
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = pattrib - > seq_num ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
2014-12-19 06:59:46 +00:00
rtw_recv_indicatepkt ( padapter , prframe ) ;
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) % 4096 ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
2014-12-19 06:59:46 +00:00
return _SUCCESS ;
}
2015-08-15 18:19:16 +00:00
} else if ( pattrib - > amsdu = = 1 ) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */
2015-01-30 03:41:53 +00:00
if ( preorder_ctrl - > enable = = false ) {
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq = pattrib - > seq_num ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
2013-05-08 21:45:39 +00:00
retval = amsdu_to_msdu ( padapter , prframe ) ;
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) % 4096 ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_SEQ
DBG_871X ( " DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d \n " , __FUNCTION__ , __LINE__ ,
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
# endif
2015-08-15 18:24:16 +00:00
if ( retval ! = _SUCCESS ) {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s amsdu_to_msdu fail \n " , __FUNCTION__ ) ;
# endif
}
2013-05-08 21:45:39 +00:00
return retval ;
}
}
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & ppending_recvframe_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ ,
2015-08-15 18:19:16 +00:00
( " recv_indicatepkt_reorder: indicate =%d seq =%d \n " ,
2013-05-08 21:45:39 +00:00
preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ) ;
2015-02-19 21:34:32 +00:00
/* s2. check if winstart_b(indicate_seq) needs to been updated */
2015-08-15 18:02:34 +00:00
if ( ! check_indicate_seq ( preorder_ctrl , pattrib - > seq_num ) ) {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s check_indicate_seq fail \n " , __FUNCTION__ ) ;
# endif
2014-11-20 06:12:27 +00:00
goto _err_exit ;
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
/* s3. Insert all packet into Reorder Queue to maintain its ordering. */
2015-08-15 18:02:34 +00:00
if ( ! enqueue_reorder_recvframe ( preorder_ctrl , prframe ) ) {
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s enqueue_reorder_recvframe fail \n " , __FUNCTION__ ) ;
# endif
2013-05-08 21:45:39 +00:00
goto _err_exit ;
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
/* s4. */
/* Indication process. */
/* After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets */
/* with the SeqNum smaller than latest WinStart and buffer other packets. */
/* */
/* For Rx Reorder condition: */
/* 1. All packets with SeqNum smaller than WinStart => Indicate */
/* 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. */
/* */
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( recv_indicatepkts_in_order ( padapter , preorder_ctrl , false ) ) {
2013-05-08 21:45:39 +00:00
_set_timer ( & preorder_ctrl - > reordering_ctrl_timer , REORDER_WAIT_TIME ) ;
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ppending_recvframe_queue - > lock ) ;
2015-01-30 03:41:53 +00:00
} else {
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ppending_recvframe_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
_cancel_timer_ex ( & preorder_ctrl - > reordering_ctrl_timer ) ;
}
return _SUCCESS ;
_err_exit :
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ppending_recvframe_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
void rtw_reordering_ctrl_timeout_handler ( void * pcontext )
{
2015-03-16 13:54:18 +00:00
unsigned long irql ;
2013-05-08 21:45:39 +00:00
struct recv_reorder_ctrl * preorder_ctrl = ( struct recv_reorder_ctrl * ) pcontext ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = preorder_ctrl - > padapter ;
2015-03-16 13:54:18 +00:00
struct __queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
2013-05-08 21:45:39 +00:00
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( padapter - > bDriverStopped | | padapter - > bSurpriseRemoved )
2013-05-08 21:45:39 +00:00
return ;
2015-03-06 17:54:48 +00:00
spin_lock_bh ( & ppending_recvframe_queue - > lock ) ;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
if ( recv_indicatepkts_in_order ( padapter , preorder_ctrl , true ) = = true )
2014-12-19 06:59:46 +00:00
_set_timer ( & preorder_ctrl - > reordering_ctrl_timer , REORDER_WAIT_TIME ) ;
2014-12-11 21:15:04 +00:00
2015-03-06 17:54:48 +00:00
spin_unlock_bh ( & ppending_recvframe_queue - > lock ) ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 04:04:53 +00:00
static int process_recv_indicatepkts ( struct adapter * padapter , union recv_frame * prframe )
2013-05-08 21:45:39 +00:00
{
int retval = _SUCCESS ;
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2014-12-11 21:15:04 +00:00
struct ht_priv * phtpriv = & pmlmepriv - > htpriv ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
if ( phtpriv - > ht_option = = true ) /* B/G/N Mode */
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:02:34 +00:00
if ( recv_indicatepkt_reorder ( padapter , prframe ) ! = _SUCCESS ) /* including perform A-MPDU Rx Ordering Buffer Control */
2014-12-11 21:15:04 +00:00
{
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s recv_indicatepkt_reorder error! \n " , __FUNCTION__ ) ;
# endif
2014-12-19 06:59:46 +00:00
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = false ) & &
( padapter - > bSurpriseRemoved = = false ) )
2014-12-11 21:15:04 +00:00
{
2013-05-08 21:45:39 +00:00
retval = _FAIL ;
return retval ;
}
}
2014-12-11 21:15:04 +00:00
}
2015-02-19 21:34:32 +00:00
else /* B/G mode */
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
retval = wlanhdr_to_ethhdr ( prframe ) ;
2015-08-15 18:02:34 +00:00
if ( retval ! = _SUCCESS )
2014-12-11 21:15:04 +00:00
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " wlanhdr_to_ethhdr: drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s wlanhdr_to_ethhdr error! \n " , __FUNCTION__ ) ;
# endif
2013-05-08 21:45:39 +00:00
return retval ;
}
2015-08-15 18:19:16 +00:00
if ( ( padapter - > bDriverStopped = = false ) & & ( padapter - > bSurpriseRemoved = = false ) )
2014-12-11 21:15:04 +00:00
{
2015-02-19 21:34:32 +00:00
/* indicate this recv_frame */
2014-12-11 21:15:04 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " @@@@ process_recv_indicatepkts- recv_func recv_indicatepkt \n " ) ) ;
2013-05-08 21:45:39 +00:00
rtw_recv_indicatepkt ( padapter , prframe ) ;
2014-12-11 21:15:04 +00:00
}
else
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " @@@@ process_recv_indicatepkts- recv_func free_indicatepkt \n " ) ) ;
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_notice_ , ( " recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d) " , padapter - > bDriverStopped , padapter - > bSurpriseRemoved ) ) ;
retval = _FAIL ;
return retval ;
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
return retval ;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
}
2015-01-30 03:41:53 +00:00
static int recv_func_prehandle ( struct adapter * padapter , union recv_frame * rframe )
2013-05-08 21:45:39 +00:00
{
int ret = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & rframe - > u . hdr . attrib ;
2014-12-11 21:15:04 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-03-16 13:54:18 +00:00
struct __queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* check the frame crtl field and decache */
2013-05-08 21:45:39 +00:00
ret = validate_recv_frame ( padapter , rframe ) ;
2014-12-11 21:15:04 +00:00
if ( ret ! = _SUCCESS )
{
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " recv_func: validate_recv_frame fail! drop pkt \n " ) ) ;
2015-02-19 21:34:32 +00:00
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
2013-05-08 21:45:39 +00:00
goto exit ;
}
exit :
return ret ;
}
2015-01-30 03:41:53 +00:00
static int recv_func_posthandle ( struct adapter * padapter , union recv_frame * prframe )
2013-05-08 21:45:39 +00:00
{
int ret = _SUCCESS ;
union recv_frame * orig_prframe = prframe ;
2014-12-11 21:15:04 +00:00
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-03-16 13:54:18 +00:00
struct __queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
2014-12-19 06:59:46 +00:00
2015-02-19 21:34:32 +00:00
/* DATA FRAME */
2013-05-08 21:45:39 +00:00
rtw_led_control ( padapter , LED_CTL_RX ) ;
prframe = decryptor ( padapter , prframe ) ;
if ( prframe = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " decryptor: drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s decryptor: drop pkt \n " , __FUNCTION__ ) ;
# endif
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
goto _recv_data_drop ;
}
prframe = recvframe_chk_defrag ( padapter , prframe ) ;
2015-08-15 18:22:58 +00:00
if ( prframe = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvframe_chk_defrag: drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s recvframe_chk_defrag: drop pkt \n " , __FUNCTION__ ) ;
# endif
2014-12-19 06:59:46 +00:00
goto _recv_data_drop ;
2013-05-08 21:45:39 +00:00
}
2015-08-15 18:19:16 +00:00
prframe = portctrl ( padapter , prframe ) ;
2013-05-08 21:45:39 +00:00
if ( prframe = = NULL ) {
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " portctrl: drop pkt \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s portctrl: drop pkt \n " , __FUNCTION__ ) ;
# endif
2013-05-08 21:45:39 +00:00
ret = _FAIL ;
goto _recv_data_drop ;
}
count_rx_stats ( padapter , prframe , NULL ) ;
ret = process_recv_indicatepkts ( padapter , prframe ) ;
2014-12-11 21:15:04 +00:00
if ( ret ! = _SUCCESS )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recv_func: process_recv_indicatepkts fail! \n " ) ) ;
2014-12-11 21:15:04 +00:00
# ifdef DBG_RX_DROP_FRAME
DBG_871X ( " DBG_RX_DROP_FRAME %s process_recv_indicatepkts fail! \n " , __FUNCTION__ ) ;
# endif
2015-02-19 21:34:32 +00:00
rtw_free_recvframe ( orig_prframe , pfree_recv_queue ) ; /* free this recv_frame */
2014-12-11 21:15:04 +00:00
goto _recv_data_drop ;
}
_exit_recv_func :
2013-05-08 21:45:39 +00:00
return ret ;
_recv_data_drop :
precvpriv - > rx_drop + + ;
return ret ;
}
2014-12-11 21:15:04 +00:00
2014-12-17 23:13:53 +00:00
int recv_func ( struct adapter * padapter , union recv_frame * rframe ) ;
int recv_func ( struct adapter * padapter , union recv_frame * rframe )
2013-05-08 21:45:39 +00:00
{
int ret ;
struct rx_pkt_attrib * prxattrib = & rframe - > u . hdr . attrib ;
2014-11-20 06:12:27 +00:00
struct recv_priv * recvpriv = & padapter - > recvpriv ;
2015-08-15 18:19:16 +00:00
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
2014-12-11 21:15:04 +00:00
struct mlme_priv * mlmepriv = & padapter - > mlmepriv ;
2013-05-08 21:45:39 +00:00
/* check if need to handle uc_swdec_pending_queue*/
2014-12-11 21:15:04 +00:00
if ( check_fwstate ( mlmepriv , WIFI_STATION_STATE ) & & psecuritypriv - > busetkipkey )
{
2013-05-08 21:45:39 +00:00
union recv_frame * pending_frame ;
2014-11-20 06:12:27 +00:00
int cnt = 0 ;
2013-05-08 21:45:39 +00:00
2015-08-15 18:19:16 +00:00
while ( ( pending_frame = rtw_alloc_recvframe ( & padapter - > recvpriv . uc_swdec_pending_queue ) ) ) {
2014-11-20 06:12:27 +00:00
cnt + + ;
recv_func_posthandle ( padapter , pending_frame ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
if ( cnt )
DBG_871X ( FUNC_ADPT_FMT " dequeue %d from uc_swdec_pending_queue \n " ,
FUNC_ADPT_ARG ( padapter ) , cnt ) ;
2013-05-08 21:45:39 +00:00
}
ret = recv_func_prehandle ( padapter , rframe ) ;
2015-08-15 18:02:34 +00:00
if ( ret = = _SUCCESS ) {
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
/* check if need to enqueue into uc_swdec_pending_queue*/
if ( check_fwstate ( mlmepriv , WIFI_STATION_STATE ) & &
2014-12-11 21:15:04 +00:00
! IS_MCAST ( prxattrib - > ra ) & & prxattrib - > encrypt > 0 & &
2014-12-29 02:13:24 +00:00
( prxattrib - > bdecrypted = = 0 | | psecuritypriv - > sw_decrypt = = true ) & &
2014-12-11 21:15:04 +00:00
psecuritypriv - > ndisauthtype = = Ndis802_11AuthModeWPAPSK & &
! psecuritypriv - > busetkipkey )
{
2013-05-08 21:45:39 +00:00
rtw_enqueue_recvframe ( rframe , & padapter - > recvpriv . uc_swdec_pending_queue ) ;
2015-02-19 21:34:32 +00:00
/* DBG_871X("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); */
2014-12-11 21:15:04 +00:00
2014-11-20 06:12:27 +00:00
if ( recvpriv - > free_recvframe_cnt < NR_RECVFRAME / 4 ) {
2014-12-11 21:15:04 +00:00
/* to prevent from recvframe starvation, get recvframe from uc_swdec_pending_queue to free_recvframe_cnt */
2014-11-20 06:12:27 +00:00
rframe = rtw_alloc_recvframe ( & padapter - > recvpriv . uc_swdec_pending_queue ) ;
if ( rframe )
goto do_posthandle ;
}
2013-05-08 21:45:39 +00:00
goto exit ;
}
2014-12-11 21:15:04 +00:00
2014-11-20 06:12:27 +00:00
do_posthandle :
2013-05-08 21:45:39 +00:00
ret = recv_func_posthandle ( padapter , rframe ) ;
}
exit :
return ret ;
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
s32 rtw_recv_entry ( union recv_frame * precvframe )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter ;
2013-05-08 21:45:39 +00:00
struct recv_priv * precvpriv ;
2015-08-15 18:19:16 +00:00
s32 ret = _SUCCESS ;
2014-12-11 21:15:04 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2015-08-15 18:19:16 +00:00
/* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+rtw_recv_entry\n")); */
2013-05-08 21:45:39 +00:00
padapter = precvframe - > u . hdr . adapter ;
precvpriv = & padapter - > recvpriv ;
2014-12-11 21:15:04 +00:00
if ( ( ret = recv_func ( padapter , precvframe ) ) = = _FAIL )
{
2015-08-15 18:19:16 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " rtw_recv_entry: recv_func return fail!!! \n " ) ) ;
2013-05-08 21:45:39 +00:00
goto _recv_entry_drop ;
}
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
precvpriv - > rx_pkts + + ;
2015-01-26 22:20:25 +00:00
;
2014-12-11 21:15:04 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
_recv_entry_drop :
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
return ret ;
}
2015-08-15 18:24:16 +00:00
void rtw_signal_stat_timer_hdl ( RTW_TIMER_HDL_ARGS ) {
2014-12-17 23:13:53 +00:00
struct adapter * adapter = ( struct adapter * ) FunctionContext ;
2013-05-08 21:45:39 +00:00
struct recv_priv * recvpriv = & adapter - > recvpriv ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
u32 tmp_s , tmp_q ;
u8 avg_signal_strength = 0 ;
u8 avg_signal_qual = 0 ;
2014-12-11 21:15:04 +00:00
u32 num_signal_strength = 0 ;
u32 num_signal_qual = 0 ;
2015-02-19 21:34:32 +00:00
u8 _alpha = 3 ; /* this value is based on converging_constant = 5000 and sampling_interval = 1000 */
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( adapter - > recvpriv . is_signal_dbg ) {
2015-02-19 21:34:32 +00:00
/* update the user specific value, signal_strength_dbg, to signal_strength, rssi */
2015-08-15 18:19:16 +00:00
adapter - > recvpriv . signal_strength = adapter - > recvpriv . signal_strength_dbg ;
adapter - > recvpriv . rssi = ( s8 ) translate_percentage_to_dbm ( ( u8 ) adapter - > recvpriv . signal_strength_dbg ) ;
2013-05-08 21:45:39 +00:00
} else {
2014-12-11 21:15:04 +00:00
2015-08-15 18:02:34 +00:00
if ( recvpriv - > signal_strength_data . update_req = = 0 ) { /* update_req is clear, means we got rx */
2013-05-08 21:45:39 +00:00
avg_signal_strength = recvpriv - > signal_strength_data . avg_val ;
2014-12-11 21:15:04 +00:00
num_signal_strength = recvpriv - > signal_strength_data . total_num ;
2015-02-19 21:34:32 +00:00
/* after avg_vals are accquired, we can re-stat the signal values */
2013-05-08 21:45:39 +00:00
recvpriv - > signal_strength_data . update_req = 1 ;
}
2014-12-19 06:59:46 +00:00
2015-08-15 18:02:34 +00:00
if ( recvpriv - > signal_qual_data . update_req = = 0 ) { /* update_req is clear, means we got rx */
2013-05-08 21:45:39 +00:00
avg_signal_qual = recvpriv - > signal_qual_data . avg_val ;
2014-12-11 21:15:04 +00:00
num_signal_qual = recvpriv - > signal_qual_data . total_num ;
2015-02-19 21:34:32 +00:00
/* after avg_vals are accquired, we can re-stat the signal values */
2013-05-08 21:45:39 +00:00
recvpriv - > signal_qual_data . update_req = 1 ;
}
2014-12-11 21:15:04 +00:00
if ( num_signal_strength = = 0 ) {
if ( rtw_get_on_cur_ch_time ( adapter ) = = 0
| | rtw_get_passing_time_ms ( rtw_get_on_cur_ch_time ( adapter ) ) < 2 * adapter - > mlmeextpriv . mlmext_info . bcn_interval
# ifdef CONFIG_BT_COEXIST
2014-12-29 02:13:24 +00:00
| | ( ( BTDM_IsBtDisabled ( adapter ) = = false ) & & ( BT_IsBtInquiryPage ( adapter ) = = true ) )
2014-12-11 21:15:04 +00:00
# endif
) {
goto set_timer ;
}
}
2013-05-08 21:45:39 +00:00
2015-08-15 18:02:34 +00:00
if ( check_fwstate ( & adapter - > mlmepriv , _FW_UNDER_SURVEY ) = = true
2014-12-29 02:13:24 +00:00
| | check_fwstate ( & adapter - > mlmepriv , _FW_LINKED ) = = false
2014-12-19 06:59:46 +00:00
) {
2014-12-11 21:15:04 +00:00
goto set_timer ;
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
2015-02-19 21:34:32 +00:00
/* update value of signal_strength, rssi, signal_qual */
2014-12-11 21:15:04 +00:00
tmp_s = ( avg_signal_strength + ( _alpha - 1 ) * recvpriv - > signal_strength ) ;
2015-08-15 18:02:34 +00:00
if ( tmp_s % _alpha )
2014-12-11 21:15:04 +00:00
tmp_s = tmp_s / _alpha + 1 ;
else
tmp_s = tmp_s / _alpha ;
2015-08-15 18:02:34 +00:00
if ( tmp_s > 100 )
2014-12-11 21:15:04 +00:00
tmp_s = 100 ;
tmp_q = ( avg_signal_qual + ( _alpha - 1 ) * recvpriv - > signal_qual ) ;
2015-08-15 18:02:34 +00:00
if ( tmp_q % _alpha )
2014-12-11 21:15:04 +00:00
tmp_q = tmp_q / _alpha + 1 ;
else
tmp_q = tmp_q / _alpha ;
2015-08-15 18:02:34 +00:00
if ( tmp_q > 100 )
2014-12-11 21:15:04 +00:00
tmp_q = 100 ;
recvpriv - > signal_strength = tmp_s ;
recvpriv - > rssi = ( s8 ) translate_percentage_to_dbm ( tmp_s ) ;
recvpriv - > signal_qual = tmp_q ;
# if defined(DBG_RX_SIGNAL_DISPLAY_PROCESSING) && 1
DBG_871X ( FUNC_ADPT_FMT " signal_strength:%3u, rssi:%3d, signal_qual:%3u "
" , num_signal_strength:%u, num_signal_qual:%u "
" , on_cur_ch_ms:%d "
" \n "
, FUNC_ADPT_ARG ( adapter )
, recvpriv - > signal_strength
, recvpriv - > rssi
, recvpriv - > signal_qual
, num_signal_strength , num_signal_qual
, rtw_get_on_cur_ch_time ( adapter ) ? rtw_get_passing_time_ms ( rtw_get_on_cur_ch_time ( adapter ) ) : 0
) ;
# endif
2013-05-08 21:45:39 +00:00
}
2014-12-11 21:15:04 +00:00
set_timer :
2013-05-08 21:45:39 +00:00
rtw_set_signal_stat_timer ( recvpriv ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}