2010-09-08 21:46:36 +00:00
# include "headers.h"
2012-05-26 16:05:12 +00:00
static int BcmFileDownload ( struct bcm_mini_adapter * Adapter , const char * path , unsigned int loc ) ;
2012-10-19 02:40:08 +00:00
static void doPowerAutoCorrection ( struct bcm_mini_adapter * psAdapter ) ;
2012-05-26 16:05:12 +00:00
static void HandleShutDownModeRequest ( struct bcm_mini_adapter * Adapter , PUCHAR pucBuffer ) ;
static int bcm_parse_target_params ( struct bcm_mini_adapter * Adapter ) ;
static void beceem_protocol_reset ( struct bcm_mini_adapter * Adapter ) ;
2010-11-01 16:24:00 +00:00
2012-10-19 02:40:08 +00:00
static void default_wimax_protocol_initialize ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiLoopIndex ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
for ( uiLoopIndex = 0 ; uiLoopIndex < NO_OF_QUEUES - 1 ; uiLoopIndex + + ) {
Adapter - > PackInfo [ uiLoopIndex ] . uiThreshold = TX_PACKET_THRESHOLD ;
Adapter - > PackInfo [ uiLoopIndex ] . uiMaxAllowedRate = MAX_ALLOWED_RATE ;
Adapter - > PackInfo [ uiLoopIndex ] . uiMaxBucketSize = 20 * 1024 * 1024 ;
}
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
Adapter - > BEBucketSize = BE_BUCKET_SIZE ;
Adapter - > rtPSBucketSize = rtPS_BUCKET_SIZE ;
Adapter - > LinkStatus = SYNC_UP_REQUEST ;
Adapter - > TransferMode = IP_PACKET_ONLY_MODE ;
Adapter - > usBestEffortQueueIndex = - 1 ;
return ;
}
2010-09-08 21:46:36 +00:00
2012-10-19 02:40:13 +00:00
int InitAdapter ( struct bcm_mini_adapter * psAdapter )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
int i = 0 ;
2012-10-19 02:40:13 +00:00
int Status = STATUS_SUCCESS ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Initialising Adapter = %p " , psAdapter ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( psAdapter = = NULL ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Adapter is NULL " ) ;
2010-09-08 21:46:36 +00:00
return - EINVAL ;
}
2011-10-07 22:50:09 +00:00
sema_init ( & psAdapter - > NVMRdmWrmLock , 1 ) ;
2010-09-08 21:46:36 +00:00
sema_init ( & psAdapter - > rdmwrmsync , 1 ) ;
spin_lock_init ( & psAdapter - > control_queue_lock ) ;
spin_lock_init ( & psAdapter - > txtransmitlock ) ;
2011-10-07 22:50:09 +00:00
sema_init ( & psAdapter - > RxAppControlQueuelock , 1 ) ;
sema_init ( & psAdapter - > fw_download_sema , 1 ) ;
sema_init ( & psAdapter - > LowPowerModeSync , 1 ) ;
for ( i = 0 ; i < NO_OF_QUEUES ; i + + )
spin_lock_init ( & psAdapter - > PackInfo [ i ] . SFQueueLock ) ;
i = 0 ;
init_waitqueue_head ( & psAdapter - > process_rx_cntrlpkt ) ;
init_waitqueue_head ( & psAdapter - > tx_packet_wait_queue ) ;
init_waitqueue_head ( & psAdapter - > process_read_wait_queue ) ;
init_waitqueue_head ( & psAdapter - > ioctl_fw_dnld_wait_queue ) ;
init_waitqueue_head ( & psAdapter - > lowpower_mode_wait_queue ) ;
2010-09-08 21:46:36 +00:00
psAdapter - > waiting_to_fw_download_done = TRUE ;
2011-10-07 22:50:09 +00:00
psAdapter - > fw_download_done = FALSE ;
2010-09-08 21:46:36 +00:00
default_wimax_protocol_initialize ( psAdapter ) ;
2011-10-07 22:50:09 +00:00
for ( i = 0 ; i < MAX_CNTRL_PKTS ; i + + ) {
2010-11-10 20:31:38 +00:00
psAdapter - > txctlpacket [ i ] = kmalloc ( MAX_CNTL_PKT_SIZE , GFP_KERNEL ) ;
2011-10-07 22:50:09 +00:00
if ( ! psAdapter - > txctlpacket [ i ] ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " No More Cntl pkts got, max got is %d " , i ) ;
2010-09-08 21:46:36 +00:00
return - ENOMEM ;
}
}
2011-10-07 22:50:09 +00:00
if ( AllocAdapterDsxBuffer ( psAdapter ) ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Failed to allocate DSX buffers " ) ;
2010-09-08 21:46:36 +00:00
return - EINVAL ;
}
2011-10-07 22:50:09 +00:00
/* Initialize PHS interface */
if ( phs_init ( & psAdapter - > stBCMPhsContext , psAdapter ) ! = 0 ) {
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " %s:%s:%d:Error PHS Init Failed=====> \n " , __FILE__ , __func__ , __LINE__ ) ;
2010-09-08 21:46:36 +00:00
return - ENOMEM ;
}
Status = BcmAllocFlashCSStructure ( psAdapter ) ;
2011-10-07 22:50:09 +00:00
if ( Status ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Memory Allocation for Flash structure failed " ) ;
return Status ;
2010-09-08 21:46:36 +00:00
}
Status = vendorextnInit ( psAdapter ) ;
2011-10-07 22:50:09 +00:00
if ( STATUS_SUCCESS ! = Status ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Vendor Init Failed " ) ;
return Status ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Adapter initialised " ) ;
2010-09-08 21:46:36 +00:00
return STATUS_SUCCESS ;
}
2012-10-19 02:40:08 +00:00
void AdapterFree ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2010-11-01 13:52:14 +00:00
int count ;
2010-09-08 21:46:36 +00:00
beceem_protocol_reset ( Adapter ) ;
vendorextnExit ( Adapter ) ;
2011-10-07 22:50:09 +00:00
if ( Adapter - > control_packet_handler & & ! IS_ERR ( Adapter - > control_packet_handler ) )
kthread_stop ( Adapter - > control_packet_handler ) ;
2010-11-01 13:52:14 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > transmit_packet_thread & & ! IS_ERR ( Adapter - > transmit_packet_thread ) )
kthread_stop ( Adapter - > transmit_packet_thread ) ;
2010-11-01 13:52:14 +00:00
wake_up ( & Adapter - > process_read_wait_queue ) ;
2011-10-07 22:50:09 +00:00
if ( Adapter - > LEDInfo . led_thread_running & ( BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY ) )
kthread_stop ( Adapter - > LEDInfo . led_cntrl_threadid ) ;
2010-11-01 13:52:14 +00:00
2010-11-01 18:06:24 +00:00
unregister_networkdev ( Adapter ) ;
2010-11-01 13:52:14 +00:00
/* FIXME: use proper wait_event and refcounting */
2011-10-07 22:50:09 +00:00
while ( atomic_read ( & Adapter - > ApplicationRunning ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Waiting for Application to close.. %d \n " , atomic_read ( & Adapter - > ApplicationRunning ) ) ;
2010-09-08 21:46:36 +00:00
msleep ( 100 ) ;
}
unregister_control_device_interface ( Adapter ) ;
2010-11-01 13:52:14 +00:00
kfree ( Adapter - > pstargetparams ) ;
2011-10-07 22:50:09 +00:00
for ( count = 0 ; count < MAX_CNTRL_PKTS ; count + + )
2010-11-01 13:52:14 +00:00
kfree ( Adapter - > txctlpacket [ count ] ) ;
2010-09-08 21:46:36 +00:00
FreeAdapterDsxBuffer ( Adapter ) ;
2010-11-01 13:52:14 +00:00
kfree ( Adapter - > pvInterfaceAdapter ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
/* Free the PHS Interface */
2010-09-08 21:46:36 +00:00
PhsCleanup ( & Adapter - > stBCMPhsContext ) ;
BcmDeAllocFlashCSStructure ( Adapter ) ;
2010-11-01 13:52:14 +00:00
free_netdev ( Adapter - > dev ) ;
2010-09-08 21:46:36 +00:00
}
2012-05-26 16:05:12 +00:00
static int create_worker_threads ( struct bcm_mini_adapter * psAdapter )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
/* Rx Control Packets Processing */
2010-09-08 21:46:36 +00:00
psAdapter - > control_packet_handler = kthread_run ( ( int ( * ) ( void * ) )
2010-11-01 16:14:01 +00:00
control_packet_handler , psAdapter , " %s-rx " , DRV_NAME ) ;
2011-10-07 22:50:09 +00:00
if ( IS_ERR ( psAdapter - > control_packet_handler ) ) {
2010-11-01 16:14:01 +00:00
pr_notice ( DRV_NAME " : could not create control thread \n " ) ;
2010-09-08 21:46:36 +00:00
return PTR_ERR ( psAdapter - > control_packet_handler ) ;
}
2010-11-01 16:14:01 +00:00
2011-10-07 22:50:09 +00:00
/* Tx Thread */
2010-09-08 21:46:36 +00:00
psAdapter - > transmit_packet_thread = kthread_run ( ( int ( * ) ( void * ) )
2010-11-01 16:14:01 +00:00
tx_pkt_handler , psAdapter , " %s-tx " , DRV_NAME ) ;
2011-10-07 22:50:09 +00:00
if ( IS_ERR ( psAdapter - > transmit_packet_thread ) ) {
2010-11-01 16:14:01 +00:00
pr_notice ( DRV_NAME " : could not creat transmit thread \n " ) ;
2010-09-08 21:46:36 +00:00
kthread_stop ( psAdapter - > control_packet_handler ) ;
return PTR_ERR ( psAdapter - > transmit_packet_thread ) ;
}
return 0 ;
}
2012-05-26 16:05:12 +00:00
static struct file * open_firmware_file ( struct bcm_mini_adapter * Adapter , const char * path )
2010-09-08 21:46:36 +00:00
{
2012-07-22 17:02:01 +00:00
struct file * flp = filp_open ( path , O_RDONLY , S_IRWXU ) ;
2011-10-07 22:50:09 +00:00
if ( IS_ERR ( flp ) ) {
pr_err ( DRV_NAME " Unable To Open File %s, err %ld " , path , PTR_ERR ( flp ) ) ;
flp = NULL ;
}
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > device_removed )
flp = NULL ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
return flp ;
}
/* Arguments:
* Logical Adapter
* Path to image file
* Download Address on the chip
*/
2012-05-26 16:05:12 +00:00
static int BcmFileDownload ( struct bcm_mini_adapter * Adapter , const char * path , unsigned int loc )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
int errorno = 0 ;
struct file * flp = NULL ;
struct timeval tv = { 0 } ;
flp = open_firmware_file ( Adapter , path ) ;
if ( ! flp ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Unable to Open %s \n " , path ) ;
2012-07-22 17:02:01 +00:00
return - ENOENT ;
2011-10-07 22:50:09 +00:00
}
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Opened file is = %s and length =0x%lx to be downloaded at =0x%x " , path , ( unsigned long ) flp - > f_dentry - > d_inode - > i_size , loc ) ;
do_gettimeofday ( & tv ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " download start %lx " , ( ( tv . tv_sec * 1000 ) + ( tv . tv_usec / 1000 ) ) ) ;
if ( Adapter - > bcm_file_download ( Adapter - > pvInterfaceAdapter , flp , loc ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Failed to download the firmware with error %x!!! " , - EIO ) ;
errorno = - EIO ;
goto exit_download ;
}
vfs_llseek ( flp , 0 , 0 ) ;
if ( Adapter - > bcm_file_readback_from_chip ( Adapter - > pvInterfaceAdapter , flp , loc ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Failed to read back firmware! " ) ;
errorno = - EIO ;
goto exit_download ;
}
2010-09-08 21:46:36 +00:00
exit_download :
2012-07-22 17:02:01 +00:00
filp_close ( flp , NULL ) ;
2011-10-07 22:50:09 +00:00
return errorno ;
2010-09-08 21:46:36 +00:00
}
/**
2011-10-07 22:50:09 +00:00
* @ ingroup ctrl_pkt_functions
* This function copies the contents of given buffer
* to the control packet and queues it for transmission .
* @ note Do not acquire the spinock , as it it already acquired .
* @ return SUCCESS / FAILURE .
* Arguments :
* Logical Adapter
* Control Packet Buffer
*/
2012-10-19 02:40:13 +00:00
int CopyBufferToControlPacket ( struct bcm_mini_adapter * Adapter , void * ioBuffer )
2010-09-08 21:46:36 +00:00
{
2012-05-26 16:05:11 +00:00
struct bcm_leader * pLeader = NULL ;
2012-10-19 02:40:13 +00:00
int Status = 0 ;
2012-10-19 02:40:14 +00:00
unsigned char * ctrl_buff ;
2012-10-19 02:40:12 +00:00
unsigned int pktlen = 0 ;
2012-05-26 16:05:08 +00:00
struct bcm_link_request * pLinkReq = NULL ;
2011-10-07 22:50:09 +00:00
PUCHAR pucAddIndication = NULL ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " ======> " ) ;
if ( ! ioBuffer ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Got Null Buffer \n " ) ;
2010-09-08 21:46:36 +00:00
return - EINVAL ;
}
2012-05-26 16:05:08 +00:00
pLinkReq = ( struct bcm_link_request * ) ioBuffer ;
2012-05-26 16:05:11 +00:00
pLeader = ( struct bcm_leader * ) ioBuffer ; /* ioBuffer Contains sw_Status and Payload */
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > bShutStatus = = TRUE & &
2010-09-08 21:46:36 +00:00
pLinkReq - > szData [ 0 ] = = LINK_DOWN_REQ_PAYLOAD & &
2011-10-07 22:50:09 +00:00
pLinkReq - > szData [ 1 ] = = LINK_SYNC_UP_SUBTYPE ) {
/* Got sync down in SHUTDOWN..we could not process this. */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " SYNC DOWN Request in Shut Down Mode.. \n " ) ;
2010-09-08 21:46:36 +00:00
return STATUS_FAILURE ;
}
2011-10-07 22:50:09 +00:00
if ( ( pLeader - > Status = = LINK_UP_CONTROL_REQ ) & &
2010-09-08 21:46:36 +00:00
( ( pLinkReq - > szData [ 0 ] = = LINK_UP_REQ_PAYLOAD & &
2011-10-07 22:50:09 +00:00
( pLinkReq - > szData [ 1 ] = = LINK_SYNC_UP_SUBTYPE ) ) | | /* Sync Up Command */
pLinkReq - > szData [ 0 ] = = NETWORK_ENTRY_REQ_PAYLOAD ) ) /* Net Entry Command */ {
if ( Adapter - > LinkStatus > PHY_SYNC_ACHIVED ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " LinkStatus is Greater than PHY_SYN_ACHIEVED " ) ;
2010-09-08 21:46:36 +00:00
return STATUS_FAILURE ;
}
2011-10-07 22:50:09 +00:00
2012-10-19 02:40:15 +00:00
if ( Adapter - > bShutStatus = = TRUE ) {
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " SYNC UP IN SHUTDOWN..Device WakeUp \n " ) ;
if ( Adapter - > bTriedToWakeUpFromlowPowerMode = = FALSE ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Waking up for the First Time.. \n " ) ;
Adapter - > usIdleModePattern = ABORT_SHUTDOWN_MODE ; /* change it to 1 for current support. */
2010-09-08 21:46:36 +00:00
Adapter - > bWakeUpDevice = TRUE ;
wake_up ( & Adapter - > process_rx_cntrlpkt ) ;
2011-10-07 22:50:09 +00:00
Status = wait_event_interruptible_timeout ( Adapter - > lowpower_mode_wait_queue , ! Adapter - > bShutStatus , ( 5 * HZ ) ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Status = = - ERESTARTSYS )
2010-09-08 21:46:36 +00:00
return Status ;
2011-10-07 22:50:09 +00:00
if ( Adapter - > bShutStatus ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Shutdown Mode Wake up Failed - No Wake Up Received \n " ) ;
2010-09-08 21:46:36 +00:00
return STATUS_FAILURE ;
}
2011-10-07 22:50:09 +00:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Wakeup has been tried already... \n " ) ;
2010-09-08 21:46:36 +00:00
}
}
}
2012-10-19 02:40:15 +00:00
if ( Adapter - > IdleMode = = TRUE ) {
2011-10-07 22:50:09 +00:00
/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence\n"); */
if ( pLeader - > Status = = LINK_UP_CONTROL_REQ | | pLeader - > Status = = 0x80 | |
pLeader - > Status = = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ ) {
if ( ( pLeader - > Status = = LINK_UP_CONTROL_REQ ) & & ( pLinkReq - > szData [ 0 ] = = LINK_DOWN_REQ_PAYLOAD ) ) {
if ( ( pLinkReq - > szData [ 1 ] = = LINK_SYNC_DOWN_SUBTYPE ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Link Down Sent in Idle Mode \n " ) ;
Adapter - > usIdleModePattern = ABORT_IDLE_SYNCDOWN ; /* LINK DOWN sent in Idle Mode */
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " ABORT_IDLE_MODE pattern is being written \n " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > usIdleModePattern = ABORT_IDLE_REG ;
}
2011-10-07 22:50:09 +00:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " ABORT_IDLE_MODE pattern is being written \n " ) ;
Adapter - > usIdleModePattern = ABORT_IDLE_MODE ;
2010-09-08 21:46:36 +00:00
}
/*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
2011-10-07 22:50:09 +00:00
* the wake up from idlemode is from host
*/
/* Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE; */
2010-09-08 21:46:36 +00:00
Adapter - > bWakeUpDevice = TRUE ;
wake_up ( & Adapter - > process_rx_cntrlpkt ) ;
2011-10-07 22:50:09 +00:00
/* We should not send DREG message down while in idlemode. */
if ( LINK_DOWN_REQ_PAYLOAD = = pLinkReq - > szData [ 0 ] )
2010-09-08 21:46:36 +00:00
return STATUS_SUCCESS ;
2011-10-07 22:50:09 +00:00
Status = wait_event_interruptible_timeout ( Adapter - > lowpower_mode_wait_queue , ! Adapter - > IdleMode , ( 5 * HZ ) ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Status = = - ERESTARTSYS )
2010-09-08 21:46:36 +00:00
return Status ;
2011-10-07 22:50:09 +00:00
if ( Adapter - > IdleMode ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Idle Mode Wake up Failed - No Wake Up Received \n " ) ;
2010-09-08 21:46:36 +00:00
return STATUS_FAILURE ;
}
2011-10-07 22:50:09 +00:00
} else {
2010-09-08 21:46:36 +00:00
return STATUS_SUCCESS ;
2011-10-07 22:50:09 +00:00
}
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
/* The Driver has to send control messages with a particular VCID */
pLeader - > Vcid = VCID_CONTROL_PACKET ; /* VCID for control packet. */
2010-09-08 21:46:36 +00:00
/* Allocate skb for Control Packet */
pktlen = pLeader - > PLength ;
ctrl_buff = ( char * ) Adapter - > txctlpacket [ atomic_read ( & Adapter - > index_wr_txcntrlpkt ) % MAX_CNTRL_PKTS ] ;
2012-10-19 02:40:14 +00:00
if ( ! ctrl_buff ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " mem allocation Failed " ) ;
return - ENOMEM ;
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x " ,
atomic_read ( & Adapter - > index_wr_txcntrlpkt ) , ctrl_buff , ioBuffer , pktlen ) ;
2012-10-19 02:40:14 +00:00
if ( pLeader ) {
if ( ( pLeader - > Status = = 0x80 ) | |
( pLeader - > Status = = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ ) ) {
/*
* Restructure the DSX message to handle Multiple classifier Support
* Write the Service Flow param Structures directly to the target
* and embed the pointers in the DSX messages sent to target .
*/
/* Lets store the current length of the control packet we are transmitting */
pucAddIndication = ( PUCHAR ) ioBuffer + LEADER_SIZE ;
pktlen = pLeader - > PLength ;
Status = StoreCmControlResponseMessage ( Adapter , pucAddIndication , & pktlen ) ;
if ( Status ! = 1 ) {
2012-10-31 01:50:43 +00:00
ClearTargetDSXBuffer ( Adapter , ( ( struct bcm_add_indication_alt * ) pucAddIndication ) - > u16TID , FALSE ) ;
2012-10-19 02:40:14 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly " ) ;
return STATUS_FAILURE ;
2010-09-08 21:46:36 +00:00
}
2012-10-19 02:40:14 +00:00
/*
* update the leader to use the new length
* The length of the control packet is length of message being sent + Leader length
*/
pLeader - > PLength = pktlen ;
2010-09-08 21:46:36 +00:00
}
}
2012-10-19 02:40:14 +00:00
if ( pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE )
return - EINVAL ;
memset ( ctrl_buff , 0 , pktlen + LEADER_SIZE ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Copying the Control Packet Buffer with length=%d \n " , pLeader - > PLength ) ;
* ( struct bcm_leader * ) ctrl_buff = * pLeader ;
memcpy ( ctrl_buff + LEADER_SIZE , ( ( PUCHAR ) ioBuffer + LEADER_SIZE ) , pLeader - > PLength ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Enqueuing the Control Packet " ) ;
/* Update the statistics counters */
spin_lock_bh ( & Adapter - > PackInfo [ HiPriority ] . SFQueueLock ) ;
Adapter - > PackInfo [ HiPriority ] . uiCurrentBytesOnHost + = pLeader - > PLength ;
Adapter - > PackInfo [ HiPriority ] . uiCurrentPacketsOnHost + + ;
atomic_inc ( & Adapter - > TotalPacketCount ) ;
spin_unlock_bh ( & Adapter - > PackInfo [ HiPriority ] . SFQueueLock ) ;
Adapter - > PackInfo [ HiPriority ] . bValid = TRUE ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " CurrBytesOnHost: %x bValid: %x " ,
Adapter - > PackInfo [ HiPriority ] . uiCurrentBytesOnHost ,
Adapter - > PackInfo [ HiPriority ] . bValid ) ;
Status = STATUS_SUCCESS ;
/*Queue the packet for transmission */
atomic_inc ( & Adapter - > index_wr_txcntrlpkt ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " Calling transmit_packets " ) ;
atomic_set ( & Adapter - > TxPktAvail , 1 ) ;
wake_up ( & Adapter - > tx_packet_wait_queue ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_TX , TX_CONTROL , DBG_LVL_ALL , " <==== " ) ;
2010-09-08 21:46:36 +00:00
return Status ;
}
/******************************************************************
* Function - LinkMessage ( )
*
* Description - This function builds the Sync - up and Link - up request
2011-10-07 22:50:09 +00:00
* packet messages depending on the device Link status .
2010-09-08 21:46:36 +00:00
*
* Parameters - Adapter : Pointer to the Adapter structure .
*
* Returns - None .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-10-19 02:40:08 +00:00
void LinkMessage ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-05-26 16:05:08 +00:00
struct bcm_link_request * pstLinkRequest = NULL ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " =====> " ) ;
if ( Adapter - > LinkStatus = = SYNC_UP_REQUEST & & Adapter - > AutoSyncup ) {
2012-05-26 16:05:08 +00:00
pstLinkRequest = kzalloc ( sizeof ( struct bcm_link_request ) , GFP_ATOMIC ) ;
2011-10-07 22:50:09 +00:00
if ( ! pstLinkRequest ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " Can not allocate memory for Link request! " ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2011-10-07 22:50:09 +00:00
/* sync up request... */
Adapter - > LinkStatus = WAIT_FOR_SYNC ; /* current link status */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " Requesting For SyncUp... " ) ;
pstLinkRequest - > szData [ 0 ] = LINK_UP_REQ_PAYLOAD ;
pstLinkRequest - > szData [ 1 ] = LINK_SYNC_UP_SUBTYPE ;
pstLinkRequest - > Leader . Status = LINK_UP_CONTROL_REQ ;
pstLinkRequest - > Leader . PLength = sizeof ( ULONG ) ;
2010-09-08 21:46:36 +00:00
Adapter - > bSyncUpRequestSent = TRUE ;
2011-10-07 22:50:09 +00:00
} else if ( Adapter - > LinkStatus = = PHY_SYNC_ACHIVED & & Adapter - > AutoLinkUp ) {
2012-05-26 16:05:08 +00:00
pstLinkRequest = kzalloc ( sizeof ( struct bcm_link_request ) , GFP_ATOMIC ) ;
2011-10-07 22:50:09 +00:00
if ( ! pstLinkRequest ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " Can not allocate memory for Link request! " ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2011-10-07 22:50:09 +00:00
/* LINK_UP_REQUEST */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " Requesting For LinkUp... " ) ;
pstLinkRequest - > szData [ 0 ] = LINK_UP_REQ_PAYLOAD ;
pstLinkRequest - > szData [ 1 ] = LINK_NET_ENTRY ;
pstLinkRequest - > Leader . Status = LINK_UP_CONTROL_REQ ;
pstLinkRequest - > Leader . PLength = sizeof ( ULONG ) ;
}
if ( pstLinkRequest ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " Calling CopyBufferToControlPacket " ) ;
2010-09-08 21:46:36 +00:00
CopyBufferToControlPacket ( Adapter , pstLinkRequest ) ;
2010-11-01 13:35:21 +00:00
kfree ( pstLinkRequest ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , LINK_UP_MSG , DBG_LVL_ALL , " LinkMessage <===== " ) ;
2010-09-08 21:46:36 +00:00
return ;
}
/**********************************************************************
* Function - StatisticsResponse ( )
*
* Description - This function handles the Statistics response packet .
*
* Parameters - Adapter : Pointer to the Adapter structure .
2011-10-07 22:50:09 +00:00
* - pvBuffer : Starting address of Statistic response data .
2010-09-08 21:46:36 +00:00
*
* Returns - None .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-10-19 02:40:08 +00:00
void StatisticsResponse ( struct bcm_mini_adapter * Adapter , void * pvBuffer )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " %s====> " , __func__ ) ;
2010-11-01 15:14:29 +00:00
Adapter - > StatisticsPointer = ntohl ( * ( __be32 * ) pvBuffer ) ;
2012-10-19 02:40:12 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Stats at %x " , ( unsigned int ) Adapter - > StatisticsPointer ) ;
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " %s <==== " , __func__ ) ;
2010-09-08 21:46:36 +00:00
return ;
}
/**********************************************************************
* Function - LinkControlResponseMessage ( )
*
* Description - This function handles the Link response packets .
*
* Parameters - Adapter : Pointer to the Adapter structure .
2011-10-07 22:50:09 +00:00
* - pucBuffer : Starting address of Link response data .
2010-09-08 21:46:36 +00:00
*
* Returns - None .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-10-19 02:40:08 +00:00
void LinkControlResponseMessage ( struct bcm_mini_adapter * Adapter , PUCHAR pucBuffer )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " =====> " ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( * pucBuffer = = LINK_UP_ACK ) {
switch ( * ( pucBuffer + 1 ) ) {
case PHY_SYNC_ACHIVED : /* SYNCed UP */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " PHY_SYNC_ACHIVED " ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > LinkStatus = = LINKUP_DONE )
2010-09-08 21:46:36 +00:00
beceem_protocol_reset ( Adapter ) ;
2011-10-07 22:50:09 +00:00
Adapter - > usBestEffortQueueIndex = INVALID_QUEUE_INDEX ;
Adapter - > LinkStatus = PHY_SYNC_ACHIVED ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2010-09-08 21:46:36 +00:00
Adapter - > DriverState = NO_NETWORK_ENTRY ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
}
LinkMessage ( Adapter ) ;
break ;
2011-10-07 22:50:09 +00:00
case LINKUP_DONE :
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " LINKUP_DONE " ) ;
Adapter - > LinkStatus = LINKUP_DONE ;
Adapter - > bPHSEnabled = * ( pucBuffer + 3 ) ;
Adapter - > bETHCSEnabled = * ( pucBuffer + 4 ) & ETH_CS_MASK ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " PHS Support Status Received In LinkUp Ack : %x \n " , Adapter - > bPHSEnabled ) ;
if ( ( FALSE = = Adapter - > bShutStatus ) & & ( FALSE = = Adapter - > IdleMode ) ) {
if ( Adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
Adapter - > DriverState = NORMAL_OPERATION ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
}
LinkMessage ( Adapter ) ;
break ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
case WAIT_FOR_SYNC :
/*
* Driver to ignore the DREG_RECEIVED
* WiMAX Application should handle this Message
*/
/* Adapter->liTimeSinceLastNetEntry = 0; */
Adapter - > LinkUpStatus = 0 ;
Adapter - > LinkStatus = 0 ;
Adapter - > usBestEffortQueueIndex = INVALID_QUEUE_INDEX ;
Adapter - > bTriedToWakeUpFromlowPowerMode = FALSE ;
Adapter - > IdleMode = FALSE ;
beceem_protocol_reset ( Adapter ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
break ;
case LINK_SHUTDOWN_REQ_FROM_FIRMWARE :
case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW :
{
HandleShutDownModeRequest ( Adapter , pucBuffer ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
break ;
default :
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " default case:LinkResponse %x " , * ( pucBuffer + 1 ) ) ;
break ;
}
} else if ( SET_MAC_ADDRESS_RESPONSE = = * pucBuffer ) {
2010-09-08 21:46:36 +00:00
PUCHAR puMacAddr = ( pucBuffer + 1 ) ;
2011-10-07 22:50:09 +00:00
Adapter - > LinkStatus = SYNC_UP_REQUEST ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " MAC address response, sending SYNC_UP " ) ;
2010-09-08 21:46:36 +00:00
LinkMessage ( Adapter ) ;
memcpy ( Adapter - > dev - > dev_addr , puMacAddr , MAC_ADDRESS_SIZE ) ;
}
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " %s <===== " , __func__ ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2012-05-26 16:05:12 +00:00
void SendIdleModeResponse ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:13 +00:00
int status = 0 , NVMAccess = 0 , lowPwrAbortMsg = 0 ;
2010-09-08 21:46:36 +00:00
struct timeval tv ;
2012-05-26 16:05:08 +00:00
struct bcm_link_request stIdleResponse = { { 0 } } ;
2010-09-08 21:46:36 +00:00
memset ( & tv , 0 , sizeof ( tv ) ) ;
2011-10-07 22:50:09 +00:00
stIdleResponse . Leader . Status = IDLE_MESSAGE ;
2010-09-08 21:46:36 +00:00
stIdleResponse . Leader . PLength = IDLE_MODE_PAYLOAD_LENGTH ;
stIdleResponse . szData [ 0 ] = GO_TO_IDLE_MODE_PAYLOAD ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " ============> " ) ;
2010-09-08 21:46:36 +00:00
/*********************************
2011-10-07 22:50:09 +00:00
* down_trylock -
* if [ semaphore is available ]
* acquire semaphone and return value 0 ;
* else
* return non - zero value ;
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-08 21:46:36 +00:00
NVMAccess = down_trylock ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
lowPwrAbortMsg = down_trylock ( & Adapter - > LowPowerModeSync ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ( NVMAccess | | lowPwrAbortMsg | | atomic_read ( & Adapter - > TotalPacketCount ) ) & &
( Adapter - > ulPowerSaveMode ! = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE ) ) {
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ! NVMAccess )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
if ( ! lowPwrAbortMsg )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > LowPowerModeSync ) ;
2011-10-07 22:50:09 +00:00
stIdleResponse . szData [ 1 ] = TARGET_CAN_NOT_GO_TO_IDLE_MODE ; /* NACK- device access is going on. */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " HOST IS NACKING Idle mode To F/W!!!!!!!! " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > bPreparingForLowPowerMode = FALSE ;
2011-10-07 22:50:09 +00:00
} else {
stIdleResponse . szData [ 1 ] = TARGET_CAN_GO_TO_IDLE_MODE ; /* 2; Idle ACK */
2010-09-08 21:46:36 +00:00
Adapter - > StatisticsPointer = 0 ;
/* Wait for the LED to TURN OFF before sending ACK response */
2011-10-07 22:50:09 +00:00
if ( Adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2012-10-19 02:40:13 +00:00
int iRetVal = 0 ;
2010-09-08 21:46:36 +00:00
/* Wake the LED Thread with IDLEMODE_ENTER State */
Adapter - > DriverState = LOWPOWER_MODE_ENTER ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld " , jiffies ) ;
2010-09-08 21:46:36 +00:00
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
/* Wait for 1 SEC for LED to OFF */
2011-10-07 22:50:09 +00:00
iRetVal = wait_event_timeout ( Adapter - > LEDInfo . idleModeSyncEvent , Adapter - > LEDInfo . bIdle_led_off , msecs_to_jiffies ( 1000 ) ) ;
2010-09-08 21:46:36 +00:00
/* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
2011-10-07 22:50:09 +00:00
if ( iRetVal < = 0 ) {
stIdleResponse . szData [ 1 ] = TARGET_CAN_NOT_GO_TO_IDLE_MODE ; /* NACK- device access is going on. */
2010-09-08 21:46:36 +00:00
Adapter - > DriverState = NORMAL_OPERATION ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " NACKING Idle mode as time out happen from LED side!!!!!!!! " ) ;
2010-09-08 21:46:36 +00:00
}
}
2011-10-07 22:50:09 +00:00
if ( stIdleResponse . szData [ 1 ] = = TARGET_CAN_GO_TO_IDLE_MODE ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " ACKING IDLE MODE !!!!!!!!! " ) ;
2010-09-08 21:46:36 +00:00
down ( & Adapter - > rdmwrmsync ) ;
Adapter - > bPreparingForLowPowerMode = TRUE ;
up ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
/* Killing all URBS. */
if ( Adapter - > bDoSuspend = = TRUE )
2012-11-02 03:42:21 +00:00
Bcm_kill_all_URBs ( ( struct bcm_interface_adapter * ) ( Adapter - > pvInterfaceAdapter ) ) ;
2011-10-07 22:50:09 +00:00
} else {
2010-09-08 21:46:36 +00:00
Adapter - > bPreparingForLowPowerMode = FALSE ;
}
2011-10-07 22:50:09 +00:00
if ( ! NVMAccess )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
if ( ! lowPwrAbortMsg )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > LowPowerModeSync ) ;
}
2011-10-07 22:50:09 +00:00
status = CopyBufferToControlPacket ( Adapter , & stIdleResponse ) ;
if ( ( status ! = STATUS_SUCCESS ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " fail to send the Idle mode Request \n " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > bPreparingForLowPowerMode = FALSE ;
2012-11-02 03:42:21 +00:00
StartInterruptUrb ( ( struct bcm_interface_adapter * ) ( Adapter - > pvInterfaceAdapter ) ) ;
2010-09-08 21:46:36 +00:00
}
do_gettimeofday ( & tv ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_RX , RX_DPC , DBG_LVL_ALL , " IdleMode Msg submitter to Q :%ld ms " , tv . tv_sec * 1000 + tv . tv_usec / 1000 ) ;
2010-09-08 21:46:36 +00:00
}
/******************************************************************
* Function - DumpPackInfo ( )
*
* Description - This function dumps the all Queue ( PackInfo [ ] ) details .
*
* Parameters - Adapter : Pointer to the Adapter structure .
*
* Returns - None .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-10-19 02:40:08 +00:00
void DumpPackInfo ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiLoopIndex = 0 ;
unsigned int uiIndex = 0 ;
unsigned int uiClsfrIndex = 0 ;
2012-05-26 16:05:03 +00:00
struct bcm_classifier_rule * pstClassifierEntry = NULL ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
for ( uiLoopIndex = 0 ; uiLoopIndex < NO_OF_QUEUES ; uiLoopIndex + + ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " *********** Showing Details Of Queue %d***** ****** " , uiLoopIndex ) ;
if ( FALSE = = Adapter - > PackInfo [ uiLoopIndex ] . bValid ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " bValid is FALSE for %X index \n " , uiLoopIndex ) ;
2010-09-08 21:46:36 +00:00
continue ;
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Dumping SF Rule Entry For SFID %lX \n " , Adapter - > PackInfo [ uiLoopIndex ] . ulSFID ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ucDirection %X \n " , Adapter - > PackInfo [ uiLoopIndex ] . ucDirection ) ;
if ( Adapter - > PackInfo [ uiLoopIndex ] . ucIpVersion = = IPV6 )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Ipv6 Service Flow \n " ) ;
2010-09-08 21:46:36 +00:00
else
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Ipv4 Service Flow \n " ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " SF Traffic Priority %X \n " , Adapter - > PackInfo [ uiLoopIndex ] . u8TrafficPriority ) ;
for ( uiClsfrIndex = 0 ; uiClsfrIndex < MAX_CLASSIFIERS ; uiClsfrIndex + + ) {
2010-09-08 21:46:36 +00:00
pstClassifierEntry = & Adapter - > astClassifierTable [ uiClsfrIndex ] ;
2011-10-07 22:50:09 +00:00
if ( ! pstClassifierEntry - > bUsed )
2010-09-08 21:46:36 +00:00
continue ;
2011-10-07 22:50:09 +00:00
if ( pstClassifierEntry - > ulSFID ! = Adapter - > PackInfo [ uiLoopIndex ] . ulSFID )
2010-09-08 21:46:36 +00:00
continue ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X \n " , uiClsfrIndex , pstClassifierEntry - > uiClassifierRuleIndex ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X usVCID_Value : %X \n " , uiClsfrIndex , pstClassifierEntry - > usVCID_Value ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X bProtocolValid : %X \n " , uiClsfrIndex , pstClassifierEntry - > bProtocolValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X bTOSValid : %X \n " , uiClsfrIndex , pstClassifierEntry - > bTOSValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X bDestIpValid : %X \n " , uiClsfrIndex , pstClassifierEntry - > bDestIpValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Dumping Classifier Rule Entry For Index: %X bSrcIpValid : %X \n " , uiClsfrIndex , pstClassifierEntry - > bSrcIpValid ) ;
for ( uiIndex = 0 ; uiIndex < MAX_PORT_RANGE ; uiIndex + + ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t usSrcPortRangeLo:%X \n " , pstClassifierEntry - > usSrcPortRangeLo [ uiIndex ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t usSrcPortRangeHi:%X \n " , pstClassifierEntry - > usSrcPortRangeHi [ uiIndex ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t usDestPortRangeLo:%X \n " , pstClassifierEntry - > usDestPortRangeLo [ uiIndex ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t usDestPortRangeHi:%X \n " , pstClassifierEntry - > usDestPortRangeHi [ uiIndex ] ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ucIPSourceAddressLength : 0x%x \n " , pstClassifierEntry - > ucIPSourceAddressLength ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ucIPDestinationAddressLength : 0x%x \n " , pstClassifierEntry - > ucIPDestinationAddressLength ) ;
for ( uiIndex = 0 ; uiIndex < pstClassifierEntry - > ucIPSourceAddressLength ; uiIndex + + ) {
if ( Adapter - > PackInfo [ uiLoopIndex ] . ucIpVersion = = IPV6 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Ipv6 ulSrcIpAddr : \n " ) ;
2010-09-08 21:46:36 +00:00
DumpIpv6Address ( pstClassifierEntry - > stSrcIpAddress . ulIpv6Addr ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Ipv6 ulSrcIpMask : \n " ) ;
2010-09-08 21:46:36 +00:00
DumpIpv6Address ( pstClassifierEntry - > stSrcIpAddress . ulIpv6Mask ) ;
2011-10-07 22:50:09 +00:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ulSrcIpAddr:%lX \n " , pstClassifierEntry - > stSrcIpAddress . ulIpv4Addr [ uiIndex ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ulSrcIpMask:%lX \n " , pstClassifierEntry - > stSrcIpAddress . ulIpv4Mask [ uiIndex ] ) ;
2010-09-08 21:46:36 +00:00
}
}
2011-10-07 22:50:09 +00:00
for ( uiIndex = 0 ; uiIndex < pstClassifierEntry - > ucIPDestinationAddressLength ; uiIndex + + ) {
if ( Adapter - > PackInfo [ uiLoopIndex ] . ucIpVersion = = IPV6 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Ipv6 ulDestIpAddr : \n " ) ;
2010-09-08 21:46:36 +00:00
DumpIpv6Address ( pstClassifierEntry - > stDestIpAddress . ulIpv6Addr ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t Ipv6 ulDestIpMask : \n " ) ;
2010-09-08 21:46:36 +00:00
DumpIpv6Address ( pstClassifierEntry - > stDestIpAddress . ulIpv6Mask ) ;
2011-10-07 22:50:09 +00:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ulDestIpAddr:%lX \n " , pstClassifierEntry - > stDestIpAddress . ulIpv4Addr [ uiIndex ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ulDestIpMask:%lX \n " , pstClassifierEntry - > stDestIpAddress . ulIpv4Mask [ uiIndex ] ) ;
2010-09-08 21:46:36 +00:00
}
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t ucProtocol:0x%X \n " , pstClassifierEntry - > ucProtocol [ 0 ] ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " \t u8ClassifierRulePriority:%X \n " , pstClassifierEntry - > u8ClassifierRulePriority ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ulSFID:%lX \n " , Adapter - > PackInfo [ uiLoopIndex ] . ulSFID ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " usVCID_Value:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . usVCID_Value ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " PhsEnabled: 0x%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . bHeaderSuppressionEnabled ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiThreshold:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiThreshold ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " bValid:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . bValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " bActive:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . bActive ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ActivateReqSent: %x " , Adapter - > PackInfo [ uiLoopIndex ] . bActivateRequestSent ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " u8QueueType:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . u8QueueType ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiMaxBucketSize:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiMaxBucketSize ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiPerSFTxResourceCount:%X \n " , atomic_read ( & Adapter - > PackInfo [ uiLoopIndex ] . uiPerSFTxResourceCount ) ) ;
/* DumpDebug(DUMP_INFO,("bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport)); */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " CurrQueueDepthOnTarget: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiCurrentQueueDepthOnTarget ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiCurrentBytesOnHost:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiCurrentBytesOnHost ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiCurrentPacketsOnHost:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiCurrentPacketsOnHost ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiDroppedCountBytes:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiDroppedCountBytes ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiDroppedCountPackets:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiDroppedCountPackets ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiSentBytes:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiSentBytes ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiSentPackets:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiSentPackets ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiCurrentDrainRate:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiCurrentDrainRate ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiThisPeriodSentBytes:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiThisPeriodSentBytes ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " liDrainCalculated:%llX \n " , Adapter - > PackInfo [ uiLoopIndex ] . liDrainCalculated ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiCurrentTokenCount:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiCurrentTokenCount ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " liLastUpdateTokenAt:%llX \n " , Adapter - > PackInfo [ uiLoopIndex ] . liLastUpdateTokenAt ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiMaxAllowedRate:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiMaxAllowedRate ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiPendedLast:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiPendedLast ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " NumOfPacketsSent:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . NumOfPacketsSent ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Direction: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . ucDirection ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " CID: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . usCID ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ProtocolValid: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bProtocolValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " TOSValid: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bTOSValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " DestIpValid: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bDestIpValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " SrcIpValid: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bSrcIpValid ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ActiveSet: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bActiveSet ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " AdmittedSet: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bAdmittedSet ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " AuthzSet: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bAuthorizedSet ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " ClassifyPrority: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . bClassifierPriority ) ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiMaxLatency: %x \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiMaxLatency ) ;
2012-08-02 16:05:44 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO ,
DBG_LVL_ALL , " ServiceClassName: %*ph \n " ,
4 , Adapter - > PackInfo [ uiLoopIndex ] .
ucServiceClassName ) ;
2011-10-07 22:50:09 +00:00
/* BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiTotalTxBytes:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiTotalTxBytes ) ;
* BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " uiTotalRxBytes:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiTotalRxBytes ) ;
* DumpDebug ( DUMP_INFO , ( " uiRanOutOfResCount:%X \n " , Adapter - > PackInfo [ uiLoopIndex ] . uiRanOutOfResCount ) ) ;
*/
}
for ( uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex + + )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Adapter->aRxPktSizeHist[%x] = %x \n " , uiLoopIndex , Adapter - > aRxPktSizeHist [ uiLoopIndex ] ) ;
for ( uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex + + )
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , DUMP_INFO , DBG_LVL_ALL , " Adapter->aTxPktSizeHist[%x] = %x \n " , uiLoopIndex , Adapter - > aTxPktSizeHist [ uiLoopIndex ] ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2012-05-26 16:05:12 +00:00
int reset_card_proc ( struct bcm_mini_adapter * ps_adapter )
2010-09-08 21:46:36 +00:00
{
int retval = STATUS_SUCCESS ;
2012-05-26 16:05:12 +00:00
struct bcm_mini_adapter * Adapter = GET_BCM_ADAPTER ( gblpnetdev ) ;
2012-11-02 03:42:21 +00:00
struct bcm_interface_adapter * psIntfAdapter = NULL ;
2010-09-08 21:46:36 +00:00
unsigned int value = 0 , uiResetValue = 0 ;
2011-11-06 14:40:11 +00:00
int bytes ;
2010-09-08 21:46:36 +00:00
2012-11-02 03:42:21 +00:00
psIntfAdapter = ( ( struct bcm_interface_adapter * ) ( ps_adapter - > pvInterfaceAdapter ) ) ;
2010-09-08 21:46:36 +00:00
ps_adapter - > bDDRInitDone = FALSE ;
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > chip_id > = T3LPB ) {
/* SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before */
rdmalt ( ps_adapter , SYS_CFG , & value , sizeof ( value ) ) ;
rdmalt ( ps_adapter , SYS_CFG , & value , sizeof ( value ) ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
/* making bit[6...5] same as was before f/w download. this setting force the h/w to */
/* re-populated the SP RAM area with the string descriptor. */
value = value | ( ps_adapter - > syscfgBefFwDld & 0x00000060 ) ;
2010-09-08 21:46:36 +00:00
wrmalt ( ps_adapter , SYS_CFG , & value , sizeof ( value ) ) ;
}
2011-10-07 22:50:09 +00:00
/* killing all submitted URBs. */
psIntfAdapter - > psAdapter - > StopAllXaction = TRUE ;
2010-09-08 21:46:36 +00:00
Bcm_kill_all_URBs ( psIntfAdapter ) ;
/* Reset the UMA-B Device */
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > chip_id > = T3LPB ) {
2012-04-06 14:33:52 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Resetting UMA-B \n " ) ;
2010-09-08 21:46:36 +00:00
retval = usb_reset_device ( psIntfAdapter - > udev ) ;
2011-10-07 22:50:09 +00:00
psIntfAdapter - > psAdapter - > StopAllXaction = FALSE ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( retval ! = STATUS_SUCCESS ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Reset failed with ret value :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
2011-10-07 22:50:09 +00:00
2010-09-08 21:46:36 +00:00
if ( ps_adapter - > chip_id = = BCS220_2 | |
ps_adapter - > chip_id = = BCS220_2BC | |
ps_adapter - > chip_id = = BCS250_BC | |
2011-10-07 22:50:09 +00:00
ps_adapter - > chip_id = = BCS220_3 ) {
2011-11-06 14:40:11 +00:00
bytes = rdmalt ( ps_adapter , HPM_CONFIG_LDO145 , & value , sizeof ( value ) ) ;
if ( bytes < 0 ) {
retval = bytes ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " read failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
2011-10-07 22:50:09 +00:00
/* setting 0th bit */
2010-09-08 21:46:36 +00:00
value | = ( 1 < < 0 ) ;
retval = wrmalt ( ps_adapter , HPM_CONFIG_LDO145 , & value , sizeof ( value ) ) ;
2011-10-07 22:50:09 +00:00
if ( retval < 0 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " write failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
}
2011-10-07 22:50:09 +00:00
} else {
2011-11-06 14:40:11 +00:00
bytes = rdmalt ( ps_adapter , 0x0f007018 , & value , sizeof ( value ) ) ;
if ( bytes < 0 ) {
retval = bytes ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " read failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
2011-10-07 22:50:09 +00:00
value & = ( ~ ( 1 < < 16 ) ) ;
retval = wrmalt ( ps_adapter , 0x0f007018 , & value , sizeof ( value ) ) ;
if ( retval < 0 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " write failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
2011-10-07 22:50:09 +00:00
/* Toggling the GPIO 8, 9 */
2010-09-08 21:46:36 +00:00
value = 0 ;
retval = wrmalt ( ps_adapter , GPIO_OUTPUT_REGISTER , & value , sizeof ( value ) ) ;
2011-10-07 22:50:09 +00:00
if ( retval < 0 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " write failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
value = 0x300 ;
2011-10-07 22:50:09 +00:00
retval = wrmalt ( ps_adapter , GPIO_MODE_REGISTER , & value , sizeof ( value ) ) ;
if ( retval < 0 ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " write failed with status :%d " , retval ) ;
2010-09-08 21:46:36 +00:00
goto err_exit ;
}
mdelay ( 50 ) ;
}
2011-10-07 22:50:09 +00:00
/* ps_adapter->downloadDDR = false; */
if ( ps_adapter - > bFlashBoot ) {
/* In flash boot mode MIPS state register has reverse polarity.
* So just or with setting bit 30.
* Make the MIPS in Reset state .
*/
2010-09-08 21:46:36 +00:00
rdmalt ( ps_adapter , CLOCK_RESET_CNTRL_REG_1 , & uiResetValue , sizeof ( uiResetValue ) ) ;
2011-10-07 22:50:09 +00:00
uiResetValue | = ( 1 < < 30 ) ;
2010-09-08 21:46:36 +00:00
wrmalt ( ps_adapter , CLOCK_RESET_CNTRL_REG_1 , & uiResetValue , sizeof ( uiResetValue ) ) ;
}
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > chip_id > = T3LPB ) {
2010-09-08 21:46:36 +00:00
uiResetValue = 0 ;
2011-10-07 22:50:09 +00:00
/*
* WA for SYSConfig Issue .
* Read SYSCFG Twice to make it writable .
*/
2010-09-08 21:46:36 +00:00
rdmalt ( ps_adapter , SYS_CFG , & uiResetValue , sizeof ( uiResetValue ) ) ;
2011-10-07 22:50:09 +00:00
if ( uiResetValue & ( 1 < < 4 ) ) {
2010-09-08 21:46:36 +00:00
uiResetValue = 0 ;
2011-10-07 22:50:09 +00:00
rdmalt ( ps_adapter , SYS_CFG , & uiResetValue , sizeof ( uiResetValue ) ) ; /* 2nd read to make it writable. */
2010-09-08 21:46:36 +00:00
uiResetValue & = ( ~ ( 1 < < 4 ) ) ;
2011-10-07 22:50:09 +00:00
wrmalt ( ps_adapter , SYS_CFG , & uiResetValue , sizeof ( uiResetValue ) ) ;
2010-09-08 21:46:36 +00:00
}
}
uiResetValue = 0 ;
wrmalt ( ps_adapter , 0x0f01186c , & uiResetValue , sizeof ( uiResetValue ) ) ;
2011-10-07 22:50:09 +00:00
err_exit :
psIntfAdapter - > psAdapter - > StopAllXaction = FALSE ;
2010-09-08 21:46:36 +00:00
return retval ;
}
2012-05-26 16:05:12 +00:00
int run_card_proc ( struct bcm_mini_adapter * ps_adapter )
2010-09-08 21:46:36 +00:00
{
2011-11-06 14:40:11 +00:00
int status = STATUS_SUCCESS ;
int bytes ;
2011-10-07 22:50:09 +00:00
unsigned int value = 0 ;
2010-09-08 21:46:36 +00:00
{
2011-11-06 14:40:11 +00:00
bytes = rdmalt ( ps_adapter , CLOCK_RESET_CNTRL_REG_1 , & value , sizeof ( value ) ) ;
if ( bytes < 0 ) {
status = bytes ;
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " %s:%d \n " , __func__ , __LINE__ ) ;
2011-11-06 14:40:11 +00:00
return status ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > bFlashBoot )
value & = ( ~ ( 1 < < 30 ) ) ;
2010-09-08 21:46:36 +00:00
else
2011-10-07 22:50:09 +00:00
value | = ( 1 < < 30 ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( wrmalt ( ps_adapter , CLOCK_RESET_CNTRL_REG_1 , & value , sizeof ( value ) ) < 0 ) {
2011-10-07 22:50:10 +00:00
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " %s:%d \n " , __func__ , __LINE__ ) ;
2010-09-08 21:46:36 +00:00
return STATUS_FAILURE ;
}
}
2011-11-06 14:40:11 +00:00
return status ;
2010-09-08 21:46:36 +00:00
}
2012-05-26 16:05:12 +00:00
int InitCardAndDownloadFirmware ( struct bcm_mini_adapter * ps_adapter )
2010-09-08 21:46:36 +00:00
{
2010-11-13 08:24:22 +00:00
int status ;
2012-10-19 02:40:12 +00:00
unsigned int value = 0 ;
2010-09-08 21:46:36 +00:00
/*
2011-10-07 22:50:09 +00:00
* Create the threads first and then download the
* Firm / DDR Settings . .
*/
2010-11-01 16:14:01 +00:00
status = create_worker_threads ( ps_adapter ) ;
2011-10-07 22:50:09 +00:00
if ( status < 0 )
2010-09-08 21:46:36 +00:00
return status ;
2010-11-01 16:14:01 +00:00
2011-10-07 22:50:09 +00:00
status = bcm_parse_target_params ( ps_adapter ) ;
if ( status )
2010-09-08 21:46:36 +00:00
return status ;
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > chip_id > = T3LPB ) {
rdmalt ( ps_adapter , SYS_CFG , & value , sizeof ( value ) ) ;
ps_adapter - > syscfgBefFwDld = value ;
if ( ( value & 0x60 ) = = 0 )
2010-09-08 21:46:36 +00:00
ps_adapter - > bFlashBoot = TRUE ;
}
reset_card_proc ( ps_adapter ) ;
2011-10-07 22:50:09 +00:00
/* Initializing the NVM. */
2010-09-08 21:46:36 +00:00
BcmInitNVM ( ps_adapter ) ;
status = ddr_init ( ps_adapter ) ;
2011-10-07 22:50:09 +00:00
if ( status ) {
2010-11-01 16:14:01 +00:00
pr_err ( DRV_NAME " ddr_init Failed \n " ) ;
2010-09-08 21:46:36 +00:00
return status ;
}
/* Download cfg file */
status = buffDnldVerify ( ps_adapter ,
2011-10-07 22:50:09 +00:00
( PUCHAR ) ps_adapter - > pstargetparams ,
sizeof ( STARGETPARAMS ) ,
CONFIG_BEGIN_ADDR ) ;
if ( status ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Error downloading CFG file " ) ;
2010-09-08 21:46:36 +00:00
goto OUT ;
}
2011-10-07 22:50:09 +00:00
if ( register_networkdev ( ps_adapter ) ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Register Netdevice failed. Cleanup needs to be performed. " ) ;
2010-09-08 21:46:36 +00:00
return - EIO ;
}
2011-10-07 22:50:09 +00:00
if ( FALSE = = ps_adapter - > AutoFirmDld ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " AutoFirmDld Disabled in CFG File.. \n " ) ;
/* If Auto f/w download is disable, register the control interface, */
/* register the control interface after the mailbox. */
if ( register_control_device_interface ( ps_adapter ) < 0 ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Register Control Device failed. Cleanup needs to be performed. " ) ;
2010-09-08 21:46:36 +00:00
return - EIO ;
}
return STATUS_SUCCESS ;
}
/*
2011-10-07 22:50:09 +00:00
* Do the LED Settings here . It will be used by the Firmware Download
* Thread .
*/
2010-09-08 21:46:36 +00:00
/*
2011-10-07 22:50:09 +00:00
* 1. If the LED Settings fails , do not stop and do the Firmware download .
* 2. This init would happened only if the cfg file is present , else
* call from the ioctl context .
*/
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
status = InitLedSettings ( ps_adapter ) ;
if ( status ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_PRINTK , 0 , 0 , " INIT LED FAILED \n " ) ;
2010-09-08 21:46:36 +00:00
return status ;
}
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2010-09-08 21:46:36 +00:00
ps_adapter - > DriverState = DRIVER_INIT ;
wake_up ( & ps_adapter - > LEDInfo . notify_led_event ) ;
}
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2010-09-08 21:46:36 +00:00
ps_adapter - > DriverState = FW_DOWNLOAD ;
wake_up ( & ps_adapter - > LEDInfo . notify_led_event ) ;
}
value = 0 ;
wrmalt ( ps_adapter , EEPROM_CAL_DATA_INTERNAL_LOC - 4 , & value , sizeof ( value ) ) ;
wrmalt ( ps_adapter , EEPROM_CAL_DATA_INTERNAL_LOC - 8 , & value , sizeof ( value ) ) ;
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > eNVMType = = NVM_FLASH ) {
2010-09-08 21:46:36 +00:00
status = PropagateCalParamsFromFlashToMemory ( ps_adapter ) ;
2011-10-07 22:50:09 +00:00
if ( status ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Propagation of Cal param failed .. " ) ;
2010-09-08 21:46:36 +00:00
goto OUT ;
}
}
/* Download Firmare */
2011-10-07 22:50:12 +00:00
status = BcmFileDownload ( ps_adapter , BIN_FILE , FIRMWARE_BEGIN_ADDR ) ;
if ( status ! = 0 ) {
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " No Firmware File is present... \n " ) ;
2010-09-08 21:46:36 +00:00
goto OUT ;
}
status = run_card_proc ( ps_adapter ) ;
2011-10-07 22:50:09 +00:00
if ( status ) {
BCM_DEBUG_PRINT ( ps_adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " run_card_proc Failed \n " ) ;
2010-09-08 21:46:36 +00:00
goto OUT ;
}
ps_adapter - > fw_download_done = TRUE ;
mdelay ( 10 ) ;
OUT :
2011-10-07 22:50:09 +00:00
if ( ps_adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2010-09-08 21:46:36 +00:00
ps_adapter - > DriverState = FW_DOWNLOAD_DONE ;
wake_up ( & ps_adapter - > LEDInfo . notify_led_event ) ;
}
return status ;
}
2012-05-26 16:05:12 +00:00
static int bcm_parse_target_params ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
struct file * flp = NULL ;
2010-11-10 20:31:38 +00:00
char * buff ;
2010-09-08 21:46:36 +00:00
int len = 0 ;
2011-10-07 22:50:09 +00:00
buff = kmalloc ( BUFFER_1K , GFP_KERNEL ) ;
if ( ! buff )
2010-09-08 21:46:36 +00:00
return - ENOMEM ;
2011-10-07 22:50:09 +00:00
2011-10-07 22:50:11 +00:00
Adapter - > pstargetparams = kmalloc ( sizeof ( STARGETPARAMS ) , GFP_KERNEL ) ;
if ( Adapter - > pstargetparams = = NULL ) {
2010-11-01 13:35:21 +00:00
kfree ( buff ) ;
2010-09-08 21:46:36 +00:00
return - ENOMEM ;
}
2011-10-07 22:50:09 +00:00
flp = open_firmware_file ( Adapter , CFG_FILE ) ;
if ( ! flp ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " NOT ABLE TO OPEN THE %s FILE \n " , CFG_FILE ) ;
2010-11-01 13:35:21 +00:00
kfree ( buff ) ;
kfree ( Adapter - > pstargetparams ) ;
2010-09-08 21:46:36 +00:00
Adapter - > pstargetparams = NULL ;
return - ENOENT ;
}
2012-07-22 17:02:01 +00:00
len = kernel_read ( flp , 0 , buff , BUFFER_1K ) ;
filp_close ( flp , NULL ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( len ! = sizeof ( STARGETPARAMS ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Mismatch in Target Param Structure! \n " ) ;
2010-11-01 13:35:21 +00:00
kfree ( buff ) ;
kfree ( Adapter - > pstargetparams ) ;
2010-09-08 21:46:36 +00:00
Adapter - > pstargetparams = NULL ;
return - ENOENT ;
}
/* Check for autolink in config params */
/*
* Values in Adapter - > pstargetparams are in network byte order
*/
memcpy ( Adapter - > pstargetparams , buff , sizeof ( STARGETPARAMS ) ) ;
2011-10-07 22:50:09 +00:00
kfree ( buff ) ;
2010-09-08 21:46:36 +00:00
beceem_parse_target_struct ( Adapter ) ;
return STATUS_SUCCESS ;
}
2012-05-26 16:05:12 +00:00
void beceem_parse_target_struct ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiHostDrvrCfg6 = 0 , uiEEPROMFlag = 0 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ntohl ( Adapter - > pstargetparams - > m_u32PhyParameter2 ) & AUTO_SYNC_DISABLE ) {
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : AutoSyncup is Disabled \n " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > AutoSyncup = FALSE ;
2011-10-07 22:50:09 +00:00
} else {
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : AutoSyncup is Enabled \n " ) ;
2011-10-07 22:50:09 +00:00
Adapter - > AutoSyncup = TRUE ;
2010-09-08 21:46:36 +00:00
}
2010-11-01 16:14:01 +00:00
2011-10-07 22:50:09 +00:00
if ( ntohl ( Adapter - > pstargetparams - > HostDrvrConfig6 ) & AUTO_LINKUP_ENABLE ) {
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : Enabling autolink up " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > AutoLinkUp = TRUE ;
2011-10-07 22:50:09 +00:00
} else {
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : Disabling autolink up " ) ;
2010-09-08 21:46:36 +00:00
Adapter - > AutoLinkUp = FALSE ;
}
2011-10-07 22:50:09 +00:00
/* Setting the DDR Setting.. */
Adapter - > DDRSetting = ( ntohl ( Adapter - > pstargetparams - > HostDrvrConfig6 ) > > 8 ) & 0x0F ;
Adapter - > ulPowerSaveMode = ( ntohl ( Adapter - > pstargetparams - > HostDrvrConfig6 ) > > 12 ) & 0x0F ;
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : DDR Setting: %x \n " , Adapter - > DDRSetting ) ;
pr_info ( DRV_NAME " : Power Save Mode: %lx \n " , Adapter - > ulPowerSaveMode ) ;
2011-10-07 22:50:09 +00:00
if ( ntohl ( Adapter - > pstargetparams - > HostDrvrConfig6 ) & AUTO_FIRM_DOWNLOAD ) {
pr_info ( DRV_NAME " : Enabling Auto Firmware Download \n " ) ;
Adapter - > AutoFirmDld = TRUE ;
} else {
pr_info ( DRV_NAME " : Disabling Auto Firmware Download \n " ) ;
Adapter - > AutoFirmDld = FALSE ;
}
2010-09-08 21:46:36 +00:00
uiHostDrvrCfg6 = ntohl ( Adapter - > pstargetparams - > HostDrvrConfig6 ) ;
Adapter - > bMipsConfig = ( uiHostDrvrCfg6 > > 20 ) & 0x01 ;
2011-10-07 22:50:09 +00:00
pr_info ( DRV_NAME " : MIPSConfig : 0x%X \n " , Adapter - > bMipsConfig ) ;
/* used for backward compatibility. */
2010-09-08 21:46:36 +00:00
Adapter - > bDPLLConfig = ( uiHostDrvrCfg6 > > 19 ) & 0x01 ;
2011-10-07 22:50:09 +00:00
Adapter - > PmuMode = ( uiHostDrvrCfg6 > > 24 ) & 0x03 ;
2010-11-01 16:14:01 +00:00
pr_info ( DRV_NAME " : PMU MODE: %x " , Adapter - > PmuMode ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ( uiHostDrvrCfg6 > > HOST_BUS_SUSPEND_BIT ) & ( 0x01 ) ) {
Adapter - > bDoSuspend = TRUE ;
pr_info ( DRV_NAME " : Making DoSuspend TRUE as per configFile " ) ;
}
2010-09-08 21:46:36 +00:00
uiEEPROMFlag = ntohl ( Adapter - > pstargetparams - > m_u32EEPROMFlag ) ;
2011-10-07 22:50:09 +00:00
pr_info ( DRV_NAME " : uiEEPROMFlag : 0x%X \n " , uiEEPROMFlag ) ;
2010-09-08 21:46:36 +00:00
Adapter - > eNVMType = ( NVM_TYPE ) ( ( uiEEPROMFlag > > 4 ) & 0x3 ) ;
Adapter - > bStatusWrite = ( uiEEPROMFlag > > 6 ) & 0x1 ;
Adapter - > uiSectorSizeInCFG = 1024 * ( 0xFFFF & ntohl ( Adapter - > pstargetparams - > HostDrvrConfig4 ) ) ;
2011-10-07 22:50:09 +00:00
Adapter - > bSectorSizeOverride = ( bool ) ( ( ntohl ( Adapter - > pstargetparams - > HostDrvrConfig4 ) ) > > 16 ) & 0x1 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ntohl ( Adapter - > pstargetparams - > m_u32PowerSavingModeOptions ) & 0x01 )
2010-09-08 21:46:36 +00:00
Adapter - > ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE ;
2010-11-01 16:14:01 +00:00
2011-10-07 22:50:09 +00:00
if ( Adapter - > ulPowerSaveMode ! = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE )
2010-09-08 21:46:36 +00:00
doPowerAutoCorrection ( Adapter ) ;
}
2012-10-19 02:40:08 +00:00
static void doPowerAutoCorrection ( struct bcm_mini_adapter * psAdapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int reporting_mode ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
reporting_mode = ntohl ( psAdapter - > pstargetparams - > m_u32PowerSavingModeOptions ) & 0x02 ;
2010-09-08 21:46:36 +00:00
psAdapter - > bIsAutoCorrectEnabled = ! ( ( char ) ( psAdapter - > ulPowerSaveMode > > 3 ) & 0x1 ) ;
2011-10-07 22:50:09 +00:00
if ( reporting_mode = = TRUE ) {
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " can't do suspen/resume as reporting mode is enable " ) ;
2010-09-08 21:46:36 +00:00
psAdapter - > bDoSuspend = FALSE ;
}
2011-10-07 22:50:09 +00:00
if ( psAdapter - > bIsAutoCorrectEnabled & & ( psAdapter - > chip_id > = T3LPB ) ) {
/* If reporting mode is enable, switch PMU to PMC */
2010-09-08 21:46:36 +00:00
{
psAdapter - > ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING ;
2011-10-07 22:50:09 +00:00
psAdapter - > bDoSuspend = FALSE ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
/* clearing space bit[15..12] */
2010-09-08 21:46:36 +00:00
psAdapter - > pstargetparams - > HostDrvrConfig6 & = ~ ( htonl ( ( 0xF < < 12 ) ) ) ;
2011-10-07 22:50:09 +00:00
/* placing the power save mode option */
2010-09-08 21:46:36 +00:00
psAdapter - > pstargetparams - > HostDrvrConfig6 | = htonl ( ( psAdapter - > ulPowerSaveMode < < 12 ) ) ;
2011-10-07 22:50:09 +00:00
} else if ( psAdapter - > bIsAutoCorrectEnabled = = FALSE ) {
/* remove the autocorrect disable bit set before dumping. */
2010-09-08 21:46:36 +00:00
psAdapter - > ulPowerSaveMode & = ~ ( 1 < < 3 ) ;
psAdapter - > pstargetparams - > HostDrvrConfig6 & = ~ ( htonl ( 1 < < 15 ) ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( psAdapter , DBG_TYPE_INITEXIT , MP_INIT , DBG_LVL_ALL , " Using Forced User Choice: %lx \n " , psAdapter - > ulPowerSaveMode ) ;
2010-09-08 21:46:36 +00:00
}
}
2010-09-30 08:24:12 +00:00
2012-10-19 02:40:12 +00:00
static void convertEndian ( unsigned char rwFlag , unsigned int * puiBuffer , unsigned int uiByteCount )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiIndex = 0 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( RWM_WRITE = = rwFlag ) {
2012-10-19 02:40:12 +00:00
for ( uiIndex = 0 ; uiIndex < ( uiByteCount / sizeof ( unsigned int ) ) ; uiIndex + + )
2010-09-08 21:46:36 +00:00
puiBuffer [ uiIndex ] = htonl ( puiBuffer [ uiIndex ] ) ;
} else {
2012-10-19 02:40:12 +00:00
for ( uiIndex = 0 ; uiIndex < ( uiByteCount / sizeof ( unsigned int ) ) ; uiIndex + + )
2010-09-08 21:46:36 +00:00
puiBuffer [ uiIndex ] = ntohl ( puiBuffer [ uiIndex ] ) ;
}
}
2012-10-19 02:40:12 +00:00
int rdm ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , PCHAR pucBuff , size_t sSize )
2010-09-08 21:46:36 +00:00
{
2011-06-13 18:11:47 +00:00
return Adapter - > interface_rdm ( Adapter - > pvInterfaceAdapter ,
2011-10-07 22:50:09 +00:00
uiAddress , pucBuff , sSize ) ;
2010-09-08 21:46:36 +00:00
}
2011-06-13 18:11:47 +00:00
2012-10-19 02:40:12 +00:00
int wrm ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , PCHAR pucBuff , size_t sSize )
2010-09-08 21:46:36 +00:00
{
int iRetVal ;
iRetVal = Adapter - > interface_wrm ( Adapter - > pvInterfaceAdapter ,
2011-10-07 22:50:09 +00:00
uiAddress , pucBuff , sSize ) ;
2010-09-08 21:46:36 +00:00
return iRetVal ;
}
2012-10-19 02:40:12 +00:00
int wrmalt ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , unsigned int * pucBuff , size_t size )
2010-09-08 21:46:36 +00:00
{
convertEndian ( RWM_WRITE , pucBuff , size ) ;
return wrm ( Adapter , uiAddress , ( PUCHAR ) pucBuff , size ) ;
}
2012-10-19 02:40:12 +00:00
int rdmalt ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , unsigned int * pucBuff , size_t size )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:13 +00:00
int uiRetVal = 0 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
uiRetVal = rdm ( Adapter , uiAddress , ( PUCHAR ) pucBuff , size ) ;
2012-10-19 02:40:09 +00:00
convertEndian ( RWM_READ , ( unsigned int * ) pucBuff , size ) ;
2010-09-08 21:46:36 +00:00
return uiRetVal ;
}
2012-10-19 02:40:12 +00:00
int wrmWithLock ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , PCHAR pucBuff , size_t sSize )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:13 +00:00
int status = STATUS_SUCCESS ;
2010-09-08 21:46:36 +00:00
down ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
if ( ( Adapter - > IdleMode = = TRUE ) | |
( Adapter - > bShutStatus = = TRUE ) | |
( Adapter - > bPreparingForLowPowerMode = = TRUE ) ) {
2010-09-08 21:46:36 +00:00
status = - EACCES ;
goto exit ;
}
2011-10-07 22:50:09 +00:00
status = wrm ( Adapter , uiAddress , pucBuff , sSize ) ;
2010-09-08 21:46:36 +00:00
exit :
up ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
return status ;
2010-09-08 21:46:36 +00:00
}
2012-10-19 02:40:12 +00:00
int wrmaltWithLock ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , unsigned int * pucBuff , size_t size )
2010-09-08 21:46:36 +00:00
{
int iRetVal = STATUS_SUCCESS ;
down ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
if ( ( Adapter - > IdleMode = = TRUE ) | |
( Adapter - > bShutStatus = = TRUE ) | |
( Adapter - > bPreparingForLowPowerMode = = TRUE ) ) {
2010-09-08 21:46:36 +00:00
iRetVal = - EACCES ;
goto exit ;
}
2011-10-07 22:50:09 +00:00
iRetVal = wrmalt ( Adapter , uiAddress , pucBuff , size ) ;
2010-09-08 21:46:36 +00:00
exit :
up ( & Adapter - > rdmwrmsync ) ;
return iRetVal ;
}
2012-10-19 02:40:12 +00:00
int rdmaltWithLock ( struct bcm_mini_adapter * Adapter , unsigned int uiAddress , unsigned int * pucBuff , size_t size )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:13 +00:00
int uiRetVal = STATUS_SUCCESS ;
2010-09-08 21:46:36 +00:00
down ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
if ( ( Adapter - > IdleMode = = TRUE ) | |
( Adapter - > bShutStatus = = TRUE ) | |
( Adapter - > bPreparingForLowPowerMode = = TRUE ) ) {
2010-09-08 21:46:36 +00:00
uiRetVal = - EACCES ;
goto exit ;
}
2011-10-07 22:50:09 +00:00
uiRetVal = rdmalt ( Adapter , uiAddress , pucBuff , size ) ;
2010-09-08 21:46:36 +00:00
exit :
up ( & Adapter - > rdmwrmsync ) ;
return uiRetVal ;
}
2012-10-19 02:40:08 +00:00
static void HandleShutDownModeWakeup ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
int clear_abort_pattern = 0 , Status = 0 ;
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " ====> \n " ) ;
/* target has woken up From Shut Down */
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " Clearing Shut Down Software abort pattern \n " ) ;
2012-10-19 02:40:09 +00:00
Status = wrmalt ( Adapter , SW_ABORT_IDLEMODE_LOC , ( unsigned int * ) & clear_abort_pattern , sizeof ( clear_abort_pattern ) ) ;
2011-10-07 22:50:09 +00:00
if ( Status ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d " , Status ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2011-10-07 22:50:09 +00:00
if ( Adapter - > ulPowerSaveMode ! = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE ) {
2010-09-08 21:46:36 +00:00
msleep ( 100 ) ;
InterfaceHandleShutdownModeWakeup ( Adapter ) ;
msleep ( 100 ) ;
}
2011-10-07 22:50:09 +00:00
if ( Adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2010-09-08 21:46:36 +00:00
Adapter - > DriverState = NO_NETWORK_ENTRY ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
}
Adapter - > bTriedToWakeUpFromlowPowerMode = FALSE ;
Adapter - > bShutStatus = FALSE ;
wake_up ( & Adapter - > lowpower_mode_wait_queue ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " <==== \n " ) ;
2010-09-08 21:46:36 +00:00
}
2012-10-19 02:40:08 +00:00
static void SendShutModeResponse ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-05-26 16:05:08 +00:00
struct bcm_link_request stShutdownResponse ;
2012-10-19 02:40:12 +00:00
unsigned int NVMAccess = 0 , lowPwrAbortMsg = 0 ;
unsigned int Status = 0 ;
2010-09-08 21:46:36 +00:00
2012-05-26 16:05:08 +00:00
memset ( & stShutdownResponse , 0 , sizeof ( struct bcm_link_request ) ) ;
2010-09-08 21:46:36 +00:00
stShutdownResponse . Leader . Status = LINK_UP_CONTROL_REQ ;
2011-10-07 22:50:09 +00:00
stShutdownResponse . Leader . PLength = 8 ; /* 8 bytes; */
2010-09-08 21:46:36 +00:00
stShutdownResponse . szData [ 0 ] = LINK_UP_ACK ;
stShutdownResponse . szData [ 1 ] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE ;
/*********************************
2011-10-07 22:50:09 +00:00
* down_trylock -
* if [ semaphore is available ]
* acquire semaphone and return value 0 ;
* else
* return non - zero value ;
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2010-09-08 21:46:36 +00:00
NVMAccess = down_trylock ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
lowPwrAbortMsg = down_trylock ( & Adapter - > LowPowerModeSync ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( NVMAccess | | lowPwrAbortMsg | | atomic_read ( & Adapter - > TotalPacketCount ) ) {
if ( ! NVMAccess )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
if ( ! lowPwrAbortMsg )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > LowPowerModeSync ) ;
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " Device Access is going on NACK the Shut Down MODE \n " ) ;
stShutdownResponse . szData [ 2 ] = SHUTDOWN_NACK_FROM_DRIVER ; /* NACK- device access is going on. */
2010-09-08 21:46:36 +00:00
Adapter - > bPreparingForLowPowerMode = FALSE ;
2011-10-07 22:50:09 +00:00
} else {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " Sending SHUTDOWN MODE ACK \n " ) ;
stShutdownResponse . szData [ 2 ] = SHUTDOWN_ACK_FROM_DRIVER ; /* ShutDown ACK */
2010-09-08 21:46:36 +00:00
/* Wait for the LED to TURN OFF before sending ACK response */
2011-10-07 22:50:09 +00:00
if ( Adapter - > LEDInfo . led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY ) {
2012-10-19 02:40:13 +00:00
int iRetVal = 0 ;
2010-09-08 21:46:36 +00:00
/* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
Adapter - > DriverState = LOWPOWER_MODE_ENTER ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
/* Wait for 1 SEC for LED to OFF */
2011-10-07 22:50:09 +00:00
iRetVal = wait_event_timeout ( Adapter - > LEDInfo . idleModeSyncEvent , Adapter - > LEDInfo . bIdle_led_off , msecs_to_jiffies ( 1000 ) ) ;
2010-09-08 21:46:36 +00:00
/* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
2011-10-07 22:50:09 +00:00
if ( iRetVal < = 0 ) {
stShutdownResponse . szData [ 1 ] = SHUTDOWN_NACK_FROM_DRIVER ; /* NACK- device access is going on. */
2010-09-08 21:46:36 +00:00
Adapter - > DriverState = NO_NETWORK_ENTRY ;
wake_up ( & Adapter - > LEDInfo . notify_led_event ) ;
}
}
2011-10-07 22:50:09 +00:00
if ( stShutdownResponse . szData [ 2 ] = = SHUTDOWN_ACK_FROM_DRIVER ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " ACKING SHUTDOWN MODE !!!!!!!!! " ) ;
2010-09-08 21:46:36 +00:00
down ( & Adapter - > rdmwrmsync ) ;
Adapter - > bPreparingForLowPowerMode = TRUE ;
up ( & Adapter - > rdmwrmsync ) ;
2011-10-07 22:50:09 +00:00
/* Killing all URBS. */
if ( Adapter - > bDoSuspend = = TRUE )
2012-11-02 03:42:21 +00:00
Bcm_kill_all_URBs ( ( struct bcm_interface_adapter * ) ( Adapter - > pvInterfaceAdapter ) ) ;
2011-10-07 22:50:09 +00:00
} else {
2010-09-08 21:46:36 +00:00
Adapter - > bPreparingForLowPowerMode = FALSE ;
}
2011-10-07 22:50:09 +00:00
if ( ! NVMAccess )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > NVMRdmWrmLock ) ;
2011-10-07 22:50:09 +00:00
if ( ! lowPwrAbortMsg )
2010-09-08 21:46:36 +00:00
up ( & Adapter - > LowPowerModeSync ) ;
}
2011-10-07 22:50:09 +00:00
Status = CopyBufferToControlPacket ( Adapter , & stShutdownResponse ) ;
if ( ( Status ! = STATUS_SUCCESS ) ) {
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " fail to send the Idle mode Request \n " ) ;
Adapter - > bPreparingForLowPowerMode = FALSE ;
2012-11-02 03:42:21 +00:00
StartInterruptUrb ( ( struct bcm_interface_adapter * ) ( Adapter - > pvInterfaceAdapter ) ) ;
2010-09-08 21:46:36 +00:00
}
}
2012-05-26 16:05:12 +00:00
static void HandleShutDownModeRequest ( struct bcm_mini_adapter * Adapter , PUCHAR pucBuffer )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:11 +00:00
unsigned int uiResetValue = 0 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " ====> \n " ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( * ( pucBuffer + 1 ) = = COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW ) {
2010-09-08 21:46:36 +00:00
HandleShutDownModeWakeup ( Adapter ) ;
2011-10-07 22:50:09 +00:00
} else if ( * ( pucBuffer + 1 ) = = LINK_SHUTDOWN_REQ_FROM_FIRMWARE ) {
/* Target wants to go to Shut Down Mode */
/* InterfacePrepareForShutdown(Adapter); */
if ( Adapter - > chip_id = = BCS220_2 | |
Adapter - > chip_id = = BCS220_2BC | |
Adapter - > chip_id = = BCS250_BC | |
Adapter - > chip_id = = BCS220_3 ) {
rdmalt ( Adapter , HPM_CONFIG_MSW , & uiResetValue , 4 ) ;
2010-09-08 21:46:36 +00:00
uiResetValue | = ( 1 < < 17 ) ;
wrmalt ( Adapter , HPM_CONFIG_MSW , & uiResetValue , 4 ) ;
}
SendShutModeResponse ( Adapter ) ;
2012-10-19 02:40:13 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " ShutDownModeResponse:Notification received: Sending the response(Ack/Nack) \n " ) ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_OTHERS , MP_SHUTDOWN , DBG_LVL_ALL , " <==== \n " ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2012-10-19 02:40:08 +00:00
void ResetCounters ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
beceem_protocol_reset ( Adapter ) ;
2010-09-08 21:46:36 +00:00
Adapter - > CurrNumRecvDescs = 0 ;
2011-10-07 22:50:09 +00:00
Adapter - > PrevNumRecvDescs = 0 ;
Adapter - > LinkUpStatus = 0 ;
2010-09-08 21:46:36 +00:00
Adapter - > LinkStatus = 0 ;
2011-10-07 22:50:09 +00:00
atomic_set ( & Adapter - > cntrlpktCnt , 0 ) ;
atomic_set ( & Adapter - > TotalPacketCount , 0 ) ;
Adapter - > fw_download_done = FALSE ;
2010-09-08 21:46:36 +00:00
Adapter - > LinkStatus = 0 ;
2011-10-07 22:50:09 +00:00
Adapter - > AutoLinkUp = FALSE ;
2010-09-08 21:46:36 +00:00
Adapter - > IdleMode = FALSE ;
Adapter - > bShutStatus = FALSE ;
}
2011-10-07 22:50:09 +00:00
2012-05-26 16:05:12 +00:00
struct bcm_classifier_rule * GetFragIPClsEntry ( struct bcm_mini_adapter * Adapter , USHORT usIpIdentification , ULONG SrcIP )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiIndex = 0 ;
2011-10-07 22:50:09 +00:00
for ( uiIndex = 0 ; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES ; uiIndex + + ) {
if ( ( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . bUsed ) & &
( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . usIpIdentification = = usIpIdentification ) & &
( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . ulSrcIpAddress = = SrcIP ) & &
2010-09-08 21:46:36 +00:00
! Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . bOutOfOrderFragment )
2011-10-07 22:50:09 +00:00
2010-09-08 21:46:36 +00:00
return Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . pstMatchedClassifierEntry ;
}
return NULL ;
}
2012-05-26 16:05:12 +00:00
void AddFragIPClsEntry ( struct bcm_mini_adapter * Adapter , struct bcm_fragmented_packet_info * psFragPktInfo )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiIndex = 0 ;
2011-10-07 22:50:09 +00:00
for ( uiIndex = 0 ; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES ; uiIndex + + ) {
if ( ! Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . bUsed ) {
2012-05-26 16:05:02 +00:00
memcpy ( & Adapter - > astFragmentedPktClassifierTable [ uiIndex ] , psFragPktInfo , sizeof ( struct bcm_fragmented_packet_info ) ) ;
2010-09-08 21:46:36 +00:00
break ;
}
}
}
2012-05-26 16:05:12 +00:00
void DelFragIPClsEntry ( struct bcm_mini_adapter * Adapter , USHORT usIpIdentification , ULONG SrcIp )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int uiIndex = 0 ;
2011-10-07 22:50:09 +00:00
for ( uiIndex = 0 ; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES ; uiIndex + + ) {
if ( ( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . bUsed ) & &
( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . usIpIdentification = = usIpIdentification ) & &
( Adapter - > astFragmentedPktClassifierTable [ uiIndex ] . ulSrcIpAddress = = SrcIp ) )
2012-05-26 16:05:02 +00:00
memset ( & Adapter - > astFragmentedPktClassifierTable [ uiIndex ] , 0 , sizeof ( struct bcm_fragmented_packet_info ) ) ;
2010-09-08 21:46:36 +00:00
}
}
2012-05-26 16:05:12 +00:00
void update_per_cid_rx ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:12 +00:00
unsigned int qindex = 0 ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ( jiffies - Adapter - > liDrainCalculated ) < XSECONDS )
2010-09-08 21:46:36 +00:00
return ;
2011-10-07 22:50:09 +00:00
for ( qindex = 0 ; qindex < HiPriority ; qindex + + ) {
if ( Adapter - > PackInfo [ qindex ] . ucDirection = = 0 ) {
2010-09-08 21:46:36 +00:00
Adapter - > PackInfo [ qindex ] . uiCurrentRxRate =
( Adapter - > PackInfo [ qindex ] . uiCurrentRxRate +
2011-10-07 22:50:09 +00:00
Adapter - > PackInfo [ qindex ] . uiThisPeriodRxBytes ) / 2 ;
2010-09-08 21:46:36 +00:00
Adapter - > PackInfo [ qindex ] . uiThisPeriodRxBytes = 0 ;
2011-10-07 22:50:09 +00:00
} else {
2010-09-08 21:46:36 +00:00
Adapter - > PackInfo [ qindex ] . uiCurrentDrainRate =
( Adapter - > PackInfo [ qindex ] . uiCurrentDrainRate +
2011-10-07 22:50:09 +00:00
Adapter - > PackInfo [ qindex ] . uiThisPeriodSentBytes ) / 2 ;
Adapter - > PackInfo [ qindex ] . uiThisPeriodSentBytes = 0 ;
2010-09-08 21:46:36 +00:00
}
}
2011-10-07 22:50:09 +00:00
Adapter - > liDrainCalculated = jiffies ;
2010-09-08 21:46:36 +00:00
}
2011-10-07 22:50:09 +00:00
2012-05-26 16:05:12 +00:00
void update_per_sf_desc_cnts ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2012-10-19 02:40:13 +00:00
int iIndex = 0 ;
2010-09-08 21:46:36 +00:00
u32 uibuff [ MAX_TARGET_DSX_BUFFERS ] ;
2011-11-06 14:40:11 +00:00
int bytes ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
if ( ! atomic_read ( & Adapter - > uiMBupdate ) )
2010-09-08 21:46:36 +00:00
return ;
2012-10-19 02:40:12 +00:00
bytes = rdmaltWithLock ( Adapter , TARGET_SFID_TXDESC_MAP_LOC , ( unsigned int * ) uibuff , sizeof ( unsigned int ) * MAX_TARGET_DSX_BUFFERS ) ;
2011-11-06 14:40:11 +00:00
if ( bytes < 0 ) {
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " rdm failed \n " ) ;
2010-09-08 21:46:36 +00:00
return ;
}
2011-10-07 22:50:09 +00:00
for ( iIndex = 0 ; iIndex < HiPriority ; iIndex + + ) {
if ( Adapter - > PackInfo [ iIndex ] . bValid & & Adapter - > PackInfo [ iIndex ] . ucDirection ) {
if ( Adapter - > PackInfo [ iIndex ] . usVCID_Value < MAX_TARGET_DSX_BUFFERS )
2010-09-08 21:46:36 +00:00
atomic_set ( & Adapter - > PackInfo [ iIndex ] . uiPerSFTxResourceCount , uibuff [ Adapter - > PackInfo [ iIndex ] . usVCID_Value ] ) ;
else
2011-10-07 22:50:09 +00:00
BCM_DEBUG_PRINT ( Adapter , DBG_TYPE_PRINTK , 0 , 0 , " Invalid VCID : %x \n " , Adapter - > PackInfo [ iIndex ] . usVCID_Value ) ;
2010-09-08 21:46:36 +00:00
}
}
2011-10-07 22:50:09 +00:00
atomic_set ( & Adapter - > uiMBupdate , FALSE ) ;
2010-09-08 21:46:36 +00:00
}
2012-10-19 02:40:12 +00:00
void flush_queue ( struct bcm_mini_adapter * Adapter , unsigned int iQIndex )
2010-09-08 21:46:36 +00:00
{
2011-10-07 22:50:09 +00:00
struct sk_buff * PacketToDrop = NULL ;
struct net_device_stats * netstats = & Adapter - > dev - > stats ;
2010-09-08 21:46:36 +00:00
spin_lock_bh ( & Adapter - > PackInfo [ iQIndex ] . SFQueueLock ) ;
2011-10-07 22:50:09 +00:00
while ( Adapter - > PackInfo [ iQIndex ] . FirstTxQueue & & atomic_read ( & Adapter - > TotalPacketCount ) ) {
2010-09-08 21:46:36 +00:00
PacketToDrop = Adapter - > PackInfo [ iQIndex ] . FirstTxQueue ;
2011-10-07 22:50:09 +00:00
if ( PacketToDrop & & PacketToDrop - > len ) {
2010-09-08 21:46:36 +00:00
netstats - > tx_dropped + + ;
2011-10-07 22:50:09 +00:00
DEQUEUEPACKET ( Adapter - > PackInfo [ iQIndex ] . FirstTxQueue , Adapter - > PackInfo [ iQIndex ] . LastTxQueue ) ;
2010-09-08 21:46:36 +00:00
Adapter - > PackInfo [ iQIndex ] . uiCurrentPacketsOnHost - - ;
Adapter - > PackInfo [ iQIndex ] . uiCurrentBytesOnHost - = PacketToDrop - > len ;
2011-10-07 22:50:09 +00:00
/* Adding dropped statistics */
2010-09-08 21:46:36 +00:00
Adapter - > PackInfo [ iQIndex ] . uiDroppedCountBytes + = PacketToDrop - > len ;
Adapter - > PackInfo [ iQIndex ] . uiDroppedCountPackets + + ;
2010-11-01 13:35:21 +00:00
dev_kfree_skb ( PacketToDrop ) ;
2010-09-08 21:46:36 +00:00
atomic_dec ( & Adapter - > TotalPacketCount ) ;
}
}
spin_unlock_bh ( & Adapter - > PackInfo [ iQIndex ] . SFQueueLock ) ;
}
2012-05-26 16:05:12 +00:00
static void beceem_protocol_reset ( struct bcm_mini_adapter * Adapter )
2010-09-08 21:46:36 +00:00
{
2010-11-01 16:12:31 +00:00
int i ;
if ( netif_msg_link ( Adapter ) )
2010-11-01 16:18:36 +00:00
pr_notice ( PFX " %s: protocol reset \n " , Adapter - > dev - > name ) ;
2010-11-01 16:12:31 +00:00
netif_carrier_off ( Adapter - > dev ) ;
netif_stop_queue ( Adapter - > dev ) ;
2010-09-08 21:46:36 +00:00
Adapter - > IdleMode = FALSE ;
Adapter - > LinkUpStatus = FALSE ;
2011-10-07 22:50:09 +00:00
ClearTargetDSXBuffer ( Adapter , 0 , TRUE ) ;
/* Delete All Classifier Rules */
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
for ( i = 0 ; i < HiPriority ; i + + )
DeleteAllClassifiersForSF ( Adapter , i ) ;
2010-09-08 21:46:36 +00:00
flush_all_queues ( Adapter ) ;
2011-10-07 22:50:09 +00:00
if ( Adapter - > TimerActive = = TRUE )
2010-09-08 21:46:36 +00:00
Adapter - > TimerActive = FALSE ;
2012-05-26 16:05:02 +00:00
memset ( Adapter - > astFragmentedPktClassifierTable , 0 , sizeof ( struct bcm_fragmented_packet_info ) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES ) ;
2010-09-08 21:46:36 +00:00
2011-10-07 22:50:09 +00:00
for ( i = 0 ; i < HiPriority ; i + + ) {
/* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */
/* It is same between MIBs and SF. */
2012-11-26 00:28:59 +00:00
memset ( & Adapter - > PackInfo [ i ] . stMibsExtServiceFlowTable , 0 , sizeof ( struct bcm_mibs_parameters ) ) ;
2010-09-08 21:46:36 +00:00
}
}