Condividi tramite


SRIOV_GET_RESOURCE_FOR_BAR funzione di callback (pcivirt.h)

Ottiene la risorsa tradotta per un registro di indirizzi di base specifico (BAR)

Sintassi

SRIOV_GET_RESOURCE_FOR_BAR SriovGetResourceForBar;

NTSTATUS SriovGetResourceForBar(
  [in]  PVOID Context,
  [in]  USHORT VfIndex,
  [in]  USHORT BarIndex,
  [out] PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource
)
{...}

Parametri

[in] Context

Puntatore a un contesto definito dal driver.

[in] VfIndex

Indice in base zero dell'oggetto VF su cui viene eseguita una query.

[in] BarIndex

Indice della barra (compreso tra 0 e 5).

[out] Resource

Puntatore a una struttura CM_PARTIAL_RESOURCE_DESCRIPTOR riempita con le risorse hardware convertite per la barra specificata.

Valore restituito

Restituisce STATUS_SUCCESS se l'operazione ha esito positivo. In caso contrario, restituire un NTSTATUS codice di errore appropriato.

Osservazioni

Questa funzione di callback viene implementata dal driver pf (Physical Function). Viene richiamato quando il sistema vuole accedere alle risorse hardware tradotte di una specifica barra di una funzione virtuale.

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

Di seguito è riportato un esempio di implementazione di questa funzione di callback.


NTSTATUS
Virtualization_GetResourceForBar(
    __inout     PVOID             Context,
    __in        USHORT            VfIndex,
    __in        USHORT            BarIndex,
    __out       PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource
    )

{
    PDEVICE_CONTEXT  deviceContext;

    PAGED_CODE();

    deviceContext = (PDEVICE_CONTEXT)Context;

    TraceEvents(TRACE_LEVEL_VERBOSE, DBG_INTERFACE,
        "Virtualization_GetResourceForBar received with"
        "VFIndex = %d, BarIndex = %d\n",
        VfIndex, BarIndex);

    NT_ASSERT(BarIndex < PCI_TYPE0_BAR_COUNT);

    if(VfIndex >= deviceContext->NumVFs)
    {
        NT_ASSERT(FALSE);
        return STATUS_INVALID_DEVICE_REQUEST;
    }

    //
    // Copy the descriptor for all VFs at the given Bar index
    // to the output descriptor.
    //

    *Resource = deviceContext->AssignedVfBarResources[BarIndex];

    if(Resource->Type == CmResourceTypeMemory ||
       Resource->Type == CmResourceTypeMemoryLarge)
    {
        NT_ASSERT((Resource->u.Memory.Length % deviceContext->NumVFs) == 0);
        Resource->u.Memory.Length /= deviceContext->NumVFs;
        Resource->u.Memory.Start.QuadPart += (Resource->u.Memory.Length * VfIndex);
    }

    return STATUS_SUCCESS;
}


Fabbisogno

Requisito Valore
client minimo supportato Windows 10
server minimo supportato Windows Server 2016
piattaforma di destinazione Finestre
intestazione pcivirt.h
IRQL PASSIVE_LEVEL