/*----------------------------------------------------------------------------*/
BOOLEAN
nicpmSetDriverOwn (
    IN P_ADAPTER_T prAdapter
    )
{
#define LP_OWN_BACK_TOTAL_DELAY_MS      8192    //exponential of 2
#define LP_OWN_BACK_LOOP_DELAY_MS       1       //exponential of 2
#define LP_OWN_BACK_CLR_OWN_ITERATION   256     //exponential of 2

    BOOLEAN fgStatus = TRUE;
    UINT32 i, u4CurrTick;
    UINT_32 u4RegValue = 0;

    ASSERT(prAdapter);

    if(prAdapter->fgIsFwOwn == FALSE)
        return fgStatus;

    u4CurrTick = kalGetTimeTick();
    i = 0;

    while(1) {
        HAL_MCR_RD(prAdapter, MCR_WHLPCR, &u4RegValue);

        if (u4RegValue & WHLPCR_FW_OWN_REQ_SET) {
            prAdapter->fgIsFwOwn = FALSE;
            break;
        }
        else if(kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
                || fgIsBusAccessFailed == TRUE
                || (kalGetTimeTick() - u4CurrTick) > LP_OWN_BACK_TOTAL_DELAY_MS
		|| fgIsResetting == TRUE) {
            //ERRORLOG(("LP cannot be own back (for %ld ms)", kalGetTimeTick() - u4CurrTick));
            fgStatus = FALSE;
            if (fgIsResetting != TRUE)
            {
                static unsigned int owncnt = 0;
                HAL_MCR_RD(prAdapter, MCR_D2HRM2R, &u4RegValue);
                printk("<WiFi> MCR_D2HRM2R = 0x%x\n", (UINT32)u4RegValue);
                printk("<WiFi> Fatal error! Driver own fail!!!!!!!!!!!! %d\n", owncnt++);
            }
            break;
        }
        else {
            if((i & (LP_OWN_BACK_CLR_OWN_ITERATION - 1)) == 0) {
                /* Software get LP ownership - per 256 iterations */
                HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
            }

            /* Delay for LP engine to complete its operation. */
            kalMsleep(LP_OWN_BACK_LOOP_DELAY_MS);
            i++;
        }
    }

    return fgStatus;
}
示例#2
0
/*----------------------------------------------------------------------------*/
BOOLEAN
nicpmSetDriverOwn (
    IN P_ADAPTER_T prAdapter
    )
{
#define LP_OWN_BACK_TOTAL_DELAY_MS      2048    //exponential of 2
#define LP_OWN_BACK_LOOP_DELAY_MS       1       //exponential of 2
#define LP_OWN_BACK_CLR_OWN_ITERATION   256     //exponential of 2

    BOOLEAN fgStatus = TRUE;
    UINT_32 i, u4CurrTick, u4RegValue = 0;
    BOOLEAN fgTimeout;

    ASSERT(prAdapter);

    if(prAdapter->fgIsFwOwn == FALSE)
        return fgStatus;

    DBGLOG(INIT, INFO, ("DRIVER OWN\n"));

    u4CurrTick = kalGetTimeTick();
    i = 0;
    while(1) {
        HAL_MCR_RD(prAdapter, MCR_WHLPCR, &u4RegValue);

        fgTimeout = ((kalGetTimeTick() - u4CurrTick) > LP_OWN_BACK_TOTAL_DELAY_MS)? TRUE:FALSE;

        if (u4RegValue & WHLPCR_FW_OWN_REQ_SET) {
            prAdapter->fgIsFwOwn = FALSE;
            break;
        }
        else if(kalIsCardRemoved(prAdapter->prGlueInfo) || fgIsBusAccessFailed || fgTimeout || wlanIsChipNoAck(prAdapter)) {
            DBGLOG(INIT, ERROR, ("LP cannot be own back, Timeout[%u](%ums), BusAccessError[%u], Reseting[%u], CardRemoved[%u] NoAck[%u]\n",
                fgTimeout,
                kalGetTimeTick() - u4CurrTick,
                fgIsBusAccessFailed,
                kalIsResetting(),
                kalIsCardRemoved(prAdapter->prGlueInfo),
                wlanIsChipNoAck(prAdapter)));
            fgStatus = FALSE;
            break;
        }
        else {
            if((i & (LP_OWN_BACK_CLR_OWN_ITERATION - 1)) == 0) {
                /* Software get LP ownership - per 256 iterations */
                HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
            }

            /* Delay for LP engine to complete its operation. */
            kalMsleep(LP_OWN_BACK_LOOP_DELAY_MS);
            i++;
        }
    }

    return fgStatus;
}
示例#3
0
/*----------------------------------------------------------------------------*/
VOID roamingFsmRunEventStart(IN P_ADAPTER_T prAdapter)
{
	P_ROAMING_INFO_T prRoamingFsmInfo;
	ENUM_ROAMING_STATE_T eNextState;
	P_BSS_INFO_T prAisBssInfo;
	ROAMING_PARAM_T rParam;

	prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);

	/* Check Roaming Conditions */
	ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

	prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
	if (prAisBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
		return;

	DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING START: Current Time = %u\n", kalGetTimeTick()));

	/* IDLE, ROAM -> DECISION */
	/* Errors as DECISION, DISCOVERY -> DECISION */
	if (!(prRoamingFsmInfo->eCurrentState == ROAMING_STATE_IDLE ||
		prRoamingFsmInfo->eCurrentState == ROAMING_STATE_ROAM))
		return;

	eNextState = ROAMING_STATE_DECISION;
	if (eNextState != prRoamingFsmInfo->eCurrentState) {
		rParam.u2Event = ROAMING_EVENT_START;
		roamingFsmSendCmd(prAdapter, (P_ROAMING_PARAM_T) & rParam);

		/* Step to next state */
		roamingFsmSteps(prAdapter, eNextState);
	}

	return;
}				/* end of roamingFsmRunEventStart() */
示例#4
0
/*----------------------------------------------------------------------------*/
VOID
roamingFsmSendCmd (
    IN P_ADAPTER_T prAdapter,
    IN P_ROAMING_PARAM_T prParam
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    WLAN_STATUS rStatus;

    DBGLOG(ROAMING, LOUD, ("->roamingFsmSendCmd(): Current Time = %ld\n", kalGetTimeTick()));

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    rStatus = wlanSendSetQueryCmd (
                prAdapter,                  /* prAdapter */
                CMD_ID_ROAMING_TRANSIT,     /* ucCID */
                TRUE,                       /* fgSetQuery */
                FALSE,                      /* fgNeedResp */
                FALSE,                      /* fgIsOid */
                NULL,                       /* pfCmdDoneHandler */
                NULL,                       /* pfCmdTimeoutHandler */
                sizeof(ROAMING_PARAM_T),    /* u4SetQueryInfoLen */
                (PUINT_8) prParam,          /* pucInfoBuffer */
                NULL,                       /* pvSetQueryBuffer */
                0                           /* u4SetQueryBufferLen */
                );

    ASSERT(rStatus == WLAN_STATUS_PENDING);

    return;
} /* end of roamingFsmSendCmd() */
示例#5
0
/*----------------------------------------------------------------------------*/
VOID roamingFsmRunEventFail(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Param)
{
	P_ROAMING_INFO_T prRoamingFsmInfo;
	ENUM_ROAMING_STATE_T eNextState;
	ROAMING_PARAM_T rParam;

	prRoamingFsmInfo =
	    (P_ROAMING_INFO_T) & (prAdapter->rWifiVar.rRoamingInfo);

/* Check Roaming Conditions */
	ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

	DBGLOG(ROAMING, EVENT,
	       ("EVENT-ROAMING FAIL: reason %x Current Time = %ld\n", u4Param,
		kalGetTimeTick()));

/* IDLE, ROAM -> DECISION */
/* Errors as IDLE, DECISION, DISCOVERY -> DECISION */
	if (prRoamingFsmInfo->eCurrentState != ROAMING_STATE_ROAM) {
		return;
	}

	eNextState = ROAMING_STATE_DECISION;
/* ROAM -> DECISION */
	if (eNextState != prRoamingFsmInfo->eCurrentState) {
		rParam.u2Event = ROAMING_EVENT_FAIL;
		rParam.u2Data = (UINT_16) (u4Param & 0xffff);
		roamingFsmSendCmd(prAdapter, (P_ROAMING_PARAM_T) & rParam);

/* Step to next state */
		roamingFsmSteps(prAdapter, eNextState);
	}

	return;
}				/* end of roamingFsmRunEventFail() */
示例#6
0
/*----------------------------------------------------------------------------*/
VOID
roamingFsmRunEventRoam (
    IN P_ADAPTER_T prAdapter
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    ENUM_ROAMING_STATE_T eNextState;
    ROAMING_PARAM_T rParam;

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    /* Check Roaming Conditions */
    ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

    DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING ROAM: Current Time = %ld\n", kalGetTimeTick()));

    /* IDLE, ROAM -> DECISION */
    /* Errors as IDLE, DECISION, ROAM -> ROAM */
    if (prRoamingFsmInfo->eCurrentState != ROAMING_STATE_DISCOVERY) {
        return;
    }

    eNextState = ROAMING_STATE_ROAM;
    /* DISCOVERY -> ROAM */
    if (eNextState != prRoamingFsmInfo->eCurrentState) {
    	  rParam.u2Event = ROAMING_EVENT_ROAM;
    	  roamingFsmSendCmd(prAdapter, (P_ROAMING_PARAM_T) &rParam);

    	  /* Step to next state */
        roamingFsmSteps(prAdapter, eNextState);
    }

    return;
} /* end of roamingFsmRunEventRoam() */
示例#7
0
/*----------------------------------------------------------------------------*/
VOID
roamingFsmRunEventAbort (
    IN P_ADAPTER_T prAdapter
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    ENUM_ROAMING_STATE_T eNextState;
    ROAMING_PARAM_T rParam;

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

    DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING ABORT: Current Time = %ld\n", kalGetTimeTick()));

    eNextState = ROAMING_STATE_IDLE;
    /* IDLE, DECISION, DISCOVERY, ROAM -> IDLE */
    if (eNextState != prRoamingFsmInfo->eCurrentState) {
    	  rParam.u2Event = ROAMING_EVENT_ABORT;
    	  roamingFsmSendCmd(prAdapter, (P_ROAMING_PARAM_T) &rParam);

        /* Step to next state */
        roamingFsmSteps(prAdapter, eNextState);
    }

    return;
} /* end of roamingFsmRunEventAbort() */
示例#8
0
/*----------------------------------------------------------------------------*/
static WLAN_STATUS
wnmRunEventTimgingMeasTxDone(IN P_ADAPTER_T prAdapter,
			     IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
{
	P_STA_RECORD_T prStaRec;

	ASSERT(prAdapter);
	ASSERT(prMsduInfo);

	DBGLOG(WNM, LOUD, "EVENT-TX DONE: Current Time = %ld\n", kalGetTimeTick());

	prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);

	if ((!prStaRec) || (!prStaRec->fgIsInUse))
		return WLAN_STATUS_SUCCESS;	/* For the case of replying ERROR STATUS CODE */

	DBGLOG(WNM, TRACE,
	       "wnmRunEventTimgingMeasTxDone: ucDialog %d ucFollowUp %d u4ToD %x u4ToA %x",
		prStaRec->rWNMTimingMsmt.ucDialogToken,
		prStaRec->rWNMTimingMsmt.ucFollowUpDialogToken, prStaRec->rWNMTimingMsmt.u4ToD,
		prStaRec->rWNMTimingMsmt.u4ToA);

	prStaRec->rWNMTimingMsmt.ucFollowUpDialogToken = prStaRec->rWNMTimingMsmt.ucDialogToken;
	prStaRec->rWNMTimingMsmt.ucDialogToken = ++ucTimingMeasToken;

	wnmComposeTimingMeasFrame(prAdapter, prStaRec, NULL);

	return WLAN_STATUS_SUCCESS;

}				/* end of wnmRunEventTimgingMeasTxDone() */
WLAN_STATUS
wlanoidQueryP2pRssi(IN P_ADAPTER_T prAdapter,
		    IN PVOID pvQueryBuffer,
		    IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
{
	DEBUGFUNC("wlanoidQueryP2pRssi");

	ASSERT(prAdapter);
	ASSERT(pu4QueryInfoLen);
	if (u4QueryBufferLen) {
		ASSERT(pvQueryBuffer);
	}

	*pu4QueryInfoLen = sizeof(PARAM_RSSI);

	/* Check for query buffer length */
	if (u4QueryBufferLen < *pu4QueryInfoLen) {
		DBGLOG(REQ, WARN, ("Too short length %ld\n", u4QueryBufferLen));
		return WLAN_STATUS_BUFFER_TOO_SHORT;
	}

	if (prAdapter->fgIsP2pLinkQualityValid == TRUE &&
	    (kalGetTimeTick() - prAdapter->rP2pLinkQualityUpdateTime) <=
	    CFG_LINK_QUALITY_VALID_PERIOD) {
		PARAM_RSSI rRssi;

		rRssi = (PARAM_RSSI) prAdapter->rP2pLinkQuality.cRssi;	/* ranged from (-128 ~ 30) in unit of dBm */

		if (rRssi > PARAM_WHQL_RSSI_MAX_DBM)
			rRssi = PARAM_WHQL_RSSI_MAX_DBM;
		else if (rRssi < PARAM_WHQL_RSSI_MIN_DBM)
			rRssi = PARAM_WHQL_RSSI_MIN_DBM;

		kalMemCopy(pvQueryBuffer, &rRssi, sizeof(PARAM_RSSI));
		return WLAN_STATUS_SUCCESS;
	}
#ifdef LINUX
	return wlanSendSetQueryCmd(prAdapter,
				   CMD_ID_GET_LINK_QUALITY,
				   FALSE,
				   TRUE,
				   TRUE,
				   nicCmdEventQueryLinkQuality,
				   nicOidCmdTimeoutCommon,
				   *pu4QueryInfoLen,
				   pvQueryBuffer, pvQueryBuffer, u4QueryBufferLen);
#else
	return wlanSendSetQueryCmd(prAdapter,
				   CMD_ID_GET_LINK_QUALITY,
				   FALSE,
				   TRUE,
				   TRUE,
				   nicCmdEventQueryLinkQuality,
				   nicOidCmdTimeoutCommon,
				   0, NULL, pvQueryBuffer, u4QueryBufferLen);

#endif
}				/* wlanoidQueryP2pRssi */
示例#10
0
/*----------------------------------------------------------------------------*/
BOOLEAN nicpmSetDriverOwn(IN P_ADAPTER_T prAdapter)
{
#define LP_OWN_BACK_TOTAL_DELAY_MS      8192	/* exponential of 2 */
#define LP_OWN_BACK_LOOP_DELAY_MS       1	/* exponential of 2 */
#define LP_OWN_BACK_CLR_OWN_ITERATION   256	/* exponential of 2 */

	BOOLEAN fgStatus = TRUE;
	UINT_32 i, u4CurrTick, u4RegValue = 0;

	ASSERT(prAdapter);

	if (prAdapter->fgIsFwOwn == FALSE)
		return fgStatus;

	u4CurrTick = kalGetTimeTick();
	i = 0;
	while (1) {
		HAL_MCR_RD(prAdapter, MCR_WHLPCR, &u4RegValue);

		if (u4RegValue & WHLPCR_FW_OWN_REQ_SET) {
			prAdapter->fgIsFwOwn = FALSE;
			break;
		} else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
			   || fgIsBusAccessFailed == TRUE
			   || (kalGetTimeTick() - u4CurrTick) >
			   LP_OWN_BACK_TOTAL_DELAY_MS
			   || fgIsResetting == TRUE) {
/* ERRORLOG(("LP cannot be own back (for %ld ms)", kalGetTimeTick() - u4CurrTick)); */
			fgStatus = FALSE;
			break;
		} else {
			if ((i & (LP_OWN_BACK_CLR_OWN_ITERATION - 1)) == 0) {
/* Software get LP ownership - per 256 iterations */
				HAL_MCR_WR(prAdapter,
					   MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
			}

/* Delay for LP engine to complete its operation. */
			kalMsleep(LP_OWN_BACK_LOOP_DELAY_MS);
			i++;
		}
	}

	return fgStatus;
}
示例#11
0
/*----------------------------------------------------------------------------*/
WLAN_STATUS roamingFsmProcessEvent(IN P_ADAPTER_T prAdapter, IN P_ROAMING_PARAM_T prParam)
{
	DBGLOG(ROAMING, LOUD, ("ROAMING Process Events: Current Time = %u\n", kalGetTimeTick()));

	if (ROAMING_EVENT_DISCOVERY == prParam->u2Event)
		roamingFsmRunEventDiscovery(prAdapter, prParam->u2Data);

	return WLAN_STATUS_SUCCESS;
}
示例#12
0
/*----------------------------------------------------------------------------*/
VOID roamingFsmUninit(IN P_ADAPTER_T prAdapter)
{
	P_ROAMING_INFO_T prRoamingFsmInfo;

	DBGLOG(ROAMING, LOUD, ("->roamingFsmUninit(): Current Time = %u\n", kalGetTimeTick()));

	prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);

	prRoamingFsmInfo->eCurrentState = ROAMING_STATE_IDLE;

	return;
}				/* end of roamingFsmUninit() */
示例#13
0
文件: roaming_fsm.c 项目: SelfImp/m75
/*----------------------------------------------------------------------------*/
WLAN_STATUS
roamingFsmProcessEvent (
    IN P_ADAPTER_T prAdapter,
    IN P_CMD_ROAMING_TRANSIT_T prTransit
    )
{
    DBGLOG(ROAMING, LOUD, ("ROAMING Process Events: Current Time = %ld\n", kalGetTimeTick()));

    if (ROAMING_EVENT_DISCOVERY == prTransit->u2Event) {
        roamingFsmRunEventDiscovery(prAdapter, prTransit->u2Data);
    }

    return WLAN_STATUS_SUCCESS;
}
示例#14
0
/*----------------------------------------------------------------------------*/
VOID roamingFsmScanResultsUpdate(IN P_ADAPTER_T prAdapter)
{
	P_ROAMING_INFO_T prRoamingFsmInfo;

	prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);

	/* Check Roaming Conditions */
	ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

	DBGLOG(ROAMING, LOUD, ("->roamingFsmScanResultsUpdate(): Current Time = %u", kalGetTimeTick()));

	GET_CURRENT_SYSTIME(&prRoamingFsmInfo->rRoamingDiscoveryUpdateTime);

	return;
}				/* end of roamingFsmScanResultsUpdate() */
示例#15
0
/*----------------------------------------------------------------------------*/
VOID roamingFsmInit(IN P_ADAPTER_T prAdapter)
{
	P_ROAMING_INFO_T prRoamingFsmInfo;
	P_CONNECTION_SETTINGS_T prConnSettings;

	DBGLOG(ROAMING, LOUD, ("->roamingFsmInit(): Current Time = %u\n", kalGetTimeTick()));

	prRoamingFsmInfo = (P_ROAMING_INFO_T) &(prAdapter->rWifiVar.rRoamingInfo);
	prConnSettings = &(prAdapter->rWifiVar.rConnSettings);

	/* 4 <1> Initiate FSM */
	prRoamingFsmInfo->fgIsEnableRoaming = prConnSettings->fgIsEnableRoaming;
	prRoamingFsmInfo->eCurrentState = ROAMING_STATE_IDLE;
	prRoamingFsmInfo->rRoamingDiscoveryUpdateTime = 0;

	return;
}				/* end of roamingFsmInit() */
/*----------------------------------------------------------------------------*/
VOID
roamingFsmRunEventDiscovery (
    IN P_ADAPTER_T prAdapter,
	IN P_ROAMING_PARAM_T pParam
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    ENUM_ROAMING_STATE_T eNextState;

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    /* Check Roaming Conditions */
    ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

    DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING DISCOVERY: Current Time = %u Reason = %u\n",
		kalGetTimeTick(), pParam->u2Reason));

    /* DECISION -> DISCOVERY */
    /* Errors as IDLE, DISCOVERY, ROAM -> DISCOVERY */
    if (prRoamingFsmInfo->eCurrentState != ROAMING_STATE_DECISION) {
        return;
    }

#if CFG_SUPPORT_ROAMING_ENC
	prRoamingFsmInfo->RoamingEntryTimeoutSkipCount = 0;
#endif

    eNextState = ROAMING_STATE_DISCOVERY;
    /* DECISION -> DISCOVERY */
    if (eNextState != prRoamingFsmInfo->eCurrentState) {
        P_BSS_INFO_T prAisBssInfo;
        P_BSS_DESC_T prBssDesc;

        // sync. rcpi with firmware
        prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
        prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
        if (prBssDesc) {
			   prBssDesc->ucRCPI = (UINT_8)(pParam->u2Data&0xff);
        }

        roamingFsmSteps(prAdapter, eNextState);
    }

    return;
} /* end of roamingFsmRunEventDiscovery() */
示例#17
0
/*----------------------------------------------------------------------------*/
VOID
timerStartTimer (
    IN P_ADAPTER_T              prAdapter,
    IN P_TIMER_T                prTimer,
    IN UINT_32                  u4TimeoutMs
    )
{
    P_LINK_T prTimerList;
    OS_SYSTIME rExpiredSysTime;

    ASSERT(prAdapter);
    ASSERT(prTimer);

    prTimerList= &prAdapter->rTimerList;

    /* To avoid infinite loop in function wlanDoTimeOutCheck(),
     * zero interval is not permitted.
     */
    if (u4TimeoutMs == 0) {
        u4TimeoutMs = 1;
    }

    rExpiredSysTime = kalGetTimeTick() + MSEC_TO_SYSTIME(u4TimeoutMs);

    /* If no timer pending or the fast time interval is used. */
    if (prTimerList->prNext == (P_LINK_ENTRY_T)prTimerList ||
        TIME_BEFORE(rExpiredSysTime, prAdapter->rNextExpiredSysTime)) {
        if (timerSetTimer(prAdapter, MSEC_TO_SYSTIME(u4TimeoutMs))) {
            prAdapter->rNextExpiredSysTime = rExpiredSysTime;
        }
    }

    /* Add this timer to checking list */
    prTimer->rExpiredSysTime = rExpiredSysTime;

    if (!timerPendingTimer(prTimer)) {
        LINK_INSERT_TAIL(prTimerList, &prTimer->rLinkEntry);
    }

    return;
} /* timerStartTimer */
示例#18
0
文件: roaming_fsm.c 项目: SelfImp/m75
/*----------------------------------------------------------------------------*/
VOID
roamingFsmRunEventStart (
    IN P_ADAPTER_T prAdapter
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    ENUM_ROAMING_STATE_T eNextState;
    P_BSS_INFO_T prAisBssInfo;
    CMD_ROAMING_TRANSIT_T rTransit;

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    /* Check Roaming Conditions */
    ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

    prAisBssInfo = prAdapter->prAisBssInfo;
    if (prAisBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE) {
        return;
    }

    DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING START: Current Time = %ld\n", kalGetTimeTick()));

    /* IDLE, ROAM -> DECISION */
    /* Errors as DECISION, DISCOVERY -> DECISION */
    if (!(prRoamingFsmInfo->eCurrentState == ROAMING_STATE_IDLE
    	  || prRoamingFsmInfo->eCurrentState == ROAMING_STATE_ROAM)) {
        return;
    }

    eNextState = ROAMING_STATE_DECISION;
    if (eNextState != prRoamingFsmInfo->eCurrentState) {
    	  rTransit.u2Event = ROAMING_EVENT_START;
          rTransit.u2Data = prAisBssInfo->ucBssIndex;
    	  roamingFsmSendCmd(prAdapter, (P_CMD_ROAMING_TRANSIT_T) &rTransit);

    	  /* Step to next state */
        roamingFsmSteps(prAdapter, eNextState);
    }

    return;
} /* end of roamingFsmRunEventStart() */
示例#19
0
文件: roaming_fsm.c 项目: SelfImp/m75
/*----------------------------------------------------------------------------*/
VOID
roamingFsmRunEventDiscovery (
    IN P_ADAPTER_T prAdapter,
    IN UINT_32 u4Param
    )
{
    P_ROAMING_INFO_T prRoamingFsmInfo;
    ENUM_ROAMING_STATE_T eNextState;

    prRoamingFsmInfo = (P_ROAMING_INFO_T)&(prAdapter->rWifiVar.rRoamingInfo);

    /* Check Roaming Conditions */
    ROAMING_ENABLE_CHECK(prRoamingFsmInfo);

    DBGLOG(ROAMING, EVENT, ("EVENT-ROAMING DISCOVERY: Current Time = %ld\n", kalGetTimeTick()));

    /* DECISION -> DISCOVERY */
    /* Errors as IDLE, DISCOVERY, ROAM -> DISCOVERY */
    if (prRoamingFsmInfo->eCurrentState != ROAMING_STATE_DECISION) {
        return;
    }

    eNextState = ROAMING_STATE_DISCOVERY;
    /* DECISION -> DISCOVERY */
    if (eNextState != prRoamingFsmInfo->eCurrentState) {
        P_BSS_INFO_T prAisBssInfo;
        P_BSS_DESC_T prBssDesc;

        // sync. rcpi with firmware
        prAisBssInfo = prAdapter->prAisBssInfo;
        prBssDesc = scanSearchBssDescByBssid(prAdapter, prAisBssInfo->aucBSSID);
        if (prBssDesc) {
        	  prBssDesc->ucRCPI = (UINT_8)(u4Param&0xff);
        }

        roamingFsmSteps(prAdapter, eNextState);
    }

    return;
} /* end of roamingFsmRunEventDiscovery() */
/*----------------------------------------------------------------------------*/
BOOLEAN nicpmSetDriverOwn(IN P_ADAPTER_T prAdapter)
{
#define LP_OWN_BACK_TOTAL_DELAY_MS      2048    /* exponential of 2 */
#define LP_OWN_BACK_LOOP_DELAY_MS       1       /* exponential of 2 */
#define LP_OWN_BACK_CLR_OWN_ITERATION   256     /* exponential of 2 */
#define LP_OWN_BACK_FAILED_RETRY_CNT    5
#define LP_OWN_BACK_FAILED_LOG_SKIP_MS  2000
#define LP_OWN_BACK_FAILED_RESET_CNT    5

	BOOLEAN fgStatus = TRUE;
	UINT_32 i, u4CurrTick, u4RegValue = 0;
	BOOLEAN fgTimeout;

	ASSERT(prAdapter);

	if (prAdapter->fgIsFwOwn == FALSE)
		return fgStatus;

	DBGLOG(INIT, INFO, ("DRIVER OWN\n"));

	u4CurrTick = kalGetTimeTick();
	i = 0;
	while (1) {
		HAL_MCR_RD(prAdapter, MCR_WHLPCR, &u4RegValue);

		fgTimeout =
		    ((kalGetTimeTick() - u4CurrTick) > LP_OWN_BACK_TOTAL_DELAY_MS) ? TRUE : FALSE;

		if (u4RegValue & WHLPCR_FW_OWN_REQ_SET) {
			prAdapter->fgIsFwOwn = FALSE;
            prAdapter->u4OwnFailedCount = 0;
            prAdapter->u4OwnFailedLogCount = 0;
			break;
        }
        else if((i > LP_OWN_BACK_FAILED_RETRY_CNT) && 
            (kalIsCardRemoved(prAdapter->prGlueInfo) || fgIsBusAccessFailed || fgTimeout || wlanIsChipNoAck(prAdapter))) {

            if ((prAdapter->u4OwnFailedCount == 0) || 
                CHECK_FOR_TIMEOUT(u4CurrTick, prAdapter->rLastOwnFailedLogTime, MSEC_TO_SYSTIME(LP_OWN_BACK_FAILED_LOG_SKIP_MS))) {
                      
                DBGLOG(INIT, ERROR, ("LP cannot be own back, Timeout[%u](%ums), BusAccessError[%u], Reseting[%u], CardRemoved[%u] NoAck[%u] Cnt[%u]\n",
                    fgTimeout,
                    kalGetTimeTick() - u4CurrTick,
                    fgIsBusAccessFailed,
                    kalIsResetting(),
                    kalIsCardRemoved(prAdapter->prGlueInfo),
                    wlanIsChipNoAck(prAdapter), 
                    prAdapter->u4OwnFailedCount));

                DBGLOG(INIT, INFO, ("Skip LP own back failed log for next %ums\n", LP_OWN_BACK_FAILED_LOG_SKIP_MS));

                prAdapter->u4OwnFailedLogCount++;
                if(prAdapter->u4OwnFailedLogCount > LP_OWN_BACK_FAILED_RESET_CNT) {
                    /* Trigger RESET */
#if CFG_CHIP_RESET_SUPPORT                    
                    glResetTrigger(prAdapter);
#endif
                }
                GET_CURRENT_SYSTIME(&prAdapter->rLastOwnFailedLogTime);
            }
            
            prAdapter->u4OwnFailedCount++;
			fgStatus = FALSE;
			break;
		} else {
			if ((i & (LP_OWN_BACK_CLR_OWN_ITERATION - 1)) == 0) {
				/* Software get LP ownership - per 256 iterations */
				HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
			}

			/* Delay for LP engine to complete its operation. */
			kalMsleep(LP_OWN_BACK_LOOP_DELAY_MS);
			i++;
		}
	}

	return fgStatus;
}
示例#21
0
/*----------------------------------------------------------------------------*/
WLAN_STATUS
aaaFsmRunEventTxDone(IN P_ADAPTER_T prAdapter,
		     IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
{
	P_STA_RECORD_T prStaRec;
	P_BSS_INFO_T prBssInfo;


	ASSERT(prAdapter);
	ASSERT(prMsduInfo);

	DBGLOG(AAA, LOUD, ("EVENT-TX DONE: Current Time = %ld\n", kalGetTimeTick()));

	prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);

	if ((!prStaRec) || (!prStaRec->fgIsInUse))
		return WLAN_STATUS_SUCCESS;	/* For the case of replying ERROR STATUS CODE */


	ASSERT(prStaRec->ucBssIndex <= MAX_BSS_INDEX);

	prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);

    /* Trigger statistics log if Auth/Assoc Tx failed */
    if(rTxDoneStatus != TX_RESULT_SUCCESS) {
        wlanTriggerStatsLog(prAdapter, prAdapter->rWifiVar.u4StatsLogDuration);
    }

	switch (prStaRec->eAuthAssocState) {
	case AAA_STATE_SEND_AUTH2:
		{
			/* Strictly check the outgoing frame is matched with current AA STATE */
			if (authCheckTxAuthFrame(prAdapter,
						 prMsduInfo,
						 AUTH_TRANSACTION_SEQ_2) != WLAN_STATUS_SUCCESS) {
				break;
			}

			if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
				if (TX_RESULT_SUCCESS == rTxDoneStatus) {

					/* NOTE(Kevin): Change to STATE_2 at TX Done */
					cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
				} else {

					prStaRec->eAuthAssocState = AA_STATE_IDLE;

					/* NOTE(Kevin): Change to STATE_1 */
					cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);

#if CFG_ENABLE_WIFI_DIRECT
					if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P) {
						p2pRoleFsmRunEventAAATxFail(prAdapter, prStaRec,
									    prBssInfo);
					}
#endif				/* CFG_ENABLE_WIFI_DIRECT */
#if CFG_ENABLE_BT_OVER_WIFI
					if (IS_STA_BOW_TYPE(prStaRec))
						bowRunEventAAATxFail(prAdapter, prStaRec);

#endif				/* CFG_ENABLE_BT_OVER_WIFI */
				}

			}
			/* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */

		}
		break;

	case AAA_STATE_SEND_ASSOC2:
		{
			/* Strictly check the outgoing frame is matched with current SAA STATE */
			if (assocCheckTxReAssocRespFrame(prAdapter, prMsduInfo) !=
			    WLAN_STATUS_SUCCESS) {
				break;
			}

			if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
				if (TX_RESULT_SUCCESS == rTxDoneStatus) {

					prStaRec->eAuthAssocState = AA_STATE_IDLE;

					/* NOTE(Kevin): Change to STATE_3 at TX Done */
#if CFG_ENABLE_WIFI_DIRECT
					if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P) {
						p2pRoleFsmRunEventAAASuccess(prAdapter, prStaRec,
									     prBssInfo);
					}
#endif				/* CFG_ENABLE_WIFI_DIRECT */

#if CFG_ENABLE_BT_OVER_WIFI

					if (IS_STA_BOW_TYPE(prStaRec))
						bowRunEventAAAComplete(prAdapter, prStaRec);

#endif				/* CFG_ENABLE_BT_OVER_WIFI */

				} else {

					prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;

					/* NOTE(Kevin): Change to STATE_2 */
					cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);

#if CFG_ENABLE_WIFI_DIRECT
					if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P) {
						p2pRoleFsmRunEventAAATxFail(prAdapter, prStaRec,
									    prBssInfo);
					}
#endif				/* CFG_ENABLE_WIFI_DIRECT */

#if CFG_ENABLE_BT_OVER_WIFI
					if (IS_STA_BOW_TYPE(prStaRec))
						bowRunEventAAATxFail(prAdapter, prStaRec);

#endif				/* CFG_ENABLE_BT_OVER_WIFI */

				}
			}
			/* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
		}
		break;

	case AA_STATE_IDLE:
		/* 2013-08-27 frog:  Do nothing.
		 * Somtimes we may send Assoc Resp twice. (Rx Assoc Req before the first Assoc TX Done)
		 * The AssocState is changed to IDLE after first TX done.
		 * Free station record when IDLE is seriously wrong.
		 */
		/* /cnmStaRecFree(prAdapter, prStaRec); */

	default:
		break;		/* Ignore other cases */
	}


	return WLAN_STATUS_SUCCESS;

}				/* end of aaaFsmRunEventTxDone() */
示例#22
0
/*----------------------------------------------------------------------------*/
BOOLEAN nicpmSetDriverOwn(IN P_ADAPTER_T prAdapter)
{
#define LP_OWN_BACK_TOTAL_DELAY_MS      2000	/* exponential of 2 */
#define LP_OWN_BACK_LOOP_DELAY_MS       1	/* exponential of 2 */
#define LP_OWN_BACK_CLR_OWN_ITERATION   256	/* exponential of 2 */

	BOOLEAN fgStatus = TRUE;
	UINT_32 i, u4CurrTick;
	UINT_32 u4RegValue = 0;
	GL_HIF_INFO_T *HifInfo;

	ASSERT(prAdapter);

	if (prAdapter->fgIsFwOwn == FALSE)
		return fgStatus;

	HifInfo = &prAdapter->prGlueInfo->rHifInfo;

	u4CurrTick = kalGetTimeTick();
	STATS_DRIVER_OWN_START_RECORD();
	i = 0;

	while (1) {
		HAL_MCR_RD(prAdapter, MCR_WHLPCR, &u4RegValue);

		if (u4RegValue & WHLPCR_FW_OWN_REQ_SET) {
			prAdapter->fgIsFwOwn = FALSE;
			break;
		} else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
			   || fgIsBusAccessFailed == TRUE
			   || (kalGetTimeTick() - u4CurrTick) > LP_OWN_BACK_TOTAL_DELAY_MS || fgIsResetting == TRUE) {
			/* ERRORLOG(("LP cannot be own back (for %ld ms)", kalGetTimeTick() - u4CurrTick)); */
			fgStatus = FALSE;
			if (fgIsResetting != TRUE) {
				UINT_32 u4FwCnt;
				static unsigned int u4OwnCnt;
				HAL_MCR_RD(prAdapter, MCR_D2HRM2R, &u4RegValue);
				DBGLOG(NIC, WARN, "<WiFi> MCR_D2HRM2R = 0x%x\n", u4RegValue);
				DBGLOG(NIC, WARN,
					"<WiFi> Fatal error! Driver own fail!!!!!!!!!!!! %d\n", u4OwnCnt++);

				DBGLOG(NIC, WARN, "CONNSYS FW CPUINFO:\n");
				for (u4FwCnt = 0; u4FwCnt < 16; u4FwCnt++)
					DBGLOG(NIC, WARN, "0x%08x ", MCU_REG_READL(HifInfo, CONN_MCU_CPUPCR));
				/* CONSYS_REG_READ(CONSYS_CPUPCR_REG) */
			}
			break;
		} else {
			if ((i & (LP_OWN_BACK_CLR_OWN_ITERATION - 1)) == 0) {
				/* Software get LP ownership - per 256 iterations */
				HAL_MCR_WR(prAdapter, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
			}

			/* Delay for LP engine to complete its operation. */
			kalMsleep(LP_OWN_BACK_LOOP_DELAY_MS);
			i++;
		}
	}

	STATS_DRIVER_OWN_END_RECORD();
	STATS_DRIVER_OWN_STOP();

	return fgStatus;
}
VOID
nicCmdEventLeaveRfTest(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
{
	UINT_32 u4WHISR = 0, u4Value = 0;
	UINT_8 aucTxCount[8];

	ASSERT(prAdapter);
	ASSERT(prCmdInfo);

	/* 1. Disable Interrupt */
	HAL_INTR_DISABLE(prAdapter);

	/* 2. Block til firmware completed leaving from RF test mode */
	kalMsleep(500);
	while (1) {
		HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);

		if (u4Value & WCIR_WLAN_READY) {
			break;
		} else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE
			   || fgIsBusAccessFailed == TRUE) {
			if (prCmdInfo->fgIsOid) {
				/* Update Set Infomation Length */
				kalOidComplete(prAdapter->prGlueInfo,
					       prCmdInfo->fgSetQuery,
					       prCmdInfo->u4SetInfoLen, WLAN_STATUS_NOT_SUPPORTED);

			}
			return;
		} else {
			kalMsleep(10);
		}
	}

	/* 3. Clear Interrupt Status */
	HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8) & u4WHISR);
	if (HAL_IS_TX_DONE_INTR(u4WHISR)) {
		HAL_READ_TX_RELEASED_COUNT(prAdapter, aucTxCount);
	}
	/* 4. Reset TX Counter */
	nicTxResetResource(prAdapter);

	/* 5. Re-enable Interrupt */
	HAL_INTR_ENABLE(prAdapter);

	/* 6. set driver-land variable */
	prAdapter->fgTestMode = FALSE;

	/* 7. completion indication */
	if (prCmdInfo->fgIsOid) {
		/* Update Set Infomation Length */
		kalOidComplete(prAdapter->prGlueInfo,
			       prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_SUCCESS);
	}

	/* 8. Indicate as disconnected */
	if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {

		kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
					     WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);

		prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
	}
#if CFG_SUPPORT_NVRAM
	/* 9. load manufacture data */
	wlanLoadManufactureData(prAdapter, kalGetConfiguration(prAdapter->prGlueInfo));
#endif

	/* 10. Override network address */
	wlanUpdateNetworkAddress(prAdapter);

	return;
}
/*----------------------------------------------------------------------------*/
VOID
nicCmdEventQueryMemDump(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
{
	UINT_32 u4QueryInfoLen;
	P_PARAM_CUSTOM_MEM_DUMP_STRUC_T prMemDumpInfo;
	P_GLUE_INFO_T prGlueInfo;
	P_EVENT_DUMP_MEM_T prEventDumpMem;
	static UINT_8 aucPath[256];
	static UINT_32 u4CurTimeTick;

	ASSERT(prAdapter);
	ASSERT(prCmdInfo);
	ASSERT(pucEventBuf);

	/* 4 <2> Update information of OID */
	if (prCmdInfo->fgIsOid) {
		prGlueInfo = prAdapter->prGlueInfo;
		prEventDumpMem = (P_EVENT_DUMP_MEM_T) (pucEventBuf);

		u4QueryInfoLen = sizeof(P_PARAM_CUSTOM_MEM_DUMP_STRUC_T);

		prMemDumpInfo = (P_PARAM_CUSTOM_MEM_DUMP_STRUC_T) prCmdInfo->pvInformationBuffer;
		prMemDumpInfo->u4Address = prEventDumpMem->u4Address;
		prMemDumpInfo->u4Length = prEventDumpMem->u4Length;
		prMemDumpInfo->u4RemainLength = prEventDumpMem->u4RemainLength;
		prMemDumpInfo->ucFragNum = prEventDumpMem->ucFragNum;

#if 0
		do {
			UINT_32 i = 0;
			printk("Rx dump address 0x%X, Length %d, FragNum %d, remain %d\n",
			       prEventDumpMem->u4Address,
			       prEventDumpMem->u4Length,
			       prEventDumpMem->ucFragNum, prEventDumpMem->u4RemainLength);
#if 0
			for (i = 0; i < prEventDumpMem->u4Length; i++) {
				printk("%02X ", prEventDumpMem->aucBuffer[i]);
				if (i % 32 == 31) {
					printk("\n");
				}
			}
#endif
		} while (FALSE);
#endif

		if (prEventDumpMem->ucFragNum == 1) {
			/* Store memory dump into sdcard,
			 * path /sdcard/dump_<current  system tick>_<memory address>_<memory length>.hex
			 */
			u4CurTimeTick = kalGetTimeTick();
			sprintf(aucPath, "/sdcard/dump_%ld_0x%08lX_%ld.hex",
				u4CurTimeTick,
				prEventDumpMem->u4Address,
				prEventDumpMem->u4Length + prEventDumpMem->u4RemainLength);
			kalWriteToFile(aucPath, FALSE, &prEventDumpMem->aucBuffer[0],
				       prEventDumpMem->u4Length);
		} else {
			/* Append current memory dump to the hex file */
			kalWriteToFile(aucPath, TRUE, &prEventDumpMem->aucBuffer[0],
				       prEventDumpMem->u4Length);
		}

		if (prEventDumpMem->u4RemainLength == 0 || prEventDumpMem->u4Address == 0xFFFFFFFF) {
			/* The request is finished or firmware response a error */
			/* Reply time tick to iwpriv */
			*((PUINT_32) prCmdInfo->pvInformationBuffer) = u4CurTimeTick;
			kalOidComplete(prGlueInfo, prCmdInfo->fgSetQuery, u4QueryInfoLen,
				       WLAN_STATUS_SUCCESS);
		} else {
			/* The memory dump request is not finished, Send next command */
			wlanSendMemDumpCmd(prAdapter,
					   prCmdInfo->pvInformationBuffer,
					   prCmdInfo->u4InformationBufferLength);
		}
	}

	return;

}