Exemple #1
0
VOID
Hvl11Free(
    _In_ _Post_ptr_invalid_  PHVL pHvl
    )
{
    if (NULL != pHvl)
    {
        HvlWaitForPendingThreads(pHvl);
        
        NdisFreeSpinLock(&(pHvl->Lock));
        
        if (pHvl->CtxSWorkItemHandle)
        {
            NdisFreeIoWorkItem(pHvl->CtxSWorkItemHandle);
        }
        
        if (pHvl->NotificationsWorkItemHandle)
        {
            NdisFreeIoWorkItem(pHvl->NotificationsWorkItemHandle);
        }

        if (pHvl->pPnpOpExReq)
        {
            FREE_MEM(pHvl->pPnpOpExReq);
        }

        // free the memory allocated for any pending operations
        HvlDeleteAllPendingOperations(pHvl);
        
        FREE_MEM(pHvl);
    }
}
Exemple #2
0
NTSTATUS
MpResetWorkItem(
    _In_  PVOID                   Context,
    _In_  NDIS_HANDLE             NdisIoWorkItemHandle
    )    
{
    PADAPTER                    adapter = (PADAPTER)Context;
    NDIS_STATUS                 ndisStatus = NDIS_STATUS_SUCCESS;
    BOOLEAN                     addressingReset = FALSE;

    MP_VERIFY_PASSIVE_IRQL();

    //
    // Pass the reset request to the helper port
    //
    ndisStatus = HelperPortHandleMiniportReset(adapter->HelperPort, &addressingReset);
    if (ndisStatus != NDIS_STATUS_SUCCESS)
    {
        MpTrace(COMP_MISC, DBG_SERIOUS, ("Requesting adapter removal because Hw Reset has failed\n"));
        MpRemoveAdapter(adapter);            
    }

    MP_CLEAR_ADAPTER_STATUS(adapter, MP_ADAPTER_IN_RESET);

    NdisFreeIoWorkItem(NdisIoWorkItemHandle);

    // Inform NDIS about reset complete
    NdisMResetComplete(
        adapter->MiniportAdapterHandle,
        ndisStatus,
        addressingReset
        );

    return STATUS_SUCCESS;
}
/**********************************************************
Required NDIS handler for RESET operation
Never happens under normal condition, only if
OID or other call returns PENDING and not completed or if
ParaNdis6_CheckForHang returns true
***********************************************************/
static NDIS_STATUS ParaNdis6_Reset(
        NDIS_HANDLE miniportAdapterContext,
        PBOOLEAN  pAddressingReset)
{
    NDIS_STATUS  status = NDIS_STATUS_FAILURE;
    PARANDIS_ADAPTER *pContext = (PARANDIS_ADAPTER *)miniportAdapterContext;
    NDIS_HANDLE hwo;
    tGeneralWorkItem *pwi;
    DEBUG_ENTRY(0);
    *pAddressingReset = TRUE;
    ParaNdis_DebugHistory(pContext, hopSysReset, NULL, 1, 0, 0);
    hwo = NdisAllocateIoWorkItem(pContext->MiniportHandle);
    pwi = ParaNdis_AllocateMemory(pContext, sizeof(tGeneralWorkItem));
    if (pwi && hwo)
    {
        pwi->pContext = pContext;
        pwi->WorkItem = hwo;
        NdisQueueIoWorkItem(hwo, OnResetWorkItem, pwi);
        status = NDIS_STATUS_PENDING;
    }
    else
    {
        if (pwi) NdisFreeMemory(pwi, 0, 0);
        if (hwo) NdisFreeIoWorkItem(hwo);
        ParaNdis_DebugHistory(pContext, hopSysReset, NULL, 0, status, 0);
    }
    DEBUG_EXIT_STATUS(0, status);
    return status;
}
Exemple #4
0
VOID
Hw11Free(
    __in  PHW                     Hw
    )
{
    NdisFreeSpinLock(&Hw->Lock);

    if (Hw->PhyState.PhyProgramWorkItem != NULL)
    {
        NdisFreeIoWorkItem(Hw->PhyState.PhyProgramWorkItem);
        Hw->PhyState.PhyProgramWorkItem = NULL;
    }

    if (Hw->ScanContext.Timer_Scan)
    {
        NdisFreeTimerObject(Hw->ScanContext.Timer_Scan);
        Hw->ScanContext.Timer_Scan = NULL;
    }

    if (Hw->PhyState.Timer_Doze)
    {
        NdisFreeTimerObject(Hw->PhyState.Timer_Doze);
        Hw->PhyState.Timer_Doze = NULL;
    }
    
    if (Hw->PhyState.Timer_Awake)
    {
        NdisFreeTimerObject(Hw->PhyState.Timer_Awake);
        Hw->PhyState.Timer_Awake = NULL;
    }
    
    if (Hw->PhyState.RegDomainsSupportValue)
    {
        MP_FREE_MEMORY(Hw->PhyState.RegDomainsSupportValue);
        Hw->PhyState.RegDomainsSupportValue = NULL;
    }

    if (Hw->PhyState.DiversitySelectionRxList)
    {
        MP_FREE_MEMORY(Hw->PhyState.DiversitySelectionRxList);
        Hw->PhyState.DiversitySelectionRxList = NULL;
    }
    if (Hw->Hal != NULL)
    {
        HalFreeNic(Hw->Hal);
        Hw->Hal = NULL;
    }
    
    MP_FREE_MEMORY(Hw);
}
static void OnResetWorkItem(PVOID  WorkItemContext, NDIS_HANDLE  NdisIoWorkItemHandle)
{
    if (WorkItemContext)
    {
        tGeneralWorkItem *pwi = (tGeneralWorkItem *)WorkItemContext;
        PARANDIS_ADAPTER *pContext = pwi->pContext;
        BOOLEAN bSendActive, bReceiveActive;
        DEBUG_ENTRY(0);
        bSendActive = pContext->SendState == srsEnabled;
        bReceiveActive = pContext->ReceiveState == srsEnabled;
        pContext->bResetInProgress = TRUE;
        ParaNdis_Suspend(pContext);
        ParaNdis_PowerOff(pContext);
        ParaNdis_PowerOn(pContext);
        if (bSendActive) ParaNdis6_SendPauseRestart(pContext, FALSE, NULL);
        if (bReceiveActive) ParaNdis6_ReceivePauseRestart(pContext, FALSE, NULL);
        pContext->bResetInProgress = FALSE;

        NdisFreeMemory(pwi, 0, 0);
        NdisFreeIoWorkItem(NdisIoWorkItemHandle);
        ParaNdis_DebugHistory(pContext, hopSysReset, NULL, 0, NDIS_STATUS_SUCCESS, 0);
        NdisMResetComplete(pContext->MiniportHandle, NDIS_STATUS_SUCCESS, TRUE);
    }
}
Exemple #6
0
NDIS_STATUS
Hvl11Allocate(
    _In_  NDIS_HANDLE             MiniportAdapterHandle,
    _Outptr_result_maybenull_ PHVL*         ppHvl,
    _In_  PADAPTER                pAdapter
    )
{
    NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS;
    PHVL pHvl = NULL;
    NDIS_HANDLE ctxSWorkItemHandle = NULL, notificationsWorkItemHandle = NULL;
    BOOLEAN fFreeCtxSWorkItemHandle = FALSE, fFreeNotifWorkItemHandle = FALSE;
    PHVL_EX_ACCESS_REQ pExReq = NULL;

    ASSERT(MiniportAdapterHandle && ppHvl && pAdapter);
    
    *ppHvl = NULL;

    do
    {
        ndisStatus = ALLOC_MEM(MiniportAdapterHandle, sizeof(HVL), &pHvl);
        if (NDIS_STATUS_SUCCESS != ndisStatus)
        {
            MpTrace(COMP_HVL, DBG_SERIOUS, ("Failed to allocate memory for a new HVL"));
            break;
        }

        // the list heads should be the first ones to be initialized. This allows us to free things 
        // correctly if Free is called without Initialize being called in between        
        InitializeListHead(&pHvl->VNiclist);
        InitializeListHead(&pHvl->InactiveContextList);
        InitializeListHead(&pHvl->PendingOpQueue);
        InitializeListHead(&pHvl->NotificationsQueue);        

        // Allocate memory for fields inside the HVL structure
        
        // pre-allocate the exclusive access request structure for PnP related exclusive accesses        
        ndisStatus = ALLOC_MEM(MiniportAdapterHandle, sizeof(HVL_EX_ACCESS_REQ), &pExReq);
        if (NDIS_STATUS_SUCCESS != ndisStatus)
        {
            MpTrace(COMP_HVL, DBG_SERIOUS, ("Failed to allocate memory for exclusive access request"));
            break;
        }

        NdisAllocateSpinLock(&(pHvl->Lock));

        // Allocate the context switch work item 
        ctxSWorkItemHandle = NdisAllocateIoWorkItem(MiniportAdapterHandle);
        if(NULL == ctxSWorkItemHandle)
        {
            MpTrace (COMP_HVL, DBG_SERIOUS, ("NdisAllocateIoWorkItem failed"));
            ndisStatus = NDIS_STATUS_RESOURCES;
            break;
        }
        fFreeCtxSWorkItemHandle = TRUE;
        
        notificationsWorkItemHandle = NdisAllocateIoWorkItem(MiniportAdapterHandle);
        if(NULL == notificationsWorkItemHandle)
        {
            MpTrace (COMP_HVL, DBG_SERIOUS, ("NdisAllocateIoWorkItem failed"));
            ndisStatus = NDIS_STATUS_RESOURCES;
            break;
        }
        fFreeNotifWorkItemHandle = TRUE;
        
        pHvl->MiniportAdapterHandle = MiniportAdapterHandle;
        pHvl->Adapter = pAdapter;
        
        pHvl->CtxSWorkItemHandle = ctxSWorkItemHandle;
        pHvl->NotificationsWorkItemHandle = notificationsWorkItemHandle;

        pHvl->fVirtualizationEnabled = TRUE;    
        pHvl->pPnpOpExReq = pExReq;

        *ppHvl = pHvl;
    }while (FALSE);
    
    if (NDIS_STATUS_SUCCESS != ndisStatus)
    {
        if (fFreeNotifWorkItemHandle)
        {
            NdisFreeIoWorkItem(notificationsWorkItemHandle);
        }
        if (fFreeCtxSWorkItemHandle)
        {
            NdisFreeIoWorkItem(ctxSWorkItemHandle);
        }
        if (pExReq)
        {
            FREE_MEM(pExReq);
        }
        if (pHvl)
        {
            FREE_MEM(pHvl);
        }
    }    

    return ndisStatus;
}