2013-05-08 21:45:39 +00:00
/******************************************************************************
*
* Copyright ( c ) 2007 - 2011 Realtek Corporation . All rights reserved .
2014-12-19 06:59:46 +00:00
*
2013-05-08 21:45:39 +00:00
* This program is free software ; you can redistribute it and / or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License for
* more details .
*
* You should have received a copy of the GNU General Public License along with
* this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 , USA
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define _HCI_OPS_OS_C_
2014-12-17 04:09:56 +00:00
# include <drv_conf.h>
2013-05-08 21:45:39 +00:00
# include <osdep_service.h>
# include <drv_types.h>
# include <osdep_intf.h>
# include <usb_ops.h>
2014-12-17 04:09:56 +00:00
# include <circ_buf.h>
2013-05-08 21:45:39 +00:00
# include <recv_osdep.h>
# include <rtl8188e_hal.h>
static int usbctrl_vendorreq ( struct intf_hdl * pintfhdl , u8 request , u16 value , u16 index , void * pdata , u16 len , u8 requesttype )
{
2014-12-17 23:13:53 +00:00
struct adapter * padapter = pintfhdl - > padapter ;
2014-12-17 04:09:56 +00:00
struct dvobj_priv * pdvobjpriv = adapter_to_dvobj ( padapter ) ;
struct usb_device * udev = pdvobjpriv - > pusbdev ;
2013-05-08 21:45:39 +00:00
unsigned int pipe ;
int status = 0 ;
2014-12-17 04:09:56 +00:00
u32 tmp_buflen = 0 ;
2013-05-08 21:45:39 +00:00
u8 reqtype ;
u8 * pIo_buf ;
int vendorreq_times = 0 ;
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_VENDOR_REQ_BUFFER_DYNAMIC_ALLOCATE
u8 * tmp_buf ;
# else // use stack memory
u8 tmp_buf [ MAX_USB_IO_CTL_SIZE ] ;
# endif
# ifdef CONFIG_CONCURRENT_MODE
if ( padapter - > adapter_type > PRIMARY_ADAPTER )
{
padapter = padapter - > pbuddy_adapter ;
pdvobjpriv = adapter_to_dvobj ( padapter ) ;
udev = pdvobjpriv - > pusbdev ;
2013-05-19 04:28:07 +00:00
}
2014-12-17 04:09:56 +00:00
# endif
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
//DBG_871X("%s %s:%d\n",__FUNCTION__, current->comm, current->pid);
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
if ( ( padapter - > bSurpriseRemoved ) | | ( dvobj_to_pwrctl ( pdvobjpriv ) - > pnp_bstop_trx ) ) {
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usbctrl_vendorreq:(padapter->bSurpriseRemoved ||pwrctl->pnp_bstop_trx)!!! \n " ) ) ;
2014-12-19 06:59:46 +00:00
status = - EPERM ;
2014-12-17 04:09:56 +00:00
goto exit ;
2014-12-19 06:59:46 +00:00
}
2013-05-19 04:28:07 +00:00
2014-12-17 04:09:56 +00:00
if ( len > MAX_VENDOR_REQ_CMD_SIZE ) {
DBG_8192C ( " [%s] Buffer len error ,vendor request failed \n " , __FUNCTION__ ) ;
status = - EINVAL ;
goto exit ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_VENDOR_REQ_MUTEX
_enter_critical_mutex ( & pdvobjpriv - > usb_vendor_req_mutex , NULL ) ;
# endif
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
// Acquire IO memory for vendorreq
# ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
pIo_buf = pdvobjpriv - > usb_vendor_req_buf ;
# else
# ifdef CONFIG_USB_VENDOR_REQ_BUFFER_DYNAMIC_ALLOCATE
tmp_buf = rtw_malloc ( ( u32 ) len + ALIGNMENT_UNIT ) ;
tmp_buflen = ( u32 ) len + ALIGNMENT_UNIT ;
# else // use stack memory
tmp_buflen = MAX_USB_IO_CTL_SIZE ;
# endif
// Added by Albert 2010/02/09
// For mstar platform, mstar suggests the address for USB IO should be 16 bytes alignment.
// Trying to fix it here.
2014-12-19 06:59:46 +00:00
pIo_buf = ( tmp_buf = = NULL ) ? NULL : tmp_buf + ALIGNMENT_UNIT - ( ( SIZE_PTR ) ( tmp_buf ) & 0x0f ) ;
2014-12-17 04:09:56 +00:00
# endif
if ( pIo_buf = = NULL ) {
DBG_8192C ( " [%s] pIo_buf == NULL \n " , __FUNCTION__ ) ;
2013-05-08 21:45:39 +00:00
status = - ENOMEM ;
goto release_mutex ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
while ( + + vendorreq_times < = MAX_USBCTRL_VENDORREQ_TIMES )
{
2013-05-08 21:45:39 +00:00
_rtw_memset ( pIo_buf , 0 , len ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( requesttype = = 0x01 )
{
pipe = usb_rcvctrlpipe ( udev , 0 ) ; //read_in
2014-12-19 06:59:46 +00:00
reqtype = REALTEK_USB_VENQT_READ ;
}
else
2014-12-17 04:09:56 +00:00
{
pipe = usb_sndctrlpipe ( udev , 0 ) ; //write_out
2014-12-19 06:59:46 +00:00
reqtype = REALTEK_USB_VENQT_WRITE ;
2014-12-17 04:09:56 +00:00
_rtw_memcpy ( pIo_buf , pdata , len ) ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
status = rtw_usb_control_msg ( udev , pipe , request , reqtype , value , index , pIo_buf , len , RTW_USB_CONTROL_MSG_TIMEOUT ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( status = = len ) // Success this control transfer.
{
rtw_reset_continual_io_error ( pdvobjpriv ) ;
if ( requesttype = = 0x01 )
{ // For Control read transfer, we have to copy the read data from pIo_buf to pdata.
_rtw_memcpy ( pdata , pIo_buf , len ) ;
}
}
else { // error cases
DBG_8192C ( " reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d \n "
, value , ( requesttype = = 0x01 ) ? " read " : " write " , len , status , * ( u32 * ) pdata , vendorreq_times ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
if ( status < 0 ) {
2014-12-17 04:09:56 +00:00
if ( status = = ( - ESHUTDOWN ) | | status = = - ENODEV )
2014-12-19 06:59:46 +00:00
{
2014-12-29 02:13:24 +00:00
padapter - > bSurpriseRemoved = true ;
2013-05-08 21:45:39 +00:00
} else {
2014-12-17 04:09:56 +00:00
# ifdef DBG_CONFIG_ERROR_DETECT
{
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
pHalData - > srestpriv . Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL ;
}
# endif
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
}
else // status != len && status >= 0
{
if ( status > 0 ) {
if ( requesttype = = 0x01 )
{ // For Control read transfer, we have to copy the read data from pIo_buf to pdata.
_rtw_memcpy ( pdata , pIo_buf , len ) ;
2013-05-08 21:45:39 +00:00
}
}
}
2014-12-29 02:13:24 +00:00
if ( rtw_inc_and_chk_continual_io_error ( pdvobjpriv ) = = true ) {
padapter - > bSurpriseRemoved = true ;
2013-05-08 21:45:39 +00:00
break ;
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
// firmware download is checksumed, don't retry
if ( ( value > = FW_8188E_START_ADDRESS & & value < = FW_8188E_END_ADDRESS ) | | status = = len )
2013-05-08 21:45:39 +00:00
break ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
// release IO memory used by vendorreq
# ifdef CONFIG_USB_VENDOR_REQ_BUFFER_DYNAMIC_ALLOCATE
rtw_mfree ( tmp_buf , tmp_buflen ) ;
# endif
2013-05-08 21:45:39 +00:00
release_mutex :
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_VENDOR_REQ_MUTEX
_exit_critical_mutex ( & pdvobjpriv - > usb_vendor_req_mutex , NULL ) ;
# endif
2013-05-08 21:45:39 +00:00
exit :
return status ;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
}
static u8 usb_read8 ( struct intf_hdl * pintfhdl , u32 addr )
{
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2015-01-28 17:28:01 +00:00
u8 data ;
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x01 ; //read_in
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
2014-12-19 06:59:46 +00:00
len = 1 ;
2013-05-08 21:45:39 +00:00
usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
return data ;
}
static u16 usb_read16 ( struct intf_hdl * pintfhdl , u32 addr )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2015-01-28 17:28:01 +00:00
__le32 data ;
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x01 ; //read_in
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
2014-12-19 06:59:46 +00:00
len = 2 ;
2013-05-08 21:45:39 +00:00
usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
2015-01-28 17:28:01 +00:00
return le16_to_cpu ( data ) & 0xffff ;
2013-05-08 21:45:39 +00:00
}
static u32 usb_read32 ( struct intf_hdl * pintfhdl , u32 addr )
{
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2015-01-28 17:28:01 +00:00
__le32 data ;
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x01 ; //read_in
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
2014-12-19 06:59:46 +00:00
len = 4 ;
2013-05-08 21:45:39 +00:00
usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
2015-01-28 17:28:01 +00:00
return le32_to_cpu ( data ) ;
2013-05-08 21:45:39 +00:00
}
static int usb_write8 ( struct intf_hdl * pintfhdl , u32 addr , u8 val )
{
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
u8 data ;
int ret ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x00 ; //write_out
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
len = 1 ;
2014-12-19 06:59:46 +00:00
data = val ;
2014-12-17 04:09:56 +00:00
ret = usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
static int usb_write16 ( struct intf_hdl * pintfhdl , u32 addr , u16 val )
2014-12-19 06:59:46 +00:00
{
2013-05-08 21:45:39 +00:00
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2015-01-28 17:28:01 +00:00
__le32 data ;
2013-05-08 21:45:39 +00:00
int ret ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x00 ; //write_out
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
len = 2 ;
2014-12-19 06:59:46 +00:00
2015-01-28 17:28:01 +00:00
data = cpu_to_le32 ( val ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
ret = usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
static int usb_write32 ( struct intf_hdl * pintfhdl , u32 addr , u32 val )
{
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2015-01-28 17:28:01 +00:00
__le32 data ;
2013-05-08 21:45:39 +00:00
int ret ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x00 ; //write_out
index = 0 ; //n/a
2013-05-08 21:45:39 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
len = 4 ;
2015-01-28 17:28:01 +00:00
data = cpu_to_le32 ( val ) ;
2013-05-19 04:28:07 +00:00
2014-12-17 04:09:56 +00:00
ret = usbctrl_vendorreq ( pintfhdl , request , wvalue , index , & data , len , requesttype ) ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
}
static int usb_writeN ( struct intf_hdl * pintfhdl , u32 addr , u32 length , u8 * pdata )
{
2013-11-29 22:10:20 +00:00
u8 request ;
u8 requesttype ;
u16 wvalue ;
u16 index ;
u16 len ;
2014-12-17 04:09:56 +00:00
u8 buf [ VENDOR_CMD_MAX_DATA_LEN ] = { 0 } ;
2013-05-08 21:45:39 +00:00
int ret ;
2014-12-19 06:59:46 +00:00
2013-11-29 22:10:20 +00:00
request = 0x05 ;
2014-12-17 04:09:56 +00:00
requesttype = 0x00 ; //write_out
index = 0 ; //n/a
2013-05-19 04:28:07 +00:00
2013-11-29 22:10:20 +00:00
wvalue = ( u16 ) ( addr & 0x0000ffff ) ;
len = length ;
2014-12-17 04:09:56 +00:00
_rtw_memcpy ( buf , pdata , len ) ;
2014-12-19 06:59:46 +00:00
2013-11-29 22:10:20 +00:00
ret = usbctrl_vendorreq ( pintfhdl , request , wvalue , index , buf , len , requesttype ) ;
2014-12-19 06:59:46 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
return ret ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
# ifdef CONFIG_SUPPORT_USB_INT
2014-12-17 23:13:53 +00:00
void interrupt_handler_8188eu ( struct adapter * padapter , u16 pkt_len , u8 * pbuf )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
struct reportpwrstate_parm pwr_rpt ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( pkt_len ! = INTERRUPT_MSG_FORMAT_LEN )
{
DBG_8192C ( " %s Invalid interrupt content length (%d)! \n " , __FUNCTION__ , pkt_len ) ;
return ;
}
2014-12-19 06:59:46 +00:00
// HISR
2014-12-17 04:09:56 +00:00
_rtw_memcpy ( & ( pHalData - > IntArray [ 0 ] ) , & ( pbuf [ USB_INTR_CONTENT_HISR_OFFSET ] ) , 4 ) ;
_rtw_memcpy ( & ( pHalData - > IntArray [ 1 ] ) , & ( pbuf [ USB_INTR_CONTENT_HISRE_OFFSET ] ) , 4 ) ;
# ifdef CONFIG_LPS_LCLK
if ( pHalData - > IntArray [ 0 ] & IMR_CPWM_88E )
{
_rtw_memcpy ( & pwr_rpt . state , & ( pbuf [ USB_INTR_CONTENT_CPWM1_OFFSET ] ) , 1 ) ;
//_rtw_memcpy(&pwr_rpt.state2, &(pbuf[USB_INTR_CONTENT_CPWM2_OFFSET]), 1);
2014-12-19 06:59:46 +00:00
//88e's cpwm value only change BIT0, so driver need to add PS_STATE_S2 for LPS flow.
pwr_rpt . state | = PS_STATE_S2 ;
2014-12-17 04:09:56 +00:00
_set_workitem ( & ( adapter_to_pwrctl ( padapter ) - > cpwm_event ) ) ;
}
# endif //CONFIG_LPS_LCLK
# ifdef CONFIG_INTERRUPT_BASED_TXBCN
# ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT
if ( pHalData - > IntArray [ 0 ] & IMR_BCNDMAINT0_88E )
# endif
# ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR
if ( pHalData - > IntArray [ 0 ] & ( IMR_TBDER_88E | IMR_TBDOK_88E ) )
2014-12-19 06:59:46 +00:00
# endif
{
2014-12-17 04:09:56 +00:00
struct mlme_priv * pmlmepriv = & padapter - > mlmepriv ;
if ( check_fwstate ( pmlmepriv , WIFI_AP_STATE ) )
{
//send_beacon(padapter);
2014-12-29 02:13:24 +00:00
if ( pmlmepriv - > update_bcn = = true )
2014-12-17 04:09:56 +00:00
{
//tx_beacon_hdl(padapter, NULL);
set_tx_beacon_cmd ( padapter ) ;
}
}
# ifdef CONFIG_CONCURRENT_MODE
if ( check_buddy_fwstate ( padapter , WIFI_AP_STATE ) )
{
//send_beacon(padapter);
2014-12-29 02:13:24 +00:00
if ( padapter - > pbuddy_adapter - > mlmepriv . update_bcn = = true )
2014-12-17 04:09:56 +00:00
{
//tx_beacon_hdl(padapter, NULL);
set_tx_beacon_cmd ( padapter - > pbuddy_adapter ) ;
}
}
# endif
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
# endif //CONFIG_INTERRUPT_BASED_TXBCN
# ifdef DBG_CONFIG_ERROR_DETECT_INT
if ( pHalData - > IntArray [ 1 ] & IMR_TXERR_88E )
DBG_871X ( " ===> %s Tx Error Flag Interrupt Status \n " , __FUNCTION__ ) ;
if ( pHalData - > IntArray [ 1 ] & IMR_RXERR_88E )
DBG_871X ( " ===> %s Rx Error Flag INT Status \n " , __FUNCTION__ ) ;
if ( pHalData - > IntArray [ 1 ] & IMR_TXFOVW_88E )
DBG_871X ( " ===> %s Transmit FIFO Overflow \n " , __FUNCTION__ ) ;
if ( pHalData - > IntArray [ 1 ] & IMR_RXFOVW_88E )
2014-12-19 06:59:46 +00:00
DBG_871X ( " ===> %s Receive FIFO Overflow \n " , __FUNCTION__ ) ;
2014-12-17 04:09:56 +00:00
# endif //DBG_CONFIG_ERROR_DETECT_INT
2014-12-19 06:59:46 +00:00
// C2H Event
2014-12-17 04:09:56 +00:00
if ( pbuf [ 0 ] ! = 0 ) {
2014-12-19 06:59:46 +00:00
_rtw_memcpy ( & ( pHalData - > C2hArray [ 0 ] ) , & ( pbuf [ USB_INTR_CONTENT_C2H_OFFSET ] ) , 16 ) ;
2014-12-17 04:09:56 +00:00
//rtw_c2h_wk_cmd(padapter); to do..
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
}
# endif
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_INTERRUPT_IN_PIPE
static void usb_read_interrupt_complete ( struct urb * purb , struct pt_regs * regs )
{
int err ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) purb - > context ;
2014-12-17 04:09:56 +00:00
if ( padapter - > bSurpriseRemoved | | padapter - > bDriverStopped | | padapter - > bReadPortCancel )
{
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d) \n " ,
2014-12-17 04:09:56 +00:00
__FUNCTION__ , padapter - > bDriverStopped , padapter - > bSurpriseRemoved , padapter - > bReadPortCancel ) ;
2013-11-29 22:10:20 +00:00
2014-12-17 04:09:56 +00:00
return ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( purb - > status = = 0 ) //SUCCESS
{
if ( purb - > actual_length > INTERRUPT_MSG_FORMAT_LEN )
{
2014-12-19 06:59:46 +00:00
DBG_8192C ( " usb_read_interrupt_complete: purb->actual_length > INTERRUPT_MSG_FORMAT_LEN(%d) \n " , INTERRUPT_MSG_FORMAT_LEN ) ;
2014-12-17 04:09:56 +00:00
}
interrupt_handler_8188eu ( padapter , purb - > actual_length , purb - > transfer_buffer ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
err = usb_submit_urb ( purb , GFP_ATOMIC ) ;
if ( ( err ) & & ( err ! = ( - EPERM ) ) )
{
DBG_8192C ( " cannot submit interrupt in-token(err = 0x%08x),urb_status = %d \n " , err , purb - > status ) ;
}
}
else
{
DBG_8192C ( " ###=> usb_read_interrupt_complete => urb status(%d) \n " , purb - > status ) ;
switch ( purb - > status ) {
case - EINVAL :
2014-12-19 06:59:46 +00:00
case - EPIPE :
2014-12-17 04:09:56 +00:00
case - ENODEV :
case - ESHUTDOWN :
2014-12-29 02:13:24 +00:00
//padapter->bSurpriseRemoved=true;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bSurpriseRemoved=TRUE \n " ) ) ;
case - ENOENT :
2014-12-29 02:13:24 +00:00
padapter - > bDriverStopped = true ;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bDriverStopped=TRUE \n " ) ) ;
break ;
case - EPROTO :
break ;
case - EINPROGRESS :
DBG_8192C ( " ERROR: URB IS IN PROGRESS!/n " ) ;
break ;
default :
2014-12-19 06:59:46 +00:00
break ;
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
}
static u32 usb_read_interrupt ( struct intf_hdl * pintfhdl , u32 addr )
{
int err ;
unsigned int pipe ;
u32 ret = _SUCCESS ;
2014-12-17 23:13:53 +00:00
struct adapter * adapter = pintfhdl - > padapter ;
2014-12-17 04:09:56 +00:00
struct dvobj_priv * pdvobj = adapter_to_dvobj ( adapter ) ;
struct recv_priv * precvpriv = & adapter - > recvpriv ;
struct usb_device * pusbd = pdvobj - > pusbdev ;
2015-01-26 22:20:25 +00:00
;
2014-12-17 04:09:56 +00:00
//translate DMA FIFO addr to pipehandle
pipe = ffaddr2pipehdl ( pdvobj , addr ) ;
2014-12-19 06:59:46 +00:00
usb_fill_int_urb ( precvpriv - > int_in_urb , pusbd , pipe ,
2014-12-17 04:09:56 +00:00
precvpriv - > int_in_buf ,
2014-12-19 06:59:46 +00:00
INTERRUPT_MSG_FORMAT_LEN ,
usb_read_interrupt_complete ,
adapter ,
1 ) ;
2014-12-17 04:09:56 +00:00
err = usb_submit_urb ( precvpriv - > int_in_urb , GFP_ATOMIC ) ;
if ( ( err ) & & ( err ! = ( - EPERM ) ) )
{
DBG_8192C ( " cannot submit interrupt in-token(err = 0x%08x),urb_status = %d \n " , err , precvpriv - > int_in_urb - > status ) ;
ret = _FAIL ;
}
2015-01-26 22:20:25 +00:00
;
2014-12-17 04:09:56 +00:00
return ret ;
}
# endif
static s32 pre_recv_entry ( union recv_frame * precvframe , struct recv_stat * prxstat , struct phy_stat * pphy_status )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
s32 ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
# ifdef CONFIG_CONCURRENT_MODE
2014-12-17 04:09:56 +00:00
u8 * primary_myid , * secondary_myid , * paddr1 ;
union recv_frame * precvframe_if2 = NULL ;
2014-12-17 23:13:53 +00:00
struct adapter * primary_padapter = precvframe - > u . hdr . adapter ;
struct adapter * secondary_padapter = primary_padapter - > pbuddy_adapter ;
2014-12-17 04:09:56 +00:00
struct recv_priv * precvpriv = & primary_padapter - > recvpriv ;
_queue * pfree_recv_queue = & precvpriv - > free_recv_queue ;
u8 * pbuf = precvframe - > u . hdr . rx_data ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( ! secondary_padapter )
return ret ;
2014-12-19 06:59:46 +00:00
paddr1 = GetAddr1Ptr ( precvframe - > u . hdr . rx_data ) ;
2014-12-17 04:09:56 +00:00
2014-12-29 02:13:24 +00:00
if ( IS_MCAST ( paddr1 ) = = false ) //unicast packets
2014-12-17 04:09:56 +00:00
{
//primary_myid = myid(&primary_padapter->eeprompriv);
secondary_myid = myid ( & secondary_padapter - > eeprompriv ) ;
if ( _rtw_memcmp ( paddr1 , secondary_myid , ETH_ALEN ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
//change to secondary interface
precvframe - > u . hdr . adapter = secondary_padapter ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
//ret = recv_entry(precvframe);
}
2014-12-19 06:59:46 +00:00
else // Handle BC/MC Packets
2014-12-17 04:09:56 +00:00
{
2014-12-29 02:13:24 +00:00
u8 clone = true ;
2014-12-19 06:59:46 +00:00
2014-12-29 02:13:24 +00:00
if ( true = = clone ) {
2014-12-17 04:09:56 +00:00
//clone/copy to if2
u8 shift_sz = 0 ;
2014-12-19 06:59:46 +00:00
u32 alloc_sz , skb_len ;
2014-12-17 04:09:56 +00:00
_pkt * pkt_copy = NULL ;
struct rx_pkt_attrib * pattrib = NULL ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
precvframe_if2 = rtw_alloc_recvframe ( pfree_recv_queue ) ;
if ( precvframe_if2 )
{
precvframe_if2 - > u . hdr . adapter = secondary_padapter ;
2014-12-19 06:59:46 +00:00
_rtw_init_listhead ( & precvframe_if2 - > u . hdr . list ) ;
2014-12-17 04:09:56 +00:00
precvframe_if2 - > u . hdr . precvbuf = NULL ; //can't access the precvbuf for new arch.
precvframe_if2 - > u . hdr . len = 0 ;
_rtw_memcpy ( & precvframe_if2 - > u . hdr . attrib , & precvframe - > u . hdr . attrib , sizeof ( struct rx_pkt_attrib ) ) ;
pattrib = & precvframe_if2 - > u . hdr . attrib ;
// Modified by Albert 20101213
// For 8 bytes IP header alignment.
if ( pattrib - > qos ) // Qos data, wireless lan header length is 26
{
shift_sz = 6 ;
}
else
{
shift_sz = 0 ;
}
skb_len = pattrib - > pkt_len ;
// for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet.
// modify alloc_sz for recvive crc error packet by thomas 2011-06-02
if ( ( pattrib - > mfrag = = 1 ) & & ( pattrib - > frag_num = = 0 ) ) {
//alloc_sz = 1664; //1664 is 128 alignment.
if ( skb_len < = 1650 )
alloc_sz = 1664 ;
else
alloc_sz = skb_len + 14 ;
}
else {
alloc_sz = skb_len ;
// 6 is for IP header 8 bytes alignment in QoS packet case.
// 8 is for skb->data 4 bytes alignment.
alloc_sz + = 14 ;
}
pkt_copy = rtw_skb_alloc ( alloc_sz ) ;
if ( pkt_copy )
{
pkt_copy - > dev = secondary_padapter - > pnetdev ;
precvframe_if2 - > u . hdr . pkt = pkt_copy ;
precvframe_if2 - > u . hdr . rx_head = pkt_copy - > data ;
precvframe_if2 - > u . hdr . rx_end = pkt_copy - > data + alloc_sz ;
skb_reserve ( pkt_copy , 8 - ( ( SIZE_PTR ) ( pkt_copy - > data ) & 7 ) ) ; //force pkt_copy->data at 8-byte alignment address
skb_reserve ( pkt_copy , shift_sz ) ; //force ip_hdr at 8-byte alignment address according to shift_sz.
_rtw_memcpy ( pkt_copy - > data , pbuf , skb_len ) ;
precvframe_if2 - > u . hdr . rx_data = precvframe_if2 - > u . hdr . rx_tail = pkt_copy - > data ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
recvframe_put ( precvframe_if2 , skb_len ) ;
2014-12-19 06:59:46 +00:00
if ( pattrib - > physt )
2014-12-17 04:09:56 +00:00
update_recvframe_phyinfo_88e ( precvframe_if2 , ( struct phy_stat * ) pphy_status ) ;
2014-12-19 06:59:46 +00:00
ret = rtw_recv_entry ( precvframe_if2 ) ;
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
else {
rtw_free_recvframe ( precvframe_if2 , pfree_recv_queue ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: alloc_skb() failed! \n " , __FUNCTION__ , __LINE__ ) ;
2014-12-17 04:09:56 +00:00
}
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
if ( precvframe - > u . hdr . attrib . physt )
2014-12-19 06:59:46 +00:00
update_recvframe_phyinfo_88e ( precvframe , ( struct phy_stat * ) pphy_status ) ;
2014-12-17 04:09:56 +00:00
ret = rtw_recv_entry ( precvframe ) ;
# endif
2013-05-19 04:28:07 +00:00
2013-05-08 21:45:39 +00:00
return ret ;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX
2014-12-17 23:13:53 +00:00
static int recvbuf2recvframe ( struct adapter * padapter , struct recv_buf * precvbuf )
2013-05-19 04:28:07 +00:00
{
2014-12-17 04:09:56 +00:00
u8 * pbuf ;
u8 shift_sz = 0 ;
u16 pkt_cnt , drvinfo_sz ;
u32 pkt_offset , skb_len , alloc_sz ;
s32 transfer_len ;
struct recv_stat * prxstat ;
struct phy_stat * pphy_status = NULL ;
_pkt * pkt_copy = NULL ;
union recv_frame * precvframe = NULL ;
struct rx_pkt_attrib * pattrib = NULL ;
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
_queue * pfree_recv_queue = & precvpriv - > free_recv_queue ;
2013-05-19 04:28:07 +00:00
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
transfer_len = ( s32 ) precvbuf - > transfer_len ;
2014-12-17 04:09:56 +00:00
pbuf = precvbuf - > pbuf ;
2014-12-19 06:59:46 +00:00
prxstat = ( struct recv_stat * ) pbuf ;
2014-12-17 04:09:56 +00:00
pkt_cnt = ( le32_to_cpu ( prxstat - > rxdw2 ) > > 16 ) & 0xff ;
2014-12-19 06:59:46 +00:00
do {
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ ,
( " recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x \n " ,
prxstat - > rxdw0 , prxstat - > rxdw1 , prxstat - > rxdw2 , prxstat - > rxdw4 ) ) ;
prxstat = ( struct recv_stat * ) pbuf ;
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
precvframe = rtw_alloc_recvframe ( pfree_recv_queue ) ;
if ( precvframe = = NULL )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvbuf2recvframe: precvframe==NULL \n " ) ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: rtw_alloc_recvframe() failed! RX Drop! \n " , __FUNCTION__ , __LINE__ ) ;
2014-12-17 04:09:56 +00:00
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
_rtw_init_listhead ( & precvframe - > u . hdr . list ) ;
2014-12-17 04:09:56 +00:00
precvframe - > u . hdr . precvbuf = NULL ; //can't access the precvbuf for new arch.
precvframe - > u . hdr . len = 0 ;
//rtl8192c_query_rx_desc_status(precvframe, prxstat);
update_recvframe_attrib_88e ( precvframe , prxstat ) ;
pattrib = & precvframe - > u . hdr . attrib ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( ( padapter - > registrypriv . mp_mode = = 0 ) & & ( ( pattrib - > crc_err ) | | ( pattrib - > icv_err ) ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
DBG_8192C ( " %s: RX Warning! crc_err=%d icv_err=%d, skip! \n " , __FUNCTION__ , pattrib - > crc_err , pattrib - > icv_err ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( ( pattrib - > physt ) & & ( pattrib - > pkt_rpt_type = = NORMAL_RX ) )
{
pphy_status = ( struct phy_stat * ) ( pbuf + RXDESC_OFFSET ) ;
}
pkt_offset = RXDESC_SIZE + pattrib - > drvinfo_sz + pattrib - > shift_sz + pattrib - > pkt_len ;
if ( ( pattrib - > pkt_len < = 0 ) | | ( pkt_offset > transfer_len ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " recvbuf2recvframe: pkt_len<=0 \n " ) ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: RX Warning! \n " , __FUNCTION__ , __LINE__ ) ;
2014-12-17 04:09:56 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
// Modified by Albert 20101213
// For 8 bytes IP header alignment.
if ( pattrib - > qos ) // Qos data, wireless lan header length is 26
{
shift_sz = 6 ;
}
else
{
shift_sz = 0 ;
}
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
skb_len = pattrib - > pkt_len ;
// for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet.
// modify alloc_sz for recvive crc error packet by thomas 2011-06-02
if ( ( pattrib - > mfrag = = 1 ) & & ( pattrib - > frag_num = = 0 ) ) {
//alloc_sz = 1664; //1664 is 128 alignment.
if ( skb_len < = 1650 )
alloc_sz = 1664 ;
else
alloc_sz = skb_len + 14 ;
}
else {
alloc_sz = skb_len ;
// 6 is for IP header 8 bytes alignment in QoS packet case.
// 8 is for skb->data 4 bytes alignment.
alloc_sz + = 14 ;
}
pkt_copy = rtw_skb_alloc ( alloc_sz ) ;
if ( pkt_copy )
{
pkt_copy - > dev = padapter - > pnetdev ;
precvframe - > u . hdr . pkt = pkt_copy ;
precvframe - > u . hdr . rx_head = pkt_copy - > data ;
precvframe - > u . hdr . rx_end = pkt_copy - > data + alloc_sz ;
skb_reserve ( pkt_copy , 8 - ( ( SIZE_PTR ) ( pkt_copy - > data ) & 7 ) ) ; //force pkt_copy->data at 8-byte alignment address
skb_reserve ( pkt_copy , shift_sz ) ; //force ip_hdr at 8-byte alignment address according to shift_sz.
_rtw_memcpy ( pkt_copy - > data , ( pbuf + pattrib - > drvinfo_sz + RXDESC_SIZE ) , skb_len ) ;
precvframe - > u . hdr . rx_data = precvframe - > u . hdr . rx_tail = pkt_copy - > data ;
}
else
{
DBG_8192C ( " recvbuf2recvframe:can not allocate memory for skb copy \n " ) ;
//precvframe->u.hdr.pkt = rtw_skb_clone(pskb);
//precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pbuf;
//precvframe->u.hdr.rx_end = pbuf + (pkt_offset>1612?pkt_offset:1612);
precvframe - > u . hdr . pkt = NULL ;
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
recvframe_put ( precvframe , skb_len ) ;
2014-12-19 06:59:46 +00:00
//recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE);
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_RX_AGGREGATION
switch ( pHalData - > UsbRxAggMode )
{
case USB_RX_AGG_DMA :
case USB_RX_AGG_MIX :
pkt_offset = ( u16 ) _RND128 ( pkt_offset ) ;
break ;
case USB_RX_AGG_USB :
pkt_offset = ( u16 ) _RND4 ( pkt_offset ) ;
break ;
2014-12-19 06:59:46 +00:00
case USB_RX_AGG_DISABLE :
default :
2014-12-17 04:09:56 +00:00
break ;
}
# endif
if ( pattrib - > pkt_rpt_type = = NORMAL_RX ) //Normal rx packet
{
# ifdef CONFIG_CONCURRENT_MODE
if ( rtw_buddy_adapter_up ( padapter ) )
{
if ( pre_recv_entry ( precvframe , prxstat , pphy_status ) ! = _SUCCESS )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ ,
( " recvbuf2recvframe: recv_entry(precvframe) != _SUCCESS \n " ) ) ;
}
}
else
2014-12-19 06:59:46 +00:00
# endif
2014-12-17 04:09:56 +00:00
{
2014-12-19 06:59:46 +00:00
if ( pattrib - > physt )
2014-12-17 04:09:56 +00:00
update_recvframe_phyinfo_88e ( precvframe , ( struct phy_stat * ) pphy_status ) ;
if ( rtw_recv_entry ( precvframe ) ! = _SUCCESS )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ ,
( " recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS \n " ) ) ;
}
}
}
else { // pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
//enqueue recvframe to txrtp queue
if ( pattrib - > pkt_rpt_type = = TX_REPORT1 ) {
//DBG_8192C("rx CCX \n");
//CCX-TXRPT ack for xmit mgmt frames.
handle_txrpt_ccx_88e ( padapter , precvframe - > u . hdr . rx_data ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
else if ( pattrib - > pkt_rpt_type = = TX_REPORT2 ) {
//DBG_8192C("rx TX RPT \n");
ODM_RA_TxRPT2Handle_8188E (
& pHalData - > odmpriv ,
precvframe - > u . hdr . rx_data ,
pattrib - > pkt_len ,
pattrib - > MacIDValidEntry [ 0 ] ,
pattrib - > MacIDValidEntry [ 1 ]
) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
else if ( pattrib - > pkt_rpt_type = = HIS_REPORT )
{
//DBG_8192C("%s , rx USB HISR \n",__FUNCTION__);
# ifdef CONFIG_SUPPORT_USB_INT
interrupt_handler_8188eu ( padapter , pattrib - > pkt_len , precvframe - > u . hdr . rx_data ) ;
# endif
2014-12-19 06:59:46 +00:00
}
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
}
2014-12-17 04:09:56 +00:00
pkt_cnt - - ;
transfer_len - = pkt_offset ;
2014-12-19 06:59:46 +00:00
pbuf + = pkt_offset ;
2014-12-17 04:09:56 +00:00
precvframe = NULL ;
pkt_copy = NULL ;
if ( transfer_len > 0 & & pkt_cnt = = 0 )
pkt_cnt = ( le32_to_cpu ( prxstat - > rxdw2 ) > > 16 ) & 0xff ;
} while ( ( transfer_len > 0 ) & & ( pkt_cnt > 0 ) ) ;
_exit_recvbuf2recvframe :
return _SUCCESS ;
}
void rtl8188eu_recv_tasklet ( void * priv )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
struct recv_buf * precvbuf = NULL ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) priv ;
2014-12-17 04:09:56 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
while ( NULL ! = ( precvbuf = rtw_dequeue_recvbuf ( & precvpriv - > recv_buf_pending_queue ) ) )
{
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = true ) | | ( padapter - > bSurpriseRemoved = = true ) )
2014-12-17 04:09:56 +00:00
{
DBG_8192C ( " recv_tasklet => bDriverStopped or bSurpriseRemoved \n " ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
break ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
recvbuf2recvframe ( padapter , precvbuf ) ;
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
}
static void usb_read_port_complete ( struct urb * purb , struct pt_regs * regs )
2014-12-19 06:59:46 +00:00
{
struct recv_buf * precvbuf = ( struct recv_buf * ) purb - > context ;
struct adapter * padapter = ( struct adapter * ) precvbuf - > adapter ;
2014-12-17 04:09:56 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete!!! \n " ) ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
precvpriv - > rx_pending_cnt - - ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( padapter - > bSurpriseRemoved | | padapter - > bDriverStopped | | padapter - > bReadPortCancel )
{
2014-12-19 06:59:46 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d) \n " , padapter - > bDriverStopped , padapter - > bSurpriseRemoved ) ) ;
DBG_8192C ( " %s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d) \n " ,
__FUNCTION__ , padapter - > bDriverStopped , padapter - > bSurpriseRemoved , padapter - > bReadPortCancel ) ;
2014-12-17 04:09:56 +00:00
goto exit ;
}
if ( purb - > status = = 0 ) //SUCCESS
{
if ( ( purb - > actual_length > MAX_RECVBUF_SZ ) | | ( purb - > actual_length < RXDESC_SIZE ) )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE) \n " ) ) ;
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
}
2014-12-19 06:59:46 +00:00
else
{
2014-12-17 04:09:56 +00:00
rtw_reset_continual_io_error ( adapter_to_dvobj ( padapter ) ) ;
2014-12-19 06:59:46 +00:00
precvbuf - > transfer_len = purb - > actual_length ;
//rtw_enqueue_rx_transfer_buffer(precvpriv, rx_transfer_buf);
2014-12-17 04:09:56 +00:00
rtw_enqueue_recvbuf ( precvbuf , & precvpriv - > recv_buf_pending_queue ) ;
2014-12-19 06:59:46 +00:00
tasklet_schedule ( & precvpriv - > recv_tasklet ) ;
}
2014-12-17 04:09:56 +00:00
}
else
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete : purb->status(%d) != 0 \n " , purb - > status ) ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
DBG_8192C ( " ###=> usb_read_port_complete => urb status(%d) \n " , purb - > status ) ;
2014-12-29 02:13:24 +00:00
if ( rtw_inc_and_chk_continual_io_error ( adapter_to_dvobj ( padapter ) ) = = true ) {
padapter - > bSurpriseRemoved = true ;
2014-12-17 04:09:56 +00:00
}
switch ( purb - > status ) {
case - EINVAL :
2014-12-19 06:59:46 +00:00
case - EPIPE :
2014-12-17 04:09:56 +00:00
case - ENODEV :
case - ESHUTDOWN :
2014-12-29 02:13:24 +00:00
//padapter->bSurpriseRemoved=true;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bSurpriseRemoved=TRUE \n " ) ) ;
case - ENOENT :
2014-12-29 02:13:24 +00:00
padapter - > bDriverStopped = true ;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bDriverStopped=TRUE \n " ) ) ;
break ;
case - EPROTO :
case - EILSEQ :
case - ETIME :
case - ECOMM :
case - EOVERFLOW :
2014-12-19 06:59:46 +00:00
# ifdef DBG_CONFIG_ERROR_DETECT
{
2014-12-17 04:09:56 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
2014-12-19 06:59:46 +00:00
pHalData - > srestpriv . Wifi_Error_Status = USB_READ_PORT_FAIL ;
2014-12-17 04:09:56 +00:00
}
# endif
2014-12-19 06:59:46 +00:00
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
2014-12-17 04:09:56 +00:00
break ;
case - EINPROGRESS :
DBG_8192C ( " ERROR: URB IS IN PROGRESS!/n " ) ;
break ;
default :
2014-12-19 06:59:46 +00:00
break ;
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
static u32 usb_read_port ( struct intf_hdl * pintfhdl , u32 addr , u32 cnt , u8 * rmem )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
int err ;
unsigned int pipe ;
u32 ret = _SUCCESS ;
2014-12-19 06:59:46 +00:00
PURB purb = NULL ;
2014-12-17 04:09:56 +00:00
struct recv_buf * precvbuf = ( struct recv_buf * ) rmem ;
2014-12-17 23:13:53 +00:00
struct adapter * adapter = pintfhdl - > padapter ;
2014-12-17 04:09:56 +00:00
struct dvobj_priv * pdvobj = adapter_to_dvobj ( adapter ) ;
struct recv_priv * precvpriv = & adapter - > recvpriv ;
struct usb_device * pusbd = pdvobj - > pusbdev ;
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( adapter - > bDriverStopped | | adapter - > bSurpriseRemoved | | dvobj_to_pwrctl ( pdvobj ) - > pnp_bstop_trx )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||pwrctl->pnp_bstop_trx)!!! \n " ) ) ;
return _FAIL ;
}
if ( precvbuf ! = NULL )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
rtl8188eu_init_recvbuf ( adapter , precvbuf ) ;
if ( precvbuf - > pbuf )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
precvpriv - > rx_pending_cnt + + ;
2014-12-19 06:59:46 +00:00
purb = precvbuf - > purb ;
2014-12-17 04:09:56 +00:00
//translate DMA FIFO addr to pipehandle
2014-12-19 06:59:46 +00:00
pipe = ffaddr2pipehdl ( pdvobj , addr ) ;
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
usb_fill_bulk_urb ( purb , pusbd , pipe ,
2014-12-17 04:09:56 +00:00
precvbuf - > pbuf ,
2014-12-19 06:59:46 +00:00
MAX_RECVBUF_SZ ,
usb_read_port_complete ,
precvbuf ) ; //context is precvbuf
2014-12-17 04:09:56 +00:00
purb - > transfer_dma = precvbuf - > dma_transfer_addr ;
2014-12-19 06:59:46 +00:00
purb - > transfer_flags | = URB_NO_TRANSFER_DMA_MAP ;
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
err = usb_submit_urb ( purb , GFP_ATOMIC ) ;
2014-12-17 04:09:56 +00:00
if ( ( err ) & & ( err ! = ( - EPERM ) ) )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x " , err , purb - > status ) ) ;
DBG_8192C ( " cannot submit rx in-token(err = 0x%08x),urb_status = %d \n " , err , purb - > status ) ;
ret = _FAIL ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
}
else
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port:precvbuf ==NULL \n " ) ) ;
ret = _FAIL ;
}
2015-01-26 22:20:25 +00:00
;
2014-12-17 04:09:56 +00:00
return ret ;
}
# else // CONFIG_USE_USB_BUFFER_ALLOC_RX
2014-12-17 23:13:53 +00:00
static int recvbuf2recvframe ( struct adapter * padapter , _pkt * pskb )
2013-05-08 21:45:39 +00:00
{
u8 * pbuf ;
u8 shift_sz = 0 ;
u16 pkt_cnt ;
u32 pkt_offset , skb_len , alloc_sz ;
s32 transfer_len ;
struct recv_stat * prxstat ;
struct phy_stat * pphy_status = NULL ;
2014-12-17 04:09:56 +00:00
_pkt * pkt_copy = NULL ;
2013-05-08 21:45:39 +00:00
union recv_frame * precvframe = NULL ;
struct rx_pkt_attrib * pattrib = NULL ;
2014-12-17 04:09:56 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
_queue * pfree_recv_queue = & precvpriv - > free_recv_queue ;
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
transfer_len = ( s32 ) pskb - > len ;
2013-05-08 21:45:39 +00:00
pbuf = pskb - > data ;
2014-12-19 06:59:46 +00:00
prxstat = ( struct recv_stat * ) pbuf ;
2014-12-17 04:09:56 +00:00
pkt_cnt = ( le32_to_cpu ( prxstat - > rxdw2 ) > > 16 ) & 0xff ;
2013-05-08 21:45:39 +00:00
2014-12-19 06:59:46 +00:00
do {
2013-05-08 21:45:39 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ ,
( " recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x \n " ,
prxstat - > rxdw0 , prxstat - > rxdw1 , prxstat - > rxdw2 , prxstat - > rxdw4 ) ) ;
prxstat = ( struct recv_stat * ) pbuf ;
precvframe = rtw_alloc_recvframe ( pfree_recv_queue ) ;
2014-12-17 04:09:56 +00:00
if ( precvframe = = NULL )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ , ( " recvbuf2recvframe: precvframe==NULL \n " ) ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: rtw_alloc_recvframe() failed! RX Drop! \n " , __FUNCTION__ , __LINE__ ) ;
2013-05-08 21:45:39 +00:00
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
_rtw_init_listhead ( & precvframe - > u . hdr . list ) ;
2014-12-17 04:09:56 +00:00
precvframe - > u . hdr . precvbuf = NULL ; //can't access the precvbuf for new arch.
precvframe - > u . hdr . len = 0 ;
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
//rtl8192c_query_rx_desc_status(precvframe, prxstat);
2013-05-08 21:45:39 +00:00
update_recvframe_attrib_88e ( precvframe , prxstat ) ;
2014-12-19 06:59:46 +00:00
pattrib = & precvframe - > u . hdr . attrib ;
2014-12-17 04:09:56 +00:00
if ( ( padapter - > registrypriv . mp_mode = = 0 ) & & ( ( pattrib - > crc_err ) | | ( pattrib - > icv_err ) ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
DBG_8192C ( " %s: RX Warning! crc_err=%d icv_err=%d, skip! \n " , __FUNCTION__ , pattrib - > crc_err , pattrib - > icv_err ) ;
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
2014-12-17 04:09:56 +00:00
if ( ( pattrib - > physt ) & & ( pattrib - > pkt_rpt_type = = NORMAL_RX ) )
{
2013-05-08 21:45:39 +00:00
pphy_status = ( struct phy_stat * ) ( pbuf + RXDESC_OFFSET ) ;
2014-12-17 04:09:56 +00:00
}
2013-05-08 21:45:39 +00:00
pkt_offset = RXDESC_SIZE + pattrib - > drvinfo_sz + pattrib - > shift_sz + pattrib - > pkt_len ;
2014-12-17 04:09:56 +00:00
if ( ( pattrib - > pkt_len < = 0 ) | | ( pkt_offset > transfer_len ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_info_ , ( " recvbuf2recvframe: pkt_len<=0 \n " ) ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len \n " , __FUNCTION__ , __LINE__ ) ;
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
// Modified by Albert 20101213
// For 8 bytes IP header alignment.
if ( pattrib - > qos ) // Qos data, wireless lan header length is 26
{
2013-05-08 21:45:39 +00:00
shift_sz = 6 ;
2014-12-17 04:09:56 +00:00
}
2013-05-08 21:45:39 +00:00
else
2014-12-17 04:09:56 +00:00
{
2013-05-08 21:45:39 +00:00
shift_sz = 0 ;
2014-12-17 04:09:56 +00:00
}
2013-05-08 21:45:39 +00:00
skb_len = pattrib - > pkt_len ;
2014-12-17 04:09:56 +00:00
// for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet.
// modify alloc_sz for recvive crc error packet by thomas 2011-06-02
if ( ( pattrib - > mfrag = = 1 ) & & ( pattrib - > frag_num = = 0 ) ) {
//alloc_sz = 1664; //1664 is 128 alignment.
if ( skb_len < = 1650 )
2013-05-08 21:45:39 +00:00
alloc_sz = 1664 ;
else
alloc_sz = skb_len + 14 ;
2014-12-17 04:09:56 +00:00
}
else {
2013-05-08 21:45:39 +00:00
alloc_sz = skb_len ;
2014-12-17 04:09:56 +00:00
// 6 is for IP header 8 bytes alignment in QoS packet case.
// 8 is for skb->data 4 bytes alignment.
2013-05-08 21:45:39 +00:00
alloc_sz + = 14 ;
}
2014-12-17 04:09:56 +00:00
pkt_copy = rtw_skb_alloc ( alloc_sz ) ;
if ( pkt_copy )
{
pkt_copy - > dev = padapter - > pnetdev ;
2013-05-08 21:45:39 +00:00
precvframe - > u . hdr . pkt = pkt_copy ;
precvframe - > u . hdr . rx_head = pkt_copy - > data ;
precvframe - > u . hdr . rx_end = pkt_copy - > data + alloc_sz ;
2014-12-17 04:09:56 +00:00
skb_reserve ( pkt_copy , 8 - ( ( SIZE_PTR ) ( pkt_copy - > data ) & 7 ) ) ; //force pkt_copy->data at 8-byte alignment address
skb_reserve ( pkt_copy , shift_sz ) ; //force ip_hdr at 8-byte alignment address according to shift_sz.
_rtw_memcpy ( pkt_copy - > data , ( pbuf + pattrib - > drvinfo_sz + RXDESC_SIZE ) , skb_len ) ;
precvframe - > u . hdr . rx_data = precvframe - > u . hdr . rx_tail = pkt_copy - > data ;
}
else
{
if ( ( pattrib - > mfrag = = 1 ) & & ( pattrib - > frag_num = = 0 ) )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
DBG_8192C ( " recvbuf2recvframe: alloc_skb fail , drop frag frame \n " ) ;
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
precvframe - > u . hdr . pkt = rtw_skb_clone ( pskb ) ;
if ( precvframe - > u . hdr . pkt )
{
2014-12-19 06:59:46 +00:00
precvframe - > u . hdr . rx_head = precvframe - > u . hdr . rx_data = precvframe - > u . hdr . rx_tail
2014-12-17 04:09:56 +00:00
= pbuf + pattrib - > drvinfo_sz + RXDESC_SIZE ;
precvframe - > u . hdr . rx_end = pbuf + pattrib - > drvinfo_sz + RXDESC_SIZE + alloc_sz ;
}
else
{
DBG_8192C ( " recvbuf2recvframe: rtw_skb_clone fail \n " ) ;
2013-05-08 21:45:39 +00:00
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
goto _exit_recvbuf2recvframe ;
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
recvframe_put ( precvframe , skb_len ) ;
2014-12-19 06:59:46 +00:00
//recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE);
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_RX_AGGREGATION
switch ( pHalData - > UsbRxAggMode )
{
case USB_RX_AGG_DMA :
case USB_RX_AGG_MIX :
pkt_offset = ( u16 ) _RND128 ( pkt_offset ) ;
break ;
case USB_RX_AGG_USB :
pkt_offset = ( u16 ) _RND4 ( pkt_offset ) ;
break ;
2014-12-19 06:59:46 +00:00
case USB_RX_AGG_DISABLE :
default :
2014-12-17 04:09:56 +00:00
break ;
}
# endif
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
if ( pattrib - > pkt_rpt_type = = NORMAL_RX ) //Normal rx packet
{
# ifdef CONFIG_CONCURRENT_MODE
if ( rtw_buddy_adapter_up ( padapter ) )
{
if ( pre_recv_entry ( precvframe , prxstat , pphy_status ) ! = _SUCCESS )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ ,
( " recvbuf2recvframe: recv_entry(precvframe) != _SUCCESS \n " ) ) ;
}
}
else
# endif
{
2014-12-19 06:59:46 +00:00
if ( pattrib - > physt )
2014-12-17 04:09:56 +00:00
update_recvframe_phyinfo_88e ( precvframe , ( struct phy_stat * ) pphy_status ) ;
if ( rtw_recv_entry ( precvframe ) ! = _SUCCESS )
{
RT_TRACE ( _module_rtl871x_recv_c_ , _drv_err_ ,
( " recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS \n " ) ) ;
}
}
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
else { // pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
//enqueue recvframe to txrtp queue
if ( pattrib - > pkt_rpt_type = = TX_REPORT1 ) {
//DBG_8192C("rx CCX \n");
//CCX-TXRPT ack for xmit mgmt frames.
handle_txrpt_ccx_88e ( padapter , precvframe - > u . hdr . rx_data ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
else if ( pattrib - > pkt_rpt_type = = TX_REPORT2 ) {
//DBG_8192C("rx TX RPT \n");
2013-05-08 21:45:39 +00:00
ODM_RA_TxRPT2Handle_8188E (
2014-12-17 04:09:56 +00:00
& pHalData - > odmpriv ,
2013-05-08 21:45:39 +00:00
precvframe - > u . hdr . rx_data ,
pattrib - > pkt_len ,
pattrib - > MacIDValidEntry [ 0 ] ,
pattrib - > MacIDValidEntry [ 1 ]
) ;
2014-12-19 06:59:46 +00:00
2013-05-19 04:28:07 +00:00
}
2014-12-17 04:09:56 +00:00
else if ( pattrib - > pkt_rpt_type = = HIS_REPORT )
{
//DBG_8192C("%s , rx USB HISR \n",__FUNCTION__);
# ifdef CONFIG_SUPPORT_USB_INT
interrupt_handler_8188eu ( padapter , pattrib - > pkt_len , precvframe - > u . hdr . rx_data ) ;
# endif
2014-12-19 06:59:46 +00:00
}
rtw_free_recvframe ( precvframe , pfree_recv_queue ) ;
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
pkt_cnt - - ;
transfer_len - = pkt_offset ;
2014-12-19 06:59:46 +00:00
pbuf + = pkt_offset ;
2013-05-08 21:45:39 +00:00
precvframe = NULL ;
pkt_copy = NULL ;
2014-12-17 04:09:56 +00:00
if ( transfer_len > 0 & & pkt_cnt = = 0 )
2013-05-08 21:45:39 +00:00
pkt_cnt = ( le32_to_cpu ( prxstat - > rxdw2 ) > > 16 ) & 0xff ;
2014-12-17 04:09:56 +00:00
} while ( ( transfer_len > 0 ) & & ( pkt_cnt > 0 ) ) ;
2013-05-08 21:45:39 +00:00
_exit_recvbuf2recvframe :
2014-12-19 06:59:46 +00:00
return _SUCCESS ;
2013-05-08 21:45:39 +00:00
}
void rtl8188eu_recv_tasklet ( void * priv )
{
2014-12-17 04:09:56 +00:00
_pkt * pskb ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) priv ;
2014-12-17 04:09:56 +00:00
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
while ( NULL ! = ( pskb = skb_dequeue ( & precvpriv - > rx_skb_queue ) ) )
{
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = true ) | | ( padapter - > bSurpriseRemoved = = true ) )
2014-12-17 04:09:56 +00:00
{
DBG_8192C ( " recv_tasklet => bDriverStopped or bSurpriseRemoved \n " ) ;
rtw_skb_free ( pskb ) ;
2013-05-08 21:45:39 +00:00
break ;
}
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
recvbuf2recvframe ( padapter , pskb ) ;
# ifdef CONFIG_PREALLOC_RECV_SKB
2013-05-08 21:45:39 +00:00
skb_reset_tail_pointer ( pskb ) ;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
pskb - > len = 0 ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
skb_queue_tail ( & precvpriv - > free_recv_skb_queue , pskb ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
# else
rtw_skb_free ( pskb ) ;
# endif
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
static void usb_read_port_complete ( struct urb * purb , struct pt_regs * regs )
{
2014-12-17 04:09:56 +00:00
_irqL irqL ;
uint isevt , * pbuf ;
2014-12-19 06:59:46 +00:00
struct recv_buf * precvbuf = ( struct recv_buf * ) purb - > context ;
struct adapter * padapter = ( struct adapter * ) precvbuf - > adapter ;
struct recv_priv * precvpriv = & padapter - > recvpriv ;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete!!! \n " ) ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
//_enter_critical(&precvpriv->lock, &irqL);
2014-12-29 02:13:24 +00:00
//precvbuf->irp_pending=false;
2014-12-17 04:09:56 +00:00
//precvpriv->rx_pending_cnt --;
//_exit_critical(&precvpriv->lock, &irqL);
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
precvpriv - > rx_pending_cnt - - ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
//if(precvpriv->rx_pending_cnt== 0)
2014-12-19 06:59:46 +00:00
//{
2014-12-17 04:09:56 +00:00
// RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: rx_pending_cnt== 0, set allrxreturnevt!\n"));
2014-12-19 06:59:46 +00:00
// _rtw_up_sema(&precvpriv->allrxreturnevt);
2014-12-17 04:09:56 +00:00
//}
if ( padapter - > bSurpriseRemoved | | padapter - > bDriverStopped | | padapter - > bReadPortCancel )
{
2014-12-19 06:59:46 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d) \n " , padapter - > bDriverStopped , padapter - > bSurpriseRemoved ) ) ;
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_PREALLOC_RECV_SKB
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = true ;
2014-12-17 04:09:56 +00:00
# else
if ( precvbuf - > pskb ) {
DBG_8192C ( " ==> free skb(%p) \n " , precvbuf - > pskb ) ;
rtw_skb_free ( precvbuf - > pskb ) ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
# endif
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d) \n " ,
__FUNCTION__ , padapter - > bDriverStopped , padapter - > bSurpriseRemoved , padapter - > bReadPortCancel ) ;
2014-12-17 04:09:56 +00:00
goto exit ;
2013-05-08 21:45:39 +00:00
}
2014-12-17 04:09:56 +00:00
if ( purb - > status = = 0 ) //SUCCESS
{
if ( ( purb - > actual_length > MAX_RECVBUF_SZ ) | | ( purb - > actual_length < RXDESC_SIZE ) )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE) \n " ) ) ;
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = true ;
2014-12-17 04:09:56 +00:00
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
2014-12-19 06:59:46 +00:00
DBG_8192C ( " %s()-%d: RX Warning! \n " , __FUNCTION__ , __LINE__ ) ;
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
else
{
2014-12-17 04:09:56 +00:00
rtw_reset_continual_io_error ( adapter_to_dvobj ( padapter ) ) ;
2014-12-19 06:59:46 +00:00
precvbuf - > transfer_len = purb - > actual_length ;
skb_put ( precvbuf - > pskb , purb - > actual_length ) ;
2013-05-08 21:45:39 +00:00
skb_queue_tail ( & precvpriv - > rx_skb_queue , precvbuf - > pskb ) ;
2014-12-17 04:09:56 +00:00
if ( skb_queue_len ( & precvpriv - > rx_skb_queue ) < = 1 )
2013-05-08 21:45:39 +00:00
tasklet_schedule ( & precvpriv - > recv_tasklet ) ;
precvbuf - > pskb = NULL ;
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = false ;
2014-12-19 06:59:46 +00:00
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
}
2013-05-19 04:28:07 +00:00
}
2014-12-17 04:09:56 +00:00
else
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete : purb->status(%d) != 0 \n " , purb - > status ) ) ;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
DBG_8192C ( " ###=> usb_read_port_complete => urb status(%d) \n " , purb - > status ) ;
2014-12-29 02:13:24 +00:00
if ( rtw_inc_and_chk_continual_io_error ( adapter_to_dvobj ( padapter ) ) = = true ) {
padapter - > bSurpriseRemoved = true ;
2014-12-17 04:09:56 +00:00
}
switch ( purb - > status ) {
case - EINVAL :
2014-12-19 06:59:46 +00:00
case - EPIPE :
2014-12-17 04:09:56 +00:00
case - ENODEV :
case - ESHUTDOWN :
2014-12-29 02:13:24 +00:00
//padapter->bSurpriseRemoved=true;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bSurpriseRemoved=TRUE \n " ) ) ;
case - ENOENT :
2014-12-29 02:13:24 +00:00
padapter - > bDriverStopped = true ;
2014-12-17 04:09:56 +00:00
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port_complete:bDriverStopped=TRUE \n " ) ) ;
break ;
case - EPROTO :
case - EILSEQ :
case - ETIME :
case - ECOMM :
case - EOVERFLOW :
2014-12-19 06:59:46 +00:00
# ifdef DBG_CONFIG_ERROR_DETECT
{
2014-12-17 04:09:56 +00:00
HAL_DATA_TYPE * pHalData = GET_HAL_DATA ( padapter ) ;
2014-12-19 06:59:46 +00:00
pHalData - > srestpriv . Wifi_Error_Status = USB_READ_PORT_FAIL ;
2014-12-17 04:09:56 +00:00
}
# endif
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = true ;
2014-12-19 06:59:46 +00:00
rtw_read_port ( padapter , precvpriv - > ff_hwaddr , 0 , ( unsigned char * ) precvbuf ) ;
2014-12-17 04:09:56 +00:00
break ;
case - EINPROGRESS :
DBG_8192C ( " ERROR: URB IS IN PROGRESS!/n " ) ;
break ;
default :
2014-12-19 06:59:46 +00:00
break ;
2014-12-17 04:09:56 +00:00
}
2014-12-19 06:59:46 +00:00
}
exit :
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
static u32 usb_read_port ( struct intf_hdl * pintfhdl , u32 addr , u32 cnt , u8 * rmem )
2014-12-19 06:59:46 +00:00
{
2014-12-17 04:09:56 +00:00
_irqL irqL ;
int err ;
unsigned int pipe ;
SIZE_PTR tmpaddr = 0 ;
SIZE_PTR alignment = 0 ;
u32 ret = _SUCCESS ;
PURB purb = NULL ;
2013-05-08 21:45:39 +00:00
struct recv_buf * precvbuf = ( struct recv_buf * ) rmem ;
2014-12-17 23:13:53 +00:00
struct adapter * adapter = pintfhdl - > padapter ;
2013-05-08 21:45:39 +00:00
struct dvobj_priv * pdvobj = adapter_to_dvobj ( adapter ) ;
struct recv_priv * precvpriv = & adapter - > recvpriv ;
struct usb_device * pusbd = pdvobj - > pusbdev ;
2014-12-19 06:59:46 +00:00
2013-05-19 04:28:07 +00:00
2015-01-26 22:20:25 +00:00
;
2014-12-19 06:59:46 +00:00
2014-12-17 04:09:56 +00:00
if ( adapter - > bDriverStopped | | adapter - > bSurpriseRemoved | | dvobj_to_pwrctl ( pdvobj ) - > pnp_bstop_trx )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||pwrctl->pnp_bstop_trx)!!! \n " ) ) ;
2013-05-08 21:45:39 +00:00
return _FAIL ;
}
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_PREALLOC_RECV_SKB
2014-12-29 02:13:24 +00:00
if ( ( precvbuf - > reuse = = false ) | | ( precvbuf - > pskb = = NULL ) )
2014-12-17 04:09:56 +00:00
{
if ( NULL ! = ( precvbuf - > pskb = skb_dequeue ( & precvpriv - > free_recv_skb_queue ) ) )
{
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = true ;
2014-12-17 04:09:56 +00:00
}
2013-11-29 22:10:20 +00:00
}
2014-12-17 04:09:56 +00:00
# endif
2014-12-19 06:59:46 +00:00
2013-11-29 22:10:20 +00:00
2014-12-17 04:09:56 +00:00
if ( precvbuf ! = NULL )
2014-12-19 06:59:46 +00:00
{
rtl8188eu_init_recvbuf ( adapter , precvbuf ) ;
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
//re-assign for linux based on skb
2014-12-29 02:13:24 +00:00
if ( ( precvbuf - > reuse = = false ) | | ( precvbuf - > pskb = = NULL ) )
2014-12-17 04:09:56 +00:00
{
precvbuf - > pskb = rtw_skb_alloc ( MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ ) ;
2013-05-08 21:45:39 +00:00
2014-12-19 06:59:46 +00:00
if ( precvbuf - > pskb = = NULL )
2014-12-17 04:09:56 +00:00
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " init_recvbuf(): alloc_skb fail! \n " ) ) ;
DBG_8192C ( " #### usb_read_port() alloc_skb fail!##### \n " ) ;
2013-10-19 17:45:47 +00:00
return _FAIL ;
2014-12-19 06:59:46 +00:00
}
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
tmpaddr = ( SIZE_PTR ) precvbuf - > pskb - > data ;
2014-12-19 06:59:46 +00:00
alignment = tmpaddr & ( RECVBUFF_ALIGN_SZ - 1 ) ;
2013-10-19 17:45:47 +00:00
skb_reserve ( precvbuf - > pskb , ( RECVBUFF_ALIGN_SZ - alignment ) ) ;
precvbuf - > phead = precvbuf - > pskb - > head ;
2014-12-19 06:59:46 +00:00
precvbuf - > pdata = precvbuf - > pskb - > data ;
2013-10-19 17:45:47 +00:00
precvbuf - > ptail = skb_tail_pointer ( precvbuf - > pskb ) ;
precvbuf - > pend = skb_end_pointer ( precvbuf - > pskb ) ;
precvbuf - > pbuf = precvbuf - > pskb - > data ;
2014-12-19 06:59:46 +00:00
}
2014-12-17 04:09:56 +00:00
else //reuse skb
{
2013-10-19 17:45:47 +00:00
precvbuf - > phead = precvbuf - > pskb - > head ;
precvbuf - > pdata = precvbuf - > pskb - > data ;
precvbuf - > ptail = skb_tail_pointer ( precvbuf - > pskb ) ;
precvbuf - > pend = skb_end_pointer ( precvbuf - > pskb ) ;
2014-12-19 06:59:46 +00:00
precvbuf - > pbuf = precvbuf - > pskb - > data ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
precvbuf - > reuse = false ;
2013-10-19 17:45:47 +00:00
}
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
//_enter_critical(&precvpriv->lock, &irqL);
//precvpriv->rx_pending_cnt++;
2014-12-29 02:13:24 +00:00
//precvbuf->irp_pending = true;
2014-12-17 04:09:56 +00:00
//_exit_critical(&precvpriv->lock, &irqL);
2013-10-19 17:45:47 +00:00
precvpriv - > rx_pending_cnt + + ;
2013-05-08 21:45:39 +00:00
2013-10-19 17:45:47 +00:00
purb = precvbuf - > purb ;
2013-05-08 21:45:39 +00:00
2014-12-17 04:09:56 +00:00
//translate DMA FIFO addr to pipehandle
2013-10-19 17:45:47 +00:00
pipe = ffaddr2pipehdl ( pdvobj , addr ) ;
2013-09-05 22:58:13 +00:00
2014-12-19 06:59:46 +00:00
usb_fill_bulk_urb ( purb , pusbd , pipe ,
2014-12-17 04:09:56 +00:00
precvbuf - > pbuf ,
2014-12-19 06:59:46 +00:00
MAX_RECVBUF_SZ ,
usb_read_port_complete ,
precvbuf ) ; //context is precvbuf
2013-10-19 17:45:47 +00:00
err = usb_submit_urb ( purb , GFP_ATOMIC ) ;
2014-12-17 04:09:56 +00:00
if ( ( err ) & & ( err ! = ( - EPERM ) ) )
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x " , err , purb - > status ) ) ;
DBG_8192C ( " cannot submit rx in-token(err = 0x%08x),urb_status = %d \n " , err , purb - > status ) ;
2013-10-19 17:45:47 +00:00
ret = _FAIL ;
}
2014-12-17 04:09:56 +00:00
}
else
{
RT_TRACE ( _module_hci_ops_os_c_ , _drv_err_ , ( " usb_read_port:precvbuf ==NULL \n " ) ) ;
ret = _FAIL ;
}
2015-01-26 22:20:25 +00:00
;
2013-05-08 21:45:39 +00:00
return ret ;
}
2014-12-17 04:09:56 +00:00
# endif // CONFIG_USE_USB_BUFFER_ALLOC_RX
2013-05-08 21:45:39 +00:00
void rtl8188eu_xmit_tasklet ( void * priv )
2014-12-19 06:59:46 +00:00
{
2014-12-29 02:13:24 +00:00
int ret = false ;
2014-12-17 23:13:53 +00:00
struct adapter * padapter = ( struct adapter * ) priv ;
2014-12-17 04:09:56 +00:00
struct xmit_priv * pxmitpriv = & padapter - > xmitpriv ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( check_fwstate ( & padapter - > mlmepriv , _FW_UNDER_SURVEY ) = = true )
2013-05-08 21:45:39 +00:00
return ;
2014-12-17 04:09:56 +00:00
while ( 1 )
{
2014-12-29 02:13:24 +00:00
if ( ( padapter - > bDriverStopped = = true ) | | ( padapter - > bSurpriseRemoved = = true ) | | ( padapter - > bWritePortCancel = = true ) )
2014-12-17 04:09:56 +00:00
{
DBG_8192C ( " xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel \n " ) ;
2013-05-08 21:45:39 +00:00
break ;
}
2014-12-17 04:09:56 +00:00
ret = rtl8188eu_xmitframe_complete ( padapter , pxmitpriv , NULL ) ;
2013-05-08 21:45:39 +00:00
2014-12-29 02:13:24 +00:00
if ( ret = = false )
2013-05-08 21:45:39 +00:00
break ;
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-19 06:59:46 +00:00
2013-05-08 21:45:39 +00:00
}
void rtl8188eu_set_intf_ops ( struct _io_ops * pops )
2014-12-19 06:59:46 +00:00
{
2015-01-26 22:20:25 +00:00
;
2014-12-17 04:09:56 +00:00
2014-12-19 06:59:46 +00:00
_rtw_memset ( ( u8 * ) pops , 0 , sizeof ( struct _io_ops ) ) ;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
pops - > _read8 = & usb_read8 ;
pops - > _read16 = & usb_read16 ;
pops - > _read32 = & usb_read32 ;
pops - > _read_mem = & usb_read_mem ;
2014-12-19 06:59:46 +00:00
pops - > _read_port = & usb_read_port ;
2013-05-08 21:45:39 +00:00
pops - > _write8 = & usb_write8 ;
pops - > _write16 = & usb_write16 ;
pops - > _write32 = & usb_write32 ;
pops - > _writeN = & usb_writeN ;
2014-12-19 06:59:46 +00:00
# ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
2014-12-17 04:09:56 +00:00
pops - > _write8_async = & usb_async_write8 ;
pops - > _write16_async = & usb_async_write16 ;
pops - > _write32_async = & usb_async_write32 ;
2014-12-19 06:59:46 +00:00
# endif
2013-05-08 21:45:39 +00:00
pops - > _write_mem = & usb_write_mem ;
pops - > _write_port = & usb_write_port ;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
pops - > _read_port_cancel = & usb_read_port_cancel ;
pops - > _write_port_cancel = & usb_write_port_cancel ;
2014-12-17 04:09:56 +00:00
# ifdef CONFIG_USB_INTERRUPT_IN_PIPE
pops - > _read_interrupt = & usb_read_interrupt ;
# endif
2015-01-26 22:20:25 +00:00
;
2014-12-17 04:09:56 +00:00
2013-05-08 21:45:39 +00:00
}
2014-12-17 23:13:53 +00:00
void rtl8188eu_set_hw_type ( struct adapter * padapter )
2013-05-08 21:45:39 +00:00
{
2014-12-17 04:09:56 +00:00
padapter - > chip_type = RTL8188E ;
padapter - > HardwareType = HARDWARE_TYPE_RTL8188EU ;
DBG_871X ( " CHIP TYPE: RTL8188E \n " ) ;
2013-05-08 21:45:39 +00:00
}