Condividi tramite


SRIOV_SET_POWER_STATE funzione di callback (pcivirt.h)

Imposta lo stato di alimentazione della funzione virtuale PCI Express SR-IOV specificata.

Sintassi

SRIOV_SET_POWER_STATE SriovSetPowerState;

NTSTATUS SriovSetPowerState(
  [in] PVOID Context,
  [in] USHORT VfIndex,
  [in] DEVICE_POWER_STATE PowerState,
  [in] BOOLEAN Wake
)
{...}

Parametri

[in] Context

Puntatore a un contesto definito dal driver.

[in] VfIndex

Indice in base zero dell'VF a cui si applica questa operazione di set di stato di alimentazione.

[in] PowerState

Valore DEVICE_POWER_STATE tipo che indica lo stato di alimentazione Dx da impostare.

[in] Wake

Valore booleano che indica se armere il dispositivo per un segnale di riattivazione (PME per i dispositivi PCI Express), mentre entra nello stato di bassa potenza. TRUE indica che il dispositivo è armato; FALSE in caso contrario. Questo valore deve essere FALSE se PowerState è PowerDeviceD0.

Valore restituito

Impostare su STATUS_SUCCESS se la richiesta ha esito positivo. In caso contrario, restituire un codice NTSTATUS appropriato per indicare la condizione di errore.

Commenti

Questa funzione di callback viene implementata dal driver PF (Physical Function). Il callback viene richiamato quando il sistema vuole modificare lo stato di alimentazione di una funzione virtuale.

Il driver PF registra l'implementazione impostando il membro SetVfPowerStatedell'SRIOV_DEVICE_INTERFACE_STANDARD , configurando una struttura WDF_QUERY_INTERFACE_CONFIG e chiamando WdfDeviceAddQueryInterface.

Ecco un esempio di implementazione di questa funzione di callback.


NTSTATUS
Virtualization_SetPowerState (
    __inout              PVOID              Context,
                         USHORT             VfIndex,
                         DEVICE_POWER_STATE PowerState,
                         BOOLEAN            Wake
    )

{
    PDEVICE_CONTEXT         deviceContext;
    WDF_POWER_DEVICE_STATE  wdfPowerState;
    NTSTATUS                status;

    PAGED_CODE();
    status = STATUS_SUCCESS;

    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INTERFACE,
                        "Virtualization_SetPowerState received with \
                        VFIndex = %d, PowerState = %d, Wake = %d\n",
                        VfIndex, PowerState, Wake);


    deviceContext = (PDEVICE_CONTEXT) Context;

    if (VfIndex >= deviceContext->NumVFs)
    {
        TraceEvents(TRACE_LEVEL_ERROR, DBG_INTERFACE,
                "VfIndex specified: %d was out of bounds. NumVFs: %d\n",
                VfIndex, deviceContext->NumVFs);
        return STATUS_INVALID_PARAMETER;
    }

    switch (PowerState)
    {
    case PowerDeviceD0:
        wdfPowerState = WdfPowerDeviceD0;
        break;
    case PowerDeviceD1:
        wdfPowerState = WdfPowerDeviceD1;
        break;
    case PowerDeviceD2:
        wdfPowerState = WdfPowerDeviceD2;
        break;
    case PowerDeviceD3:
        wdfPowerState = WdfPowerDeviceD3;
        break;
    default:
        return STATUS_INVALID_PARAMETER;
    }

    WdfWaitLockAcquire(deviceContext->PowerStateLock, NULL);
    deviceContext->VfContext[VfIndex].VfPowerDeviceState = wdfPowerState;
    deviceContext->VfContext[VfIndex].VfWake = Wake;
    WdfWaitLockRelease(deviceContext->PowerStateLock);

    return status;
}

Requisiti

Requisito Valore
Client minimo supportato Windows 10
Server minimo supportato Windows Server 2016
Piattaforma di destinazione Windows
Intestazione pcivirt.h
IRQL PASSIVE_LEVEL