2015-08-18 19:03:09 +00:00
/******************************************************************************
*
2019-11-09 10:12:08 +00:00
* Copyright ( c ) 2007 - 2017 Realtek Corporation .
*
2015-08-18 19:03:09 +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 .
*
2019-11-09 10:12:08 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2015-08-18 19:03:09 +00:00
# define _RTW_RECV_C_
# include <drv_types.h>
2017-05-11 18:47:23 +00:00
# include <hal_data.h>
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
static void rtw_signal_stat_timer_hdl ( void * ctx ) ;
2015-08-18 19:03:09 +00:00
2017-05-11 18:47:23 +00:00
enum {
SIGNAL_STAT_CALC_PROFILE_0 = 0 ,
SIGNAL_STAT_CALC_PROFILE_1 ,
SIGNAL_STAT_CALC_PROFILE_MAX
} ;
u8 signal_stat_calc_profile [ SIGNAL_STAT_CALC_PROFILE_MAX ] [ 2 ] = {
{ 4 , 1 } , /* Profile 0 => pre_stat : curr_stat = 4 : 1 */
{ 3 , 7 } /* Profile 1 => pre_stat : curr_stat = 3 : 7 */
} ;
2019-11-09 10:12:08 +00:00
# ifndef RTW_SIGNAL_STATE_CALC_PROFILE
# define RTW_SIGNAL_STATE_CALC_PROFILE SIGNAL_STAT_CALC_PROFILE_1
2017-05-11 18:47:23 +00:00
# endif
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
u8 rtw_bridge_tunnel_header [ ] = { 0xaa , 0xaa , 0x03 , 0x00 , 0x00 , 0xf8 } ;
u8 rtw_rfc1042_header [ ] = { 0xaa , 0xaa , 0x03 , 0x00 , 0x00 , 0x00 } ;
static u8 SNAP_ETH_TYPE_IPX [ 2 ] = { 0x81 , 0x37 } ;
static u8 SNAP_ETH_TYPE_APPLETALK_AARP [ 2 ] = { 0x80 , 0xf3 } ;
# ifdef CONFIG_TDLS
static u8 SNAP_ETH_TYPE_TDLS [ 2 ] = { 0x89 , 0x0d } ;
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_CUSTOMER_ALIBABA_GENERAL
int recv_frame_monitor ( _adapter * padapter , union recv_frame * rframe ) ;
# endif
2015-08-18 19:03:09 +00:00
void _rtw_init_sta_recv_priv ( struct sta_recv_priv * psta_recvpriv )
{
2021-10-11 10:07:17 +00:00
memset ( ( u8 * ) psta_recvpriv , 0 , sizeof ( struct sta_recv_priv ) ) ;
2015-08-18 19:03:09 +00:00
_rtw_spinlock_init ( & psta_recvpriv - > lock ) ;
2019-11-09 10:12:08 +00:00
/* for(i=0; i<MAX_RX_NUMBLKS; i++) */
/* _rtw_init_queue(&psta_recvpriv->blk_strms[i]); */
2015-08-18 19:03:09 +00:00
_rtw_init_queue ( & psta_recvpriv - > defrag_q ) ;
}
sint _rtw_init_recv_priv ( struct recv_priv * precvpriv , _adapter * padapter )
{
sint i ;
union recv_frame * precvframe ;
2019-11-09 10:12:08 +00:00
sint res = _SUCCESS ;
2015-08-18 19:03:09 +00:00
2021-08-18 23:48:50 +00:00
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
2021-10-11 10:07:17 +00:00
/* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */
2015-08-18 19:03:09 +00:00
_rtw_spinlock_init ( & precvpriv - > lock ) ;
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RECV_THREAD_MODE
_rtw_init_sema ( & precvpriv - > recv_sema , 0 ) ;
# endif
2015-08-18 19:03:09 +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 ;
2017-05-11 18:47:23 +00:00
precvpriv - > sink_udpport = 0 ;
precvpriv - > pre_rtp_rxseq = 0 ;
precvpriv - > cur_rtp_rxseq = 0 ;
# ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
precvpriv - > store_law_data_flag = 1 ;
# else
precvpriv - > store_law_data_flag = 0 ;
# endif
2015-08-18 19:03:09 +00:00
rtw_os_recv_resource_init ( precvpriv , padapter ) ;
2021-08-18 23:48:50 +00:00
precvpriv - > pallocated_frame_buf = vzalloc ( NR_RECVFRAME * sizeof ( union recv_frame ) + RXFRAME_ALIGN_SZ ) ;
2019-11-09 10:12:08 +00:00
if ( precvpriv - > pallocated_frame_buf = = NULL ) {
res = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2021-10-11 10:07:17 +00:00
/* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */
2015-08-18 19:03:09 +00:00
precvpriv - > precv_frame_buf = ( u8 * ) N_BYTE_ALIGMENT ( ( SIZE_PTR ) ( precvpriv - > pallocated_frame_buf ) , RXFRAME_ALIGN_SZ ) ;
2019-11-09 10:12:08 +00:00
/* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */
/* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
precvframe = ( union recv_frame * ) precvpriv - > precv_frame_buf ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
for ( i = 0 ; i < NR_RECVFRAME ; i + + ) {
2015-08-18 19:03:09 +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 ;
2019-11-09 10:12:08 +00:00
precvframe - > u . hdr . adapter = padapter ;
2015-08-18 19:03:09 +00:00
precvframe + + ;
}
# ifdef CONFIG_USB_HCI
2021-08-02 19:27:18 +00:00
atomic_set ( & ( precvpriv - > rx_pending_cnt ) , 1 ) ;
2015-08-18 19:03:09 +00:00
_rtw_init_sema ( & precvpriv - > allrxreturnevt , 0 ) ;
# endif
res = rtw_hal_init_recv_priv ( padapter ) ;
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
rtw_init_timer ( & precvpriv - > signal_stat_timer , padapter , rtw_signal_stat_timer_hdl , padapter ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
precvpriv - > signal_stat_sampling_interval = 2000 ; /* ms */
/* precvpriv->signal_stat_converging_constant = 5000; */ /* ms */
2015-08-18 19:03:09 +00:00
rtw_set_signal_stat_timer ( precvpriv ) ;
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2015-08-18 19:03:09 +00:00
exit :
return res ;
}
2019-11-09 10:12:08 +00:00
void _rtw_free_recv_priv ( struct recv_priv * precvpriv )
2015-08-18 19:03:09 +00:00
{
_adapter * padapter = precvpriv - > adapter ;
rtw_free_uc_swdec_pending_queue ( padapter ) ;
rtw_os_recv_resource_free ( precvpriv ) ;
2021-08-05 18:37:14 +00:00
vfree ( precvpriv - > pallocated_frame_buf ) ;
2015-08-18 19:03:09 +00:00
rtw_hal_free_recv_priv ( padapter ) ;
}
2017-05-11 18:47:23 +00:00
bool rtw_rframe_del_wfd_ie ( union recv_frame * rframe , u8 ies_offset )
{
# define DBG_RFRAME_DEL_WFD_IE 0
2021-10-21 15:30:03 +00:00
u8 * ies = rframe - > u . hdr . rx_data + sizeof ( struct ieee80211_hdr_3addr ) + ies_offset ;
2017-05-11 18:47:23 +00:00
uint ies_len_ori = rframe - > u . hdr . len - ( ies - rframe - > u . hdr . rx_data ) ;
uint ies_len ;
ies_len = rtw_del_wfd_ie ( ies , ies_len_ori , DBG_RFRAME_DEL_WFD_IE ? __func__ : NULL ) ;
rframe - > u . hdr . len - = ies_len_ori - ies_len ;
return ies_len_ori ! = ies_len ;
}
2019-11-09 10:12:08 +00:00
union recv_frame * _rtw_alloc_recvframe ( _queue * pfree_recv_queue )
2015-08-18 19:03:09 +00:00
{
union recv_frame * precvframe ;
_list * plist , * phead ;
_adapter * padapter ;
struct recv_priv * precvpriv ;
2019-11-09 10:12:08 +00:00
if ( _rtw_queue_empty ( pfree_recv_queue ) = = _TRUE )
2015-08-18 19:03:09 +00:00
precvframe = NULL ;
2019-11-09 10:12:08 +00:00
else {
2015-08-18 19:03:09 +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 ) ;
2019-11-09 10:12:08 +00:00
padapter = precvframe - > u . hdr . adapter ;
if ( padapter ! = NULL ) {
precvpriv = & padapter - > recvpriv ;
if ( pfree_recv_queue = = & precvpriv - > free_recv_queue )
2015-08-18 19:03:09 +00:00
precvpriv - > free_recvframe_cnt - - ;
}
}
return precvframe ;
}
2019-11-09 10:12:08 +00:00
union recv_frame * rtw_alloc_recvframe ( _queue * pfree_recv_queue )
2015-08-18 19:03:09 +00:00
{
_irqL irqL ;
union recv_frame * precvframe ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
_enter_critical_bh ( & pfree_recv_queue - > lock , & irqL ) ;
precvframe = _rtw_alloc_recvframe ( pfree_recv_queue ) ;
_exit_critical_bh ( & pfree_recv_queue - > lock , & irqL ) ;
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 ) ;
2019-11-09 10:12:08 +00:00
precvframe - > u . hdr . len = 0 ;
2015-08-18 19:03:09 +00:00
}
int rtw_free_recvframe ( union recv_frame * precvframe , _queue * pfree_recv_queue )
{
_irqL irqL ;
2019-11-09 10:12:08 +00:00
_adapter * padapter = precvframe - > u . hdr . adapter ;
2015-08-18 19:03:09 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
# ifdef CONFIG_CONCURRENT_MODE
2019-11-09 10:12:08 +00:00
padapter = GET_PRIMARY_ADAPTER ( padapter ) ;
precvpriv = & padapter - > recvpriv ;
pfree_recv_queue = & precvpriv - > free_recv_queue ;
precvframe - > u . hdr . adapter = padapter ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
rtw_os_free_recvframe ( precvframe ) ;
_enter_critical_bh ( & pfree_recv_queue - > lock , & irqL ) ;
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 ) ) ;
2019-11-09 10:12:08 +00:00
if ( padapter ! = NULL ) {
if ( pfree_recv_queue = = & precvpriv - > free_recv_queue )
precvpriv - > free_recvframe_cnt + + ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
_exit_critical_bh ( & pfree_recv_queue - > lock , & irqL ) ;
2015-08-18 19:03:09 +00:00
return _SUCCESS ;
}
sint _rtw_enqueue_recvframe ( union recv_frame * precvframe , _queue * queue )
{
2019-11-09 10:12:08 +00:00
_adapter * padapter = precvframe - > u . hdr . adapter ;
2015-08-18 19:03:09 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2019-11-09 10:12:08 +00:00
/* _rtw_init_listhead(&(precvframe->u.hdr.list)); */
2015-08-18 19:03:09 +00:00
rtw_list_delete ( & ( precvframe - > u . hdr . list ) ) ;
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 + + ;
}
return _SUCCESS ;
}
sint rtw_enqueue_recvframe ( union recv_frame * precvframe , _queue * queue )
{
sint ret ;
_irqL irqL ;
2019-11-09 10:12:08 +00:00
/* _spinlock(&pfree_recv_queue->lock); */
2015-08-18 19:03:09 +00:00
_enter_critical_bh ( & queue - > lock , & irqL ) ;
ret = _rtw_enqueue_recvframe ( precvframe , queue ) ;
2019-11-09 10:12:08 +00:00
/* _rtw_spinunlock(&pfree_recv_queue->lock); */
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & queue - > lock , & irqL ) ;
return ret ;
}
/*
sint rtw_enqueue_recvframe ( union recv_frame * precvframe , _queue * queue )
{
return rtw_free_recvframe ( precvframe , queue ) ;
}
*/
/*
caller : defrag ; recvframe_chk_defrag in recv_thread ( passive )
pframequeue : defrag_queue : will be accessed in recv_thread ( passive )
using spinlock to protect
*/
void rtw_free_recvframe_queue ( _queue * pframequeue , _queue * pfree_recv_queue )
{
2019-11-09 10:12:08 +00:00
union recv_frame * precvframe ;
2015-08-18 19:03:09 +00:00
_list * plist , * phead ;
_rtw_spinlock ( & pframequeue - > lock ) ;
phead = get_list_head ( pframequeue ) ;
plist = get_next ( phead ) ;
2021-10-14 20:37:57 +00:00
while ( phead ! = plist ) {
2015-08-18 19:03:09 +00:00
precvframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
plist = get_next ( plist ) ;
2019-11-09 10:12:08 +00:00
/* rtw_list_delete(&precvframe->u.hdr.list); */ /* will do this in rtw_free_recvframe() */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
}
_rtw_spinunlock ( & pframequeue - > lock ) ;
}
u32 rtw_free_uc_swdec_pending_queue ( _adapter * adapter )
{
u32 cnt = 0 ;
union recv_frame * pending_frame ;
2019-11-09 10:12:08 +00:00
while ( ( pending_frame = rtw_alloc_recvframe ( & adapter - > recvpriv . uc_swdec_pending_queue ) ) ) {
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( pending_frame , & adapter - > recvpriv . free_recv_queue ) ;
cnt + + ;
}
if ( cnt )
2019-11-09 10:12:08 +00:00
RTW_INFO ( FUNC_ADPT_FMT " dequeue %d \n " , FUNC_ADPT_ARG ( adapter ) , cnt ) ;
2015-08-18 19:03:09 +00:00
return cnt ;
}
sint rtw_enqueue_recvbuf_to_head ( struct recv_buf * precvbuf , _queue * queue )
{
_irqL irqL ;
_enter_critical_bh ( & queue - > lock , & irqL ) ;
rtw_list_delete ( & precvbuf - > list ) ;
rtw_list_insert_head ( & precvbuf - > list , get_list_head ( queue ) ) ;
_exit_critical_bh ( & queue - > lock , & irqL ) ;
return _SUCCESS ;
}
sint rtw_enqueue_recvbuf ( struct recv_buf * precvbuf , _queue * queue )
{
2019-11-09 10:12:08 +00:00
_irqL irqL ;
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_SDIO_HCI
_enter_critical_bh ( & queue - > lock , & irqL ) ;
# else
_enter_critical_ex ( & queue - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
# endif /*#ifdef CONFIG_SDIO_HCI*/
2015-08-18 19:03:09 +00:00
rtw_list_delete ( & precvbuf - > list ) ;
rtw_list_insert_tail ( & precvbuf - > list , get_list_head ( queue ) ) ;
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_SDIO_HCI
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & queue - > lock , & irqL ) ;
# else
_exit_critical_ex ( & queue - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
# endif /*#ifdef CONFIG_SDIO_HCI*/
2015-08-18 19:03:09 +00:00
return _SUCCESS ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
struct recv_buf * rtw_dequeue_recvbuf ( _queue * queue )
2015-08-18 19:03:09 +00:00
{
_irqL irqL ;
struct recv_buf * precvbuf ;
2019-11-09 10:12:08 +00:00
_list * plist , * phead ;
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_SDIO_HCI
_enter_critical_bh ( & queue - > lock , & irqL ) ;
# else
_enter_critical_ex ( & queue - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
# endif /*#ifdef CONFIG_SDIO_HCI*/
if ( _rtw_queue_empty ( queue ) = = _TRUE )
2015-08-18 19:03:09 +00:00
precvbuf = NULL ;
2019-11-09 10:12:08 +00:00
else {
2015-08-18 19:03:09 +00:00
phead = get_list_head ( queue ) ;
plist = get_next ( phead ) ;
precvbuf = LIST_CONTAINOR ( plist , struct recv_buf , list ) ;
rtw_list_delete ( & precvbuf - > list ) ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
}
# ifdef CONFIG_SDIO_HCI
_exit_critical_bh ( & queue - > lock , & irqL ) ;
# else
_exit_critical_ex ( & queue - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
# endif /*#ifdef CONFIG_SDIO_HCI*/
2015-08-18 19:03:09 +00:00
return precvbuf ;
}
sint recvframe_chkmic ( _adapter * adapter , union recv_frame * precvframe ) ;
2019-11-09 10:12:08 +00:00
sint recvframe_chkmic ( _adapter * adapter , union recv_frame * precvframe )
{
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
sint i , res = _SUCCESS ;
2015-08-18 19:03:09 +00:00
u32 datalen ;
u8 miccode [ 8 ] ;
2019-11-09 10:12:08 +00:00
u8 bmic_err = _FALSE , brpt_micerror = _TRUE ;
u8 * pframe , * payload , * pframemic ;
2015-08-18 19:03:09 +00:00
u8 * mickey ;
2019-11-09 10:12:08 +00:00
/* u8 *iv,rxdata_key_idx=0; */
2015-08-18 19:03:09 +00:00
struct sta_info * stainfo ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * prxattrib = & precvframe - > u . hdr . attrib ;
struct security_priv * psecuritypriv = & adapter - > securitypriv ;
2015-08-18 19:03:09 +00:00
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
struct mlme_ext_info * pmlmeinfo = & ( pmlmeext - > mlmext_info ) ;
2019-11-09 10:12:08 +00:00
stainfo = rtw_get_stainfo ( & adapter - > stapriv , & prxattrib - > ta [ 0 ] ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( prxattrib - > encrypt = = _TKIP_ ) {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* calculate mic code */
if ( stainfo ! = NULL ) {
2021-08-23 12:01:00 +00:00
if ( is_multicast_ether_addr ( prxattrib - > ra ) ) {
2019-11-09 10:12:08 +00:00
/* mickey=&psecuritypriv->dot118021XGrprxmickey.skey[0]; */
/* iv = precvframe->u.hdr.rx_data+prxattrib->hdrlen; */
/* rxdata_key_idx =( ((iv[3])>>6)&0x3) ; */
mickey = & psecuritypriv - > dot118021XGrprxmickey [ prxattrib - > key_index ] . skey [ 0 ] ;
/* RTW_INFO("\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); */
if ( psecuritypriv - > binstallGrpkey = = _FALSE ) {
res = _FAIL ;
RTW_INFO ( " \n recvframe_chkmic:didn't install group key!!!!!!!!!! \n " ) ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
} else {
mickey = & stainfo - > dot11tkiprxmickey . skey [ 0 ] ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +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 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* rtw_seccalctkipmic(&stainfo->dot11tkiprxmickey.skey[0],pframe,payload, datalen ,&miccode[0],(unsigned char)prxattrib->priority); */ /* care the length of the data */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
rtw_seccalctkipmic ( mickey , pframe , payload , datalen , & miccode [ 0 ] , ( unsigned char ) prxattrib - > priority ) ; /* care the length of the data */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
pframemic = payload + datalen ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
bmic_err = _FALSE ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
for ( i = 0 ; i < 8 ; i + + ) {
if ( miccode [ i ] ! = * ( pframemic + i ) ) {
bmic_err = _TRUE ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
if ( bmic_err = = _TRUE ) {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* double check key_index for some timing issue , */
/* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
2021-08-23 12:01:00 +00:00
if ( ( is_multicast_ether_addr ( prxattrib - > ra ) = = _TRUE ) & & ( prxattrib - > key_index ! = pmlmeinfo - > key_index ) )
2015-08-18 19:03:09 +00:00
brpt_micerror = _FALSE ;
2019-11-09 10:12:08 +00:00
if ( ( prxattrib - > bdecrypted = = _TRUE ) & & ( brpt_micerror = = _TRUE ) ) {
2021-08-23 12:01:00 +00:00
rtw_handle_tkip_mic_err ( adapter , stainfo , ( u8 ) is_multicast_ether_addr ( prxattrib - > ra ) ) ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " mic error :prxattrib->bdecrypted=%d \n " , prxattrib - > bdecrypted ) ;
} else {
RTW_INFO ( " mic error :prxattrib->bdecrypted=%d \n " , prxattrib - > bdecrypted ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
res = _FAIL ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
} else {
/* mic checked ok */
2021-08-23 12:01:00 +00:00
if ( ( psecuritypriv - > bcheck_grpkey = = _FALSE ) & & ( is_multicast_ether_addr ( prxattrib - > ra ) = = _TRUE ) ) {
2019-11-09 10:12:08 +00:00
psecuritypriv - > bcheck_grpkey = _TRUE ;
2015-08-18 19:03:09 +00:00
}
}
}
recvframe_pull_tail ( precvframe , 8 ) ;
}
exit :
return res ;
}
2019-11-09 10:12:08 +00:00
/*#define DBG_RX_SW_DECRYPTOR*/
/* decrypt and set the ivlen,icvlen of the recv_frame */
union recv_frame * decryptor ( _adapter * padapter , union recv_frame * precv_frame ) ;
union recv_frame * decryptor ( _adapter * padapter , union recv_frame * precv_frame )
2015-08-18 19:03:09 +00:00
{
struct rx_pkt_attrib * prxattrib = & precv_frame - > u . hdr . attrib ;
2019-11-09 10:12:08 +00:00
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
union recv_frame * return_packet = precv_frame ;
u32 res = _SUCCESS ;
2017-05-11 18:35:20 +00:00
2015-08-18 19:03:09 +00:00
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( prxattrib - > encrypt > 0 ) {
u8 * iv = precv_frame - > u . hdr . rx_data + prxattrib - > hdrlen ;
prxattrib - > key_index = ( ( ( iv [ 3 ] ) > > 6 ) & 0x3 ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( prxattrib - > key_index > WEP_KEYS ) {
RTW_INFO ( " prxattrib->key_index(%d) > WEP_KEYS \n " , prxattrib - > key_index ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( prxattrib - > encrypt ) {
case _WEP40_ :
case _WEP104_ :
prxattrib - > key_index = psecuritypriv - > dot11PrivacyKeyIndex ;
break ;
case _TKIP_ :
case _AES_ :
default :
prxattrib - > key_index = psecuritypriv - > dot118021XGrpKeyid ;
break ;
}
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( prxattrib - > encrypt & & ! prxattrib - > bdecrypted ) {
2021-10-18 14:05:53 +00:00
if ( GetFrameType ( get_recvframe_data ( precv_frame ) ) = = ( IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA )
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_CONCURRENT_MODE
2021-08-23 12:01:00 +00:00
& & ! is_multicast_ether_addr ( prxattrib - > ra ) /* bc/mc packets may use sw decryption for concurrent mode */
2019-11-09 10:12:08 +00:00
# endif
)
psecuritypriv - > hw_decrypted = _FALSE ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef DBG_RX_SW_DECRYPTOR
RTW_INFO ( ADPT_FMT " - sec_type:%s DO SW decryption \n " ,
ADPT_ARG ( padapter ) , security_type_str ( prxattrib - > encrypt ) ) ;
# endif
# ifdef DBG_RX_DECRYPTOR
RTW_INFO ( " [%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d \n " ,
__FUNCTION__ ,
__LINE__ ,
prxattrib - > bdecrypted ,
prxattrib - > encrypt ,
psecuritypriv - > hw_decrypted ) ;
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( prxattrib - > encrypt ) {
2015-08-18 19:03:09 +00:00
case _WEP40_ :
case _WEP104_ :
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_wep ) ;
2015-08-18 19:03:09 +00:00
rtw_wep_decrypt ( padapter , ( u8 * ) precv_frame ) ;
break ;
case _TKIP_ :
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_tkip ) ;
2015-08-18 19:03:09 +00:00
res = rtw_tkip_decrypt ( padapter , ( u8 * ) precv_frame ) ;
break ;
case _AES_ :
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_aes ) ;
2019-11-09 10:12:08 +00:00
res = rtw_aes_decrypt ( padapter , ( u8 * ) precv_frame ) ;
2015-08-18 19:03:09 +00:00
break ;
# ifdef CONFIG_WAPI_SUPPORT
case _SMS4_ :
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_wapi ) ;
2019-11-09 10:12:08 +00:00
rtw_sms4_decrypt ( padapter , ( u8 * ) precv_frame ) ;
2015-08-18 19:03:09 +00:00
break ;
# endif
default :
2019-11-09 10:12:08 +00:00
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else if ( prxattrib - > bdecrypted = = 1
& & prxattrib - > encrypt > 0
& & ( psecuritypriv - > busetkipkey = = 1 | | prxattrib - > encrypt ! = _TKIP_ )
) {
2015-08-18 19:03:09 +00:00
#if 0
2019-11-09 10:12:08 +00:00
if ( ( prxstat - > icv = = 1 ) & & ( prxattrib - > encrypt ! = _AES_ ) ) {
psecuritypriv - > hw_decrypted = _FALSE ;
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( precv_frame , & padapter - > recvpriv . free_recv_queue ) ;
2019-11-09 10:12:08 +00:00
return_packet = NULL ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
} else
2015-08-18 19:03:09 +00:00
# endif
{
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_hw ) ;
2019-11-09 10:12:08 +00:00
psecuritypriv - > hw_decrypted = _TRUE ;
# ifdef DBG_RX_DECRYPTOR
RTW_INFO ( " [%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d \n " ,
__FUNCTION__ ,
__LINE__ ,
prxattrib - > bdecrypted ,
prxattrib - > encrypt ,
psecuritypriv - > hw_decrypted ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# endif
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_unknown ) ;
2019-11-09 10:12:08 +00:00
# ifdef DBG_RX_DECRYPTOR
RTW_INFO ( " [%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d \n " ,
__FUNCTION__ ,
__LINE__ ,
prxattrib - > bdecrypted ,
prxattrib - > encrypt ,
psecuritypriv - > hw_decrypted ) ;
# endif
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RTW_MESH
if ( res ! = _FAIL
& & ! prxattrib - > amsdu
& & prxattrib - > mesh_ctrl_present )
res = rtw_mesh_rx_validate_mctrl_non_amsdu ( padapter , precv_frame ) ;
# endif
if ( res = = _FAIL ) {
rtw_free_recvframe ( return_packet , & padapter - > recvpriv . free_recv_queue ) ;
2015-08-18 19:03:09 +00:00
return_packet = NULL ;
2019-11-09 10:12:08 +00:00
} else
2015-08-18 19:03:09 +00:00
prxattrib - > bdecrypted = _TRUE ;
2019-11-09 10:12:08 +00:00
/* recvframe_chkmic(adapter, precv_frame); */ /* move to recvframme_defrag function */
2015-08-18 19:03:09 +00:00
return return_packet ;
}
2019-11-09 10:12:08 +00:00
/* ###set the security information in the recv_frame */
union recv_frame * portctrl ( _adapter * adapter , union recv_frame * precv_frame ) ;
union recv_frame * portctrl ( _adapter * adapter , union recv_frame * precv_frame )
2015-08-18 19:03:09 +00:00
{
u8 * psta_addr = NULL ;
u8 * ptr ;
uint auth_alg ;
struct recv_frame_hdr * pfhdr ;
struct sta_info * psta ;
struct sta_priv * pstapriv ;
union recv_frame * prtnframe ;
2019-11-09 10:12:08 +00:00
u16 ether_type = 0 ;
u16 eapol_type = 0x888e ; /* for Funia BD's WPA issue */
2015-08-18 19:03:09 +00:00
struct rx_pkt_attrib * pattrib ;
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 ;
psta = rtw_get_stainfo ( pstapriv , psta_addr ) ;
2019-11-09 10:12:08 +00:00
if ( auth_alg = = dot11AuthAlgrthm_8021X ) {
if ( ( psta ! = NULL ) & & ( psta - > ieee8021x_blocked ) ) {
/* blocked */
/* only accept EAPOL frame */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
prtnframe = precv_frame ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* get ether_type */
ptr = ptr + pfhdr - > attrib . hdrlen + pfhdr - > attrib . iv_len + LLC_HEADER_SIZE ;
2021-10-12 14:53:20 +00:00
memcpy ( & ether_type , ptr , 2 ) ;
2019-11-09 10:12:08 +00:00
ether_type = ntohs ( ( unsigned short ) ether_type ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ether_type = = eapol_type )
prtnframe = precv_frame ;
2015-08-18 19:03:09 +00:00
else {
2019-11-09 10:12:08 +00:00
/* free this frame */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( precv_frame , & adapter - > recvpriv . free_recv_queue ) ;
2019-11-09 10:12:08 +00:00
prtnframe = NULL ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else {
/* allowed */
/* check decryption status, and decrypt the frame if needed */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
prtnframe = precv_frame ;
/* check is the EAPOL frame or not (Rekey) */
/* if(ether_type == eapol_type){ */
/* check Rekey */
/* prtnframe=precv_frame; */
/* } */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else
prtnframe = precv_frame ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
return prtnframe ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* VALID_PN_CHK
* Return true when PN is legal , otherwise false .
* Legal PN :
* 1. If old PN is 0 , any PN is legal
* 2. PN > old PN
*/
# define PN_LESS_CHK(a, b) (((a-b) & 0x800000000000) != 0)
# define VALID_PN_CHK(new, old) (((old) == 0) || PN_LESS_CHK(old, new))
# define CCMPH_2_KEYID(ch) (((ch) & 0x00000000c0000000) >> 30)
sint recv_ucast_pn_decache ( union recv_frame * precv_frame ) ;
sint recv_ucast_pn_decache ( union recv_frame * precv_frame )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_info * sta = precv_frame - > u . hdr . psta ;
struct stainfo_rxcache * prxcache = & sta - > sta_recvpriv . rxcache ;
u8 * pdata = precv_frame - > u . hdr . rx_data ;
2015-08-18 19:03:09 +00:00
sint tid = precv_frame - > u . hdr . attrib . priority ;
2019-11-09 10:12:08 +00:00
u64 tmp_iv_hdr = 0 ;
u64 curr_pn = 0 , pkt_pn = 0 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( tid > 15 )
return _FAIL ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( pattrib - > encrypt = = _AES_ ) {
tmp_iv_hdr = le64_to_cpu ( * ( u64 * ) ( pdata + pattrib - > hdrlen ) ) ;
pkt_pn = CCMPH_2_PN ( tmp_iv_hdr ) ;
tmp_iv_hdr = le64_to_cpu ( * ( u64 * ) prxcache - > iv [ tid ] ) ;
curr_pn = CCMPH_2_PN ( tmp_iv_hdr ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ! VALID_PN_CHK ( pkt_pn , curr_pn ) ) {
/* return _FAIL; */
} else {
prxcache - > last_tid = tid ;
2021-10-12 14:53:20 +00:00
memcpy ( prxcache - > iv [ tid ] ,
2019-11-09 10:12:08 +00:00
( pdata + pattrib - > hdrlen ) ,
sizeof ( prxcache - > iv [ tid ] ) ) ;
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
return _SUCCESS ;
}
sint recv_bcast_pn_decache ( union recv_frame * precv_frame ) ;
sint recv_bcast_pn_decache ( union recv_frame * precv_frame )
{
_adapter * padapter = precv_frame - > u . hdr . adapter ;
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
u8 * pdata = precv_frame - > u . hdr . rx_data ;
u64 tmp_iv_hdr = 0 ;
u64 curr_pn = 0 , pkt_pn = 0 ;
u8 key_id ;
if ( ( pattrib - > encrypt = = _AES_ ) & &
( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = _TRUE ) ) {
tmp_iv_hdr = le64_to_cpu ( * ( u64 * ) ( pdata + pattrib - > hdrlen ) ) ;
key_id = CCMPH_2_KEYID ( tmp_iv_hdr ) ;
pkt_pn = CCMPH_2_PN ( tmp_iv_hdr ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
curr_pn = le64_to_cpu ( * ( u64 * ) psecuritypriv - > iv_seq [ key_id ] ) ;
curr_pn & = 0x0000ffffffffffff ;
if ( ! VALID_PN_CHK ( pkt_pn , curr_pn ) )
2015-08-18 19:03:09 +00:00
return _FAIL ;
2019-11-09 10:12:08 +00:00
* ( u64 * ) psecuritypriv - > iv_seq [ key_id ] = cpu_to_le64 ( pkt_pn ) ;
}
return _SUCCESS ;
}
sint recv_decache ( union recv_frame * precv_frame )
{
struct sta_info * psta = precv_frame - > u . hdr . psta ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
_adapter * adapter = psta - > padapter ;
sint tid = pattrib - > priority ;
u16 seq_ctrl = ( ( precv_frame - > u . hdr . attrib . seq_num & 0xffff ) < < 4 ) |
( precv_frame - > u . hdr . attrib . frag_num & 0xf ) ;
u16 * prxseq ;
if ( tid > 15 )
return _FAIL ;
if ( pattrib - > qos ) {
2021-08-23 12:01:00 +00:00
if ( is_multicast_ether_addr ( pattrib - > ra ) )
2019-11-09 10:12:08 +00:00
prxseq = & psta - > sta_recvpriv . bmc_tid_rxseq [ tid ] ;
else
prxseq = & psta - > sta_recvpriv . rxcache . tid_rxseq [ tid ] ;
} else {
2021-08-23 12:01:00 +00:00
if ( is_multicast_ether_addr ( pattrib - > ra ) ) {
2019-11-09 10:12:08 +00:00
prxseq = & psta - > sta_recvpriv . nonqos_bmc_rxseq ;
# ifdef DBG_RX_SEQ
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " nonqos bmc seq_num:%d \n "
, FUNC_ADPT_ARG ( adapter ) , pattrib - > seq_num ) ;
# endif
} else {
prxseq = & psta - > sta_recvpriv . nonqos_rxseq ;
# ifdef DBG_RX_SEQ
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " nonqos seq_num:%d \n "
, FUNC_ADPT_ARG ( adapter ) , pattrib - > seq_num ) ;
# endif
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
if ( seq_ctrl = = * prxseq ) {
/* for non-AMPDU case */
psta - > sta_stats . duplicate_cnt + + ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( psta - > sta_stats . duplicate_cnt % 100 = = 0 )
RTW_INFO ( " %s: tid=%u seq=%d frag=%d \n " , __func__
, tid , precv_frame - > u . hdr . attrib . seq_num
, precv_frame - > u . hdr . attrib . frag_num ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " recv_decache _FAIL for sta= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( psta - > cmn . mac_addr ) ) ;
# endif
return _FAIL ;
}
* prxseq = seq_ctrl ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
return _SUCCESS ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
void process_pwrbit_data ( _adapter * padapter , union recv_frame * precv_frame , struct sta_info * psta )
2015-08-18 19:03:09 +00:00
{
# ifdef CONFIG_AP_MODE
unsigned char pwrbit ;
u8 * ptr = precv_frame - > u . hdr . rx_data ;
pwrbit = GetPwrMgt ( ptr ) ;
2019-11-09 10:12:08 +00:00
if ( pwrbit ) {
if ( ! ( psta - > state & WIFI_SLEEP_STATE ) ) {
/* psta->state |= WIFI_SLEEP_STATE; */
/* rtw_tim_map_set(padapter, pstapriv->sta_dz_bitmap, BIT(psta->cmn.aid)); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
stop_sta_xmit ( padapter , psta ) ;
/* RTW_INFO_DUMP("to sleep, sta_dz_bitmap=", pstapriv->sta_dz_bitmap, pstapriv->aid_bmp_len); */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else {
if ( psta - > state & WIFI_SLEEP_STATE ) {
/* psta->state ^= WIFI_SLEEP_STATE; */
/* rtw_tim_map_clear(padapter, pstapriv->sta_dz_bitmap, BIT(psta->cmn.aid)); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
wakeup_sta_to_xmit ( padapter , psta ) ;
/* RTW_INFO_DUMP("to wakeup, sta_dz_bitmap=", pstapriv->sta_dz_bitmap, pstapriv->aid_bmp_len); */
2015-08-18 19:03:09 +00:00
}
}
# endif
}
2019-11-09 10:12:08 +00:00
void process_wmmps_data ( _adapter * padapter , union recv_frame * precv_frame , struct sta_info * psta )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_AP_MODE
2015-08-18 19:03:09 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
# ifdef CONFIG_TDLS
2019-11-09 10:12:08 +00:00
if ( ! ( psta - > tdls_sta_state & TDLS_LINKED_STATE ) ) {
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ! psta - > qos_option )
return ;
if ( ! ( psta - > qos_info & 0xf ) )
return ;
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_TDLS
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( psta - > state & WIFI_SLEEP_STATE ) {
u8 wmmps_ac = 0 ;
switch ( pattrib - > priority ) {
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 ) ;
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( wmmps_ac ) {
if ( psta - > sleepq_ac_len > 0 ) {
/* process received triggered frame */
2015-08-18 19:03:09 +00:00
xmit_delivery_enabled_frames ( padapter , psta ) ;
2019-11-09 10:12:08 +00:00
} else {
/* issue one qos null frame with More data bit = 0 and the EOSP bit set (=1) */
issue_qos_nulldata ( padapter , psta - > cmn . mac_addr , ( u16 ) pattrib - > priority , 0 , 0 , 0 ) ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
2015-08-18 19:03:09 +00:00
}
# ifdef CONFIG_TDLS
sint OnTDLS ( _adapter * adapter , union recv_frame * precv_frame )
{
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
sint ret = _SUCCESS ;
u8 * paction = get_recvframe_data ( precv_frame ) ;
u8 category_field = 1 ;
# ifdef CONFIG_WFD
u8 WFA_OUI [ 3 ] = { 0x50 , 0x6f , 0x9a } ;
2017-05-11 18:47:23 +00:00
# endif /* CONFIG_WFD */
2015-08-18 19:03:09 +00:00
struct tdls_info * ptdlsinfo = & ( adapter - > tdlsinfo ) ;
2019-11-09 10:12:08 +00:00
u8 * ptr = precv_frame - > u . hdr . rx_data ;
struct sta_priv * pstapriv = & ( adapter - > stapriv ) ;
struct sta_info * ptdls_sta = NULL ;
2015-08-18 19:03:09 +00:00
2017-05-11 18:47:23 +00:00
/* point to action field */
2019-11-09 10:12:08 +00:00
paction + = pattrib - > hdrlen
+ pattrib - > iv_len
+ SNAP_SIZE
+ ETH_TYPE_LEN
+ PAYLOAD_TYPE_LEN
+ category_field ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
RTW_INFO ( " [TDLS] Recv %s from " MAC_FMT " with SeqNum = %d \n " , rtw_tdls_action_txt ( * paction ) , MAC_ARG ( pattrib - > src ) , GetSequence ( get_recvframe_data ( precv_frame ) ) ) ;
2017-05-11 18:47:23 +00:00
if ( hal_chk_wl_func ( adapter , WL_FUNC_TDLS ) = = _FALSE ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " Ignore tdls frame since hal doesn't support tdls \n " ) ;
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
return ret ;
}
2019-11-09 10:12:08 +00:00
if ( rtw_is_tdls_enabled ( adapter ) = = _FALSE ) {
RTW_INFO ( " recv tdls frame, "
" but tdls haven't enabled \n " ) ;
2015-08-18 19:03:09 +00:00
ret = _FAIL ;
return ret ;
}
2019-11-09 10:12:08 +00:00
2021-10-18 17:40:27 +00:00
ptdls_sta = rtw_get_stainfo ( pstapriv , ieee80211_get_SA ( ( struct ieee80211_hdr * ) ptr ) ) ;
2019-11-09 10:12:08 +00:00
if ( ptdls_sta = = NULL ) {
switch ( * paction ) {
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_SETUP_REQUEST :
case WLAN_TDLS_DISCOVERY_REQUEST :
2019-11-09 10:12:08 +00:00
break ;
default :
2021-10-18 17:40:27 +00:00
RTW_INFO ( " [TDLS] %s - Direct Link Peer = " MAC_FMT " not found for action = %d \n " , __func__ , MAC_ARG ( ieee80211_get_SA ( ( struct ieee80211_hdr * ) ptr ) ) , * paction ) ;
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
goto exit ;
}
}
switch ( * paction ) {
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_SETUP_REQUEST :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Setup_Req ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_SETUP_RESPONSE :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Setup_Rsp ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_SETUP_CONFIRM :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Setup_Cfm ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_TEARDOWN :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Teardown ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_DISCOVERY_REQUEST :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Dis_Req ( adapter , precv_frame ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_PEER_TRAFFIC_INDICATION :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Peer_Traffic_Indication ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_PEER_TRAFFIC_RESPONSE :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Peer_Traffic_Rsp ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_TDLS_CH_SW
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_CHANNEL_SWITCH_REQUEST :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Ch_Switch_Req ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2021-10-20 19:54:12 +00:00
case WLAN_TDLS_CHANNEL_SWITCH_RESPONSE :
2019-11-09 10:12:08 +00:00
ret = On_TDLS_Ch_Switch_Rsp ( adapter , precv_frame , ptdls_sta ) ;
2017-05-11 18:47:23 +00:00
break ;
2019-11-09 10:12:08 +00:00
# endif
# ifdef CONFIG_WFD
2017-05-11 18:47:23 +00:00
/* First byte of WFA OUI */
case 0x50 :
if ( _rtw_memcmp ( WFA_OUI , paction , 3 ) ) {
/* Probe request frame */
if ( * ( paction + 3 ) = = 0x04 ) {
/* WFDTDLS: for sigma test, do not setup direct link automatically */
ptdlsinfo - > dev_discovered = _TRUE ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " recv tunneled probe request frame \n " ) ;
2017-05-11 18:47:23 +00:00
issue_tunneled_probe_rsp ( adapter , precv_frame ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* Probe response frame */
2017-05-11 18:47:23 +00:00
if ( * ( paction + 3 ) = = 0x05 ) {
/* WFDTDLS: for sigma test, do not setup direct link automatically */
ptdlsinfo - > dev_discovered = _TRUE ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " recv tunneled probe response frame \n " ) ;
2017-05-11 18:47:23 +00:00
}
}
break ;
# endif /* CONFIG_WFD */
default :
2019-11-09 10:12:08 +00:00
RTW_INFO ( " receive TDLS frame %d but not support \n " , * paction ) ;
ret = _FAIL ;
2017-05-11 18:47:23 +00:00
break ;
2015-08-18 19:03:09 +00:00
}
exit :
return ret ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
}
2017-05-11 18:47:23 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
void count_rx_stats ( _adapter * padapter , union recv_frame * prframe , struct sta_info * sta )
2015-08-18 19:03:09 +00:00
{
int sz ;
struct sta_info * psta = NULL ;
struct stainfo_stats * pstats = NULL ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
sz = get_recvframe_len ( prframe ) ;
precvpriv - > rx_bytes + = sz ;
padapter - > mlmepriv . LinkDetectInfo . NumRxOkInPeriod + + ;
2021-08-23 12:01:00 +00:00
if ( ! is_broadcast_ether_addr ( pattrib - > dst ) & & ! is_multicast_ether_addr ( pattrib - > dst ) )
2015-08-18 19:03:09 +00:00
padapter - > mlmepriv . LinkDetectInfo . NumRxUnicastOkInPeriod + + ;
2019-11-09 10:12:08 +00:00
if ( sta )
2015-08-18 19:03:09 +00:00
psta = sta ;
else
psta = prframe - > u . hdr . psta ;
2019-11-09 10:12:08 +00:00
if ( psta ) {
2021-08-23 12:01:00 +00:00
u8 is_ra_bmc = is_multicast_ether_addr ( pattrib - > ra ) ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
pstats = & psta - > sta_stats ;
2021-10-14 19:34:26 +00:00
pstats - > last_rx_time = jiffies ;
2015-08-18 19:03:09 +00:00
pstats - > rx_data_pkts + + ;
pstats - > rx_bytes + = sz ;
2019-11-09 10:12:08 +00:00
if ( is_broadcast_mac_addr ( pattrib - > ra ) ) {
pstats - > rx_data_bc_pkts + + ;
pstats - > rx_bc_bytes + = sz ;
} else if ( is_ra_bmc ) {
pstats - > rx_data_mc_pkts + + ;
pstats - > rx_mc_bytes + = sz ;
}
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ! is_ra_bmc ) {
pstats - > rxratecnt [ pattrib - > data_rate ] + + ;
/*record rx packets for every tid*/
pstats - > rx_data_qos_pkts [ pattrib - > priority ] + + ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_DYNAMIC_SOML
rtw_dyn_soml_byte_update ( padapter , pattrib - > data_rate , sz ) ;
# endif
# if defined(CONFIG_CHECK_LEAVE_LPS) && defined(CONFIG_LPS_CHK_BY_TP)
if ( adapter_to_pwrctl ( padapter ) - > lps_chk_by_tp )
traffic_check_for_leave_lps_by_tp ( padapter , _FALSE , psta ) ;
# endif /* CONFIG_LPS */
2015-08-18 19:03:09 +00:00
}
# ifdef CONFIG_CHECK_LEAVE_LPS
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_LPS_CHK_BY_TP
if ( ! adapter_to_pwrctl ( padapter ) - > lps_chk_by_tp )
# endif
traffic_check_for_leave_lps ( padapter , _FALSE , 0 ) ;
# endif /* CONFIG_CHECK_LEAVE_LPS */
2015-08-18 19:03:09 +00:00
}
sint sta2sta_data_frame (
_adapter * adapter ,
union recv_frame * precv_frame ,
2019-11-09 10:12:08 +00:00
struct sta_info * * psta
2015-08-18 19:03:09 +00:00
)
{
u8 * ptr = precv_frame - > u . hdr . rx_data ;
sint ret = _SUCCESS ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_priv * pstapriv = & adapter - > stapriv ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
u8 * mybssid = get_bssid ( pmlmepriv ) ;
2017-05-11 18:47:23 +00:00
u8 * myhwaddr = adapter_mac_addr ( adapter ) ;
2019-11-09 10:12:08 +00:00
u8 * sta_addr = pattrib - > ta ;
2021-08-23 12:01:00 +00:00
sint bmcast = is_multicast_ether_addr ( pattrib - > dst ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_TDLS
2015-08-18 19:03:09 +00:00
struct tdls_info * ptdlsinfo = & adapter - > tdlsinfo ;
2017-05-11 18:47:23 +00:00
# ifdef CONFIG_TDLS_CH_SW
struct tdls_ch_switch * pchsw_info = & ptdlsinfo - > chsw_info ;
# endif
2019-11-09 10:12:08 +00:00
struct sta_info * ptdls_sta = NULL ;
u8 * psnap_type = ptr + pattrib - > hdrlen + pattrib - > iv_len + SNAP_SIZE ;
/* frame body located after [+2]: ether-type, [+1]: payload type */
u8 * pframe_body = psnap_type + 2 + 1 ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
/* RTW_INFO("[%s] %d, seqnum:%d\n", __FUNCTION__, __LINE__, pattrib->seq_num); */
2015-08-18 19:03:09 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_ADHOC_STATE ) = = _TRUE ) | |
2019-11-09 10:12:08 +00:00
( check_fwstate ( pmlmepriv , WIFI_ADHOC_MASTER_STATE ) = = _TRUE ) ) {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* filter packets that SA is myself or multicast or broadcast */
if ( _rtw_memcmp ( myhwaddr , pattrib - > src , ETH_ALEN ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
if ( ( ! _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) ) & & ( ! bmcast ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
if ( _rtw_memcmp ( pattrib - > bssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
_rtw_memcmp ( mybssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
} else if ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = _TRUE ) {
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_TDLS
2017-05-11 18:47:23 +00:00
/* direct link data transfer */
if ( ptdlsinfo - > link_established = = _TRUE ) {
2019-11-09 10:12:08 +00:00
* psta = ptdls_sta = rtw_get_stainfo ( pstapriv , pattrib - > ta ) ;
2017-05-11 18:47:23 +00:00
if ( ptdls_sta = = NULL ) {
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
2017-05-11 18:47:23 +00:00
} else if ( ptdls_sta - > tdls_sta_state & TDLS_LINKED_STATE ) {
/* filter packets that SA is myself or multicast or broadcast */
if ( _rtw_memcmp ( myhwaddr , pattrib - > src , ETH_ALEN ) ) {
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2017-05-11 18:47:23 +00:00
/* da should be for me */
if ( ( ! _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) ) & & ( ! bmcast ) ) {
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2017-05-11 18:47:23 +00:00
/* check BSSID */
if ( _rtw_memcmp ( pattrib - > bssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
2019-11-09 10:12:08 +00:00
_rtw_memcmp ( mybssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2017-05-11 18:47:23 +00:00
# ifdef CONFIG_TDLS_CH_SW
2021-08-02 19:27:18 +00:00
if ( atomic_read ( & pchsw_info - > chsw_on ) = = _TRUE ) {
2017-05-11 18:47:23 +00:00
if ( adapter - > mlmeextpriv . cur_channel ! = rtw_get_oper_ch ( adapter ) ) {
pchsw_info - > ch_sw_state | = TDLS_PEER_AT_OFF_STATE ;
if ( ! ( pchsw_info - > ch_sw_state & TDLS_CH_SW_INITIATOR_STATE ) )
_cancel_timer_ex ( & ptdls_sta - > ch_sw_timer ) ;
/* On_TDLS_Peer_Traffic_Rsp(adapter, precv_frame); */
}
}
# endif
/* process UAPSD tdls sta */
2019-11-09 10:12:08 +00:00
process_pwrbit_data ( adapter , precv_frame , ptdls_sta ) ;
2015-08-18 19:03:09 +00:00
2017-05-11 18:47:23 +00:00
/* if NULL-frame, check pwrbit */
2021-10-18 14:05:53 +00:00
if ( ( get_frame_sub_type ( ptr ) & IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC ) = = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC ) {
2017-05-11 18:47:23 +00:00
/* NULL-frame with pwrbit=1, buffer_STA should buffer frames for sleep_STA */
if ( GetPwrMgt ( ptr ) ) {
/* it would be triggered when we are off channel and receiving NULL DATA */
/* we can confirm that peer STA is at off channel */
2019-11-09 10:12:08 +00:00
RTW_INFO ( " TDLS: recv peer null frame with pwr bit 1 \n " ) ;
/* ptdls_sta->tdls_sta_state|=TDLS_PEER_SLEEP_STATE; */
2015-08-18 19:03:09 +00:00
}
2017-05-11 18:47:23 +00:00
/* TODO: Updated BSSID's seq. */
2019-11-09 10:12:08 +00:00
/* RTW_INFO("drop Null Data\n"); */
2015-08-18 19:03:09 +00:00
ptdls_sta - > tdls_sta_state & = ~ ( TDLS_WAIT_PTR_STATE ) ;
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2017-05-11 18:47:23 +00:00
/* receive some of all TDLS management frames, process it at ON_TDLS */
if ( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_TDLS , 2 ) ) {
2019-11-09 10:12:08 +00:00
ret = OnTDLS ( adapter , precv_frame ) ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2021-10-18 14:05:53 +00:00
if ( ( get_frame_sub_type ( ptr ) & ( IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA ) ) = = ( IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA ) )
2019-11-09 10:12:08 +00:00
process_wmmps_data ( adapter , precv_frame , ptdls_sta ) ;
2015-08-18 19:03:09 +00:00
ptdls_sta - > tdls_sta_state & = ~ ( TDLS_WAIT_PTR_STATE ) ;
}
2019-11-09 10:12:08 +00:00
} else
2017-05-11 18:47:23 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
/* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */
if ( ! _rtw_memcmp ( pattrib - > bssid , pattrib - > src , ETH_ALEN ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = _TRUE ) {
if ( bmcast ) {
/* For AP mode, if DA == MCAST, then BSSID should be also MCAST */
2021-08-23 12:01:00 +00:00
if ( ! is_multicast_ether_addr ( pattrib - > bssid ) ) {
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
goto exit ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else { /* not mc-frame */
/* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */
if ( ! _rtw_memcmp ( pattrib - > bssid , pattrib - > dst , ETH_ALEN ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
}
2019-11-09 10:12:08 +00:00
} else if ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE ) {
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ra , pattrib - > dst , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pattrib - > src , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
sta_addr = mybssid ;
2019-11-09 10:12:08 +00:00
} else
2015-08-18 19:03:09 +00:00
ret = _FAIL ;
# ifdef CONFIG_TDLS
2019-11-09 10:12:08 +00:00
if ( ptdls_sta = = NULL )
# endif
* psta = rtw_get_stainfo ( pstapriv , sta_addr ) ;
2015-08-18 19:03:09 +00:00
if ( * psta = = NULL ) {
# ifdef CONFIG_MP_INCLUDED
2019-11-09 10:12:08 +00:00
if ( adapter - > registrypriv . mp_mode = = 1 ) {
if ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE )
2017-05-11 18:47:23 +00:00
adapter - > mppriv . rx_pktloss + + ;
2015-08-18 19:03:09 +00:00
}
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
exit :
return ret ;
}
sint ap2sta_data_frame (
_adapter * adapter ,
union recv_frame * precv_frame ,
2019-11-09 10:12:08 +00:00
struct sta_info * * psta )
2015-08-18 19:03:09 +00:00
{
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
sint ret = _SUCCESS ;
2019-11-09 10:12:08 +00:00
struct sta_priv * pstapriv = & adapter - > stapriv ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
u8 * mybssid = get_bssid ( pmlmepriv ) ;
2017-05-11 18:47:23 +00:00
u8 * myhwaddr = adapter_mac_addr ( adapter ) ;
2021-08-23 12:01:00 +00:00
sint bmcast = is_multicast_ether_addr ( pattrib - > dst ) ;
2015-08-18 19:03:09 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_STATION_STATE ) = = _TRUE )
2019-11-09 10:12:08 +00:00
& & ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = _TRUE
| | check_fwstate ( pmlmepriv , _FW_UNDER_LINKING ) = = _TRUE )
) {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* filter packets that SA is myself or multicast or broadcast */
if ( _rtw_memcmp ( myhwaddr , pattrib - > src , ETH_ALEN ) ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " SA= " MAC_FMT " , myhwaddr= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( pattrib - > src ) , MAC_ARG ( myhwaddr ) ) ;
# endif
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
/* da should be for me */
if ( ( ! _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) ) & & ( ! bmcast ) ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " DA= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( pattrib - > dst ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
/* check BSSID */
if ( _rtw_memcmp ( pattrib - > bssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
_rtw_memcmp ( mybssid , " \ x0 \ x0 \ x0 \ x0 \ x0 \ x0 " , ETH_ALEN ) | |
( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " BSSID= " MAC_FMT " , mybssid= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( pattrib - > bssid ) , MAC_ARG ( mybssid ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
# ifndef CONFIG_CUSTOMER_ALIBABA_GENERAL
if ( ! bmcast
& & ! IS_RADAR_DETECTED ( adapter_to_rfctl ( adapter ) )
) {
RTW_INFO ( ADPT_FMT " -issue_deauth to the nonassociated ap= " MAC_FMT " for the reason(7) \n " , ADPT_ARG ( adapter ) , MAC_ARG ( pattrib - > bssid ) ) ;
2015-08-18 19:03:09 +00:00
issue_deauth ( adapter , pattrib - > bssid , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
}
2019-11-09 10:12:08 +00:00
# endif
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > ta ) ;
2015-08-18 19:03:09 +00:00
if ( * psta = = NULL ) {
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " can't get psta under STATION_MODE ; drop pkt \n "
, FUNC_ADPT_ARG ( adapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2021-10-18 14:05:53 +00:00
/*if ((get_frame_sub_type(ptr) & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) {
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
*/
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( get_frame_sub_type ( ptr ) & BIT ( 6 ) ) {
2015-08-18 19:03:09 +00:00
/* 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 ;
}
2019-11-09 10:12:08 +00:00
} else if ( ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE ) & &
( check_fwstate ( pmlmepriv , _FW_LINKED ) = = _TRUE ) ) {
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ra , pattrib - > dst , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pattrib - > src , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > bssid ) ; /* get sta_info */
2015-08-18 19:03:09 +00:00
if ( * psta = = NULL ) {
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " can't get psta under WIFI_MP_STATE ; drop pkt \n "
, FUNC_ADPT_ARG ( adapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
} else if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = _TRUE ) {
2015-08-18 19:03:09 +00:00
/* Special case */
ret = RTW_RX_HANDLED ;
goto exit ;
2019-11-09 10:12:08 +00:00
} else {
if ( _rtw_memcmp ( myhwaddr , pattrib - > dst , ETH_ALEN ) & & ( ! bmcast ) ) {
* psta = rtw_get_stainfo ( pstapriv , pattrib - > ta ) ;
if ( * psta = = NULL ) {
/* for AP multicast issue , modify by yiwei */
static systime send_issue_deauth_time = 0 ;
/* RTW_INFO("After send deauth , %u ms has elapsed.\n", rtw_get_passing_time_ms(send_issue_deauth_time)); */
if ( rtw_get_passing_time_ms ( send_issue_deauth_time ) > 10000 | | send_issue_deauth_time = = 0 ) {
2021-10-14 19:34:26 +00:00
send_issue_deauth_time = jiffies ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " issue_deauth to the ap= " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > bssid ) ) ;
2017-05-11 18:35:20 +00:00
issue_deauth ( adapter , pattrib - > bssid , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
ret = _FAIL ;
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " fw_state:0x%x \n "
, FUNC_ADPT_ARG ( adapter ) , get_fwstate ( pmlmepriv ) ) ;
2015-08-18 19:03:09 +00:00
# endif
}
exit :
return ret ;
}
sint sta2ap_data_frame (
_adapter * adapter ,
union recv_frame * precv_frame ,
2019-11-09 10:12:08 +00:00
struct sta_info * * psta )
2015-08-18 19:03:09 +00:00
{
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_priv * pstapriv = & adapter - > stapriv ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2019-11-09 10:12:08 +00:00
unsigned char * mybssid = get_bssid ( pmlmepriv ) ;
sint ret = _SUCCESS ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) = = _TRUE ) {
/* For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
if ( ! _rtw_memcmp ( pattrib - > bssid , mybssid , ETH_ALEN ) ) {
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > ta ) ;
if ( * psta = = NULL ) {
if ( ! IS_RADAR_DETECTED ( adapter_to_rfctl ( adapter ) ) ) {
# ifndef CONFIG_CUSTOMER_ALIBABA_GENERAL
RTW_INFO ( " issue_deauth to sta= " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > src ) ) ;
issue_deauth ( adapter , pattrib - > src , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
2017-05-11 18:47:23 +00:00
# endif
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
ret = RTW_RX_HANDLED ;
goto exit ;
}
2019-11-09 10:12:08 +00:00
process_pwrbit_data ( adapter , precv_frame , * psta ) ;
2015-08-18 19:03:09 +00:00
2021-10-18 14:05:53 +00:00
if ( ( get_frame_sub_type ( ptr ) & ( IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA ) ) = = ( IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA ) )
2019-11-09 10:12:08 +00:00
process_wmmps_data ( adapter , precv_frame , * psta ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( get_frame_sub_type ( ptr ) & BIT ( 6 ) ) {
2015-08-18 19:03:09 +00:00
/* 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 ;
}
2019-11-09 10:12:08 +00:00
} else if ( ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE ) & &
( check_fwstate ( pmlmepriv , _FW_LINKED ) = = _TRUE ) ) {
/* RTW_INFO("%s ,in WIFI_MP_STATE\n",__func__); */
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ra , pattrib - > dst , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pattrib - > src , ETH_ALEN ) ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
* psta = rtw_get_stainfo ( pstapriv , pattrib - > bssid ) ; /* get sta_info */
2017-05-11 18:35:20 +00:00
if ( * psta = = NULL ) {
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " can't get psta under WIFI_MP_STATE ; drop pkt \n "
, FUNC_ADPT_ARG ( adapter ) ) ;
2017-05-11 18:35:20 +00:00
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2017-05-11 18:35:20 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:47:23 +00:00
u8 * myhwaddr = adapter_mac_addr ( adapter ) ;
2015-08-18 19:03:09 +00:00
if ( ! _rtw_memcmp ( pattrib - > ra , myhwaddr , ETH_ALEN ) ) {
ret = RTW_RX_HANDLED ;
goto exit ;
}
2019-11-09 10:12:08 +00:00
# ifndef CONFIG_CUSTOMER_ALIBABA_GENERAL
RTW_INFO ( " issue_deauth to sta= " MAC_FMT " for the reason(7) \n " , MAC_ARG ( pattrib - > src ) ) ;
2015-08-18 19:03:09 +00:00
issue_deauth ( adapter , pattrib - > src , WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA ) ;
2019-11-09 10:12:08 +00:00
# endif
2015-08-18 19:03:09 +00:00
ret = RTW_RX_HANDLED ;
goto exit ;
}
exit :
return ret ;
}
2022-10-30 18:39:00 +00:00
void validate_recv_ctrl_frame ( _adapter * padapter , union recv_frame * precv_frame )
2015-08-18 19:03:09 +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 ;
2019-11-09 10:12:08 +00:00
struct sta_info * psta = NULL ;
/* uint len = precv_frame->u.hdr.len; */
/* RTW_INFO("+validate_recv_ctrl_frame\n"); */
2015-08-18 19:03:09 +00:00
2021-10-18 14:05:53 +00:00
if ( GetFrameType ( pframe ) ! = IEEE80211_FTYPE_CTL )
2022-10-30 18:39:00 +00:00
return ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* receive the frames that ra(a1) is my address */
2017-05-11 18:47:23 +00:00
if ( ! _rtw_memcmp ( GetAddr1Ptr ( pframe ) , adapter_mac_addr ( padapter ) , ETH_ALEN ) )
2022-10-30 18:39:00 +00:00
return ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
psta = rtw_get_stainfo ( pstapriv , get_addr2_ptr ( pframe ) ) ;
if ( psta = = NULL )
2022-10-30 18:39:00 +00:00
return ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* for rx pkt statistics */
2021-10-14 19:34:26 +00:00
psta - > sta_stats . last_rx_time = jiffies ;
2015-08-18 19:03:09 +00:00
psta - > sta_stats . rx_ctrl_pkts + + ;
2019-11-09 10:12:08 +00:00
/* only handle ps-poll */
2021-10-18 14:05:53 +00:00
if ( get_frame_sub_type ( pframe ) = = ( IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL ) ) {
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_AP_MODE
u16 aid ;
2019-11-09 10:12:08 +00:00
u8 wmmps_ac = 0 ;
2015-08-18 19:03:09 +00:00
aid = GetAid ( pframe ) ;
2019-11-09 10:12:08 +00:00
if ( psta - > cmn . aid ! = aid )
2022-10-30 18:39:00 +00:00
return ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( pattrib - > priority ) {
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 ) ;
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( wmmps_ac )
2022-10-30 18:39:00 +00:00
return ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( psta - > state & WIFI_STA_ALIVE_CHK_STATE ) {
RTW_INFO ( " %s alive check-rx ps-poll \n " , __func__ ) ;
2015-08-18 19:03:09 +00:00
psta - > expire_to = pstapriv - > expire_to ;
psta - > state ^ = WIFI_STA_ALIVE_CHK_STATE ;
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ( psta - > state & WIFI_SLEEP_STATE ) & & ( rtw_tim_map_is_set ( padapter , pstapriv - > sta_dz_bitmap , psta - > cmn . aid ) ) ) {
_irqL irqL ;
2015-08-18 19:03:09 +00:00
_list * xmitframe_plist , * xmitframe_phead ;
2019-11-09 10:12:08 +00:00
struct xmit_frame * pxmitframe = NULL ;
2015-08-18 19:03:09 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
2019-11-09 10:12:08 +00:00
/* _enter_critical_bh(&psta->sleep_q.lock, &irqL); */
2015-08-18 19:03:09 +00:00
_enter_critical_bh ( & pxmitpriv - > lock , & irqL ) ;
xmitframe_phead = get_list_head ( & psta - > sleep_q ) ;
xmitframe_plist = get_next ( xmitframe_phead ) ;
2021-10-14 20:37:57 +00:00
if ( xmitframe_phead ! = xmitframe_plist ) {
2015-08-18 19:03:09 +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 - - ;
2019-11-09 10:12:08 +00:00
if ( psta - > sleepq_len > 0 )
2015-08-18 19:03:09 +00:00
pxmitframe - > attrib . mdata = 1 ;
else
pxmitframe - > attrib . mdata = 0 ;
pxmitframe - > attrib . triggered = 1 ;
2019-11-09 10:12:08 +00:00
/* RTW_INFO("handling ps-poll, q_len=%d\n", psta->sleepq_len); */
/* RTW_INFO_DUMP("handling, tim=", pstapriv->tim_bitmap, pstapriv->aid_bmp_len); */
2015-08-18 19:03:09 +00:00
#if 0
_exit_critical_bh ( & psta - > sleep_q . lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
if ( rtw_hal_xmit ( padapter , pxmitframe ) = = _TRUE )
2015-08-18 19:03:09 +00:00
rtw_os_xmit_complete ( padapter , pxmitframe ) ;
2019-11-09 10:12:08 +00:00
_enter_critical_bh ( & psta - > sleep_q . lock , & irqL ) ;
2015-08-18 19:03:09 +00:00
# endif
rtw_hal_xmitframe_enqueue ( padapter , pxmitframe ) ;
2019-11-09 10:12:08 +00:00
if ( psta - > sleepq_len = = 0 ) {
rtw_tim_map_clear ( padapter , pstapriv - > tim_bitmap , psta - > cmn . aid ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* RTW_INFO("after handling ps-poll\n"); */
/* RTW_INFO_DUMP("after handling, tim=", pstapriv->tim_bitmap, pstapriv->aid_bmp_len); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* upate BCN for TIM IE */
/* update_BCNTIM(padapter); */
2022-10-30 18:39:00 +00:00
update_beacon ( padapter , WLAN_EID_TIM , NULL , _TRUE ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* _exit_critical_bh(&psta->sleep_q.lock, &irqL); */
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & pxmitpriv - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
} else {
/* _exit_critical_bh(&psta->sleep_q.lock, &irqL); */
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & pxmitpriv - > lock , & irqL ) ;
2019-11-09 10:12:08 +00:00
/* RTW_INFO("no buffered packets to xmit\n"); */
if ( rtw_tim_map_is_set ( padapter , pstapriv - > tim_bitmap , psta - > cmn . aid ) ) {
if ( psta - > sleepq_len = = 0 ) {
RTW_INFO ( " no buffered packets to xmit \n " ) ;
/* issue nulldata with More data bit = 0 to indicate we have no buffered packets */
issue_nulldata ( padapter , psta - > cmn . mac_addr , 0 , 0 , 0 ) ;
} else {
RTW_INFO ( " error!psta->sleepq_len=%d \n " , psta - > sleepq_len ) ;
psta - > sleepq_len = 0 ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
rtw_tim_map_clear ( padapter , pstapriv - > tim_bitmap , psta - > cmn . aid ) ;
/* upate BCN for TIM IE */
/* update_BCNTIM(padapter); */
2022-10-30 18:39:00 +00:00
update_beacon ( padapter , WLAN_EID_TIM , NULL , _TRUE ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_AP_MODE */
} else if ( get_frame_sub_type ( pframe ) = = WIFI_NDPA ) {
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_BEAMFORMING
2019-11-09 10:12:08 +00:00
rtw_beamforming_get_ndpa_frame ( padapter , precv_frame ) ;
2017-05-11 18:47:23 +00:00
# endif /*CONFIG_BEAMFORMING*/
2021-10-18 14:05:53 +00:00
} else if ( get_frame_sub_type ( pframe ) = = IEEE80211_STYPE_BACK_REQ ) {
2019-11-09 10:12:08 +00:00
rtw_process_bar_frame ( padapter , precv_frame ) ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
# if defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH)
static sint validate_mgmt_protect ( _adapter * adapter , union recv_frame * precv_frame )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
# define DBG_VALIDATE_MGMT_PROTECT 0
# define DBG_VALIDATE_MGMT_DEC 0
struct security_priv * sec = & adapter - > securitypriv ;
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct sta_info * psta = precv_frame - > u . hdr . psta ;
u8 * ptr ;
u8 type ;
u8 subtype ;
u8 is_bmc ;
u8 category = 0xFF ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_IEEE80211W
const u8 * igtk ;
u16 igtk_id ;
u64 * ipn ;
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
u8 * mgmt_DATA ;
u32 data_len = 0 ;
sint ret ;
# ifdef CONFIG_RTW_MESH
if ( MLME_IS_MESH ( adapter ) ) {
if ( ! adapter - > mesh_info . mesh_auth_id )
return pattrib - > privacy ? _FAIL : _SUCCESS ;
} else
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
if ( SEC_IS_BIP_KEY_INSTALLED ( sec ) = = _FALSE )
return _SUCCESS ;
ptr = precv_frame - > u . hdr . rx_data ;
type = GetFrameType ( ptr ) ;
subtype = get_frame_sub_type ( ptr ) ; /* bit(7)~bit(2) */
2021-08-23 12:01:00 +00:00
is_bmc = is_multicast_ether_addr ( GetAddr1Ptr ( ptr ) ) ;
2019-11-09 10:12:08 +00:00
# if DBG_VALIDATE_MGMT_PROTECT
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_DEAUTH ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( FUNC_ADPT_FMT " bmc:%u, deauth, privacy:%u, encrypt:%u, bdecrypted:%u \n "
, FUNC_ADPT_ARG ( adapter )
, is_bmc , pattrib - > privacy , pattrib - > encrypt , pattrib - > bdecrypted ) ;
2021-10-18 14:05:53 +00:00
} else if ( subtype = = IEEE80211_STYPE_DISASSOC ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( FUNC_ADPT_FMT " bmc:%u, disassoc, privacy:%u, encrypt:%u, bdecrypted:%u \n "
, FUNC_ADPT_ARG ( adapter )
, is_bmc , pattrib - > privacy , pattrib - > encrypt , pattrib - > bdecrypted ) ;
2021-10-18 14:05:53 +00:00
} if ( subtype = = IEEE80211_STYPE_ACTION ) {
2019-11-09 10:12:08 +00:00
if ( pattrib - > privacy ) {
RTW_INFO ( FUNC_ADPT_FMT " bmc:%u, action(?), privacy:%u, encrypt:%u, bdecrypted:%u \n "
, FUNC_ADPT_ARG ( adapter )
, is_bmc , pattrib - > privacy , pattrib - > encrypt , pattrib - > bdecrypted ) ;
} else {
RTW_INFO ( FUNC_ADPT_FMT " bmc:%u, action(%u), privacy:%u, encrypt:%u, bdecrypted:%u \n "
, FUNC_ADPT_ARG ( adapter ) , is_bmc
2021-10-21 15:30:03 +00:00
, * ( ptr + sizeof ( struct ieee80211_hdr_3addr ) )
2019-11-09 10:12:08 +00:00
, pattrib - > privacy , pattrib - > encrypt , pattrib - > bdecrypted ) ;
}
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
if ( ! pattrib - > privacy ) {
if ( ! psta | | ! ( psta - > flags & WLAN_STA_MFP ) ) {
/* peer is not MFP capable, no need to check */
goto exit ;
}
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_ACTION )
2021-10-21 15:30:03 +00:00
category = * ( ptr + sizeof ( struct ieee80211_hdr_3addr ) ) ;
2019-11-09 10:12:08 +00:00
if ( is_bmc ) {
/* broadcast cases */
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_ACTION ) {
2019-11-09 10:12:08 +00:00
if ( CATEGORY_IS_GROUP_PRIVACY ( category ) ) {
/* drop broadcast group privacy action frame without encryption */
# if DBG_VALIDATE_MGMT_PROTECT
RTW_INFO ( FUNC_ADPT_FMT " broadcast gp action(%u) w/o encrypt \n "
, FUNC_ADPT_ARG ( adapter ) , category ) ;
# endif
goto fail ;
}
if ( CATEGORY_IS_ROBUST ( category ) ) {
/* broadcast robust action frame need BIP check */
goto bip_verify ;
}
}
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_DEAUTH | | subtype = = IEEE80211_STYPE_DISASSOC ) {
2019-11-09 10:12:08 +00:00
/* broadcast deauth or disassoc frame need BIP check */
goto bip_verify ;
}
goto exit ;
} else {
/* unicast cases */
# ifdef CONFIG_IEEE80211W
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_DEAUTH | | subtype = = IEEE80211_STYPE_DISASSOC ) {
2019-11-09 10:12:08 +00:00
if ( ! MLME_IS_MESH ( adapter ) ) {
unsigned short reason = le16_to_cpu ( * ( unsigned short * ) ( ptr + WLAN_HDR_A3_LEN ) ) ;
# if DBG_VALIDATE_MGMT_PROTECT
RTW_INFO ( FUNC_ADPT_FMT " unicast %s, reason=%d w/o encrypt \n "
2021-10-18 14:05:53 +00:00
, FUNC_ADPT_ARG ( adapter ) , subtype = = IEEE80211_STYPE_DEAUTH ? " deauth " : " disassoc " , reason ) ;
2019-11-09 10:12:08 +00:00
# endif
if ( reason = = 6 | | reason = = 7 ) {
/* issue sa query request */
issue_action_SA_Query ( adapter , psta - > cmn . mac_addr , 0 , 0 , IEEE80211W_RIGHT_KEY ) ;
}
}
goto fail ;
}
# endif
2021-10-18 14:05:53 +00:00
if ( subtype = = IEEE80211_STYPE_ACTION & & CATEGORY_IS_ROBUST ( category ) ) {
2019-11-09 10:12:08 +00:00
if ( psta - > bpairwise_key_installed = = _TRUE ) {
# if DBG_VALIDATE_MGMT_PROTECT
RTW_INFO ( FUNC_ADPT_FMT " unicast robust action(%d) w/o encrypt \n "
, FUNC_ADPT_ARG ( adapter ) , category ) ;
# endif
goto fail ;
}
}
goto exit ;
}
bip_verify :
# ifdef CONFIG_IEEE80211W
# ifdef CONFIG_RTW_MESH
if ( MLME_IS_MESH ( adapter ) ) {
if ( psta - > igtk_bmp ) {
igtk = psta - > igtk . skey ;
igtk_id = psta - > igtk_id ;
ipn = & psta - > igtk_pn . val ;
} else {
/* mesh MFP without IGTK */
goto exit ;
}
} else
# endif
{
igtk = sec - > dot11wBIPKey [ sec - > dot11wBIPKeyid ] . skey ;
igtk_id = sec - > dot11wBIPKeyid ;
ipn = & sec - > dot11wBIPrxpn . val ;
}
/* verify BIP MME IE */
ret = rtw_BIP_verify ( adapter
, get_recvframe_data ( precv_frame )
, get_recvframe_len ( precv_frame )
, igtk , igtk_id , ipn ) ;
if ( ret = = _FAIL ) {
/* RTW_INFO("802.11w BIP verify fail\n"); */
goto fail ;
} else if ( ret = = RTW_RX_HANDLED ) {
# if DBG_VALIDATE_MGMT_PROTECT
RTW_INFO ( FUNC_ADPT_FMT " none protected packet \n " , FUNC_ADPT_ARG ( adapter ) ) ;
# endif
goto fail ;
}
# endif /* CONFIG_IEEE80211W */
goto exit ;
}
/* cases to decrypt mgmt frame */
pattrib - > bdecrypted = 0 ;
pattrib - > encrypt = _AES_ ;
2021-10-21 15:30:03 +00:00
pattrib - > hdrlen = sizeof ( struct ieee80211_hdr_3addr ) ;
2019-11-09 10:12:08 +00:00
/* set iv and icv length */
SET_ICE_IV_LEN ( pattrib - > iv_len , pattrib - > icv_len , pattrib - > encrypt ) ;
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
/* actual management data frame body */
data_len = pattrib - > pkt_len - pattrib - > hdrlen - pattrib - > iv_len - pattrib - > icv_len ;
mgmt_DATA = rtw_zmalloc ( data_len ) ;
if ( mgmt_DATA = = NULL ) {
RTW_INFO ( FUNC_ADPT_FMT " mgmt allocate fail !!!!!!!!! \n " , FUNC_ADPT_ARG ( adapter ) ) ;
goto fail ;
}
# if DBG_VALIDATE_MGMT_DEC
/* dump the packet content before decrypt */
{
int pp ;
printk ( " pattrib->pktlen = %d => " , pattrib - > pkt_len ) ;
for ( pp = 0 ; pp < pattrib - > pkt_len ; pp + + )
printk ( " %02x " , ptr [ pp ] ) ;
printk ( " \n " ) ;
}
# endif
precv_frame = decryptor ( adapter , precv_frame ) ;
/* save actual management data frame body */
2021-10-12 14:53:20 +00:00
memcpy ( mgmt_DATA , ptr + pattrib - > hdrlen + pattrib - > iv_len , data_len ) ;
2019-11-09 10:12:08 +00:00
/* overwrite the iv field */
2021-10-12 14:53:20 +00:00
memcpy ( ptr + pattrib - > hdrlen , mgmt_DATA , data_len ) ;
2019-11-09 10:12:08 +00:00
/* remove the iv and icv length */
pattrib - > pkt_len = pattrib - > pkt_len - pattrib - > iv_len - pattrib - > icv_len ;
rtw_mfree ( mgmt_DATA , data_len ) ;
# if DBG_VALIDATE_MGMT_DEC
/* print packet content after decryption */
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
int pp ;
printk ( " after decryption pattrib->pktlen = %d @@=> " , pattrib - > pkt_len ) ;
for ( pp = 0 ; pp < pattrib - > pkt_len ; pp + + )
printk ( " %02x " , ptr [ pp ] ) ;
printk ( " \n " ) ;
}
# endif
if ( ! precv_frame ) {
# if DBG_VALIDATE_MGMT_PROTECT
RTW_INFO ( FUNC_ADPT_FMT " mgmt descrypt fail !!!!!!!!! \n " , FUNC_ADPT_ARG ( adapter ) ) ;
# endif
goto fail ;
}
exit :
return _SUCCESS ;
fail :
return _FAIL ;
}
# endif /* defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH) */
union recv_frame * recvframe_chk_defrag ( PADAPTER padapter , union recv_frame * precv_frame ) ;
sint validate_recv_mgnt_frame ( PADAPTER padapter , union recv_frame * precv_frame )
{
struct sta_info * psta = precv_frame - > u . hdr . psta
= rtw_get_stainfo ( & padapter - > stapriv , get_addr2_ptr ( precv_frame - > u . hdr . rx_data ) ) ;
# if defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH)
if ( validate_mgmt_protect ( padapter , precv_frame ) = = _FAIL ) {
DBG_COUNTER ( padapter - > rx_logs . core_rx_pre_mgmt_err_80211w ) ;
goto exit ;
2015-08-18 19:03:09 +00:00
}
# endif
precv_frame = recvframe_chk_defrag ( padapter , precv_frame ) ;
2019-11-09 10:12:08 +00:00
if ( precv_frame = = NULL )
2015-08-18 19:03:09 +00:00
return _SUCCESS ;
2019-11-09 10:12:08 +00:00
/* for rx pkt statistics */
if ( psta ) {
2021-10-14 19:34:26 +00:00
psta - > sta_stats . last_rx_time = jiffies ;
2019-11-09 10:12:08 +00:00
psta - > sta_stats . rx_mgnt_pkts + + ;
2021-10-18 14:05:53 +00:00
if ( get_frame_sub_type ( precv_frame - > u . hdr . rx_data ) = = IEEE80211_STYPE_BEACON )
2019-11-09 10:12:08 +00:00
psta - > sta_stats . rx_beacon_pkts + + ;
2021-10-18 14:05:53 +00:00
else if ( get_frame_sub_type ( precv_frame - > u . hdr . rx_data ) = = IEEE80211_STYPE_PROBE_REQ )
2019-11-09 10:12:08 +00:00
psta - > sta_stats . rx_probereq_pkts + + ;
2021-10-18 14:05:53 +00:00
else if ( get_frame_sub_type ( precv_frame - > u . hdr . rx_data ) = = IEEE80211_STYPE_PROBE_RESP ) {
2019-11-09 10:12:08 +00:00
if ( _rtw_memcmp ( adapter_mac_addr ( padapter ) , GetAddr1Ptr ( precv_frame - > u . hdr . rx_data ) , ETH_ALEN ) = = _TRUE )
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 + + ;
else
psta - > sta_stats . rx_probersp_uo_pkts + + ;
2015-08-18 19:03:09 +00:00
}
}
# ifdef CONFIG_INTEL_PROXIM
2019-11-09 10:12:08 +00:00
if ( padapter - > proximity . proxim_on = = _TRUE ) {
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct recv_stat * prxstat = ( struct recv_stat * ) precv_frame - > u . hdr . rx_head ;
u8 * pda , * psa , * pbssid , * ptr ;
ptr = precv_frame - > u . hdr . rx_data ;
2021-10-18 17:40:27 +00:00
pda = ieee80211_get_DA ( ( struct ieee80211_hdr * ) ptr ) ;
psa = ieee80211_get_SA ( ( struct ieee80211_hdr * ) ptr ) ;
2015-08-18 19:03:09 +00:00
pbssid = get_hdr_bssid ( ptr ) ;
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > dst , pda , ETH_ALEN ) ;
memcpy ( pattrib - > src , psa , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > bssid , pbssid , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( pattrib - > to_fr_ds ) {
2015-08-18 19:03:09 +00:00
case 0 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
break ;
case 1 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pbssid , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
break ;
case 2 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pbssid , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
break ;
case 3 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
break ;
default :
break ;
2019-11-09 10:12:08 +00:00
}
pattrib - > priority = 0 ;
pattrib - > hdrlen = pattrib - > to_fr_ds = = 3 ? 30 : 24 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
padapter - > proximity . proxim_rx ( padapter , precv_frame ) ;
2015-08-18 19:03:09 +00:00
}
# endif
mgt_dispatcher ( padapter , precv_frame ) ;
2019-11-09 10:12:08 +00:00
# if defined(CONFIG_IEEE80211W) || defined(CONFIG_RTW_MESH)
exit :
# endif
2015-08-18 19:03:09 +00:00
return _SUCCESS ;
}
sint validate_recv_data_frame ( _adapter * adapter , union recv_frame * precv_frame )
{
2019-11-09 10:12:08 +00:00
u8 bretry , a4_shift ;
2015-08-18 19:03:09 +00:00
struct sta_info * psta = NULL ;
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct security_priv * psecuritypriv = & adapter - > securitypriv ;
2015-08-18 19:03:09 +00:00
sint ret = _SUCCESS ;
bretry = GetRetry ( ptr ) ;
2019-11-09 10:12:08 +00:00
a4_shift = ( pattrib - > to_fr_ds = = 3 ) ? ETH_ALEN : 0 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* some address fields are different when using AMSDU */
if ( pattrib - > qos )
pattrib - > amsdu = GetAMsdu ( ptr + WLAN_HDR_A3_LEN + a4_shift ) ;
else
pattrib - > amsdu = 0 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RTW_MESH
if ( MLME_IS_MESH ( adapter ) ) {
ret = rtw_mesh_rx_data_validate_hdr ( adapter , precv_frame , & psta ) ;
goto pre_validate_status_chk ;
}
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( pattrib - > to_fr_ds ) {
case 0 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = sta2sta_data_frame ( adapter , precv_frame , & psta ) ;
break ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
case 1 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > dst , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = ap2sta_data_frame ( adapter , precv_frame , & psta ) ;
break ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
case 2 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > dst , GetAddr3Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > src , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = sta2ap_data_frame ( adapter , precv_frame , & psta ) ;
break ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
case 3 :
default :
/* WDS is not supported */
ret = _FAIL ;
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RTW_MESH
pre_validate_status_chk :
# endif
if ( ret = = _FAIL ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " case:%d, res:%d, ra= " MAC_FMT " , ta= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , pattrib - > to_fr_ds , ret , MAC_ARG ( GetAddr1Ptr ( ptr ) ) , MAC_ARG ( get_addr2_ptr ( ptr ) ) ) ;
2015-08-18 19:03:09 +00:00
# endif
goto exit ;
2019-11-09 10:12:08 +00:00
} else if ( ret = = RTW_RX_HANDLED )
2015-08-18 19:03:09 +00:00
goto exit ;
2019-11-09 10:12:08 +00:00
if ( psta = = NULL ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " psta == NULL, ra= " MAC_FMT " , ta= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( GetAddr1Ptr ( ptr ) ) , MAC_ARG ( get_addr2_ptr ( ptr ) ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
2019-11-09 10:12:08 +00:00
precv_frame - > u . hdr . psta = psta ;
precv_frame - > u . hdr . preorder_ctrl = NULL ;
2015-08-18 19:03:09 +00:00
pattrib - > ack_policy = 0 ;
2019-11-09 10:12:08 +00:00
/* parsing QC field */
if ( pattrib - > qos = = 1 ) {
pattrib - > priority = GetPriority ( ( ptr + WLAN_HDR_A3_LEN + a4_shift ) ) ; /* point to Qos field*/
pattrib - > ack_policy = GetAckpolicy ( ( ptr + WLAN_HDR_A3_LEN + a4_shift ) ) ;
pattrib - > hdrlen = WLAN_HDR_A3_QOS_LEN + a4_shift ;
if ( pattrib - > priority ! = 0 & & pattrib - > priority ! = 3 )
adapter - > recvpriv . is_any_non_be_pkts = _TRUE ;
2017-05-11 18:47:23 +00:00
else
2019-11-09 10:12:08 +00:00
adapter - > recvpriv . is_any_non_be_pkts = _FALSE ;
} else {
pattrib - > priority = 0 ;
pattrib - > hdrlen = WLAN_HDR_A3_LEN + a4_shift ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( pattrib - > order ) /* HT-CTRL 11n */
2015-08-18 19:03:09 +00:00
pattrib - > hdrlen + = 4 ;
2019-11-09 10:12:08 +00:00
/* decache, drop duplicate recv packets */
ret = recv_decache ( precv_frame ) ;
if ( ret = = _FAIL )
2015-08-18 19:03:09 +00:00
goto exit ;
2021-08-23 12:01:00 +00:00
if ( ! is_multicast_ether_addr ( pattrib - > ra ) ) {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( pattrib - > qos )
precv_frame - > u . hdr . preorder_ctrl = & psta - > recvreorder_ctrl [ pattrib - > priority ] ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( recv_ucast_pn_decache ( precv_frame ) = = _FAIL ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " recv_ucast_pn_decache return _FAIL for sta= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( psta - > cmn . mac_addr ) ) ;
# endif
ret = _FAIL ;
goto exit ;
}
} else {
if ( recv_bcast_pn_decache ( precv_frame ) = = _FAIL ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " recv_bcast_pn_decache return _FAIL for sta= " MAC_FMT " \n "
, FUNC_ADPT_ARG ( adapter ) , MAC_ARG ( psta - > cmn . mac_addr ) ) ;
# endif
ret = _FAIL ;
goto exit ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
}
if ( pattrib - > privacy ) {
# ifdef CONFIG_TDLS
if ( ( psta - > tdls_sta_state & TDLS_LINKED_STATE ) & & ( psta - > dot118021XPrivacy = = _AES_ ) )
pattrib - > encrypt = psta - > dot118021XPrivacy ;
2015-08-18 19:03:09 +00:00
else
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_TDLS */
2021-08-23 12:01:00 +00:00
GET_ENCRY_ALGO ( psecuritypriv , psta , pattrib - > encrypt , is_multicast_ether_addr ( pattrib - > ra ) ) ;
2015-08-18 19:03:09 +00:00
SET_ICE_IV_LEN ( pattrib - > iv_len , pattrib - > icv_len , pattrib - > encrypt ) ;
2019-11-09 10:12:08 +00:00
} else {
2015-08-18 19:03:09 +00:00
pattrib - > encrypt = 0 ;
pattrib - > iv_len = pattrib - > icv_len = 0 ;
}
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RTW_MESH
if ( ! pattrib - > amsdu
& & pattrib - > mesh_ctrl_present
& & ( ! pattrib - > encrypt | | pattrib - > bdecrypted ) )
ret = rtw_mesh_rx_validate_mctrl_non_amsdu ( adapter , precv_frame ) ;
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
exit :
2015-08-18 19:03:09 +00:00
return ret ;
}
2017-05-11 18:35:20 +00:00
static inline void dump_rx_packet ( u8 * ptr )
{
int i ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " ############################# \n " ) ;
for ( i = 0 ; i < 64 ; i = i + 8 )
RTW_INFO ( " %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 ) ) ;
RTW_INFO ( " ############################# \n " ) ;
2017-05-11 18:35:20 +00:00
}
2015-08-18 19:03:09 +00:00
sint validate_recv_frame ( _adapter * adapter , union recv_frame * precv_frame ) ;
sint validate_recv_frame ( _adapter * adapter , union recv_frame * precv_frame )
{
2019-11-09 10:12:08 +00:00
/* shall check frame subtype, to / from ds, da, bssid */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* then call check if rx seq/frag. duplicated. */
2015-08-18 19:03:09 +00:00
u8 type ;
u8 subtype ;
sint retval = _SUCCESS ;
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib = & precv_frame - > u . hdr . attrib ;
struct recv_priv * precvpriv = & adapter - > recvpriv ;
2015-08-18 19:03:09 +00:00
u8 * ptr = precv_frame - > u . hdr . rx_data ;
2019-11-09 10:12:08 +00:00
u8 ver = ( unsigned char ) ( * ptr ) & 0x3 ;
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_FIND_BEST_CHANNEL
2019-11-09 10:12:08 +00:00
struct rf_ctl_t * rfctl = adapter_to_rfctl ( adapter ) ;
2015-08-18 19:03:09 +00:00
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
# endif
# ifdef CONFIG_TDLS
struct tdls_info * ptdlsinfo = & adapter - > tdlsinfo ;
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_WAPI_SUPPORT
PRT_WAPI_T pWapiInfo = & adapter - > wapiInfo ;
struct recv_frame_hdr * phdr = & precv_frame - > u . hdr ;
u8 wai_pkt = 0 ;
u16 sc ;
u8 external_len = 0 ;
# endif
# ifdef CONFIG_FIND_BEST_CHANNEL
if ( pmlmeext - > sitesurvey_res . state = = SCAN_PROCESS ) {
2019-11-09 10:12:08 +00:00
int ch_set_idx = rtw_chset_search_ch ( rfctl - > channel_set , rtw_get_oper_ch ( adapter ) ) ;
2015-08-18 19:03:09 +00:00
if ( ch_set_idx > = 0 )
2019-11-09 10:12:08 +00:00
rfctl - > channel_set [ ch_set_idx ] . rx_count + + ;
2015-08-18 19:03:09 +00:00
}
# endif
# ifdef CONFIG_TDLS
2019-11-09 10:12:08 +00:00
if ( ptdlsinfo - > ch_sensing = = 1 & & ptdlsinfo - > cur_channel ! = 0 )
ptdlsinfo - > collect_pkt_num [ ptdlsinfo - > cur_channel - 1 ] + + ;
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
# ifdef RTK_DMP_PLATFORM
2019-11-09 10:12:08 +00:00
if ( 0 ) {
RTW_INFO ( " ++ \n " ) ;
2015-08-18 19:03:09 +00:00
{
int i ;
2019-11-09 10:12:08 +00:00
for ( i = 0 ; i < 64 ; i = i + 8 )
RTW_INFO ( " %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X: " , * ( 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-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
RTW_INFO ( " -- \n " ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif /* RTK_DMP_PLATFORM */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* add version chk */
if ( ver ! = 0 ) {
retval = _FAIL ;
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_ver_err ) ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
type = GetFrameType ( ptr ) ;
2019-11-09 10:12:08 +00:00
subtype = get_frame_sub_type ( ptr ) ; /* bit(7)~bit(2) */
2015-08-18 19:03:09 +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 ) ;
# ifdef CONFIG_WAPI_SUPPORT
2019-11-09 10:12:08 +00:00
sc = ( pattrib - > seq_num < < 4 ) | pattrib - > frag_num ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
# if 1 /* Dump rx packets */
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
u8 bDumpRxPkt = 0 ;
rtw_hal_get_def_var ( adapter , HAL_DEF_DBG_DUMP_RXPKT , & ( bDumpRxPkt ) ) ;
if ( bDumpRxPkt = = 1 ) /* dump all rx packets */
dump_rx_packet ( ptr ) ;
2021-10-18 14:05:53 +00:00
else if ( ( bDumpRxPkt = = 2 ) & & ( type = = IEEE80211_FTYPE_MGMT ) )
2019-11-09 10:12:08 +00:00
dump_rx_packet ( ptr ) ;
2021-10-18 14:05:53 +00:00
else if ( ( bDumpRxPkt = = 3 ) & & ( type = = IEEE80211_FTYPE_DATA ) )
2019-11-09 10:12:08 +00:00
dump_rx_packet ( ptr ) ;
}
# endif
switch ( type ) {
2021-10-18 14:05:53 +00:00
case IEEE80211_FTYPE_MGMT : /* mgnt */
2019-11-09 10:12:08 +00:00
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_mgmt ) ;
retval = validate_recv_mgnt_frame ( adapter , precv_frame ) ;
if ( retval = = _FAIL ) {
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_mgmt_err ) ;
}
retval = _FAIL ; /* only data frame return _SUCCESS */
break ;
2021-10-18 14:05:53 +00:00
case IEEE80211_FTYPE_CTL : /* ctrl */
2019-11-09 10:12:08 +00:00
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_ctrl ) ;
2022-10-30 18:39:00 +00:00
validate_recv_ctrl_frame ( adapter , precv_frame ) ;
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_ctrl_err ) ;
2019-11-09 10:12:08 +00:00
retval = _FAIL ; /* only data frame return _SUCCESS */
break ;
2021-10-18 14:05:53 +00:00
case IEEE80211_FTYPE_DATA : /* data */
2019-11-09 10:12:08 +00:00
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_data ) ;
2015-08-18 19:03:09 +00:00
# ifdef CONFIG_WAPI_SUPPORT
2019-11-09 10:12:08 +00:00
if ( pattrib - > qos )
external_len = 2 ;
else
external_len = 0 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
wai_pkt = rtw_wapi_is_wai_packet ( adapter , ptr ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
phdr - > bIsWaiPacket = wai_pkt ;
if ( wai_pkt ! = 0 ) {
if ( sc ! = adapter - > wapiInfo . wapiSeqnumAndFragNum )
adapter - > wapiInfo . wapiSeqnumAndFragNum = sc ;
else {
retval = _FAIL ;
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_data_wapi_seq_err ) ;
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else {
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( rtw_wapi_drop_for_key_absent ( adapter , get_addr2_ptr ( ptr ) ) ) {
retval = _FAIL ;
WAPI_TRACE ( WAPI_RX , " drop for key absent for rx \n " ) ;
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_data_wapi_key_err ) ;
break ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
pattrib - > qos = ( subtype & BIT ( 7 ) ) ? 1 : 0 ;
retval = validate_recv_data_frame ( adapter , precv_frame ) ;
if ( retval = = _FAIL ) {
precvpriv - > dbg_rx_drop_count + + ;
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_data_err ) ;
} else if ( retval = = _SUCCESS ) {
# ifdef DBG_RX_DUMP_EAP
if ( ! pattrib - > encrypt | | pattrib - > bdecrypted ) {
2017-05-11 18:35:20 +00:00
u8 bDumpRxPkt ;
u16 eth_type ;
2019-11-09 10:12:08 +00:00
/* dump eapol */
2017-05-11 18:35:20 +00:00
rtw_hal_get_def_var ( adapter , HAL_DEF_DBG_DUMP_RXPKT , & ( bDumpRxPkt ) ) ;
2019-11-09 10:12:08 +00:00
/* get ether_type */
2021-10-12 14:53:20 +00:00
memcpy ( & eth_type , ptr + pattrib - > hdrlen + pattrib - > iv_len + RATTRIB_GET_MCTRL_LEN ( pattrib ) + LLC_HEADER_SIZE , 2 ) ;
2017-05-11 18:35:20 +00:00
eth_type = ntohs ( ( unsigned short ) eth_type ) ;
if ( ( bDumpRxPkt = = 4 ) & & ( eth_type = = 0x888e ) )
dump_rx_packet ( ptr ) ;
}
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
} else
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_data_handled ) ;
break ;
default :
DBG_COUNTER ( adapter - > rx_logs . core_rx_pre_unknown ) ;
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " fail! type=0x%x \n "
, FUNC_ADPT_ARG ( adapter ) , type ) ;
# endif
retval = _FAIL ;
break ;
2015-08-18 19:03:09 +00:00
}
exit :
return retval ;
}
2019-11-09 10:12:08 +00:00
/* remove the wlanhdr and add the eth_hdr */
2015-08-18 19:03:09 +00:00
# if 1
2019-11-09 10:12:08 +00:00
sint wlanhdr_to_ethhdr ( union recv_frame * precvframe )
2015-08-18 19:03:09 +00:00
{
sint rmv_len ;
u16 eth_type , len ;
u8 bsnaphdr ;
u8 * psnap_type ;
struct ieee80211_snap_hdr * psnap ;
2019-11-09 10:12:08 +00:00
sint ret = _SUCCESS ;
_adapter * adapter = precvframe - > u . hdr . adapter ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2019-11-09 10:12:08 +00:00
u8 * ptr = get_recvframe_data ( precvframe ) ; /* point to frame_ctrl field */
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( pattrib - > encrypt )
recvframe_pull_tail ( precvframe , pattrib - > icv_len ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
psnap = ( struct ieee80211_snap_hdr * ) ( ptr + pattrib - > hdrlen + pattrib - > iv_len + RATTRIB_GET_MCTRL_LEN ( pattrib ) ) ;
psnap_type = ptr + pattrib - > hdrlen + pattrib - > iv_len + RATTRIB_GET_MCTRL_LEN ( pattrib ) + SNAP_SIZE ;
2015-08-18 19:03:09 +00:00
/* convert hdr + possible LLC headers into Ethernet header */
2019-11-09 10:12:08 +00:00
/* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
if ( ( _rtw_memcmp ( psnap , rtw_rfc1042_header , SNAP_SIZE ) & &
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_IPX , 2 ) = = _FALSE ) & &
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_APPLETALK_AARP , 2 ) = = _FALSE ) ) | |
/* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
_rtw_memcmp ( psnap , rtw_bridge_tunnel_header , SNAP_SIZE ) ) {
2015-08-18 19:03:09 +00:00
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
bsnaphdr = _TRUE ;
2019-11-09 10:12:08 +00:00
} else {
2015-08-18 19:03:09 +00:00
/* Leave Ethernet header part of hdr and full payload */
bsnaphdr = _FALSE ;
}
2019-11-09 10:12:08 +00:00
rmv_len = pattrib - > hdrlen + pattrib - > iv_len + RATTRIB_GET_MCTRL_LEN ( pattrib ) + ( bsnaphdr ? SNAP_SIZE : 0 ) ;
2015-08-18 19:03:09 +00:00
len = precvframe - > u . hdr . len - rmv_len ;
2021-10-12 14:53:20 +00:00
memcpy ( & eth_type , ptr + rmv_len , 2 ) ;
2019-11-09 10:12:08 +00:00
eth_type = ntohs ( ( unsigned short ) eth_type ) ; /* pattrib->ether_type */
2015-08-18 19:03:09 +00:00
pattrib - > eth_type = eth_type ;
2019-11-09 10:12:08 +00:00
if ( ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE ) ) {
ptr + = rmv_len ;
2015-08-18 19:03:09 +00:00
* ptr = 0x87 ;
2019-11-09 10:12:08 +00:00
* ( ptr + 1 ) = 0x12 ;
2015-08-18 19:03:09 +00:00
eth_type = 0x8712 ;
2019-11-09 10:12:08 +00:00
/* append rx status for mp test packets */
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + 2 ) - 24 ) ;
2017-05-11 18:35:20 +00:00
if ( ! ptr ) {
ret = _FAIL ;
goto exiting ;
}
2021-10-12 14:53:20 +00:00
memcpy ( ptr , get_rxmem ( precvframe ) , 24 ) ;
2019-11-09 10:12:08 +00:00
ptr + = 24 ;
} else {
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + ( bsnaphdr ? 2 : 0 ) ) ) ;
2017-05-11 18:35:20 +00:00
if ( ! ptr ) {
ret = _FAIL ;
goto exiting ;
}
2015-08-18 19:03:09 +00:00
}
2017-05-11 18:35:20 +00:00
if ( ptr ) {
2021-10-12 14:53:20 +00:00
memcpy ( ptr , pattrib - > dst , ETH_ALEN ) ;
memcpy ( ptr + ETH_ALEN , pattrib - > src , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ! bsnaphdr ) {
2017-05-11 18:35:20 +00:00
len = htons ( len ) ;
2021-10-12 14:53:20 +00:00
memcpy ( ptr + 12 , & len , 2 ) ;
2017-05-11 18:35:20 +00:00
}
2019-11-09 10:12:08 +00:00
rtw_rframe_set_os_pkt ( precvframe ) ;
2015-08-18 19:03:09 +00:00
}
2017-05-11 18:35:20 +00:00
exiting :
2015-08-18 19:03:09 +00:00
return ret ;
}
# else
2019-11-09 10:12:08 +00:00
static u8 SNAP_ETH_TYPE_APPLETALK_DDP [ 2 ] = { 0x80 , 0x9b } ;
/* Datagram Delivery Protocol */
static u8 SNAP_HDR_APPLETALK_DDP [ 3 ] = { 0x08 , 0x00 , 0x07 } ;
static u8 oui_8021h [ ] = { 0x00 , 0x00 , 0xf8 } ;
static u8 oui_rfc1042 [ ] = { 0x00 , 0x00 , 0x00 } ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
sint wlanhdr_to_ethhdr ( union recv_frame * precvframe )
2015-08-18 19:03:09 +00:00
{
sint rmv_len ;
u16 eth_type ;
u8 bsnaphdr ;
u8 * psnap_type ;
struct ieee80211_snap_hdr * psnap ;
2019-11-09 10:12:08 +00:00
sint ret = _SUCCESS ;
_adapter * adapter = precvframe - > u . hdr . adapter ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
2019-11-09 10:12:08 +00:00
u8 * ptr = get_recvframe_data ( precvframe ) ; /* point to frame_ctrl field */
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
struct _vlan * pvlan = NULL ;
2019-11-09 10:12:08 +00:00
psnap = ( struct ieee80211_snap_hdr * ) ( ptr + pattrib - > hdrlen + pattrib - > iv_len ) ;
psnap_type = ptr + pattrib - > hdrlen + pattrib - > iv_len + SNAP_SIZE ;
if ( psnap - > dsap = = 0xaa & & psnap - > ssap = = 0xaa & & psnap - > ctrl = = 0x03 ) {
2015-08-18 19:03:09 +00:00
if ( _rtw_memcmp ( psnap - > oui , oui_rfc1042 , WLAN_IEEE_OUI_LEN ) )
2019-11-09 10:12:08 +00:00
bsnaphdr = _TRUE ; /* wlan_pkt_format = WLAN_PKT_FORMAT_SNAP_RFC1042; */
2015-08-18 19:03:09 +00:00
else if ( _rtw_memcmp ( psnap - > oui , SNAP_HDR_APPLETALK_DDP , WLAN_IEEE_OUI_LEN ) & &
2019-11-09 10:12:08 +00:00
_rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_APPLETALK_DDP , 2 ) )
bsnaphdr = _TRUE ; /* wlan_pkt_format = WLAN_PKT_FORMAT_APPLETALK; */
else if ( _rtw_memcmp ( psnap - > oui , oui_8021h , WLAN_IEEE_OUI_LEN ) )
bsnaphdr = _TRUE ; /* wlan_pkt_format = WLAN_PKT_FORMAT_SNAP_TUNNEL; */
2015-08-18 19:03:09 +00:00
else {
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
goto exit ;
}
} else
2019-11-09 10:12:08 +00:00
bsnaphdr = _FALSE ; /* wlan_pkt_format = WLAN_PKT_FORMAT_OTHERS; */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
rmv_len = pattrib - > hdrlen + pattrib - > iv_len + ( bsnaphdr ? SNAP_SIZE : 0 ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( check_fwstate ( pmlmepriv , WIFI_MP_STATE ) = = _TRUE ) {
2015-08-18 19:03:09 +00:00
ptr + = rmv_len ;
* ptr = 0x87 ;
2019-11-09 10:12:08 +00:00
* ( ptr + 1 ) = 0x12 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* back to original pointer */
2015-08-18 19:03:09 +00:00
ptr - = rmv_len ;
}
ptr + = rmv_len ;
2021-10-12 14:53:20 +00:00
memcpy ( & eth_type , ptr , 2 ) ;
2019-11-09 10:12:08 +00:00
eth_type = ntohs ( ( unsigned short ) eth_type ) ; /* pattrib->ether_type */
ptr + = 2 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( pattrib - > encrypt )
2015-08-18 19:03:09 +00:00
recvframe_pull_tail ( precvframe , pattrib - > icv_len ) ;
2019-11-09 10:12:08 +00:00
if ( eth_type = = 0x8100 ) { /* vlan */
2015-08-18 19:03:09 +00:00
pvlan = ( struct _vlan * ) ptr ;
2019-11-09 10:12:08 +00:00
/* eth_type = get_vlan_encap_proto(pvlan); */
/* eth_type = pvlan->h_vlan_encapsulated_proto; */ /* ? */
2015-08-18 19:03:09 +00:00
rmv_len + = 4 ;
2019-11-09 10:12:08 +00:00
ptr + = 4 ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( eth_type = = 0x0800 ) { /* ip */
/* struct iphdr* piphdr = (struct iphdr*) ptr; */
/* __u8 tos = (unsigned char)(pattrib->priority & 0xff); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* piphdr->tos = tos; */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
} else if ( eth_type = = 0x8712 ) { /* append rx status for mp test packets */
/* ptr -= 16; */
2021-10-12 14:53:20 +00:00
/* memcpy(ptr, get_rxmem(precvframe), 16); */
2019-11-09 10:12:08 +00:00
} else {
2015-08-18 19:03:09 +00:00
# ifdef PLATFORM_OS_XP
NDIS_PACKET_8021Q_INFO VlanPriInfo ;
UINT32 UserPriority = precvframe - > u . hdr . attrib . priority ;
2019-11-09 10:12:08 +00:00
UINT32 VlanID = ( pvlan ! = NULL ? get_vlan_id ( pvlan ) : 0 ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
VlanPriInfo . Value = /* Get current value. */
NDIS_PER_PACKET_INFO_FROM_PACKET ( precvframe - > u . hdr . pkt , Ieee8021QInfo ) ;
2015-08-18 19:03:09 +00:00
VlanPriInfo . TagHeader . UserPriority = UserPriority ;
VlanPriInfo . TagHeader . VlanId = VlanID ;
2019-11-09 10:12:08 +00:00
VlanPriInfo . TagHeader . CanonicalFormatId = 0 ; /* Should be zero. */
VlanPriInfo . TagHeader . Reserved = 0 ; /* Should be zero. */
2015-08-18 19:03:09 +00:00
NDIS_PER_PACKET_INFO_FROM_PACKET ( precvframe - > u . hdr . pkt , Ieee8021QInfo ) = VlanPriInfo . Value ;
# endif
}
2019-11-09 10:12:08 +00:00
if ( eth_type = = 0x8712 ) { /* append rx status for mp test packets */
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + 2 ) - 24 ) ;
2021-10-12 14:53:20 +00:00
memcpy ( ptr , get_rxmem ( precvframe ) , 24 ) ;
2019-11-09 10:12:08 +00:00
ptr + = 24 ;
} else
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + 2 ) ) ;
2015-08-18 19:03:09 +00:00
2021-10-12 14:53:20 +00:00
memcpy ( ptr , pattrib - > dst , ETH_ALEN ) ;
memcpy ( ptr + ETH_ALEN , pattrib - > src , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
eth_type = htons ( ( unsigned short ) eth_type ) ;
2021-10-12 14:53:20 +00:00
memcpy ( ptr + 12 , & eth_type , 2 ) ;
2015-08-18 19:03:09 +00:00
exit :
return ret ;
}
# endif
# if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
# ifdef PLATFORM_LINUX
static void recvframe_expand_pkt (
PADAPTER padapter ,
union recv_frame * prframe )
{
struct recv_frame_hdr * pfhdr ;
_pkt * ppkt ;
u8 shift_sz ;
u32 alloc_sz ;
2017-05-11 18:47:23 +00:00
u8 * ptr ;
2015-08-18 19:03:09 +00:00
pfhdr = & prframe - > u . hdr ;
2019-11-09 10:12:08 +00:00
/* 6 is for IP header 8 bytes alignment in QoS packet case. */
2015-08-18 19:03:09 +00:00
if ( pfhdr - > attrib . qos )
shift_sz = 6 ;
else
shift_sz = 0 ;
2019-11-09 10:12:08 +00:00
/* for first fragment packet, need to allocate */
/* (1536 + RXDESC_SIZE + drvinfo_sz) to reassemble packet */
/* 8 is for skb->data 8 bytes alignment.
* alloc_sz = _RND ( 1536 + RXDESC_SIZE + pfhdr - > attrib . drvinfosize + shift_sz + 8 , 128 ) ; */
alloc_sz = 1664 ; /* round (1536 + 24 + 32 + shift_sz + 8) to 128 bytes alignment */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* 3 1. alloc new skb */
/* prepare extra space for 4 bytes alignment */
2015-08-18 19:03:09 +00:00
ppkt = rtw_skb_alloc ( alloc_sz ) ;
2019-11-09 10:12:08 +00:00
if ( ! ppkt )
return ; /* no way to expand */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* 3 2. Prepare new skb to replace & release old skb */
/* force ppkt->data at 8-byte alignment address */
2015-08-18 19:03:09 +00:00
skb_reserve ( ppkt , 8 - ( ( SIZE_PTR ) ppkt - > data & 7 ) ) ;
2019-11-09 10:12:08 +00:00
/* force ip_hdr at 8-byte alignment address according to shift_sz */
2015-08-18 19:03:09 +00:00
skb_reserve ( ppkt , shift_sz ) ;
2019-11-09 10:12:08 +00:00
/* copy data to new pkt */
2017-05-11 18:47:23 +00:00
ptr = skb_put ( ppkt , pfhdr - > len ) ;
if ( ptr )
2021-10-12 14:53:20 +00:00
memcpy ( ptr , pfhdr - > rx_data , pfhdr - > len ) ;
2015-08-18 19:03:09 +00:00
rtw_skb_free ( pfhdr - > pkt ) ;
2019-11-09 10:12:08 +00:00
/* attach new pkt to recvframe */
2015-08-18 19:03:09 +00:00
pfhdr - > pkt = ppkt ;
pfhdr - > rx_head = ppkt - > head ;
pfhdr - > rx_data = ppkt - > data ;
pfhdr - > rx_tail = skb_tail_pointer ( ppkt ) ;
pfhdr - > rx_end = skb_end_pointer ( ppkt ) ;
}
# else
# warning "recvframe_expand_pkt not implement, defrag may crash system"
# endif
# endif
2019-11-09 10:12:08 +00:00
/* perform defrag */
union recv_frame * recvframe_defrag ( _adapter * adapter , _queue * defrag_q ) ;
union recv_frame * recvframe_defrag ( _adapter * adapter , _queue * defrag_q )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
_list * plist , * phead ;
u8 * data , wlanhdr_offset ;
2015-08-18 19:03:09 +00:00
u8 curfragnum ;
2019-11-09 10:12:08 +00:00
struct recv_frame_hdr * pfhdr , * pnfhdr ;
union recv_frame * prframe , * pnextrframe ;
2015-08-18 19:03:09 +00:00
_queue * pfree_recv_queue ;
2019-11-09 10:12:08 +00:00
curfragnum = 0 ;
pfree_recv_queue = & adapter - > recvpriv . free_recv_queue ;
2015-08-18 19:03:09 +00:00
phead = get_list_head ( defrag_q ) ;
plist = get_next ( phead ) ;
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2019-11-09 10:12:08 +00:00
pfhdr = & prframe - > u . hdr ;
2015-08-18 19:03:09 +00:00
rtw_list_delete ( & ( prframe - > u . list ) ) ;
2019-11-09 10:12:08 +00:00
if ( curfragnum ! = pfhdr - > attrib . frag_num ) {
/* the first fragment number must be 0 */
/* free the whole queue */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
return NULL ;
}
# if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
# ifndef CONFIG_SDIO_RX_COPY
recvframe_expand_pkt ( adapter , prframe ) ;
# endif
# endif
curfragnum + + ;
2019-11-09 10:12:08 +00:00
plist = get_list_head ( defrag_q ) ;
2015-08-18 19:03:09 +00:00
plist = get_next ( plist ) ;
2019-11-09 10:12:08 +00:00
data = get_recvframe_data ( prframe ) ;
2015-08-18 19:03:09 +00:00
2021-10-14 20:37:57 +00:00
while ( phead ! = plist ) {
2015-08-18 19:03:09 +00:00
pnextrframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2019-11-09 10:12:08 +00:00
pnfhdr = & pnextrframe - > u . hdr ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* check the fragment sequence (2nd ~n fragment frame) */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( curfragnum ! = pnfhdr - > attrib . frag_num ) {
/* the fragment number must be increasing (after decache) */
/* release the defrag_q & prframe */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
return NULL ;
}
curfragnum + + ;
2019-11-09 10:12:08 +00:00
/* copy the 2nd~n fragment frame's payload to the first fragment */
/* get the 2nd~last fragment frame's payload */
2015-08-18 19:03:09 +00:00
wlanhdr_offset = pnfhdr - > attrib . hdrlen + pnfhdr - > attrib . iv_len ;
recvframe_pull ( pnextrframe , wlanhdr_offset ) ;
2019-11-09 10:12:08 +00:00
/* append to first fragment frame's tail (if privacy frame, pull the ICV) */
2015-08-18 19:03:09 +00:00
recvframe_pull_tail ( prframe , pfhdr - > attrib . icv_len ) ;
2019-11-09 10:12:08 +00:00
/* memcpy */
2021-10-12 14:53:20 +00:00
memcpy ( pfhdr - > rx_tail , pnfhdr - > rx_data , pnfhdr - > len ) ;
2015-08-18 19:03:09 +00:00
recvframe_put ( prframe , pnfhdr - > len ) ;
2019-11-09 10:12:08 +00:00
pfhdr - > attrib . icv_len = pnfhdr - > attrib . icv_len ;
2015-08-18 19:03:09 +00:00
plist = get_next ( plist ) ;
} ;
2019-11-09 10:12:08 +00:00
/* free the defrag_q queue and return the prframe */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe_queue ( defrag_q , pfree_recv_queue ) ;
return prframe ;
}
2019-11-09 10:12:08 +00:00
/* check if need to defrag, if needed queue the frame to defrag_q */
union recv_frame * recvframe_chk_defrag ( PADAPTER padapter , union recv_frame * precv_frame )
2015-08-18 19:03:09 +00:00
{
u8 ismfrag ;
u8 fragnum ;
u8 * psta_addr ;
struct recv_frame_hdr * pfhdr ;
struct sta_info * psta ;
struct sta_priv * pstapriv ;
_list * phead ;
union recv_frame * prtnframe = NULL ;
2019-11-09 10:12:08 +00:00
_queue * pfree_recv_queue , * pdefrag_q = NULL ;
2015-08-18 19:03:09 +00:00
pstapriv = & padapter - > stapriv ;
pfhdr = & precv_frame - > u . hdr ;
pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
2019-11-09 10:12:08 +00:00
/* need to define struct of wlan header frame ctrl */
2015-08-18 19:03:09 +00:00
ismfrag = pfhdr - > attrib . mfrag ;
fragnum = pfhdr - > attrib . frag_num ;
psta_addr = pfhdr - > attrib . ta ;
psta = rtw_get_stainfo ( pstapriv , psta_addr ) ;
2019-11-09 10:12:08 +00:00
if ( psta = = NULL ) {
2015-08-18 19:03:09 +00:00
u8 type = GetFrameType ( pfhdr - > rx_data ) ;
2021-10-18 14:05:53 +00:00
if ( type ! = IEEE80211_FTYPE_DATA ) {
2015-08-18 19:03:09 +00:00
psta = rtw_get_bcmc_stainfo ( padapter ) ;
2019-11-09 10:12:08 +00:00
if ( psta )
pdefrag_q = & psta - > sta_recvpriv . defrag_q ;
2015-08-18 19:03:09 +00:00
} else
pdefrag_q = NULL ;
2019-11-09 10:12:08 +00:00
} else
2015-08-18 19:03:09 +00:00
pdefrag_q = & psta - > sta_recvpriv . defrag_q ;
2019-11-09 10:12:08 +00:00
if ( ( ismfrag = = 0 ) & & ( fragnum = = 0 ) ) {
prtnframe = precv_frame ; /* isn't a fragment frame */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
if ( ismfrag = = 1 ) {
/* 0~(n-1) fragment frame */
/* enqueue to defraf_g */
if ( pdefrag_q ! = NULL ) {
if ( fragnum = = 0 ) {
/* the first fragment */
if ( _rtw_queue_empty ( pdefrag_q ) = = _FALSE ) {
/* free current defrag_q */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe_queue ( pdefrag_q , pfree_recv_queue ) ;
}
}
2019-11-09 10:12:08 +00:00
/* Then enqueue the 0~(n-1) fragment into the defrag_q */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* _rtw_spinlock(&pdefrag_q->lock); */
2015-08-18 19:03:09 +00:00
phead = get_list_head ( pdefrag_q ) ;
rtw_list_insert_tail ( & pfhdr - > list , phead ) ;
2019-11-09 10:12:08 +00:00
/* _rtw_spinunlock(&pdefrag_q->lock); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
prtnframe = NULL ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
} else {
/* can't find this ta's defrag_queue, so free this recv_frame */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( precv_frame , pfree_recv_queue ) ;
2019-11-09 10:12:08 +00:00
prtnframe = NULL ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
if ( ( ismfrag = = 0 ) & & ( fragnum ! = 0 ) ) {
/* the last fragment frame */
/* enqueue the last fragment */
if ( pdefrag_q ! = NULL ) {
/* _rtw_spinlock(&pdefrag_q->lock); */
2015-08-18 19:03:09 +00:00
phead = get_list_head ( pdefrag_q ) ;
2019-11-09 10:12:08 +00:00
rtw_list_insert_tail ( & pfhdr - > list , phead ) ;
/* _rtw_spinunlock(&pdefrag_q->lock); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* call recvframe_defrag to defrag */
2015-08-18 19:03:09 +00:00
precv_frame = recvframe_defrag ( padapter , pdefrag_q ) ;
2019-11-09 10:12:08 +00:00
prtnframe = precv_frame ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
} else {
/* can't find this ta's defrag_queue, so free this recv_frame */
2015-08-18 19:03:09 +00:00
rtw_free_recvframe ( precv_frame , pfree_recv_queue ) ;
2019-11-09 10:12:08 +00:00
prtnframe = NULL ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
if ( ( prtnframe ! = NULL ) & & ( prtnframe - > u . hdr . attrib . privacy ) ) {
/* after defrag we must check tkip mic code */
if ( recvframe_chkmic ( padapter , prtnframe ) = = _FAIL ) {
rtw_free_recvframe ( prtnframe , pfree_recv_queue ) ;
prtnframe = NULL ;
2015-08-18 19:03:09 +00:00
}
}
return prtnframe ;
}
2019-11-09 10:12:08 +00:00
static int rtw_recv_indicatepkt_check ( union recv_frame * rframe , u8 * ehdr_pos , u32 pkt_len )
{
_adapter * adapter = rframe - > u . hdr . adapter ;
struct recv_priv * recvpriv = & adapter - > recvpriv ;
struct ethhdr * ehdr = ( struct ethhdr * ) ehdr_pos ;
# ifdef DBG_IP_R_MONITOR
int i ;
struct rx_pkt_attrib * pattrib = & rframe - > u . hdr . attrib ;
struct mlme_ext_priv * pmlmeext = & adapter - > mlmeextpriv ;
struct mlme_priv * pmlmepriv = & adapter - > mlmepriv ;
struct wlan_network * cur_network = & ( pmlmepriv - > cur_network ) ;
# endif /*DBG_IP_R_MONITOR*/
int ret = _FAIL ;
# ifdef CONFIG_WAPI_SUPPORT
if ( rtw_wapi_check_for_drop ( adapter , rframe , ehdr_pos ) ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " rtw_wapi_check_for_drop \n "
, FUNC_ADPT_ARG ( adapter ) ) ;
# endif
goto exit ;
}
# endif
if ( rframe - > u . hdr . psta )
rtw_st_ctl_rx ( rframe - > u . hdr . psta , ehdr_pos ) ;
if ( ntohs ( ehdr - > h_proto ) = = 0x888e )
parsing_eapol_packet ( adapter , ehdr_pos + ETH_HLEN , rframe - > u . hdr . psta , 0 ) ;
# ifdef DBG_ARP_DUMP
else if ( ntohs ( ehdr - > h_proto ) = = ETH_P_ARP )
dump_arp_pkt ( RTW_DBGDUMP , ehdr - > h_dest , ehdr - > h_source , ehdr_pos + ETH_HLEN , 0 ) ;
# endif
if ( recvpriv - > sink_udpport > 0 )
rtw_sink_rtp_seq_dbg ( adapter , ehdr_pos ) ;
# ifdef DBG_UDP_PKT_LOSE_11AC
# define PAYLOAD_LEN_LOC_OF_IP_HDR 0x10 /*ethernet payload length location of ip header (DA + SA+eth_type+(version&hdr_len)) */
if ( ntohs ( ehdr - > h_proto ) = = ETH_P_ARP ) {
/* ARP Payload length will be 42bytes or 42+18(tailer)=60bytes*/
if ( pkt_len ! = 42 & & pkt_len ! = 60 )
RTW_INFO ( " Error !!%s,ARP Payload length %u not correct \n " , __func__ , pkt_len ) ;
} else if ( ntohs ( ehdr - > h_proto ) = = ETH_P_IP ) {
if ( be16_to_cpu ( * ( ( u16 * ) ( ehdr_pos + PAYLOAD_LEN_LOC_OF_IP_HDR ) ) ) ! = ( pkt_len ) - ETH_HLEN ) {
RTW_INFO ( " Error !!%s,Payload length not correct \n " , __func__ ) ;
RTW_INFO ( " %s, IP header describe Total length=%u \n " , __func__ , be16_to_cpu ( * ( ( u16 * ) ( ehdr_pos + PAYLOAD_LEN_LOC_OF_IP_HDR ) ) ) ) ;
RTW_INFO ( " %s, Pkt real length=%u \n " , __func__ , ( pkt_len ) - ETH_HLEN ) ;
}
}
# endif
# ifdef DBG_IP_R_MONITOR
# define LEN_ARP_OP_HDR 7 /*ARP OERATION */
if ( ntohs ( ehdr - > h_proto ) = = ETH_P_ARP ) {
if ( check_fwstate ( pmlmepriv , WIFI_ASOC_STATE ) = = _TRUE ) {
2021-08-24 12:36:21 +00:00
if ( ehdr_pos [ ETH_HLEN + LEN_ARP_OP_HDR ] = = 2 ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " %s,[DBG_ARP] Rx ARP RSP Packet with Dst= " MAC_FMT " ;SeqNum = %d ! \n " ,
__FUNCTION__ , MAC_ARG ( pattrib - > dst ) , pattrib - > seq_num ) ;
2021-08-24 12:36:21 +00:00
for ( i = 0 ; i < ( pkt_len - ETH_HLEN ) ; i + + )
RTW_INFO ( " 0x%x " , ehdr_pos [ i + ETH_HLEN ] ) ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " \n " ) ;
}
}
}
# endif /*DBG_IP_R_MONITOR*/
# ifdef CONFIG_AUTO_AP_MODE
if ( ntohs ( ehdr - > h_proto ) = = 0x8899 )
rtw_auto_ap_rx_msg_dump ( adapter , rframe , ehdr_pos ) ;
# endif
ret = _SUCCESS ;
# ifdef CONFIG_WAPI_SUPPORT
exit :
# endif
return ret ;
}
static void recv_free_fwd_resource ( _adapter * adapter , struct xmit_frame * fwd_frame , _list * b2u_list )
{
struct xmit_priv * xmitpriv = & adapter - > xmitpriv ;
if ( fwd_frame )
rtw_free_xmitframe ( xmitpriv , fwd_frame ) ;
# ifdef CONFIG_RTW_MESH
# if CONFIG_RTW_MESH_DATA_BMC_TO_UC
if ( ! rtw_is_list_empty ( b2u_list ) ) {
struct xmit_frame * b2uframe ;
_list * list ;
list = get_next ( b2u_list ) ;
2021-10-14 20:37:57 +00:00
while ( b2u_list ! = list ) {
2019-11-09 10:12:08 +00:00
b2uframe = LIST_CONTAINOR ( list , struct xmit_frame , list ) ;
list = get_next ( list ) ;
rtw_list_delete ( & b2uframe - > list ) ;
rtw_free_xmitframe ( xmitpriv , b2uframe ) ;
}
}
# endif
# endif /* CONFIG_RTW_MESH */
}
# ifdef CONFIG_RTW_MESH
static void recv_fwd_pkt_hdl ( _adapter * adapter , _pkt * pkt
, u8 act , struct xmit_frame * fwd_frame , _list * b2u_list )
{
struct xmit_priv * xmitpriv = & adapter - > xmitpriv ;
_pkt * fwd_pkt = pkt ;
if ( act & RTW_RX_MSDU_ACT_INDICATE ) {
fwd_pkt = rtw_os_pkt_copy ( pkt ) ;
if ( ! fwd_pkt ) {
# ifdef DBG_TX_DROP_FRAME
RTW_INFO ( " DBG_TX_DROP_FRAME %s rtw_os_pkt_copy fail \n " , __func__ ) ;
# endif
recv_free_fwd_resource ( adapter , fwd_frame , b2u_list ) ;
goto exit ;
}
}
# if CONFIG_RTW_MESH_DATA_BMC_TO_UC
if ( ! rtw_is_list_empty ( b2u_list ) ) {
_list * list = get_next ( b2u_list ) ;
struct xmit_frame * b2uframe ;
2021-10-14 20:37:57 +00:00
while ( b2u_list ! = list ) {
2019-11-09 10:12:08 +00:00
b2uframe = LIST_CONTAINOR ( list , struct xmit_frame , list ) ;
list = get_next ( list ) ;
rtw_list_delete ( & b2uframe - > list ) ;
if ( ! fwd_frame & & rtw_is_list_empty ( b2u_list ) ) /* the last fwd_pkt */
b2uframe - > pkt = fwd_pkt ;
else
b2uframe - > pkt = rtw_os_pkt_copy ( fwd_pkt ) ;
if ( ! b2uframe - > pkt ) {
rtw_free_xmitframe ( xmitpriv , b2uframe ) ;
continue ;
}
rtw_xmit_posthandle ( adapter , b2uframe , b2uframe - > pkt ) ;
}
}
# endif
if ( fwd_frame ) {
fwd_frame - > pkt = fwd_pkt ;
if ( rtw_xmit_posthandle ( adapter , fwd_frame , fwd_pkt ) < 0 ) {
# ifdef DBG_TX_DROP_FRAME
RTW_INFO ( " DBG_TX_DROP_FRAME %s rtw_xmit_posthandle fail \n " , __func__ ) ;
# endif
xmitpriv - > tx_drop + + ;
}
}
exit :
return ;
}
# endif /* CONFIG_RTW_MESH */
2015-08-18 19:03:09 +00:00
int amsdu_to_msdu ( _adapter * padapter , union recv_frame * prframe )
{
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * rattrib = & prframe - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
int a_len , padding_len ;
2019-11-09 10:12:08 +00:00
u16 nSubframe_Length ;
2015-08-18 19:03:09 +00:00
u8 nr_subframes , i ;
u8 * pdata ;
2019-11-09 10:12:08 +00:00
_pkt * sub_pkt , * subframes [ MAX_SUBFRAME_COUNT ] ;
2015-08-18 19:03:09 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
_queue * pfree_recv_queue = & ( precvpriv - > free_recv_queue ) ;
2019-11-09 10:12:08 +00:00
const u8 * da , * sa ;
int act ;
struct xmit_frame * fwd_frame ;
_list b2u_list ;
u8 mctrl_len = 0 ;
2015-08-18 19:03:09 +00:00
int ret = _SUCCESS ;
nr_subframes = 0 ;
2019-11-09 10:12:08 +00:00
recvframe_pull ( prframe , rattrib - > hdrlen ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( rattrib - > iv_len > 0 )
recvframe_pull ( prframe , rattrib - > iv_len ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
a_len = prframe - > u . hdr . len ;
2015-08-18 19:03:09 +00:00
pdata = prframe - > u . hdr . rx_data ;
2019-11-09 10:12:08 +00:00
while ( a_len > ETH_HLEN ) {
2015-08-18 19:03:09 +00:00
/* Offset 12 denote 2 mac address */
nSubframe_Length = RTW_GET_BE16 ( pdata + 12 ) ;
2021-08-24 12:36:21 +00:00
if ( a_len < ( ETH_HLEN + nSubframe_Length ) ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " nRemain_Length is %d and nSubframe_Length is : %d \n " , a_len , nSubframe_Length ) ;
2015-08-18 19:03:09 +00:00
break ;
}
2019-11-09 10:12:08 +00:00
act = RTW_RX_MSDU_ACT_INDICATE ;
fwd_frame = NULL ;
# ifdef CONFIG_RTW_MESH
if ( MLME_IS_MESH ( padapter ) ) {
u8 * mda = pdata , * msa = pdata + ETH_ALEN ;
2021-10-21 15:30:03 +00:00
struct ieee80211s_hdr * mctrl = ( struct ieee80211s_hdr * ) ( pdata + ETH_HLEN ) ;
2019-11-09 10:12:08 +00:00
int v_ret ;
v_ret = rtw_mesh_rx_data_validate_mctrl ( padapter , prframe
, mctrl , mda , msa , & mctrl_len , & da , & sa ) ;
if ( v_ret ! = _SUCCESS )
goto move_to_next ;
act = rtw_mesh_rx_msdu_act_check ( prframe
, mda , msa , da , sa , mctrl , & fwd_frame , & b2u_list ) ;
} else
# endif
{
da = pdata ;
sa = pdata + ETH_ALEN ;
}
if ( ! act )
goto move_to_next ;
rtw_led_rx_control ( padapter , da ) ;
sub_pkt = rtw_os_alloc_msdu_pkt ( prframe , da , sa
, pdata + ETH_HLEN + mctrl_len , nSubframe_Length - mctrl_len ) ;
2015-08-18 19:03:09 +00:00
if ( sub_pkt = = NULL ) {
2019-11-09 10:12:08 +00:00
if ( act & RTW_RX_MSDU_ACT_INDICATE ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME %s rtw_os_alloc_msdu_pkt fail \n " , __func__ ) ;
# endif
}
if ( act & RTW_RX_MSDU_ACT_FORWARD ) {
# ifdef DBG_TX_DROP_FRAME
RTW_INFO ( " DBG_TX_DROP_FRAME %s rtw_os_alloc_msdu_pkt fail \n " , __func__ ) ;
# endif
recv_free_fwd_resource ( padapter , fwd_frame , & b2u_list ) ;
}
2015-08-18 19:03:09 +00:00
break ;
}
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_RTW_MESH
if ( act & RTW_RX_MSDU_ACT_FORWARD ) {
recv_fwd_pkt_hdl ( padapter , sub_pkt , act , fwd_frame , & b2u_list ) ;
if ( ! ( act & RTW_RX_MSDU_ACT_INDICATE ) )
goto move_to_next ;
}
# endif
if ( rtw_recv_indicatepkt_check ( prframe , rtw_os_pkt_data ( sub_pkt ) , rtw_os_pkt_len ( sub_pkt ) ) = = _SUCCESS )
subframes [ nr_subframes + + ] = sub_pkt ;
else
rtw_os_pkt_free ( sub_pkt ) ;
move_to_next :
2015-08-18 19:03:09 +00:00
/* move the data point to data content */
pdata + = ETH_HLEN ;
a_len - = ETH_HLEN ;
2019-11-09 10:12:08 +00:00
if ( nr_subframes > = MAX_SUBFRAME_COUNT ) {
RTW_WARN ( " ParseSubframe(): Too many Subframes! Packets dropped! \n " ) ;
2015-08-18 19:03:09 +00:00
break ;
}
pdata + = nSubframe_Length ;
a_len - = nSubframe_Length ;
2019-11-09 10:12:08 +00:00
if ( a_len ! = 0 ) {
padding_len = 4 - ( ( nSubframe_Length + ETH_HLEN ) & ( 4 - 1 ) ) ;
if ( padding_len = = 4 )
2015-08-18 19:03:09 +00:00
padding_len = 0 ;
2019-11-09 10:12:08 +00:00
if ( a_len < padding_len ) {
RTW_INFO ( " ParseSubframe(): a_len < padding_len ! \n " ) ;
2015-08-18 19:03:09 +00:00
break ;
}
pdata + = padding_len ;
a_len - = padding_len ;
}
}
2019-11-09 10:12:08 +00:00
for ( i = 0 ; i < nr_subframes ; i + + ) {
2015-08-18 19:03:09 +00:00
sub_pkt = subframes [ i ] ;
/* Indicat the packets to upper layer */
2019-11-09 10:12:08 +00:00
if ( sub_pkt )
rtw_os_recv_indicate_pkt ( padapter , sub_pkt , prframe ) ;
2015-08-18 19:03:09 +00:00
}
prframe - > u . hdr . len = 0 ;
2019-11-09 10:12:08 +00:00
rtw_free_recvframe ( prframe , pfree_recv_queue ) ; /* free this recv_frame */
return ret ;
}
static int recv_process_mpdu ( _adapter * padapter , union recv_frame * prframe )
{
_queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
int ret ;
if ( pattrib - > amsdu ) {
ret = amsdu_to_msdu ( padapter , prframe ) ;
if ( ret ! = _SUCCESS ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " amsdu_to_msdu fail \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
# endif
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
goto exit ;
}
} else {
int act = RTW_RX_MSDU_ACT_INDICATE ;
struct xmit_frame * fwd_frame = NULL ;
_list b2u_list ;
# ifdef CONFIG_RTW_MESH
if ( MLME_IS_MESH ( padapter ) & & pattrib - > mesh_ctrl_present ) {
act = rtw_mesh_rx_msdu_act_check ( prframe
, pattrib - > mda , pattrib - > msa
, pattrib - > dst , pattrib - > src
2021-10-21 15:30:03 +00:00
, ( struct ieee80211s_hdr * ) ( get_recvframe_data ( prframe ) + pattrib - > hdrlen + pattrib - > iv_len )
2019-11-09 10:12:08 +00:00
, & fwd_frame , & b2u_list ) ;
}
# endif
if ( ! act ) {
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
ret = _FAIL ;
goto exit ;
}
rtw_led_rx_control ( padapter , pattrib - > dst ) ;
ret = wlanhdr_to_ethhdr ( prframe ) ;
if ( ret ! = _SUCCESS ) {
if ( act & RTW_RX_MSDU_ACT_INDICATE ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " wlanhdr_to_ethhdr: drop pkt \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
# endif
}
if ( act & RTW_RX_MSDU_ACT_FORWARD ) {
# ifdef DBG_TX_DROP_FRAME
RTW_INFO ( " DBG_TX_DROP_FRAME %s wlanhdr_to_ethhdr fail \n " , __func__ ) ;
# endif
recv_free_fwd_resource ( padapter , fwd_frame , & b2u_list ) ;
}
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
goto exit ;
}
# ifdef CONFIG_RTW_MESH
if ( act & RTW_RX_MSDU_ACT_FORWARD ) {
recv_fwd_pkt_hdl ( padapter , prframe - > u . hdr . pkt , act , fwd_frame , & b2u_list ) ;
if ( ! ( act & RTW_RX_MSDU_ACT_INDICATE ) ) {
prframe - > u . hdr . pkt = NULL ;
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
goto exit ;
}
}
# endif
if ( ! RTW_CANNOT_RUN ( padapter ) ) {
ret = rtw_recv_indicatepkt_check ( prframe
, get_recvframe_data ( prframe ) , get_recvframe_len ( prframe ) ) ;
if ( ret ! = _SUCCESS ) {
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
goto exit ;
}
/* indicate this recv_frame */
ret = rtw_recv_indicatepkt ( padapter , prframe ) ;
if ( ret ! = _SUCCESS ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " rtw_recv_indicatepkt fail! \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
# endif
goto exit ;
}
} else {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " DS:%u SR:%u \n "
, FUNC_ADPT_ARG ( padapter )
, rtw_is_drv_stopped ( padapter )
, rtw_is_surprise_removed ( padapter ) ) ;
# endif
ret = _SUCCESS ; /* don't count as packet drop */
rtw_free_recvframe ( prframe , pfree_recv_queue ) ;
}
}
exit :
2015-08-18 19:03:09 +00:00
return ret ;
}
2019-11-09 10:12:08 +00:00
# if defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL)
static int check_indicate_seq ( struct recv_reorder_ctrl * preorder_ctrl , u16 seq_num )
2015-08-18 19:03:09 +00:00
{
PADAPTER padapter = preorder_ctrl - > padapter ;
2019-11-09 10:12:08 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-08-18 19:03:09 +00:00
u8 wsize = preorder_ctrl - > wsize_b ;
2019-11-09 10:12:08 +00:00
u16 wend = ( preorder_ctrl - > indicate_seq + wsize - 1 ) & 0xFFF ; /* % 4096; */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* Rx Reorder initialize condition. */
if ( preorder_ctrl - > indicate_seq = = 0xFFFF ) {
2015-08-18 19:03:09 +00:00
preorder_ctrl - > indicate_seq = seq_num ;
# ifdef DBG_RX_SEQ
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " tid:%u SN_INIT indicate_seq:%d, seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
}
2019-11-09 10:12:08 +00:00
/* Drop out the packet which SeqNum is smaller than WinStart */
if ( SN_LESS ( seq_num , preorder_ctrl - > indicate_seq ) ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( FUNC_ADPT_FMT " tid:%u indicate_seq:%d > seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
return _FALSE ;
}
2019-11-09 10:12:08 +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
*/
if ( SN_EQUAL ( seq_num , preorder_ctrl - > indicate_seq ) ) {
2015-08-18 19:03:09 +00:00
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) & 0xFFF ;
# ifdef DBG_RX_SEQ
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " tid:%u SN_EQUAL indicate_seq:%d, seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
} else if ( SN_LESS ( wend , seq_num ) ) {
/* boundary situation, when seq_num cross 0xFFF */
if ( seq_num > = ( wsize - 1 ) )
preorder_ctrl - > indicate_seq = seq_num + 1 - wsize ;
2015-08-18 19:03:09 +00:00
else
preorder_ctrl - > indicate_seq = 0xFFF - ( wsize - ( seq_num + 1 ) ) + 1 ;
2019-11-09 10:12:08 +00:00
precvpriv - > dbg_rx_ampdu_window_shift_cnt + + ;
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_SEQ
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " tid:%u SN_LESS(wend, seq_num) indicate_seq:%d, seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
}
return _TRUE ;
}
2019-11-09 10:12:08 +00:00
static int enqueue_reorder_recvframe ( struct recv_reorder_ctrl * preorder_ctrl , union recv_frame * prframe )
2015-08-18 19:03:09 +00:00
{
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
_queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
_list * phead , * plist ;
union recv_frame * pnextrframe ;
struct rx_pkt_attrib * pnextattrib ;
2019-11-09 10:12:08 +00:00
/* DbgPrint("+enqueue_reorder_recvframe()\n"); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* _enter_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* _rtw_spinlock_ex(&ppending_recvframe_queue->lock); */
2015-08-18 19:03:09 +00:00
phead = get_list_head ( ppending_recvframe_queue ) ;
plist = get_next ( phead ) ;
2021-10-14 20:37:57 +00:00
while ( phead ! = plist ) {
2015-08-18 19:03:09 +00:00
pnextrframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
pnextattrib = & pnextrframe - > u . hdr . attrib ;
2019-11-09 10:12:08 +00:00
if ( SN_LESS ( pnextattrib - > seq_num , pattrib - > seq_num ) )
2015-08-18 19:03:09 +00:00
plist = get_next ( plist ) ;
2019-11-09 10:12:08 +00:00
else if ( SN_EQUAL ( pnextattrib - > seq_num , pattrib - > seq_num ) ) {
/* Duplicate entry is found!! Do not insert current entry. */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
2015-08-18 19:03:09 +00:00
return _FALSE ;
2019-11-09 10:12:08 +00:00
} else
2015-08-18 19:03:09 +00:00
break ;
2019-11-09 10:12:08 +00:00
/* DbgPrint("enqueue_reorder_recvframe():while\n"); */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* _enter_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* _rtw_spinlock_ex(&ppending_recvframe_queue->lock); */
2015-08-18 19:03:09 +00:00
rtw_list_delete ( & ( prframe - > u . hdr . list ) ) ;
rtw_list_insert_tail ( & ( prframe - > u . hdr . list ) , plist ) ;
2019-11-09 10:12:08 +00:00
/* _rtw_spinunlock_ex(&ppending_recvframe_queue->lock); */
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
2015-08-18 19:03:09 +00:00
return _TRUE ;
}
2019-11-09 10:12:08 +00:00
static void recv_indicatepkts_pkt_loss_cnt ( _adapter * padapter , u64 prev_seq , u64 current_seq )
2017-05-11 18:35:20 +00:00
{
2019-11-09 10:12:08 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
if ( current_seq < prev_seq ) {
precvpriv - > dbg_rx_ampdu_loss_count + = ( 4096 + current_seq - prev_seq ) ;
precvpriv - > rx_drop + = ( 4096 + current_seq - prev_seq ) ;
} else {
precvpriv - > dbg_rx_ampdu_loss_count + = ( current_seq - prev_seq ) ;
precvpriv - > rx_drop + = ( current_seq - prev_seq ) ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
static int recv_indicatepkts_in_order ( _adapter * padapter , struct recv_reorder_ctrl * preorder_ctrl , int bforced )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
/* _irqL irql; */
2015-08-18 19:03:09 +00:00
_list * phead , * plist ;
union recv_frame * prframe ;
struct rx_pkt_attrib * pattrib ;
2019-11-09 10:12:08 +00:00
/* u8 index = 0; */
2015-08-18 19:03:09 +00:00
int bPktInBuf = _FALSE ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
_queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_indicate_in_oder ) ;
2019-11-09 10:12:08 +00:00
/* DbgPrint("+recv_indicatepkts_in_order\n"); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* _enter_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* _rtw_spinlock_ex(&ppending_recvframe_queue->lock); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
phead = get_list_head ( ppending_recvframe_queue ) ;
2015-08-18 19:03:09 +00:00
plist = get_next ( phead ) ;
#if 0
2019-11-09 10:12:08 +00:00
/* Check if there is any other indication thread running. */
if ( pTS - > RxIndicateState = = RXTS_INDICATE_PROCESSING )
2015-08-18 19:03:09 +00:00
return ;
# endif
2019-11-09 10:12:08 +00:00
/* Handling some condition for forced indicate case. */
if ( bforced = = _TRUE ) {
precvpriv - > dbg_rx_ampdu_forced_indicate_count + + ;
if ( rtw_is_list_empty ( phead ) ) {
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* _rtw_spinunlock_ex(&ppending_recvframe_queue->lock); */
2015-08-18 19:03:09 +00:00
return _TRUE ;
}
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
2019-11-09 10:12:08 +00:00
pattrib = & prframe - > u . hdr . attrib ;
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_SEQ
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " tid:%u FORCE indicate_seq:%d, seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
recv_indicatepkts_pkt_loss_cnt ( padapter , preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
preorder_ctrl - > indicate_seq = pattrib - > seq_num ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* Prepare indication list and indication. */
/* Check if there is any packet need indicate. */
while ( ! rtw_is_list_empty ( phead ) ) {
2015-08-18 19:03:09 +00:00
prframe = LIST_CONTAINOR ( plist , union recv_frame , u ) ;
pattrib = & prframe - > u . hdr . attrib ;
2019-11-09 10:12:08 +00:00
if ( ! SN_LESS ( preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ) {
2015-08-18 19:03:09 +00:00
#if 0
2019-11-09 10:12:08 +00:00
/* This protect buffer from overflow. */
if ( index > = REORDER_WIN_SIZE ) {
RT_ASSERT ( FALSE , ( " IndicateRxReorderList(): Buffer overflow!! \n " ) ) ;
2015-08-18 19:03:09 +00:00
bPktInBuf = TRUE ;
break ;
}
# endif
plist = get_next ( plist ) ;
rtw_list_delete ( & ( prframe - > u . hdr . list ) ) ;
2019-11-09 10:12:08 +00:00
if ( SN_EQUAL ( preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ) {
2015-08-18 19:03:09 +00:00
preorder_ctrl - > indicate_seq = ( preorder_ctrl - > indicate_seq + 1 ) & 0xFFF ;
# ifdef DBG_RX_SEQ
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_SEQ " FUNC_ADPT_FMT " tid:%u SN_EQUAL indicate_seq:%d, seq_num:%d \n "
, FUNC_ADPT_ARG ( padapter ) , preorder_ctrl - > tid , preorder_ctrl - > indicate_seq , pattrib - > seq_num ) ;
2015-08-18 19:03:09 +00:00
# endif
}
#if 0
index + + ;
2019-11-09 10:12:08 +00:00
if ( index = = 1 ) {
/* Cancel previous pending timer. */
/* PlatformCancelTimer(Adapter, &pTS->RxPktPendingTimer); */
if ( bforced ! = _TRUE ) {
/* RTW_INFO("_cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);\n"); */
_cancel_timer_ex ( & preorder_ctrl - > reordering_ctrl_timer ) ;
2015-08-18 19:03:09 +00:00
}
}
# endif
2019-11-09 10:12:08 +00:00
/* Set this as a lock to make sure that only one thread is indicating packet. */
/* pTS->RxIndicateState = RXTS_INDICATE_PROCESSING; */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* Indicate packets */
/* RT_ASSERT((index<=REORDER_WIN_SIZE), ("RxReorderIndicatePacket(): Rx Reorder buffer full!!\n")); */
2017-05-11 18:47:23 +00:00
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* indicate this recv_frame */
/* DbgPrint("recv_indicatepkts_in_order, indicate_seq=%d, seq_num=%d\n", precvpriv->indicate_seq, pattrib->seq_num); */
if ( recv_process_mpdu ( padapter , prframe ) ! = _SUCCESS )
precvpriv - > dbg_rx_drop_count + + ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* Update local variables. */
2015-08-18 19:03:09 +00:00
bPktInBuf = _FALSE ;
2019-11-09 10:12:08 +00:00
} else {
2015-08-18 19:03:09 +00:00
bPktInBuf = _TRUE ;
break ;
}
2019-11-09 10:12:08 +00:00
/* DbgPrint("recv_indicatepkts_in_order():while\n"); */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
/* _rtw_spinunlock_ex(&ppending_recvframe_queue->lock); */
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
#if 0
/* Release the indication lock and set to new indication step. */
if ( bPktInBuf ) {
/* Set new pending timer. */
/* pTS->RxIndicateState = RXTS_INDICATE_REORDER; */
/* PlatformSetTimer(Adapter, &pTS->RxPktPendingTimer, pHTInfo->RxReorderPendingTime); */
2015-08-18 19:03:09 +00:00
_set_timer ( & preorder_ctrl - > reordering_ctrl_timer , REORDER_WAIT_TIME ) ;
2019-11-09 10:12:08 +00:00
} else {
/* pTS->RxIndicateState = RXTS_INDICATE_IDLE; */
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* return _TRUE; */
2015-08-18 19:03:09 +00:00
return bPktInBuf ;
}
2019-11-09 10:12:08 +00:00
static int recv_indicatepkt_reorder ( _adapter * padapter , union recv_frame * prframe )
2015-08-18 19:03:09 +00:00
{
_irqL irql ;
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
struct recv_reorder_ctrl * preorder_ctrl = prframe - > u . hdr . preorder_ctrl ;
2019-11-09 10:12:08 +00:00
_queue * ppending_recvframe_queue = preorder_ctrl ? & preorder_ctrl - > pending_recvframe_queue : NULL ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( ! pattrib - > qos | | ! preorder_ctrl | | preorder_ctrl - > enable = = _FALSE )
goto _success_exit ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_indicate_reoder ) ;
2015-08-18 19:03:09 +00:00
_enter_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
2019-11-09 10:12:08 +00:00
/* s2. check if winstart_b(indicate_seq) needs to been updated */
if ( ! check_indicate_seq ( preorder_ctrl , pattrib - > seq_num ) ) {
precvpriv - > dbg_rx_ampdu_drop_count + + ;
/* pHTInfo->RxReorderDropCounter++; */
/* ReturnRFDList(Adapter, pRfd); */
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* return _FAIL; */
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " check_indicate_seq fail \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2019-11-09 10:12:08 +00:00
#if 0
2015-08-18 19:03:09 +00:00
rtw_recv_indicatepkt ( padapter , prframe ) ;
_exit_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
goto _success_exit ;
# else
goto _err_exit ;
# endif
}
2019-11-09 10:12:08 +00:00
/* s3. Insert all packet into Reorder Queue to maintain its ordering. */
if ( ! enqueue_reorder_recvframe ( preorder_ctrl , prframe ) ) {
/* DbgPrint("recv_indicatepkt_reorder, enqueue_reorder_recvframe fail!\n"); */
/* _exit_critical_ex(&ppending_recvframe_queue->lock, &irql); */
/* return _FAIL; */
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " enqueue_reorder_recvframe fail \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
goto _err_exit ;
}
2019-11-09 10:12:08 +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. */
/* */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* recv_indicatepkts_in_order(padapter, preorder_ctrl, _TRUE); */
if ( recv_indicatepkts_in_order ( padapter , preorder_ctrl , _FALSE ) = = _TRUE ) {
2017-05-11 18:47:23 +00:00
if ( ! preorder_ctrl - > bReorderWaiting ) {
preorder_ctrl - > bReorderWaiting = _TRUE ;
2019-11-09 10:12:08 +00:00
_set_timer ( & preorder_ctrl - > reordering_ctrl_timer , REORDER_WAIT_TIME ) ;
2017-05-11 18:47:23 +00:00
}
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:47:23 +00:00
preorder_ctrl - > bReorderWaiting = _FALSE ;
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
_cancel_timer_ex ( & preorder_ctrl - > reordering_ctrl_timer ) ;
}
2019-11-09 10:12:08 +00:00
return RTW_RX_HANDLED ;
2015-08-18 19:03:09 +00:00
_success_exit :
return _SUCCESS ;
_err_exit :
2019-11-09 10:12:08 +00:00
_exit_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
2015-08-18 19:03:09 +00:00
return _FAIL ;
}
void rtw_reordering_ctrl_timeout_handler ( void * pcontext )
{
_irqL irql ;
struct recv_reorder_ctrl * preorder_ctrl = ( struct recv_reorder_ctrl * ) pcontext ;
_adapter * padapter = preorder_ctrl - > padapter ;
_queue * ppending_recvframe_queue = & preorder_ctrl - > pending_recvframe_queue ;
2017-05-11 18:47:23 +00:00
if ( RTW_CANNOT_RUN ( padapter ) )
2015-08-18 19:03:09 +00:00
return ;
2019-11-09 10:12:08 +00:00
/* RTW_INFO("+rtw_reordering_ctrl_timeout_handler()=>\n"); */
2015-08-18 19:03:09 +00:00
_enter_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
2019-11-09 10:12:08 +00:00
if ( preorder_ctrl )
2017-05-11 18:47:23 +00:00
preorder_ctrl - > bReorderWaiting = _FALSE ;
2019-11-09 10:12:08 +00:00
if ( recv_indicatepkts_in_order ( padapter , preorder_ctrl , _TRUE ) = = _TRUE )
_set_timer ( & preorder_ctrl - > reordering_ctrl_timer , REORDER_WAIT_TIME ) ;
2015-08-18 19:03:09 +00:00
_exit_critical_bh ( & ppending_recvframe_queue - > lock , & irql ) ;
}
2019-11-09 10:12:08 +00:00
# endif /* defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL) */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
static void recv_set_iseq_before_mpdu_process ( union recv_frame * rframe , u16 seq_num , const char * caller )
2015-08-18 19:03:09 +00:00
{
2019-11-09 10:12:08 +00:00
# if defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL)
struct recv_reorder_ctrl * reorder_ctrl = rframe - > u . hdr . preorder_ctrl ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( reorder_ctrl ) {
reorder_ctrl - > indicate_seq = seq_num ;
# ifdef DBG_RX_SEQ
RTW_INFO ( " DBG_RX_SEQ %s( " ADPT_FMT " )-B tid:%u indicate_seq:%d, seq_num:%d \n "
, caller , ADPT_ARG ( reorder_ctrl - > padapter )
, reorder_ctrl - > tid , reorder_ctrl - > indicate_seq , seq_num ) ;
# endif
2015-08-18 19:03:09 +00:00
}
# endif
2019-11-09 10:12:08 +00:00
}
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
static void recv_set_iseq_after_mpdu_process ( union recv_frame * rframe , u16 seq_num , const char * caller )
{
# if defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL)
struct recv_reorder_ctrl * reorder_ctrl = rframe - > u . hdr . preorder_ctrl ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( reorder_ctrl ) {
reorder_ctrl - > indicate_seq = ( reorder_ctrl - > indicate_seq + 1 ) % 4096 ;
# ifdef DBG_RX_SEQ
RTW_INFO ( " DBG_RX_SEQ %s( " ADPT_FMT " )-A tid:%u indicate_seq:%d, seq_num:%d \n "
, caller , ADPT_ARG ( reorder_ctrl - > padapter )
, reorder_ctrl - > tid , reorder_ctrl - > indicate_seq , seq_num ) ;
# endif
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
2015-08-18 19:03:09 +00:00
}
# ifdef CONFIG_MP_INCLUDED
int validate_mp_recv_frame ( _adapter * adapter , union recv_frame * precv_frame )
{
int ret = _SUCCESS ;
2019-11-09 10:12:08 +00:00
u8 * ptr = precv_frame - > u . hdr . rx_data ;
u8 type , subtype ;
2017-05-11 18:47:23 +00:00
struct mp_priv * pmppriv = & adapter - > mppriv ;
struct mp_tx * pmptx ;
2019-11-09 10:12:08 +00:00
unsigned char * sa , * da , * bs ;
2017-05-11 18:47:23 +00:00
pmptx = & pmppriv - > tx ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
#if 0
if ( 1 ) {
2015-08-18 19:03:09 +00:00
u8 bDumpRxPkt ;
type = GetFrameType ( ptr ) ;
2019-11-09 10:12:08 +00:00
subtype = get_frame_sub_type ( ptr ) ; /* bit(7)~bit(2) */
2015-08-18 19:03:09 +00:00
rtw_hal_get_def_var ( adapter , HAL_DEF_DBG_DUMP_RXPKT , & ( bDumpRxPkt ) ) ;
2019-11-09 10:12:08 +00:00
if ( bDumpRxPkt = = 1 ) { /* dump all rx packets */
2015-08-18 19:03:09 +00:00
int i ;
2019-11-09 10:12:08 +00:00
RTW_INFO ( " ############ type:0x%02x subtype:0x%02x ################# \n " , type , subtype ) ;
for ( i = 0 ; i < 64 ; i = i + 8 )
RTW_INFO ( " %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 ) ) ;
RTW_INFO ( " ############################# \n " ) ;
2017-05-11 18:47:23 +00:00
}
}
# endif
if ( pmppriv - > bloopback ) {
if ( _rtw_memcmp ( ptr + 24 , pmptx - > buf + 24 , precv_frame - > u . hdr . len - 24 ) = = _FALSE ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " Compare payload content Fail !!! \n " ) ;
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
if ( pmppriv - > bSetRxBssid = = _TRUE ) {
sa = get_addr2_ptr ( ptr ) ;
da = GetAddr1Ptr ( ptr ) ;
bs = GetAddr3Ptr ( ptr ) ;
type = GetFrameType ( ptr ) ;
subtype = get_frame_sub_type ( ptr ) ; /* bit(7)~bit(2) */
if ( _rtw_memcmp ( bs , adapter - > mppriv . network_macaddr , ETH_ALEN ) = = _FALSE )
ret = _FAIL ;
RTW_DBG ( " ############ type:0x%02x subtype:0x%02x ################# \n " , type , subtype ) ;
RTW_DBG ( " A2 sa %02X:%02X:%02X:%02X:%02X:%02X \n " , * ( sa ) , * ( sa + 1 ) , * ( sa + 2 ) , * ( sa + 3 ) , * ( sa + 4 ) , * ( sa + 5 ) ) ;
RTW_DBG ( " A1 da %02X:%02X:%02X:%02X:%02X:%02X \n " , * ( da ) , * ( da + 1 ) , * ( da + 2 ) , * ( da + 3 ) , * ( da + 4 ) , * ( da + 5 ) ) ;
RTW_DBG ( " A3 bs %02X:%02X:%02X:%02X:%02X:%02X \n -------------------------- \n " , * ( bs ) , * ( bs + 1 ) , * ( bs + 2 ) , * ( bs + 3 ) , * ( bs + 4 ) , * ( bs + 5 ) ) ;
}
2017-05-11 18:47:23 +00:00
if ( ! adapter - > mppriv . bmac_filter )
return ret ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( _rtw_memcmp ( get_addr2_ptr ( ptr ) , adapter - > mppriv . mac_filter , ETH_ALEN ) = = _FALSE )
2015-08-18 19:03:09 +00:00
ret = _FAIL ;
return ret ;
}
2019-11-09 10:12:08 +00:00
static sint MPwlanhdr_to_ethhdr ( union recv_frame * precvframe )
2017-05-11 18:35:20 +00:00
{
sint rmv_len ;
u16 eth_type , len ;
u8 bsnaphdr ;
u8 * psnap_type ;
2019-11-09 10:12:08 +00:00
u8 mcastheadermac [ ] = { 0x01 , 0x00 , 0x5e } ;
2017-05-11 18:35:20 +00:00
struct ieee80211_snap_hdr * psnap ;
2019-11-09 10:12:08 +00:00
sint ret = _SUCCESS ;
_adapter * adapter = precvframe - > u . hdr . adapter ;
u8 * ptr = get_recvframe_data ( precvframe ) ; /* point to frame_ctrl field */
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
if ( pattrib - > encrypt )
recvframe_pull_tail ( precvframe , pattrib - > icv_len ) ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
psnap = ( struct ieee80211_snap_hdr * ) ( ptr + pattrib - > hdrlen + pattrib - > iv_len ) ;
psnap_type = ptr + pattrib - > hdrlen + pattrib - > iv_len + SNAP_SIZE ;
2017-05-11 18:35:20 +00:00
/* convert hdr + possible LLC headers into Ethernet header */
2019-11-09 10:12:08 +00:00
/* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */
if ( ( _rtw_memcmp ( psnap , rtw_rfc1042_header , SNAP_SIZE ) & &
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_IPX , 2 ) = = _FALSE ) & &
( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_APPLETALK_AARP , 2 ) = = _FALSE ) ) | |
/* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */
_rtw_memcmp ( psnap , rtw_bridge_tunnel_header , SNAP_SIZE ) ) {
2017-05-11 18:35:20 +00:00
/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */
bsnaphdr = _TRUE ;
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:35:20 +00:00
/* Leave Ethernet header part of hdr and full payload */
bsnaphdr = _FALSE ;
}
2019-11-09 10:12:08 +00:00
rmv_len = pattrib - > hdrlen + pattrib - > iv_len + ( bsnaphdr ? SNAP_SIZE : 0 ) ;
2017-05-11 18:35:20 +00:00
len = precvframe - > u . hdr . len - rmv_len ;
2021-10-12 14:53:20 +00:00
memcpy ( & eth_type , ptr + rmv_len , 2 ) ;
2019-11-09 10:12:08 +00:00
eth_type = ntohs ( ( unsigned short ) eth_type ) ; /* pattrib->ether_type */
2017-05-11 18:35:20 +00:00
pattrib - > eth_type = eth_type ;
{
2019-11-09 10:12:08 +00:00
ptr = recvframe_pull ( precvframe , ( rmv_len - sizeof ( struct ethhdr ) + ( bsnaphdr ? 2 : 0 ) ) ) ;
2017-05-11 18:35:20 +00:00
}
2021-10-12 14:53:20 +00:00
memcpy ( ptr , pattrib - > dst , ETH_ALEN ) ;
memcpy ( ptr + ETH_ALEN , pattrib - > src , ETH_ALEN ) ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
if ( ! bsnaphdr ) {
2017-05-11 18:35:20 +00:00
len = htons ( len ) ;
2021-10-12 14:53:20 +00:00
memcpy ( ptr + 12 , & len , 2 ) ;
2017-05-11 18:35:20 +00:00
}
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
len = htons ( pattrib - > seq_num ) ;
/* RTW_INFO("wlan seq = %d ,seq_num =%x\n",len,pattrib->seq_num); */
2021-10-12 14:53:20 +00:00
memcpy ( ptr + 12 , & len , 2 ) ;
2019-11-09 10:12:08 +00:00
if ( adapter - > mppriv . bRTWSmbCfg = = _TRUE ) {
/* if(_rtw_memcmp(mcastheadermac, pattrib->dst, 3) == _TRUE) */ /* SimpleConfig Dest. */
2021-10-12 14:53:20 +00:00
/* memcpy(ptr+ETH_ALEN, pattrib->bssid, ETH_ALEN); */
2019-11-09 10:12:08 +00:00
if ( _rtw_memcmp ( mcastheadermac , pattrib - > bssid , 3 ) = = _TRUE ) /* SimpleConfig Dest. */
2021-10-12 14:53:20 +00:00
memcpy ( ptr , pattrib - > bssid , ETH_ALEN ) ;
2017-05-11 18:47:23 +00:00
2017-05-11 18:35:20 +00:00
}
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
2017-05-11 18:35:20 +00:00
return ret ;
}
2017-05-11 18:47:23 +00:00
int mp_recv_frame ( _adapter * padapter , union recv_frame * rframe )
2015-08-18 19:03:09 +00:00
{
int ret = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & rframe - > u . hdr . attrib ;
_queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
# ifdef CONFIG_MP_INCLUDED
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
2017-05-11 18:35:20 +00:00
struct mp_priv * pmppriv = & padapter - > mppriv ;
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_MP_INCLUDED */
2017-05-11 18:35:20 +00:00
u8 type ;
u8 * ptr = rframe - > u . hdr . rx_data ;
u8 * psa , * pda , * pbssid ;
struct sta_info * psta = NULL ;
2019-11-09 10:12:08 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_pre ) ;
if ( ( check_fwstate ( pmlmepriv , _FW_LINKED ) = = _TRUE ) ) { /* &&(padapter->mppriv.check_mp_pkt == 0)) */
if ( pattrib - > crc_err = = 1 )
2017-05-11 18:47:23 +00:00
padapter - > mppriv . rx_crcerrpktcount + + ;
2019-11-09 10:12:08 +00:00
else {
if ( _SUCCESS = = validate_mp_recv_frame ( padapter , rframe ) )
2017-05-11 18:47:23 +00:00
padapter - > mppriv . rx_pktcount + + ;
else
padapter - > mppriv . rx_pktcount_filter_out + + ;
}
2019-11-09 10:12:08 +00:00
if ( pmppriv - > rx_bindicatePkt = = _FALSE ) {
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
2019-11-09 10:12:08 +00:00
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
2017-05-11 18:47:23 +00:00
goto exit ;
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:47:23 +00:00
type = GetFrameType ( ptr ) ;
2017-05-11 18:35:20 +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 ) ;
2019-11-09 10:12:08 +00:00
2021-10-18 14:05:53 +00:00
if ( type = = IEEE80211_FTYPE_DATA ) {
2021-10-18 17:40:27 +00:00
pda = ieee80211_get_DA ( ( struct ieee80211_hdr * ) ptr ) ;
psa = ieee80211_get_SA ( ( struct ieee80211_hdr * ) ptr ) ;
2017-05-11 18:35:20 +00:00
pbssid = get_hdr_bssid ( ptr ) ;
2019-11-09 10:12:08 +00:00
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > dst , pda , ETH_ALEN ) ;
memcpy ( pattrib - > src , psa , ETH_ALEN ) ;
memcpy ( pattrib - > bssid , pbssid , ETH_ALEN ) ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
switch ( pattrib - > to_fr_ds ) {
case 0 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = sta2sta_data_frame ( padapter , rframe , & psta ) ;
break ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
case 1 :
2017-05-11 18:35:20 +00:00
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pda , ETH_ALEN ) ;
memcpy ( pattrib - > ta , pbssid , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = ap2sta_data_frame ( padapter , rframe , & psta ) ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
break ;
case 2 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , pbssid , ETH_ALEN ) ;
memcpy ( pattrib - > ta , psa , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = sta2ap_data_frame ( padapter , rframe , & psta ) ;
break ;
case 3 :
2021-10-12 14:53:20 +00:00
memcpy ( pattrib - > ra , GetAddr1Ptr ( ptr ) , ETH_ALEN ) ;
memcpy ( pattrib - > ta , get_addr2_ptr ( ptr ) , ETH_ALEN ) ;
2019-11-09 10:12:08 +00:00
ret = _FAIL ;
break ;
default :
ret = _FAIL ;
break ;
}
ret = MPwlanhdr_to_ethhdr ( rframe ) ;
if ( ret ! = _SUCCESS ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " wlanhdr_to_ethhdr: drop pkt \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
# endif
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
goto exit ;
}
if ( ! RTW_CANNOT_RUN ( padapter ) ) {
2019-11-09 10:12:08 +00:00
/* indicate this recv_frame */
2017-05-11 18:47:23 +00:00
ret = rtw_recv_indicatepkt ( padapter , rframe ) ;
2019-11-09 10:12:08 +00:00
if ( ret ! = _SUCCESS ) {
# ifdef DBG_RX_DROP_FRAME
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " rtw_recv_indicatepkt fail! \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
# endif
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
ret = _FAIL ;
2017-05-11 18:35:20 +00:00
2019-11-09 10:12:08 +00:00
goto exit ;
2017-05-11 18:35:20 +00:00
}
2019-11-09 10:12:08 +00:00
} else {
2017-05-11 18:47:23 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " bDriverStopped(%s) OR bSurpriseRemoved(%s) \n "
, FUNC_ADPT_ARG ( padapter )
, rtw_is_drv_stopped ( padapter ) ? " True " : " False "
, rtw_is_surprise_removed ( padapter ) ? " True " : " False " ) ;
2017-05-11 18:47:23 +00:00
# endif
ret = _FAIL ;
2019-11-09 10:12:08 +00:00
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
goto exit ;
2017-05-11 18:47:23 +00:00
}
}
}
2019-11-09 10:12:08 +00:00
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
exit :
2019-11-09 10:12:08 +00:00
return ret ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
2017-05-11 18:47:23 +00:00
static sint fill_radiotap_hdr ( _adapter * padapter , union recv_frame * precvframe , u8 * buf )
{
2019-11-09 10:12:08 +00:00
# define CHAN2FREQ(a) ((a < 14) ? (2407+5*a) : (5000+5*a))
2017-05-11 18:47:23 +00:00
#if 0
2019-11-09 10:12:08 +00:00
# define RTW_RX_RADIOTAP_PRESENT (\
( 1 < < IEEE80211_RADIOTAP_TSFT ) | \
( 1 < < IEEE80211_RADIOTAP_FLAGS ) | \
( 1 < < IEEE80211_RADIOTAP_RATE ) | \
( 1 < < IEEE80211_RADIOTAP_CHANNEL ) | \
( 0 < < IEEE80211_RADIOTAP_FHSS ) | \
( 1 < < IEEE80211_RADIOTAP_DBM_ANTSIGNAL ) | \
( 1 < < IEEE80211_RADIOTAP_DBM_ANTNOISE ) | \
( 0 < < IEEE80211_RADIOTAP_LOCK_QUALITY ) | \
( 0 < < IEEE80211_RADIOTAP_TX_ATTENUATION ) | \
( 0 < < IEEE80211_RADIOTAP_DB_TX_ATTENUATION ) | \
( 0 < < IEEE80211_RADIOTAP_DBM_TX_POWER ) | \
( 1 < < IEEE80211_RADIOTAP_ANTENNA ) | \
( 1 < < IEEE80211_RADIOTAP_DB_ANTSIGNAL ) | \
( 0 < < IEEE80211_RADIOTAP_DB_ANTNOISE ) | \
( 0 < < IEEE80211_RADIOTAP_RX_FLAGS ) | \
( 0 < < IEEE80211_RADIOTAP_TX_FLAGS ) | \
( 0 < < IEEE80211_RADIOTAP_RTS_RETRIES ) | \
( 0 < < IEEE80211_RADIOTAP_DATA_RETRIES ) | \
( 0 < < IEEE80211_RADIOTAP_MCS ) | \
( 0 < < IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE ) | \
( 0 < < IEEE80211_RADIOTAP_VENDOR_NAMESPACE ) | \
( 0 < < IEEE80211_RADIOTAP_EXT ) | \
0 )
2017-05-11 18:47:23 +00:00
/* (0 << IEEE80211_RADIOTAP_AMPDU_STATUS) | \ */
/* (0 << IEEE80211_RADIOTAP_VHT) | \ */
# endif
2019-11-09 10:12:08 +00:00
# ifndef IEEE80211_RADIOTAP_RX_FLAGS
# define IEEE80211_RADIOTAP_RX_FLAGS 14
# endif
2017-05-11 18:47:23 +00:00
# ifndef IEEE80211_RADIOTAP_MCS
# define IEEE80211_RADIOTAP_MCS 19
# endif
# ifndef IEEE80211_RADIOTAP_VHT
# define IEEE80211_RADIOTAP_VHT 21
# endif
# ifndef IEEE80211_RADIOTAP_F_BADFCS
# define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */
# endif
sint ret = _SUCCESS ;
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
u16 tmp_16bit = 0 ;
u8 data_rate [ ] = {
2 , 4 , 11 , 22 , /* CCK */
12 , 18 , 24 , 36 , 48 , 72 , 93 , 108 , /* OFDM */
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , /* HT MCS index */
16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 ,
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , /* VHT Nss 1 */
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , /* VHT Nss 2 */
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , /* VHT Nss 3 */
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , /* VHT Nss 4 */
} ;
_pkt * pskb = NULL ;
struct ieee80211_radiotap_header * rtap_hdr = NULL ;
u8 * ptr = NULL ;
u8 hdr_buf [ 64 ] = { 0 } ;
u16 rt_len = 8 ;
/* create header */
rtap_hdr = ( struct ieee80211_radiotap_header * ) & hdr_buf [ 0 ] ;
rtap_hdr - > it_version = PKTHDR_RADIOTAP_VERSION ;
/* tsft */
if ( pattrib - > tsfl ) {
u64 tmp_64bit ;
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_TSFT ) ;
tmp_64bit = cpu_to_le64 ( pattrib - > tsfl ) ;
memcpy ( & hdr_buf [ rt_len ] , & tmp_64bit , 8 ) ;
rt_len + = 8 ;
}
/* flags */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_FLAGS ) ;
if ( 0 )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_CFP ;
if ( 0 )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_SHORTPRE ;
if ( ( pattrib - > encrypt = = 1 ) | | ( pattrib - > encrypt = = 5 ) )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_WEP ;
if ( pattrib - > mfrag )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_FRAG ;
/* always append FCS */
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_FCS ;
2019-11-09 10:12:08 +00:00
2017-05-11 18:47:23 +00:00
if ( 0 )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_DATAPAD ;
if ( pattrib - > crc_err )
hdr_buf [ rt_len ] | = IEEE80211_RADIOTAP_F_BADFCS ;
if ( pattrib - > sgi ) {
/* Currently unspecified but used */
hdr_buf [ rt_len ] | = 0x80 ;
}
rt_len + = 1 ;
/* rate */
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate < = DESC_RATE54M ) {
2017-05-11 18:47:23 +00:00
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_RATE ) ;
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate < = DESC_RATE11M ) {
2017-05-11 18:47:23 +00:00
/* CCK */
hdr_buf [ rt_len ] = data_rate [ pattrib - > data_rate ] ;
} else {
/* OFDM */
hdr_buf [ rt_len ] = data_rate [ pattrib - > data_rate ] ;
}
}
rt_len + = 1 ; /* force padding 1 byte for aligned */
/* channel */
tmp_16bit = 0 ;
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_CHANNEL ) ;
tmp_16bit = CHAN2FREQ ( rtw_get_oper_ch ( padapter ) ) ;
2019-11-09 10:12:08 +00:00
/*tmp_16bit = CHAN2FREQ(pHalData->current_channel);*/
2017-05-11 18:47:23 +00:00
memcpy ( & hdr_buf [ rt_len ] , & tmp_16bit , 2 ) ;
rt_len + = 2 ;
/* channel flags */
tmp_16bit = 0 ;
2019-11-09 10:12:08 +00:00
if ( pHalData - > current_band_type = = 0 )
2017-05-11 18:47:23 +00:00
tmp_16bit | = cpu_to_le16 ( IEEE80211_CHAN_2GHZ ) ;
2019-11-09 10:12:08 +00:00
else
2017-05-11 18:47:23 +00:00
tmp_16bit | = cpu_to_le16 ( IEEE80211_CHAN_5GHZ ) ;
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate < = DESC_RATE54M ) {
if ( pattrib - > data_rate < = DESC_RATE11M ) {
2017-05-11 18:47:23 +00:00
/* CCK */
tmp_16bit | = cpu_to_le16 ( IEEE80211_CHAN_CCK ) ;
} else {
/* OFDM */
tmp_16bit | = cpu_to_le16 ( IEEE80211_CHAN_OFDM ) ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
} else
2017-05-11 18:47:23 +00:00
tmp_16bit | = cpu_to_le16 ( IEEE80211_CHAN_DYN ) ;
memcpy ( & hdr_buf [ rt_len ] , & tmp_16bit , 2 ) ;
rt_len + = 2 ;
2017-05-11 18:35:20 +00:00
2017-05-11 18:47:23 +00:00
/* dBm Antenna Signal */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_DBM_ANTSIGNAL ) ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len ] = pattrib - > phy_info . recv_signal_power ;
2017-05-11 18:47:23 +00:00
rt_len + = 1 ;
#if 0
/* dBm Antenna Noise */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_DBM_ANTNOISE ) ;
hdr_buf [ rt_len ] = 0 ;
rt_len + = 1 ;
/* Signal Quality */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_LOCK_QUALITY ) ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len ] = pattrib - > phy_info . signal_quality ;
2017-05-11 18:47:23 +00:00
rt_len + = 1 ;
# endif
/* Antenna */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_ANTENNA ) ;
hdr_buf [ rt_len ] = 0 ; /* pHalData->rf_type; */
rt_len + = 1 ;
/* RX flags */
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_RX_FLAGS ) ;
#if 0
tmp_16bit = cpu_to_le16 ( 0 ) ;
memcpy ( ptr , & tmp_16bit , 1 ) ;
# endif
rt_len + = 2 ;
/* MCS information */
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate > = DESC_RATEMCS0 & & pattrib - > data_rate < = DESC_RATEMCS31 ) {
2017-05-11 18:47:23 +00:00
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_MCS ) ;
/* known, flag */
hdr_buf [ rt_len ] | = BIT1 ; /* MCS index known */
/* bandwidth */
hdr_buf [ rt_len ] | = BIT0 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 1 ] | = ( pattrib - > bw & 0x03 ) ;
2017-05-11 18:47:23 +00:00
/* guard interval */
hdr_buf [ rt_len ] | = BIT2 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 1 ] | = ( pattrib - > sgi & 0x01 ) < < 2 ;
2017-05-11 18:47:23 +00:00
/* STBC */
hdr_buf [ rt_len ] | = BIT5 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 1 ] | = ( pattrib - > stbc & 0x03 ) < < 5 ;
2017-05-11 18:47:23 +00:00
rt_len + = 2 ;
/* MCS rate index */
hdr_buf [ rt_len ] = data_rate [ pattrib - > data_rate ] ;
rt_len + = 1 ;
}
/* VHT */
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate > = DESC_RATEVHTSS1MCS0 & & pattrib - > data_rate < = DESC_RATEVHTSS4MCS9 ) {
2017-05-11 18:47:23 +00:00
rtap_hdr - > it_present | = ( 1 < < IEEE80211_RADIOTAP_VHT ) ;
/* known 16 bit, flag 8 bit */
tmp_16bit = 0 ;
/* Bandwidth */
tmp_16bit | = BIT6 ;
/* Group ID */
tmp_16bit | = BIT7 ;
/* Partial AID */
tmp_16bit | = BIT8 ;
/* STBC */
tmp_16bit | = BIT0 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 2 ] | = ( pattrib - > stbc & 0x01 ) ;
2017-05-11 18:47:23 +00:00
/* Guard interval */
tmp_16bit | = BIT2 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 2 ] | = ( pattrib - > sgi & 0x01 ) < < 2 ;
2017-05-11 18:47:23 +00:00
/* LDPC extra OFDM symbol */
tmp_16bit | = BIT4 ;
2019-11-09 10:12:08 +00:00
hdr_buf [ rt_len + 2 ] | = ( pattrib - > ldpc & 0x01 ) < < 4 ;
2017-05-11 18:47:23 +00:00
memcpy ( & hdr_buf [ rt_len ] , & tmp_16bit , 2 ) ;
rt_len + = 3 ;
/* bandwidth */
2019-11-09 10:12:08 +00:00
if ( pattrib - > bw = = 0 )
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len ] | = 0 ;
2019-11-09 10:12:08 +00:00
else if ( pattrib - > bw = = 1 )
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len ] | = 1 ;
2019-11-09 10:12:08 +00:00
else if ( pattrib - > bw = = 2 )
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len ] | = 4 ;
2019-11-09 10:12:08 +00:00
else if ( pattrib - > bw = = 3 )
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len ] | = 11 ;
rt_len + = 1 ;
/* mcs_nss */
2019-11-09 10:12:08 +00:00
if ( pattrib - > data_rate > = DESC_RATEVHTSS1MCS0 & & pattrib - > data_rate < = DESC_RATEVHTSS1MCS9 ) {
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len ] | = 1 ;
hdr_buf [ rt_len ] | = data_rate [ pattrib - > data_rate ] < < 4 ;
2019-11-09 10:12:08 +00:00
} else if ( pattrib - > data_rate > = DESC_RATEVHTSS2MCS0 & & pattrib - > data_rate < = DESC_RATEVHTSS2MCS9 ) {
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len + 1 ] | = 2 ;
hdr_buf [ rt_len + 1 ] | = data_rate [ pattrib - > data_rate ] < < 4 ;
2019-11-09 10:12:08 +00:00
} else if ( pattrib - > data_rate > = DESC_RATEVHTSS3MCS0 & & pattrib - > data_rate < = DESC_RATEVHTSS3MCS9 ) {
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len + 2 ] | = 3 ;
hdr_buf [ rt_len + 2 ] | = data_rate [ pattrib - > data_rate ] < < 4 ;
2019-11-09 10:12:08 +00:00
} else if ( pattrib - > data_rate > = DESC_RATEVHTSS4MCS0 & & pattrib - > data_rate < = DESC_RATEVHTSS4MCS9 ) {
2017-05-11 18:47:23 +00:00
hdr_buf [ rt_len + 3 ] | = 4 ;
hdr_buf [ rt_len + 3 ] | = data_rate [ pattrib - > data_rate ] < < 4 ;
}
rt_len + = 4 ;
/* coding */
hdr_buf [ rt_len ] = 0 ;
rt_len + = 1 ;
/* group_id */
hdr_buf [ rt_len ] = 0 ;
rt_len + = 1 ;
/* partial_aid */
tmp_16bit = 0 ;
memcpy ( & hdr_buf [ rt_len ] , & tmp_16bit , 2 ) ;
rt_len + = 2 ;
}
/* push to skb */
pskb = ( _pkt * ) buf ;
if ( skb_headroom ( pskb ) < rt_len ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " %s:%d %s headroom is too small. \n " , __FILE__ , __LINE__ , __func__ ) ;
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
return ret ;
}
ptr = skb_push ( pskb , rt_len ) ;
if ( ptr ) {
rtap_hdr - > it_len = cpu_to_le16 ( rt_len ) ;
2019-11-09 10:12:08 +00:00
rtap_hdr - > it_present = cpu_to_le32 ( rtap_hdr - > it_present ) ;
2017-05-11 18:47:23 +00:00
memcpy ( ptr , rtap_hdr , rt_len ) ;
2019-11-09 10:12:08 +00:00
} else
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
return ret ;
}
2019-11-09 10:12:08 +00:00
# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
2017-05-11 18:47:23 +00:00
int recv_frame_monitor ( _adapter * padapter , union recv_frame * rframe )
{
int ret = _SUCCESS ;
_queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
_pkt * pskb = NULL ;
/* read skb information from recv frame */
pskb = rframe - > u . hdr . pkt ;
pskb - > len = rframe - > u . hdr . len ;
pskb - > data = rframe - > u . hdr . rx_data ;
skb_set_tail_pointer ( pskb , rframe - > u . hdr . len ) ;
2019-11-09 10:12:08 +00:00
# ifndef CONFIG_CUSTOMER_ALIBABA_GENERAL
2017-05-11 18:47:23 +00:00
/* fill radiotap header */
if ( fill_radiotap_hdr ( padapter , rframe , ( u8 * ) pskb ) = = _FAIL ) {
2017-05-11 18:35:20 +00:00
ret = _FAIL ;
2017-05-11 18:47:23 +00:00
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
2017-05-11 18:35:20 +00:00
goto exit ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
# endif
2017-05-11 18:47:23 +00:00
/* write skb information to recv frame */
skb_reset_mac_header ( pskb ) ;
rframe - > u . hdr . len = pskb - > len ;
rframe - > u . hdr . rx_data = pskb - > data ;
rframe - > u . hdr . rx_head = pskb - > head ;
rframe - > u . hdr . rx_tail = skb_tail_pointer ( pskb ) ;
rframe - > u . hdr . rx_end = skb_end_pointer ( pskb ) ;
if ( ! RTW_CANNOT_RUN ( padapter ) ) {
/* indicate this recv_frame */
ret = rtw_recv_monitor ( padapter , rframe ) ;
if ( ret ! = _SUCCESS ) {
ret = _FAIL ;
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
goto exit ;
}
} else {
ret = _FAIL ;
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
goto exit ;
}
exit :
return ret ;
}
2019-11-09 10:12:08 +00:00
# endif
2017-05-11 18:47:23 +00:00
int recv_func_prehandle ( _adapter * padapter , union recv_frame * rframe )
{
int ret = _SUCCESS ;
2019-11-09 10:12:08 +00:00
# ifdef DBG_RX_COUNTER_DUMP
2017-05-11 18:47:23 +00:00
struct rx_pkt_attrib * pattrib = & rframe - > u . hdr . attrib ;
2019-11-09 10:12:08 +00:00
# endif
2017-05-11 18:47:23 +00:00
_queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
# ifdef DBG_RX_COUNTER_DUMP
2019-11-09 10:12:08 +00:00
if ( padapter - > dump_rx_cnt_mode & DUMP_DRV_RX_COUNTER ) {
2017-05-11 18:47:23 +00:00
if ( pattrib - > crc_err = = 1 )
padapter - > drv_rx_cnt_crcerror + + ;
else
padapter - > drv_rx_cnt_ok + + ;
}
2015-08-18 19:03:09 +00:00
# endif
2017-05-11 18:47:23 +00:00
# ifdef CONFIG_MP_INCLUDED
2019-11-09 10:12:08 +00:00
if ( padapter - > registrypriv . mp_mode = = 1 | | padapter - > mppriv . bRTWSmbCfg = = _TRUE ) {
mp_recv_frame ( padapter , rframe ) ;
2017-05-11 18:47:23 +00:00
ret = _FAIL ;
goto exit ;
2019-11-09 10:12:08 +00:00
} else
2017-05-11 18:47:23 +00:00
# endif
{
2019-11-09 10:12:08 +00:00
/* check the frame crtl field and decache */
ret = validate_recv_frame ( padapter , rframe ) ;
if ( ret ! = _SUCCESS ) {
rtw_free_recvframe ( rframe , pfree_recv_queue ) ; /* free this recv_frame */
goto exit ;
}
2017-05-11 18:47:23 +00:00
}
2015-08-18 19:03:09 +00:00
exit :
return ret ;
}
2019-11-09 10:12:08 +00:00
/*#define DBG_RX_BMC_FRAME*/
2015-08-18 19:03:09 +00:00
int recv_func_posthandle ( _adapter * padapter , union recv_frame * prframe )
{
int ret = _SUCCESS ;
union recv_frame * orig_prframe = prframe ;
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
_queue * pfree_recv_queue = & padapter - > recvpriv . free_recv_queue ;
# ifdef CONFIG_TDLS
u8 * psnap_type , * pcategory ;
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post ) ;
2015-08-18 19:03:09 +00:00
prframe = decryptor ( padapter , prframe ) ;
if ( prframe = = NULL ) {
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " decryptor: drop pkt \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
ret = _FAIL ;
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_decrypt_err ) ;
2015-08-18 19:03:09 +00:00
goto _recv_data_drop ;
}
2019-11-09 10:12:08 +00:00
# ifdef DBG_RX_BMC_FRAME
2021-08-23 12:01:00 +00:00
if ( is_multicast_ether_addr ( pattrib - > ra ) )
2019-11-09 10:12:08 +00:00
RTW_INFO ( " %s => " ADPT_FMT " Rx BC/MC from " MAC_FMT " \n " , __func__ , ADPT_ARG ( padapter ) , MAC_ARG ( pattrib - > ta ) ) ;
# endif
2015-08-18 19:03:09 +00:00
#if 0
2019-11-09 10:12:08 +00:00
if ( is_primary_adapter ( padapter ) ) {
RTW_INFO ( " +++ \n " ) ;
2015-08-18 19:03:09 +00:00
{
int i ;
u8 * ptr = get_recvframe_data ( prframe ) ;
2019-11-09 10:12:08 +00:00
for ( i = 0 ; i < 140 ; i = i + 8 )
RTW_INFO ( " %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X: " , * ( 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-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
RTW_INFO ( " --- \n " ) ;
2015-08-18 19:03:09 +00:00
}
# endif
# ifdef CONFIG_TDLS
2019-11-09 10:12:08 +00:00
/* check TDLS frame */
psnap_type = get_recvframe_data ( orig_prframe ) + pattrib - > hdrlen + pattrib - > iv_len + SNAP_SIZE ;
2015-08-18 19:03:09 +00:00
pcategory = psnap_type + ETH_TYPE_LEN + PAYLOAD_TYPE_LEN ;
2019-11-09 10:12:08 +00:00
if ( ( _rtw_memcmp ( psnap_type , SNAP_ETH_TYPE_TDLS , ETH_TYPE_LEN ) ) & &
2021-10-20 19:54:12 +00:00
( ( * pcategory = = WLAN_CATEGORY_TDLS ) | | ( * pcategory = = WLAN_CATEGORY_VENDOR_SPECIFIC ) ) ) {
2017-05-11 18:47:23 +00:00
ret = OnTDLS ( padapter , prframe ) ;
2019-11-09 10:12:08 +00:00
if ( ret = = _FAIL )
2015-08-18 19:03:09 +00:00
goto _exit_recv_func ;
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_TDLS */
2015-08-18 19:03:09 +00:00
prframe = recvframe_chk_defrag ( padapter , prframe ) ;
2019-11-09 10:12:08 +00:00
if ( prframe = = NULL ) {
2015-08-18 19:03:09 +00:00
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " recvframe_chk_defrag: drop pkt \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_defrag_err ) ;
2019-11-09 10:12:08 +00:00
goto _recv_data_drop ;
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
prframe = portctrl ( padapter , prframe ) ;
2015-08-18 19:03:09 +00:00
if ( prframe = = NULL ) {
# ifdef DBG_RX_DROP_FRAME
2019-11-09 10:12:08 +00:00
RTW_INFO ( " DBG_RX_DROP_FRAME " FUNC_ADPT_FMT " portctrl: drop pkt \n "
, FUNC_ADPT_ARG ( padapter ) ) ;
2015-08-18 19:03:09 +00:00
# endif
ret = _FAIL ;
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_post_portctrl_err ) ;
2015-08-18 19:03:09 +00:00
goto _recv_data_drop ;
}
count_rx_stats ( padapter , prframe , NULL ) ;
# ifdef CONFIG_WAPI_SUPPORT
rtw_wapi_update_info ( padapter , prframe ) ;
# endif
2019-11-09 10:12:08 +00:00
# if defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL)
/* including perform A-MPDU Rx Ordering Buffer Control */
ret = recv_indicatepkt_reorder ( padapter , prframe ) ;
if ( ret = = _FAIL ) {
rtw_free_recvframe ( orig_prframe , pfree_recv_queue ) ;
2015-08-18 19:03:09 +00:00
goto _recv_data_drop ;
2019-11-09 10:12:08 +00:00
} else if ( ret = = RTW_RX_HANDLED ) /* queued OR indicated in order */
goto _exit_recv_func ;
# endif
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
recv_set_iseq_before_mpdu_process ( prframe , pattrib - > seq_num , __func__ ) ;
ret = recv_process_mpdu ( padapter , prframe ) ;
recv_set_iseq_after_mpdu_process ( prframe , pattrib - > seq_num , __func__ ) ;
if ( ret = = _FAIL )
2015-08-18 19:03:09 +00:00
goto _recv_data_drop ;
_exit_recv_func :
return ret ;
_recv_data_drop :
2019-11-09 10:12:08 +00:00
precvpriv - > dbg_rx_drop_count + + ;
2015-08-18 19:03:09 +00:00
return ret ;
}
int recv_func ( _adapter * padapter , union recv_frame * rframe )
{
int ret ;
struct rx_pkt_attrib * prxattrib = & rframe - > u . hdr . attrib ;
struct recv_priv * recvpriv = & padapter - > recvpriv ;
2019-11-09 10:12:08 +00:00
struct security_priv * psecuritypriv = & padapter - > securitypriv ;
2015-08-18 19:03:09 +00:00
struct mlme_priv * mlmepriv = & padapter - > mlmepriv ;
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_CUSTOMER_ALIBABA_GENERAL
u8 type ;
u8 * ptr = rframe - > u . hdr . rx_data ;
# endif
2017-05-11 18:47:23 +00:00
if ( check_fwstate ( mlmepriv , WIFI_MONITOR_STATE ) ) {
/* monitor mode */
2019-11-09 10:12:08 +00:00
# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
2017-05-11 18:47:23 +00:00
recv_frame_monitor ( padapter , rframe ) ;
2019-11-09 10:12:08 +00:00
# endif
2017-05-11 18:47:23 +00:00
ret = _SUCCESS ;
goto exit ;
} else
2019-11-09 10:12:08 +00:00
{ }
# ifdef CONFIG_CUSTOMER_ALIBABA_GENERAL
type = GetFrameType ( ptr ) ;
2021-10-18 14:05:53 +00:00
if ( ( type = = IEEE80211_FTYPE_DATA ) & & check_fwstate ( mlmepriv , WIFI_STATION_STATE ) ) {
2019-11-09 10:12:08 +00:00
struct wlan_network * cur_network = & ( mlmepriv - > cur_network ) ;
if ( _rtw_memcmp ( get_addr2_ptr ( ptr ) , cur_network - > network . MacAddress , ETH_ALEN ) = = 0 ) {
recv_frame_monitor ( padapter , rframe ) ;
ret = _SUCCESS ;
goto exit ;
2015-08-18 19:03:09 +00:00
}
}
2019-11-09 10:12:08 +00:00
# endif
/* check if need to handle uc_swdec_pending_queue*/
if ( check_fwstate ( mlmepriv , WIFI_STATION_STATE ) & & psecuritypriv - > busetkipkey ) {
union recv_frame * pending_frame ;
int cnt = 0 ;
while ( ( pending_frame = rtw_alloc_recvframe ( & padapter - > recvpriv . uc_swdec_pending_queue ) ) ) {
cnt + + ;
DBG_COUNTER ( padapter - > rx_logs . core_rx_dequeue ) ;
recv_func_posthandle ( padapter , pending_frame ) ;
}
if ( cnt )
RTW_INFO ( FUNC_ADPT_FMT " dequeue %d from uc_swdec_pending_queue \n " ,
FUNC_ADPT_ARG ( padapter ) , cnt ) ;
}
2015-08-18 19:03:09 +00:00
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx ) ;
2015-08-18 19:03:09 +00:00
ret = recv_func_prehandle ( padapter , rframe ) ;
2019-11-09 10:12:08 +00:00
if ( ret = = _SUCCESS ) {
2015-08-18 19:03:09 +00:00
/* check if need to enqueue into uc_swdec_pending_queue*/
if ( check_fwstate ( mlmepriv , WIFI_STATION_STATE ) & &
2021-08-23 12:01:00 +00:00
! is_multicast_ether_addr ( prxattrib - > ra ) & & prxattrib - > encrypt > 0 & &
2019-11-09 10:12:08 +00:00
( prxattrib - > bdecrypted = = 0 | | psecuritypriv - > sw_decrypt = = _TRUE ) & &
psecuritypriv - > ndisauthtype = = Ndis802_11AuthModeWPAPSK & &
! psecuritypriv - > busetkipkey ) {
2017-05-11 18:35:20 +00:00
DBG_COUNTER ( padapter - > rx_logs . core_rx_enqueue ) ;
2015-08-18 19:03:09 +00:00
rtw_enqueue_recvframe ( rframe , & padapter - > recvpriv . uc_swdec_pending_queue ) ;
2019-11-09 10:12:08 +00:00
/* RTW_INFO("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( recvpriv - > free_recvframe_cnt < NR_RECVFRAME / 4 ) {
/* to prevent from recvframe starvation, get recvframe from uc_swdec_pending_queue to free_recvframe_cnt */
2015-08-18 19:03:09 +00:00
rframe = rtw_alloc_recvframe ( & padapter - > recvpriv . uc_swdec_pending_queue ) ;
if ( rframe )
goto do_posthandle ;
}
goto exit ;
}
do_posthandle :
ret = recv_func_posthandle ( padapter , rframe ) ;
}
exit :
return ret ;
}
s32 rtw_recv_entry ( union recv_frame * precvframe )
{
_adapter * padapter ;
struct recv_priv * precvpriv ;
2019-11-09 10:12:08 +00:00
s32 ret = _SUCCESS ;
2015-08-18 19:03:09 +00:00
padapter = precvframe - > u . hdr . adapter ;
precvpriv = & padapter - > recvpriv ;
2019-11-09 10:12:08 +00:00
ret = recv_func ( padapter , precvframe ) ;
if ( ret = = _FAIL ) {
2015-08-18 19:03:09 +00:00
goto _recv_entry_drop ;
}
precvpriv - > rx_pkts + + ;
return ret ;
_recv_entry_drop :
# ifdef CONFIG_MP_INCLUDED
if ( padapter - > registrypriv . mp_mode = = 1 )
padapter - > mppriv . rx_pktloss = precvpriv - > rx_drop ;
# endif
return ret ;
}
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
static void rtw_signal_stat_timer_hdl ( void * ctx )
{
_adapter * adapter = ( _adapter * ) ctx ;
2015-08-18 19:03:09 +00:00
struct recv_priv * recvpriv = & adapter - > recvpriv ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
u32 tmp_s , tmp_q ;
u8 avg_signal_strength = 0 ;
u8 avg_signal_qual = 0 ;
u32 num_signal_strength = 0 ;
u32 num_signal_qual = 0 ;
2017-05-11 18:47:23 +00:00
u8 ratio_pre_stat = 0 , ratio_curr_stat = 0 , ratio_total = 0 , ratio_profile = SIGNAL_STAT_CALC_PROFILE_0 ;
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
if ( adapter - > recvpriv . is_signal_dbg ) {
/* update the user specific value, signal_strength_dbg, to signal_strength, rssi */
adapter - > recvpriv . signal_strength = adapter - > recvpriv . signal_strength_dbg ;
adapter - > recvpriv . rssi = ( s8 ) translate_percentage_to_dbm ( ( u8 ) adapter - > recvpriv . signal_strength_dbg ) ;
2015-08-18 19:03:09 +00:00
} else {
2019-11-09 10:12:08 +00:00
if ( recvpriv - > signal_strength_data . update_req = = 0 ) { /* update_req is clear, means we got rx */
2015-08-18 19:03:09 +00:00
avg_signal_strength = recvpriv - > signal_strength_data . avg_val ;
num_signal_strength = recvpriv - > signal_strength_data . total_num ;
2019-11-09 10:12:08 +00:00
/* after avg_vals are accquired, we can re-stat the signal values */
2015-08-18 19:03:09 +00:00
recvpriv - > signal_strength_data . update_req = 1 ;
}
2019-11-09 10:12:08 +00:00
if ( recvpriv - > signal_qual_data . update_req = = 0 ) { /* update_req is clear, means we got rx */
2015-08-18 19:03:09 +00:00
avg_signal_qual = recvpriv - > signal_qual_data . avg_val ;
num_signal_qual = recvpriv - > signal_qual_data . total_num ;
2019-11-09 10:12:08 +00:00
/* after avg_vals are accquired, we can re-stat the signal values */
2015-08-18 19:03:09 +00:00
recvpriv - > signal_qual_data . update_req = 1 ;
}
if ( num_signal_strength = = 0 ) {
if ( rtw_get_on_cur_ch_time ( adapter ) = = 0
2019-11-09 10:12:08 +00:00
| | rtw_get_passing_time_ms ( rtw_get_on_cur_ch_time ( adapter ) ) < 2 * adapter - > mlmeextpriv . mlmext_info . bcn_interval
)
2015-08-18 19:03:09 +00:00
goto set_timer ;
}
2019-11-09 10:12:08 +00:00
if ( check_fwstate ( & adapter - > mlmepriv , _FW_UNDER_SURVEY ) = = _TRUE
| | check_fwstate ( & adapter - > mlmepriv , _FW_LINKED ) = = _FALSE
)
2015-08-18 19:03:09 +00:00
goto set_timer ;
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_CONCURRENT_MODE
if ( rtw_mi_buddy_check_fwstate ( adapter , _FW_UNDER_SURVEY ) = = _TRUE )
2015-08-18 19:03:09 +00:00
goto set_timer ;
2019-11-09 10:12:08 +00:00
# endif
2015-08-18 19:03:09 +00:00
2017-05-11 18:47:23 +00:00
if ( RTW_SIGNAL_STATE_CALC_PROFILE < SIGNAL_STAT_CALC_PROFILE_MAX )
ratio_profile = RTW_SIGNAL_STATE_CALC_PROFILE ;
ratio_pre_stat = signal_stat_calc_profile [ ratio_profile ] [ 0 ] ;
ratio_curr_stat = signal_stat_calc_profile [ ratio_profile ] [ 1 ] ;
ratio_total = ratio_pre_stat + ratio_curr_stat ;
2019-11-09 10:12:08 +00:00
/* update value of signal_strength, rssi, signal_qual */
2017-05-11 18:47:23 +00:00
tmp_s = ( ratio_curr_stat * avg_signal_strength + ratio_pre_stat * recvpriv - > signal_strength ) ;
if ( tmp_s % ratio_total )
tmp_s = tmp_s / ratio_total + 1 ;
2015-08-18 19:03:09 +00:00
else
2017-05-11 18:47:23 +00:00
tmp_s = tmp_s / ratio_total ;
if ( tmp_s > 100 )
2015-08-18 19:03:09 +00:00
tmp_s = 100 ;
2017-05-11 18:47:23 +00:00
tmp_q = ( ratio_curr_stat * avg_signal_qual + ratio_pre_stat * recvpriv - > signal_qual ) ;
if ( tmp_q % ratio_total )
tmp_q = tmp_q / ratio_total + 1 ;
2015-08-18 19:03:09 +00:00
else
2017-05-11 18:47:23 +00:00
tmp_q = tmp_q / ratio_total ;
if ( tmp_q > 100 )
2015-08-18 19:03:09 +00:00
tmp_q = 100 ;
recvpriv - > signal_strength = tmp_s ;
recvpriv - > rssi = ( s8 ) translate_percentage_to_dbm ( tmp_s ) ;
recvpriv - > signal_qual = tmp_q ;
2019-11-09 10:12:08 +00:00
# if defined(DBG_RX_SIGNAL_DISPLAY_PROCESSING) && 1
RTW_INFO ( 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
2015-08-18 19:03:09 +00:00
, rtw_get_on_cur_ch_time ( adapter ) ? rtw_get_passing_time_ms ( rtw_get_on_cur_ch_time ( adapter ) ) : 0
2019-11-09 10:12:08 +00:00
) ;
# endif
2015-08-18 19:03:09 +00:00
}
set_timer :
rtw_set_signal_stat_timer ( recvpriv ) ;
2019-11-09 10:12:08 +00:00
2015-08-18 19:03:09 +00:00
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
static void rx_process_rssi ( _adapter * padapter , union recv_frame * prframe )
2017-05-11 18:47:23 +00:00
{
struct rx_pkt_attrib * pattrib = & prframe - > u . hdr . attrib ;
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
struct signal_stat * signal_stat = & padapter - > recvpriv . signal_strength_data ;
# else /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
u32 last_rssi , tmp_val ;
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* RTW_INFO("process_rssi=> pattrib->rssil(%d) signal_strength(%d)\n ",pattrib->recv_signal_power,pattrib->signal_strength); */
/* if(pRfd->Status.bPacketToSelf || pRfd->Status.bPacketBeacon) */
2017-05-11 18:47:23 +00:00
{
2019-11-09 10:12:08 +00:00
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
if ( signal_stat - > update_req ) {
2017-05-11 18:47:23 +00:00
signal_stat - > total_num = 0 ;
signal_stat - > total_val = 0 ;
signal_stat - > update_req = 0 ;
}
signal_stat - > total_num + + ;
2019-11-09 10:12:08 +00:00
signal_stat - > total_val + = pattrib - > phy_info . signal_strength ;
signal_stat - > avg_val = signal_stat - > total_val / signal_stat - > total_num ;
# else /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
/* Adapter->RxStats.RssiCalculateCnt++; */ /* For antenna Test */
if ( padapter - > recvpriv . signal_strength_data . total_num + + > = PHY_RSSI_SLID_WIN_MAX ) {
2017-05-11 18:47:23 +00:00
padapter - > recvpriv . signal_strength_data . total_num = PHY_RSSI_SLID_WIN_MAX ;
last_rssi = padapter - > recvpriv . signal_strength_data . elements [ padapter - > recvpriv . signal_strength_data . index ] ;
padapter - > recvpriv . signal_strength_data . total_val - = last_rssi ;
}
2019-11-09 10:12:08 +00:00
padapter - > recvpriv . signal_strength_data . total_val + = pattrib - > phy_info . signal_strength ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
padapter - > recvpriv . signal_strength_data . elements [ padapter - > recvpriv . signal_strength_data . index + + ] = pattrib - > phy_info . signal_strength ;
if ( padapter - > recvpriv . signal_strength_data . index > = PHY_RSSI_SLID_WIN_MAX )
2017-05-11 18:47:23 +00:00
padapter - > recvpriv . signal_strength_data . index = 0 ;
2019-11-09 10:12:08 +00:00
tmp_val = padapter - > recvpriv . signal_strength_data . total_val / padapter - > recvpriv . signal_strength_data . total_num ;
if ( padapter - > recvpriv . is_signal_dbg ) {
padapter - > recvpriv . signal_strength = padapter - > recvpriv . signal_strength_dbg ;
padapter - > recvpriv . rssi = ( s8 ) translate_percentage_to_dbm ( padapter - > recvpriv . signal_strength_dbg ) ;
2017-05-11 18:47:23 +00:00
} else {
2019-11-09 10:12:08 +00:00
padapter - > recvpriv . signal_strength = tmp_val ;
padapter - > recvpriv . rssi = ( s8 ) translate_percentage_to_dbm ( tmp_val ) ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2017-05-11 18:47:23 +00:00
}
}
2019-11-09 10:12:08 +00:00
static void rx_process_link_qual ( _adapter * padapter , union recv_frame * prframe )
2017-05-11 18:47:23 +00:00
{
2019-11-09 10:12:08 +00:00
struct rx_pkt_attrib * pattrib ;
2017-05-11 18:47:23 +00:00
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
struct signal_stat * signal_stat ;
# else /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
u32 last_evm = 0 , tmpVal ;
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
if ( prframe = = NULL | | padapter = = NULL )
2017-05-11 18:47:23 +00:00
return ;
pattrib = & prframe - > u . hdr . attrib ;
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
signal_stat = & padapter - > recvpriv . signal_qual_data ;
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2015-08-18 19:03:09 +00:00
2019-11-09 10:12:08 +00:00
/* RTW_INFO("process_link_qual=> pattrib->signal_qual(%d)\n ",pattrib->signal_qual); */
2017-05-11 18:47:23 +00:00
# ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
2019-11-09 10:12:08 +00:00
if ( signal_stat - > update_req ) {
2017-05-11 18:47:23 +00:00
signal_stat - > total_num = 0 ;
signal_stat - > total_val = 0 ;
signal_stat - > update_req = 0 ;
}
signal_stat - > total_num + + ;
2019-11-09 10:12:08 +00:00
signal_stat - > total_val + = pattrib - > phy_info . signal_quality ;
2017-05-11 18:47:23 +00:00
signal_stat - > avg_val = signal_stat - > total_val / signal_stat - > total_num ;
2019-11-09 10:12:08 +00:00
# else /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
if ( pattrib - > phy_info . signal_quality ! = 0 ) {
/* */
/* 1. Record the general EVM to the sliding window. */
/* */
if ( padapter - > recvpriv . signal_qual_data . total_num + + > = PHY_LINKQUALITY_SLID_WIN_MAX ) {
padapter - > recvpriv . signal_qual_data . total_num = PHY_LINKQUALITY_SLID_WIN_MAX ;
last_evm = padapter - > recvpriv . signal_qual_data . elements [ padapter - > recvpriv . signal_qual_data . index ] ;
padapter - > recvpriv . signal_qual_data . total_val - = last_evm ;
}
padapter - > recvpriv . signal_qual_data . total_val + = pattrib - > phy_info . signal_quality ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
padapter - > recvpriv . signal_qual_data . elements [ padapter - > recvpriv . signal_qual_data . index + + ] = pattrib - > phy_info . signal_quality ;
if ( padapter - > recvpriv . signal_qual_data . index > = PHY_LINKQUALITY_SLID_WIN_MAX )
padapter - > recvpriv . signal_qual_data . index = 0 ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
/* <1> Showed on UI for user, in percentage. */
tmpVal = padapter - > recvpriv . signal_qual_data . total_val / padapter - > recvpriv . signal_qual_data . total_num ;
padapter - > recvpriv . signal_qual = ( u8 ) tmpVal ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
# endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
2017-05-11 18:47:23 +00:00
}
void rx_process_phy_info ( _adapter * padapter , union recv_frame * rframe )
{
/* Check RSSI */
rx_process_rssi ( padapter , rframe ) ;
/* Check PWDB */
2019-11-09 10:12:08 +00:00
/* process_PWDB(padapter, rframe); */
/* UpdateRxSignalStatistics8192C(Adapter, pRfd); */
2017-05-11 18:47:23 +00:00
/* Check EVM */
rx_process_link_qual ( padapter , rframe ) ;
2019-11-09 10:12:08 +00:00
rtw_store_phy_info ( padapter , rframe ) ;
2017-05-11 18:47:23 +00:00
}
void rx_query_phy_status (
union recv_frame * precvframe ,
u8 * pphy_status )
{
2019-11-09 10:12:08 +00:00
PADAPTER padapter = precvframe - > u . hdr . adapter ;
2017-05-11 18:47:23 +00:00
struct rx_pkt_attrib * pattrib = & precvframe - > u . hdr . attrib ;
2019-11-09 10:12:08 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
struct phydm_phyinfo_struct * p_phy_info = & pattrib - > phy_info ;
2017-05-11 18:47:23 +00:00
u8 * wlanhdr ;
2019-11-09 10:12:08 +00:00
struct phydm_perpkt_info_struct pkt_info ;
u8 * ta , * ra ;
u8 is_ra_bmc ;
2017-05-11 18:47:23 +00:00
struct sta_priv * pstapriv ;
struct sta_info * psta = NULL ;
2019-11-09 10:12:08 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
/* _irqL irqL; */
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
pkt_info . is_packet_match_bssid = _FALSE ;
pkt_info . is_packet_to_self = _FALSE ;
pkt_info . is_packet_beacon = _FALSE ;
pkt_info . ppdu_cnt = pattrib - > ppdu_cnt ;
pkt_info . station_id = 0xFF ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
wlanhdr = get_recvframe_data ( precvframe ) ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
ta = get_ta ( wlanhdr ) ;
ra = get_ra ( wlanhdr ) ;
2021-08-23 12:01:00 +00:00
is_ra_bmc = is_multicast_ether_addr ( ra ) ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
if ( _rtw_memcmp ( adapter_mac_addr ( padapter ) , ta , ETH_ALEN ) = = _TRUE ) {
static systime start_time = 0 ;
2017-05-11 18:47:23 +00:00
#if 0 /*For debug */
if ( IsFrameTypeCtrl ( wlanhdr ) ) {
2019-11-09 10:12:08 +00:00
RTW_INFO ( " -->Control frame: Y \n " ) ;
RTW_INFO ( " -->pkt_len: %d \n " , pattrib - > pkt_len ) ;
RTW_INFO ( " -->Sub Type = 0x%X \n " , get_frame_sub_type ( wlanhdr ) ) ;
2017-05-11 18:47:23 +00:00
}
/* Dump first 40 bytes of header */
int i = 0 ;
for ( i = 0 ; i < 40 ; i + + )
2019-11-09 10:12:08 +00:00
RTW_INFO ( " %d: %X \n " , i , * ( ( u8 * ) wlanhdr + i ) ) ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
RTW_INFO ( " \n " ) ;
2017-05-11 18:47:23 +00:00
# endif
if ( ( start_time = = 0 ) | | ( rtw_get_passing_time_ms ( start_time ) > 5000 ) ) {
2019-11-09 10:12:08 +00:00
RTW_PRINT ( " Warning!!! %s: Confilc mac addr!! \n " , __func__ ) ;
2021-10-14 19:34:26 +00:00
start_time = jiffies ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
precvpriv - > dbg_rx_conflic_mac_addr_cnt + + ;
} else {
2017-05-11 18:47:23 +00:00
pstapriv = & padapter - > stapriv ;
2019-11-09 10:12:08 +00:00
psta = rtw_get_stainfo ( pstapriv , ta ) ;
2017-05-11 18:47:23 +00:00
if ( psta )
2019-11-09 10:12:08 +00:00
pkt_info . station_id = psta - > cmn . mac_id ;
}
pkt_info . is_packet_match_bssid = ( ! IsFrameTypeCtrl ( wlanhdr ) )
& & ( ! pattrib - > icv_err ) & & ( ! pattrib - > crc_err )
& & ( ( ! MLME_IS_MESH ( padapter ) & & _rtw_memcmp ( get_hdr_bssid ( wlanhdr ) , get_bssid ( & padapter - > mlmepriv ) , ETH_ALEN ) )
| | ( MLME_IS_MESH ( padapter ) & & psta ) ) ;
pkt_info . is_to_self = ( ! pattrib - > icv_err ) & & ( ! pattrib - > crc_err )
& & _rtw_memcmp ( ra , adapter_mac_addr ( padapter ) , ETH_ALEN ) ;
pkt_info . is_packet_to_self = pkt_info . is_packet_match_bssid
& & _rtw_memcmp ( ra , adapter_mac_addr ( padapter ) , ETH_ALEN ) ;
pkt_info . is_packet_beacon = pkt_info . is_packet_match_bssid
2021-10-18 14:05:53 +00:00
& & ( get_frame_sub_type ( wlanhdr ) = = IEEE80211_STYPE_BEACON ) ;
2019-11-09 10:12:08 +00:00
if ( psta & & IsFrameTypeData ( wlanhdr ) ) {
if ( is_ra_bmc )
psta - > curr_rx_rate_bmc = pattrib - > data_rate ;
else
psta - > curr_rx_rate = pattrib - > data_rate ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
pkt_info . data_rate = pattrib - > data_rate ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
odm_phy_status_query ( & pHalData - > odmpriv , p_phy_info , pphy_status , & pkt_info ) ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
/* If bw is initial value, get from phy status */
if ( pattrib - > bw = = CHANNEL_WIDTH_MAX )
pattrib - > bw = p_phy_info - > band_width ;
2017-05-11 18:47:23 +00:00
{
precvframe - > u . hdr . psta = NULL ;
2019-11-09 10:12:08 +00:00
if ( padapter - > registrypriv . mp_mode ! = 1 ) {
if ( ( ! MLME_IS_MESH ( padapter ) & & pkt_info . is_packet_match_bssid )
| | ( MLME_IS_MESH ( padapter ) & & psta ) ) {
if ( psta ) {
precvframe - > u . hdr . psta = psta ;
rx_process_phy_info ( padapter , precvframe ) ;
}
} else if ( pkt_info . is_packet_to_self | | pkt_info . is_packet_beacon ) {
if ( psta )
precvframe - > u . hdr . psta = psta ;
2017-05-11 18:47:23 +00:00
rx_process_phy_info ( padapter , precvframe ) ;
}
2019-11-09 10:12:08 +00:00
} else {
# ifdef CONFIG_MP_INCLUDED
if ( padapter - > mppriv . brx_filter_beacon = = _TRUE ) {
if ( pkt_info . is_packet_beacon ) {
RTW_INFO ( " in MP Rx is_packet_beacon \n " ) ;
if ( psta )
precvframe - > u . hdr . psta = psta ;
rx_process_phy_info ( padapter , precvframe ) ;
}
} else
# endif
{
if ( psta )
precvframe - > u . hdr . psta = psta ;
rx_process_phy_info ( padapter , precvframe ) ;
}
2017-05-11 18:47:23 +00:00
}
}
2019-11-09 10:12:08 +00:00
rtw_odm_parse_rx_phy_status_chinfo ( precvframe , pphy_status ) ;
2017-05-11 18:47:23 +00:00
}
/*
* Increase and check if the continual_no_rx_packet of this @ param pmlmepriv is larger than MAX_CONTINUAL_NORXPACKET_COUNT
* @ return _TRUE :
* @ return _FALSE :
*/
int rtw_inc_and_chk_continual_no_rx_packet ( struct sta_info * sta , int tid_index )
{
2019-11-09 10:12:08 +00:00
2017-05-11 18:47:23 +00:00
int ret = _FALSE ;
2021-08-02 19:27:18 +00:00
int value = atomic_inc_return ( & sta - > continual_no_rx_packet [ tid_index ] ) ;
2017-05-11 18:47:23 +00:00
2019-11-09 10:12:08 +00:00
if ( value > = MAX_CONTINUAL_NORXPACKET_COUNT )
2017-05-11 18:47:23 +00:00
ret = _TRUE ;
2019-11-09 10:12:08 +00:00
2017-05-11 18:47:23 +00:00
return ret ;
}
/*
* Set the continual_no_rx_packet of this @ param pmlmepriv to 0
*/
void rtw_reset_continual_no_rx_packet ( struct sta_info * sta , int tid_index )
2019-11-09 10:12:08 +00:00
{
2021-08-02 19:27:18 +00:00
atomic_set ( & sta - > continual_no_rx_packet [ tid_index ] , 0 ) ;
2017-05-11 18:47:23 +00:00
}
2019-11-09 10:12:08 +00:00
u8 adapter_allow_bmc_data_rx ( _adapter * adapter )
{
if ( check_fwstate ( & adapter - > mlmepriv , WIFI_MONITOR_STATE | WIFI_MP_STATE ) = = _TRUE )
return 1 ;
if ( MLME_IS_AP ( adapter ) )
return 0 ;
if ( rtw_linked_check ( adapter ) = = _FALSE )
return 0 ;
return 1 ;
}
s32 pre_recv_entry ( union recv_frame * precvframe , u8 * pphy_status )
{
s32 ret = _SUCCESS ;
u8 * pbuf = precvframe - > u . hdr . rx_data ;
u8 * pda = get_ra ( pbuf ) ;
2021-08-23 12:01:00 +00:00
u8 ra_is_bmc = is_multicast_ether_addr ( pda ) ;
2019-11-09 10:12:08 +00:00
_adapter * primary_padapter = precvframe - > u . hdr . adapter ;
# ifdef CONFIG_CONCURRENT_MODE
_adapter * iface = NULL ;
# ifdef CONFIG_MP_INCLUDED
if ( rtw_mp_mode_check ( primary_padapter ) )
goto bypass_concurrent_hdl ;
# endif
if ( ra_is_bmc = = _FALSE ) { /*unicast packets*/
iface = rtw_get_iface_by_macddr ( primary_padapter , pda ) ;
if ( NULL = = iface ) {
# ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI
if ( _rtw_memcmp ( pda , adapter_pno_mac_addr ( primary_padapter ) ,
ETH_ALEN ) ! = _TRUE )
# endif
RTW_INFO ( " %s [WARN] Cannot find appropriate adapter - mac_addr : " MAC_FMT " \n " , __func__ , MAC_ARG ( pda ) ) ;
/*rtw_warn_on(1);*/
} else
precvframe - > u . hdr . adapter = iface ;
} else /* Handle BC/MC Packets */
rtw_mi_buddy_clone_bcmc_packet ( primary_padapter , precvframe , pphy_status ) ;
bypass_concurrent_hdl :
# endif /* CONFIG_CONCURRENT_MODE */
if ( primary_padapter - > registrypriv . mp_mode ! = 1 ) {
/* skip unnecessary bmc data frame for primary adapter */
2021-10-18 14:05:53 +00:00
if ( ra_is_bmc = = _TRUE & & GetFrameType ( pbuf ) = = IEEE80211_FTYPE_DATA
2019-11-09 10:12:08 +00:00
& & ! adapter_allow_bmc_data_rx ( precvframe - > u . hdr . adapter )
) {
rtw_free_recvframe ( precvframe , & precvframe - > u . hdr . adapter - > recvpriv . free_recv_queue ) ;
goto exit ;
}
}
if ( pphy_status )
rx_query_phy_status ( precvframe , pphy_status ) ;
ret = rtw_recv_entry ( precvframe ) ;
exit :
return ret ;
}
# ifdef CONFIG_RECV_THREAD_MODE
thread_return rtw_recv_thread ( thread_context context )
{
_adapter * adapter = ( _adapter * ) context ;
struct recv_priv * recvpriv = & adapter - > recvpriv ;
s32 err = _SUCCESS ;
# ifdef RTW_RECV_THREAD_HIGH_PRIORITY
# ifdef PLATFORM_LINUX
struct sched_param param = { . sched_priority = 1 } ;
sched_setscheduler ( current , SCHED_FIFO , & param ) ;
# endif /* PLATFORM_LINUX */
# endif /*RTW_RECV_THREAD_HIGH_PRIORITY*/
thread_enter ( " RTW_RECV_THREAD " ) ;
RTW_INFO ( FUNC_ADPT_FMT " enter \n " , FUNC_ADPT_ARG ( adapter ) ) ;
do {
err = _rtw_down_sema ( & recvpriv - > recv_sema ) ;
if ( _FAIL = = err ) {
RTW_ERR ( FUNC_ADPT_FMT " down recv_sema fail! \n " , FUNC_ADPT_ARG ( adapter ) ) ;
goto exit ;
}
if ( RTW_CANNOT_RUN ( adapter ) ) {
RTW_DBG ( FUNC_ADPT_FMT " - bDriverStopped(%s) bSurpriseRemoved(%s) \n " ,
FUNC_ADPT_ARG ( adapter ) ,
rtw_is_drv_stopped ( adapter ) ? " True " : " False " ,
rtw_is_surprise_removed ( adapter ) ? " True " : " False " ) ;
goto exit ;
}
err = rtw_hal_recv_hdl ( adapter ) ;
if ( err = = RTW_RFRAME_UNAVAIL
| | err = = RTW_RFRAME_PKT_UNAVAIL
) {
2021-08-05 19:26:40 +00:00
msleep ( 1 ) ;
2019-11-09 10:12:08 +00:00
_rtw_up_sema ( & recvpriv - > recv_sema ) ;
}
flush_signals_thread ( ) ;
} while ( err ! = _FAIL ) ;
exit :
RTW_INFO ( FUNC_ADPT_FMT " Exit \n " , FUNC_ADPT_ARG ( adapter ) ) ;
rtw_thread_wait_stop ( ) ;
return 0 ;
}
# endif /* CONFIG_RECV_THREAD_MODE */
# if DBG_RX_BH_TRACKING
void rx_bh_tk_set_stage ( struct recv_priv * recv , u32 s )
{
recv - > rx_bh_stage = s ;
}
void rx_bh_tk_set_buf ( struct recv_priv * recv , void * buf , void * data , u32 dlen )
{
if ( recv - > rx_bh_cbuf )
recv - > rx_bh_lbuf = recv - > rx_bh_cbuf ;
recv - > rx_bh_cbuf = buf ;
if ( buf ) {
recv - > rx_bh_cbuf_data = data ;
recv - > rx_bh_cbuf_dlen = dlen ;
recv - > rx_bh_buf_dq_cnt + + ;
} else {
recv - > rx_bh_cbuf_data = NULL ;
recv - > rx_bh_cbuf_dlen = 0 ;
}
}
void rx_bh_tk_set_buf_pos ( struct recv_priv * recv , void * pos )
{
if ( recv - > rx_bh_cbuf ) {
recv - > rx_bh_cbuf_pos = pos - recv - > rx_bh_cbuf_data ;
} else {
rtw_warn_on ( 1 ) ;
recv - > rx_bh_cbuf_pos = 0 ;
}
}
void rx_bh_tk_set_frame ( struct recv_priv * recv , void * frame )
{
recv - > rx_bh_cframe = frame ;
}
void dump_rx_bh_tk ( void * sel , struct recv_priv * recv )
{
RTW_PRINT_SEL ( sel , " [RXBHTK]s:%u, buf_dqc:%u, lbuf:%p, cbuf:%p, dlen:%u, pos:%u, cframe:%p \n "
, recv - > rx_bh_stage
, recv - > rx_bh_buf_dq_cnt
, recv - > rx_bh_lbuf
, recv - > rx_bh_cbuf
, recv - > rx_bh_cbuf_dlen
, recv - > rx_bh_cbuf_pos
, recv - > rx_bh_cframe
) ;
}
# endif /* DBG_RX_BH_TRACKING */