tANI_U32
limDeactivateMinChannelTimerDuringScan(tpAniSirGlobal pMac)
{
    if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) && (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE))
    {
        /**
            * Beacon/Probe Response is received during active scanning.
            * Deactivate MIN channel timer if running.
            */

        limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER);
        MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_MAX_CHANNEL_TIMER));
        if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
                                          == TX_TIMER_ERROR)
        {
            /// Could not activate max channel timer.
            // Log error
            limLog(pMac,LOGP, FL("could not activate max channel timer"));

            limCompleteMlmScan(pMac, eSIR_SME_RESOURCES_UNAVAILABLE);
            return TX_TIMER_ERROR;
        }
    }
    return eSIR_SUCCESS;
} /*** end limDeactivateMinChannelTimerDuringScan() ***/
v_UINT_t tx_timer_create_intern( v_PVOID_t pMacGlobal, TX_TIMER *timer_ptr,
   char *name_ptr, 
   v_VOID_t ( *expiration_function )( v_PVOID_t, tANI_U32 ),
   tANI_U32 expiration_input, v_ULONG_t initScheduleTimeInTicks, 
   v_ULONG_t rescheduleTimeInTicks, v_ULONG_t auto_activate )
{
    VOS_STATUS status;

    VOS_ASSERT((NULL != expiration_function) && (NULL != name_ptr));
    if((NULL == name_ptr) || (NULL == expiration_function))
        return TX_TIMER_ERROR;

    if (!initScheduleTimeInTicks)
        return TX_TICK_ERROR;

    if (!timer_ptr)
        return TX_TIMER_ERROR;

    // Initialize timer structure
    timer_ptr->pExpireFunc = expiration_function;
    timer_ptr->expireInput = expiration_input;
    timer_ptr->initScheduleTimeInMsecs =
        TX_MSECS_IN_1_TICK * initScheduleTimeInTicks;
    timer_ptr->rescheduleTimeInMsecs =
        TX_MSECS_IN_1_TICK * rescheduleTimeInTicks;
    timer_ptr->pMac = pMacGlobal;

    // Set the flag indicating that the timer was created
    timer_ptr->tmrSignature = TX_AIRGO_TMR_SIGNATURE;

#ifdef WLAN_DEBUG
    // Store the timer name
    strlcpy(timer_ptr->timerName, name_ptr, sizeof(timer_ptr->timerName));
#endif // Store the timer name, for Debug build only

    status = vos_timer_init( &timer_ptr->vosTimer, VOS_TIMER_TYPE_SW, 
          tx_main_timer_func, (v_PVOID_t)timer_ptr );
    if (VOS_STATUS_SUCCESS != status)
    {
       VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_ERROR,
             "Cannot create timer for %s\n", TIMER_NAME);
       return TX_TIMER_ERROR;
    }

    if(0 != rescheduleTimeInTicks)
    {
        VOS_TRACE(VOS_MODULE_ID_SYS, VOS_TRACE_LEVEL_INFO, 
                  "Creating periodic timer for %s\n", TIMER_NAME);
    }

    // Activate this timer if required
    if (auto_activate)
    {
        tx_timer_activate(timer_ptr);
    }

    return TX_SUCCESS;

} //** tx_timer_create() ***/
Esempio n. 3
0
uint32_t tx_timer_create_intern(void *pMacGlobal, TX_TIMER *timer_ptr,
				char *name_ptr,
				void (*expiration_function)(void *,
							    uint32_t),
				uint32_t expiration_input,
				uint64_t initScheduleTimeInTicks,
				uint64_t rescheduleTimeInTicks,
				uint64_t auto_activate)
{
	CDF_STATUS status;

	if ((NULL == name_ptr) || (NULL == expiration_function))
		return TX_TIMER_ERROR;

	if (!initScheduleTimeInTicks)
		return TX_TICK_ERROR;

	if (!timer_ptr)
		return TX_TIMER_ERROR;

	/* Initialize timer structure */
	timer_ptr->pExpireFunc = expiration_function;
	timer_ptr->expireInput = expiration_input;
	timer_ptr->initScheduleTimeInMsecs =
		TX_MSECS_IN_1_TICK * initScheduleTimeInTicks;
	timer_ptr->rescheduleTimeInMsecs =
		TX_MSECS_IN_1_TICK * rescheduleTimeInTicks;
	timer_ptr->pMac = pMacGlobal;

	/* Set the flag indicating that the timer was created */
	timer_ptr->tmrSignature = TX_AIRGO_TMR_SIGNATURE;

#ifdef WLAN_DEBUG
	/* Store the timer name */
	strlcpy(timer_ptr->timerName, name_ptr, sizeof(timer_ptr->timerName));
#endif /* Store the timer name, for Debug build only */

	status = cdf_mc_timer_init(&timer_ptr->cdf_timer, CDF_TIMER_TYPE_SW,
				   tx_main_timer_func, (void *) timer_ptr);
	if (CDF_STATUS_SUCCESS != status) {
		CDF_TRACE(CDF_MODULE_ID_SYS, CDF_TRACE_LEVEL_ERROR,
			  "Cannot create timer for %s\n", TIMER_NAME);
		return TX_TIMER_ERROR;
	}

	if (0 != rescheduleTimeInTicks) {
		CDF_TRACE(CDF_MODULE_ID_SYS, CDF_TRACE_LEVEL_INFO,
			  "Creating periodic timer for %s\n", TIMER_NAME);
	}
	/* Activate this timer if required */
	if (auto_activate) {
		tx_timer_activate(timer_ptr);
	}

	return TX_SUCCESS;

} /* ** tx_timer_create() *** / */
Esempio n. 4
0
void CTXTimerHandler::enableHandler(void){
  UINT status = tx_timer_activate(&m_stTimer);
  if (status == TX_SUCCESS)
    DEVLOG_DEBUG("Timer activated\n");
  else
    DEVLOG_DEBUG("Error activating timer\n");
  
  //TODO handle retval
}
Esempio n. 5
0
wiced_result_t wiced_rtos_start_timer( wiced_timer_t* timer )
{
    if ( tx_timer_change( timer, timer->tx_timer_internal.tx_timer_internal_re_initialize_ticks, timer->tx_timer_internal.tx_timer_internal_re_initialize_ticks ) != TX_SUCCESS )
    {
        return WICED_ERROR;
    }

    if ( tx_timer_activate( timer ) != WICED_SUCCESS )
    {
        return WICED_ERROR;
    }

    return WICED_SUCCESS;
}
Esempio n. 6
0
int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg)
{

    /* CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE - Currently removed the special optimization when a concurrent session
     * exists with operating channel same as P2P listen channel since it was causing issues in P2P search. The reason was
     * STA-AP link entering BMPS when returning to home channel causing P2P search to miss Probe Reqs and hence not
     * respond with Probe Rsp causing peer device to NOT find us.
     * If we need this optimization, we need to find a way to keep the STA-AP link awake (no BMPS) on home channel when in listen state
     */
#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
    tANI_U8 i;
    tpPESession psessionEntry;
#endif
#ifdef WLAN_FEATURE_P2P_INTERNAL
    tpPESession pP2pSession;
#endif

    tSirRemainOnChnReq *MsgBuff = (tSirRemainOnChnReq *)pMsg;
    pMac->lim.gpLimRemainOnChanReq = MsgBuff;

#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
    for (i =0; i < pMac->lim.maxBssId;i++)
    {
        psessionEntry = peFindSessionBySessionId(pMac,i);

        if ( (psessionEntry != NULL) )
        {
            if (psessionEntry->currentOperChannel == MsgBuff->chnNum)
            {
                tANI_U32 val;
                tSirMacAddr nullBssid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

                pMac->lim.p2pRemOnChanTimeStamp = vos_timer_get_system_time();
                pMac->lim.gTotalScanDuration = MsgBuff->duration;

                /* get the duration from the request */
                val = SYS_MS_TO_TICKS(MsgBuff->duration);

                limLog( pMac, LOG2, "Start listen duration = %d", val);
                if (tx_timer_change(
                        &pMac->lim.limTimers.gLimRemainOnChannelTimer, val, 0)
                                          != TX_SUCCESS)
                {
                    limLog(pMac, LOGP,
                          FL("Unable to change remain on channel Timer val"));
                    goto error;
                }
                else if(TX_SUCCESS != tx_timer_activate(
                                &pMac->lim.limTimers.gLimRemainOnChannelTimer))
                {
                    limLog(pMac, LOGP,
                    FL("Unable to activate remain on channel Timer"));
                    limDeactivateAndChangeTimer(pMac, eLIM_REMAIN_CHN_TIMER);
                    goto error;
                }

#ifdef WLAN_FEATURE_P2P_INTERNAL
                //Session is needed to send probe rsp
                if(eSIR_SUCCESS != limCreateSessionForRemainOnChn(pMac, &pP2pSession))
                {
                    limLog( pMac, LOGE, "Unable to create session");
                    goto error;
                }
#endif

                if ((limSetLinkState(pMac, eSIR_LINK_LISTEN_STATE,
                    nullBssid, pMac->lim.gSelfMacAddr, 
                    limSetLinkStateP2PCallback, NULL)) != eSIR_SUCCESS)
                {
                    limLog( pMac, LOGE, "Unable to change link state");
                    goto error;
                }
                return FALSE;
            }
        }
    }
#endif
    pMac->lim.gLimPrevMlmState = pMac->lim.gLimMlmState;
    pMac->lim.gLimMlmState     = eLIM_MLM_P2P_LISTEN_STATE;

    pMac->lim.gTotalScanDuration = MsgBuff->duration;

    /* 1st we need to suspend link with callback to initiate change channel */
    limSuspendLink(pMac, eSIR_CHECK_LINK_TRAFFIC_BEFORE_SCAN,
                   limRemainOnChnlSuspendLinkHdlr, NULL);
    return FALSE;

#ifdef CONC_OPER_AND_LISTEN_CHNL_SAME_OPTIMIZE
error:
    limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
    /* pMsg is freed by the caller */
    return FALSE;
#endif
}
Esempio n. 7
0
STATUS Do_Device_IO(
	U32 device,
	UNSIGNED offset, // offset in file 
	void *p_buffer, // pointer to data 
	UNSIGNED num_bytes, // number of bytes 
	Callback_Context *p_callback_context, // context to run when I/O is complete
	Device_IO_Type device_IO_type
	)
{
	char *p_data = p_mem_file + (device * Flash_Address::Pages_Per_Device() 
		* Flash_Address::Bytes_Per_Page()) + offset;
	char *p_data_last = p_data + num_bytes;
	CT_ASSERT((p_data_last <= p_mem_file_last), Do_Device_IO);

	// Save context to run when timer goes off.
	CT_ASSERT((timer_context[device] == 0), Do_Device_IO);
	timer_context[device] = p_callback_context;
	U32 timer_ticks;
	U32 num_words = num_bytes/4;
	U32 *p_word_buffer = (U32 *)p_buffer;
	U32 *p_word_data = (U32 *)p_data;
	U32 index;
	STATUS verify_status = OK;

	switch(device_IO_type)
	{
	case WRITE_CELL:
		// Simulate flash write by ANDing words into buffer.
		// If the memory was not erased, it will not work correctly.
		for (index = 0; index < num_words; index++)
			*(p_word_data + index) &= *(p_word_buffer + index);
		timer_ticks = FF_WRITE_TIMER_TICKS;
 		break;

	case READ_CELL:
		memcpy(p_buffer, p_data, num_bytes);
		timer_ticks = FF_READ_TIMER_TICKS;
		break;

	case ERASE_CELL:
		memset(p_data, 0XFF, num_bytes);
		timer_ticks = FF_WRITE_TIMER_TICKS;
		break;

	case VERIFY_CELL:
		for (index = 0; index < num_words; index++)
			if (*(p_word_data + index) != *(p_word_buffer + index))
				verify_status = FF_ERROR(VERIFY);
		timer_ticks = FF_READ_TIMER_TICKS;

		// Save verify status in context.
		p_callback_context->Set_Status(verify_status);

		break;
		
	}

	STATUS status;
#if 1 // Don't use timer -- it's too slow when we read the whole file.
		// Start the timer to simulate the time for I/O.
#ifdef THREADX
 	status = tx_timer_change(&timer[device],
 		timer_ticks,
 		0); // timer only expires once
	if (status == OK)
		status = tx_timer_activate(&timer[device]);
#else
 	status = NU_Reset_Timer(&timer[device],
 		&Device_Timer_Expiration_Routine,
 		timer_ticks,
 		0, // timer only expires once
 		NU_ENABLE_TIMER);
#endif

#else // instead of the timer.
	timer_context[device] = 0;
	p_callback_context->Make_Ready();
#endif


	return status;
}