Пример #1
0
VOID
TXScheduleTheSendComplete(
    _In_  PMP_ADAPTER  Adapter)
/*++

Routine Description:

    This function schedules the transmit DPC on the sending miniport.

Arguments:

    FunctionContext             Pointer to the adapter that is sending frames

Return Value:

    None.

--*/
{
    LARGE_INTEGER liDelay;

    if (!Adapter->SendCompleteWorkItemQueued)
    {
        liDelay.QuadPart = -(NIC_SIMULATED_LATENCY);
        NdisSetTimerObject(Adapter->SendCompleteTimer, liDelay, 0, NULL);
    }

    DEBUGP(MP_TRACE, "[%p] Scheduled Send Complete DPC [Delay: %i].\n", Adapter, NIC_SIMULATED_LATENCY);

}
//------------------------------------------------------------------------------
static void timerDpc(PVOID pSystemParameter1_p,
                     PVOID pFunctionContext_p,
                     PVOID pSystemParameter2_p,
                     PVOID pSystemParameter3_p)
{
    tHresTimerInfo*   pTimerInfo = (tHresTimerInfo*)pFunctionContext_p;
    tTimerHdl         orgTimerHdl;
    UINT              index;

    UNREFERENCED_PARAMETER(pSystemParameter1_p);
    UNREFERENCED_PARAMETER(pSystemParameter2_p);
    UNREFERENCED_PARAMETER(pSystemParameter3_p);

    index = (UINT)HDL_TO_IDX(pTimerInfo->eventArg.timerHdl.handle);

    if (index >= TIMER_COUNT)
        return;      // invalid handle

    orgTimerHdl = pTimerInfo->eventArg.timerHdl.handle;

    if (pTimerInfo->pfnCallback != NULL)
        pTimerInfo->pfnCallback(&pTimerInfo->eventArg);

    if (orgTimerHdl != pTimerInfo->eventArg.timerHdl.handle)
    {
        /* modified timer has already been restarted */
        return;
    }

    if (pTimerInfo->fContinuously)
    {
        NdisSetTimerObject(pTimerInfo->timerObjHandle, pTimerInfo->dueTime, 0, pTimerInfo);
    }
}
Пример #3
0
VOID
VenetResetTimerDpc(PVOID s1, PVOID context, PVOID s2, PVOID s3)
{
    PADAPTER	a = (PADAPTER) context;
    LARGE_INTEGER	interval;
    BOOLEAN		done = TRUE;
    NDIS_STATUS	rc = NDIS_STATUS_SOFT_ERRORS;
    UNREFERENCED_PARAMETER(s1);
    UNREFERENCED_PARAMETER(s2);
    UNREFERENCED_PARAMETER(s3);

    VENET_ADAPTER_GET(a);

    if (VENET_IS_BUSY(a)) {
        done = FALSE;
        VenetFreeQueuedSend(a, NDIS_STATUS_RESET_IN_PROGRESS);
    }

    /* Not done, try again? */
    if (!done && ++a->resetCount <= 20) {
        interval.QuadPart = 500;
        NdisSetTimerObject(a->resetTimer, interval, 0, NULL);
        VENET_ADAPTER_PUT(a);
        return;
    }

    if (done) {
        VENET_CLEAR_FLAG(a, VNET_ADAPTER_RESET);
        rc = NDIS_STATUS_SUCCESS;
    }

    NdisMResetComplete(a->adapterHandle, rc, FALSE);
    VENET_ADAPTER_PUT(a);
}
//------------------------------------------------------------------------------
void startHeartbeatTimer(LONG timeInMs_p)
{
    LARGE_INTEGER   dueTime;

    if (timeInMs_p < 0)
    {
        // negative time not possible.
        DEBUG_LVL_ERROR_TRACE("Negative time for heartbeat timer was specified\n");
        return;
    }

    dueTime.QuadPart = -(timeInMs_p * 10000);
    NdisSetTimerObject(heartbeatTimer_l, dueTime, timeInMs_p, NULL);
}
//------------------------------------------------------------------------------
tOplkError hrestimer_modifyTimer(tTimerHdl* pTimerHdl_p,
                                 ULONGLONG time_p,
                                 tTimerkCallback pfnCallback_p,
                                 ULONG argument_p,
                                 BOOL fContinue_p)
{
    UINT              index;
    tHresTimerInfo*   pTimerInfo;
    LONGLONG          relTime;

    if (pTimerHdl_p == NULL)
        return kErrorTimerInvalidHandle;

    if (*pTimerHdl_p == 0)
    {
        // search free timer info structure
        pTimerInfo = &hresTimerInstance_l.aTimerInfo[0];
        for (index = 0; index < TIMER_COUNT; index++, pTimerInfo++)
        {
            if (pTimerInfo->eventArg.timerHdl.handle == 0)
                break;
        }

        if (index >= TIMER_COUNT)
            return kErrorTimerNoTimerCreated;

        pTimerInfo->eventArg.timerHdl.handle = HDL_INIT(index);
    }
    else
    {
        index = (UINT)HDL_TO_IDX(*pTimerHdl_p);
        if (index >= TIMER_COUNT)
            return kErrorTimerInvalidHandle;

        pTimerInfo = &hresTimerInstance_l.aTimerInfo[index];
    }

    /* increment timer handle
     * (if timer expires right after this statement, the user
     * would detect an unknown timer handle and discard it) */
    pTimerInfo->eventArg.timerHdl.handle = HDL_INC(pTimerInfo->eventArg.timerHdl.handle);
    *pTimerHdl_p = pTimerInfo->eventArg.timerHdl.handle;

    // increase too small time values
    if (fContinue_p != FALSE)
    {
        if (time_p < TIMER_MIN_VAL_CYCLE)
            time_p = TIMER_MIN_VAL_CYCLE;
    }
    else
    {
        if (time_p < TIMER_MIN_VAL_SINGLE)
            time_p = TIMER_MIN_VAL_SINGLE;
    }

    pTimerInfo->eventArg.argument.value = argument_p;
    pTimerInfo->pfnCallback = pfnCallback_p;
    pTimerInfo->fContinuously = fContinue_p;

    relTime = time_p / 100LL;
    if (relTime < 0)
    {
        // Negative value is not allowed
        return kErrorTimerNoTimerCreated;
    }

    pTimerInfo->dueTime.QuadPart = -(relTime);
    NdisSetTimerObject(pTimerInfo->timerObjHandle, pTimerInfo->dueTime, 0, pTimerInfo);

    return kErrorOk;
}
Пример #6
0
// Called when scan on a set of channels is completed
VOID
HelperPortCompletePartialScan(
    _In_  PMP_HELPER_PORT         HelperPort,
    _In_  PMP_SCAN_PARAMETERS     ScanParameters,
    _In_  PNDIS_STATUS            CompletionStatus
    )
{
    LARGE_INTEGER               rescheduleTime;
    BOOLEAN                     requeueScan = TRUE;
    ULONG                       i;

    // release exclusive access
    HelperPortReleaseExclusiveAccess(HelperPort);

    // Determine the next step for scan
    MP_ACQUIRE_PORT_LOCK(HELPPORT_GET_MP_PORT(HelperPort), FALSE);

    if (ScanParameters->PortScanRequest->ChannelCount != 0)
    {
        // All port specified channels are scanned in one shot
        requeueScan = FALSE;
    }
    else
    {
        // Determine if we are done with all the channels on current PHY
        if (ScanParameters->NextChannelIndex >= 
                HelperPort->ScanContext.ScanChannels[ScanParameters->CurrentPhyIndex].ChannelCount)
        {
            // We are done with all phys on current channel, check if there is another
            // phy we need to scan

            requeueScan = FALSE;    // Start with a negative
            for (i = ScanParameters->CurrentPhyIndex + 1; i < HW11_MAX_PHY_COUNT; i++)
            {
                if (HelperPort->ScanContext.ScanChannels[i].ChannelCount > 0)
                {
                    // Found a phy to scan we will requeue the scan.
                    requeueScan = TRUE;

                    // Start from first channel on this new phy
                    ScanParameters->CurrentPhyIndex = i;
                    ScanParameters->NextChannelIndex = 0;
                }
            }
        }
    }
    
    if (ScanParameters->CancelScan)
    {
        // Cancelled
        requeueScan = FALSE;
    }
    
    if (requeueScan == FALSE)
    {
        // We will queuing the scan timer
        ScanParameters->State = SCAN_WAITING_FOR_TIMER;
    }

    if ((*CompletionStatus) != NDIS_STATUS_SUCCESS)
    {
        // Partial scan failed
        MpTrace(COMP_SCAN, DBG_NORMAL, ("Partial scan failed. Status = 0x%08x\n", (*CompletionStatus)));
        
        requeueScan = FALSE;
    }
    
    MP_RELEASE_PORT_LOCK(HELPPORT_GET_MP_PORT(HelperPort), FALSE);

    MpTrace(COMP_SCAN, DBG_LOUD, ("Completed partial scan of %p\n", ScanParameters));

    if (requeueScan)
    {
        if (HelperPort->ScanContext.MediaConnectedCount > 0)
        {    
            // Queue the timer for another scan. We try to schedule this after one
            // context switch interval
            rescheduleTime.QuadPart = Int32x32To64(HelperPort->RegInfo->ScanRescheduleTime, -10000);
        }
        else
        {
            // Noboby is connected yet, Queue the timer for another scan
            rescheduleTime.QuadPart = Int32x32To64(MP_SCAN_RESCHEDULE_TIME_NOT_CONNECTED, -10000);
        }
        
        NdisSetTimerObject(HelperPort->ScanContext.Timer_Scan, rescheduleTime, 0, NULL);
    }
    else
    {
        // We have finished scanning all channels, call the scan completion
        HelperPortCompleteScanProcess(
            HelperPort,
            ScanParameters,
            CompletionStatus
        );
    }
}