Esempio n. 1
0
NDIS_STATUS
MPDirectOidRequest(
    __in  NDIS_HANDLE             MiniportAdapterContext,
    __in  PNDIS_OID_REQUEST       NdisOidRequest
    )
{
    PADAPTER                    adapter = (PADAPTER)MiniportAdapterContext;
    NDIS_STATUS                 ndisStatus = NDIS_STATUS_NOT_SUPPORTED;
    NDIS_OID                    oid;
    PMP_PORT                    destinationPort = NULL;

    //
    // If the adapter has been surprise removed, fail request
    //
    if (MP_TEST_ADAPTER_STATUS(adapter, MP_ADAPTER_SURPRISE_REMOVED))
    {
        ndisStatus = NDIS_STATUS_FAILURE;
        MpTrace(COMP_OID, DBG_SERIOUS, ("NDIS_OID_REQUEST failed as surprise removal is in progress\n"));
        return ndisStatus;
    }

    // Depending on the OID, hand it to the appropriate component for processing
    oid = NdisOidRequest->DATA.QUERY_INFORMATION.Oid; // Oid is at same offset for all RequestTypes

    MpTrace(COMP_OID, DBG_SERIOUS, ("Processing NDIS_OID_REQUEST for Direct OID 0x%08x\n", oid));

    //
    // Now determine if the OID is something the helper port would process or one of the
    // ports from the port list should process
    //
    switch (oid)
    {            
        default:
            {
                // All OIDs would need to get forwarded to the appropriate port
                // for processing. 

                //
                // First we would need to translate from the NDIS_PORT_NUMBER
                // to our port structure. This is done by walking the PortList
                //
                destinationPort = Port11TranslatePortNumberToPort(
                                    adapter, 
                                    NdisOidRequest->PortNumber
                                    );
                if (destinationPort == NULL)
                {
                    MpTrace(COMP_OID, DBG_SERIOUS, ("Unable to find Port corresponding to PortNumber %d\n", 
                        NdisOidRequest->PortNumber));

                    ndisStatus = NDIS_STATUS_INVALID_PORT;
                }
                else
                {
                    //
                    // Pass it to the appropriate port for processing
                    //
                    ndisStatus = Port11HandleDirectOidRequest(
                                    destinationPort,
                                    NdisOidRequest
                                    );
                }
            }
            break;
    }

    if ((ndisStatus != NDIS_STATUS_SUCCESS) && (ndisStatus != NDIS_STATUS_PENDING))
    {
        MpTrace(COMP_OID, DBG_SERIOUS, ("NDIS_OID_REQUEST for Direct OID 0x%08x failed. Status = 0x%08x\n", 
            oid, ndisStatus));
    }
    else
    {
        MpTrace(COMP_OID, DBG_SERIOUS, ("NDIS_OID_REQUEST for Direct OID 0x%08x succeeded. Status = 0x%08x\n", 
            oid, ndisStatus));
    }

    return ndisStatus;
}
Esempio n. 2
0
VOID
MPSendNetBufferLists(
    NDIS_HANDLE             MiniportAdapterContext,
    PNET_BUFFER_LIST        NetBufferLists,
    NDIS_PORT_NUMBER        PortNumber,
    ULONG                   SendFlags
    )
{
    PADAPTER                    adapter = (PADAPTER)MiniportAdapterContext;
    NDIS_STATUS                 ndisStatus = NDIS_STATUS_SUCCESS;
    PMP_PORT                    destinationPort = NULL;
    PNET_BUFFER_LIST            currentNetBufferList;

    //
    // We increment the port list refcount. This would avoid a pause from finishing
    // while we are processing this NBL and that ensures that the port list does not
    // change
    //    
    MP_INCREMENT_PORTLIST_REFCOUNT(adapter);


    do
    {
        //
        // If the adapter is paused, surprise removed, etc, fail the send
        //
        if (MP_TEST_ADAPTER_STATUS(adapter, MP_ADAPTER_CANNOT_SEND_MASK))
        {
            ndisStatus = MpGetAdapterStatus(adapter);
            MpTrace(COMP_SEND, DBG_NORMAL, ("Sends failed as adapter is not in a valid send state\n"));
            break;
        }

        //
        // First we would need to translate from the NDIS_PORT_NUMBER
        // to our port structure. This is done by walking the PortList
        //
        destinationPort = Port11TranslatePortNumberToPort(
                            adapter, 
                            PortNumber
                            );
        if (destinationPort == NULL)
        {
            MpTrace(COMP_SEND, DBG_SERIOUS, ("Unable to find Port corresponding to PortNumber %d\n", 
                PortNumber));

            ndisStatus = NDIS_STATUS_INVALID_PORT;
        }
        else
        {
            //
            // Pass it to the appropriate port for processing
            //
            Port11HandleSendNetBufferLists(
                destinationPort,
                NetBufferLists,
                SendFlags
                );
        }

    } while (FALSE);

    //
    // We were protecting the port list only until we hand it to the port. After this point, the port
    // is responsible for ensuring that it does not let the port get deleted while
    // it has packets pending on it
    //
    MP_DECREMENT_PORTLIST_REFCOUNT(adapter);

    if (ndisStatus != NDIS_STATUS_SUCCESS)
    {
        #if DBG
        ULONG ulNumFailedNBLs = 0;
        #endif
        
        //
        // Send failed. Complete the NBLs back to NDIS
        //
        for(currentNetBufferList = NetBufferLists;
            currentNetBufferList != NULL;
            currentNetBufferList = NET_BUFFER_LIST_NEXT_NBL(currentNetBufferList))
        {
            #if DBG
            ulNumFailedNBLs++;
            #endif
            NET_BUFFER_LIST_STATUS(currentNetBufferList) = ndisStatus;
        }
        
        #if DBG
            MpTrace(COMP_SEND, DBG_NORMAL, ("NdisMSendNetBufferListsComplete called with %d NBLs\n", ulNumFailedNBLs));
        #endif

        if (NetBufferLists != NULL)
        {
            NdisMSendNetBufferListsComplete(
                adapter->MiniportAdapterHandle, 
                NetBufferLists, 
                (NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags) ? NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0)
                );
        }
    }

}
Esempio n. 3
0
NTSTATUS
MpOidRequestWorkItem(
    __in  PVOID                   Context,
    __in  NDIS_HANDLE             NdisIoWorkItemHandle
    )    
{
    NDIS_STATUS                 ndisStatus = NDIS_STATUS_SUCCESS;
    PADAPTER                    adapter = (PADAPTER)Context;
    PNDIS_OID_REQUEST           NdisOidRequest = adapter->DeferredOidRequest;
    NDIS_OID                    oid;
    PMP_PORT                    destinationPort = NULL;
    BOOLEAN                     fOidCompleted = FALSE;
    
    UNREFERENCED_PARAMETER(NdisIoWorkItemHandle);

    // Depending on the OID, hand it to the appropriate component for processing
    oid = NdisOidRequest->DATA.QUERY_INFORMATION.Oid; // Oid is at same offset for all RequestTypes
    
    MpTrace(COMP_OID, DBG_SERIOUS, ("Port(%d): Processing NDIS_OID_REQUEST for OID 0x%08x\n", NdisOidRequest->PortNumber, oid));

    //
    // Now determine if the OID is something the helper port would process or one of the
    // ports from the port list should process
    //
    switch (oid)
    {
        // Oids that the helper port should handle since they have an impact on 
        // virtualization
        case OID_PNP_SET_POWER:
        case OID_PNP_QUERY_POWER:
        case OID_DOT11_CREATE_MAC:
        case OID_DOT11_DELETE_MAC:
            ndisStatus = HelperPortHandleOidRequest(
                            adapter->HelperPort,
                            NdisOidRequest,
                            &fOidCompleted
                            );
            break;
            
        default:
            {
                // All other OIDs would need to get forwarded to the appropriate port
                // for processing. 

                //
                // First we would need to translate from the NDIS_PORT_NUMBER
                // to our port structure. This is done by walking the PortList
                // Since OID calls are serialized, we do not expect the Portlist to change
                // while we are trying to find the port or for the port to get deleted
                // until this OID is completed. So we do not need to protect the Port/PortList
                // in any way
                //
                destinationPort = Port11TranslatePortNumberToPort(
                                    adapter, 
                                    NdisOidRequest->PortNumber
                                    );
                if (destinationPort == NULL)
                {
                    MpTrace(COMP_OID, DBG_SERIOUS, ("Unable to find Port corresponding to PortNumber %d\n", 
                        NdisOidRequest->PortNumber));

                    ndisStatus = NDIS_STATUS_INVALID_PORT;
                }
                else
                {
                    //
                    // Pass it to the appropriate port for processing
                    //
                    ndisStatus = Port11HandleOidRequest(
                                    destinationPort,
                                    NdisOidRequest
                                    );
                }
            }
            break;
    }

    if ((ndisStatus != NDIS_STATUS_SUCCESS) && (ndisStatus != NDIS_STATUS_PENDING))
    {
        MpTrace(COMP_OID, DBG_SERIOUS, ("Port(%d): NDIS_OID_REQUEST for OID 0x%08x failed. Status = 0x%08x\n", 
            NdisOidRequest->PortNumber,
            oid, ndisStatus));
    }
    else
    {
        MpTrace(COMP_OID, DBG_SERIOUS, ("NDIS_OID_REQUEST for OID 0x%08x succeeded. Status = 0x%08x\n", 
            oid, ndisStatus));
    }

    // complete the Oid request if it hasn't already been completed
    if (!fOidCompleted && NDIS_STATUS_PENDING != ndisStatus)
    {
        // Complete the OID request
        Mp11CompleteOidRequest(
            adapter,
            NULL,
            NdisOidRequest,
            ndisStatus
            );        
    }
    
    return STATUS_SUCCESS;
}