SRIOV_SET_POWER_STATE fonction de rappel (pcivirt.h)

Définit l’état d’alimentation de la fonction virtuelle (VF) PCI Express SR-IOV spécifiée.

Syntaxe

SRIOV_SET_POWER_STATE SriovSetPowerState;

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

Paramètres

[in] Context

Pointeur vers un contexte défini par le pilote.

[in] VfIndex

Index de base zéro de la VF à laquelle s’applique cette opération de groupe d’état d’alimentation.

[in] PowerState

Valeur de type DEVICE_POWER_STATE qui indique l’état d’alimentation Dx à définir.

[in] Wake

Valeur booléenne qui indique s’il faut armer l’appareil pour un signal de veille (PME pour les appareils PCI Express), car il passe à l’état d’alimentation faible. TRUE indique que l’appareil est armé ; FALSE dans le cas contraire. Cette valeur doit être FALSE si PowerState est PowerDeviceD0.

Valeur retournée

Définissez sur STATUS_SUCCESS si la demande réussit. Sinon, retournez un code NTSTATUS approprié pour indiquer la condition d’erreur.

Remarques

Cette fonction de rappel est implémentée par le pilote de fonction physique (PF). Le rappel est appelé lorsque le système souhaite modifier l’état d’alimentation d’une fonction virtuelle.

Le pilote PF inscrit son implémentation en définissant le membre SetVfPowerState du SRIOV_DEVICE_INTERFACE_STANDARD, en configurant une structure WDF_QUERY_INTERFACE_CONFIG et en appelant WdfDeviceAddQueryInterface.

Voici un exemple d’implémentation de cette fonction de rappel.


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;
}

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 10
Serveur minimal pris en charge Windows Server 2016
Plateforme cible Windows
En-tête pcivirt.h
IRQL PASSIVE_LEVEL