TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbCdcEcm.h File Reference

Go to the source code of this file.

Data Structures

struct  USB_ETHERNET_DRIVER
 
struct  BIT_MAP
 

Macros

#define USB_ECM_DRIVER_VERSION   1
 
#define USB_ETHERNET_BULK_TIMEOUT   1
 
#define USB_ETHERNET_TRANSFER_TIMEOUT   200
 
#define USB_ETHERNET_SIGNATURE   SIGNATURE_32('u', 'e', 't', 'h')
 
#define USB_ETHERNET_DEV_FROM_THIS(a)   CR (a, USB_ETHERNET_DRIVER, UsbEth, USB_ETHERNET_SIGNATURE)
 

Functions

EFI_STATUS EFIAPI UsbEcmDriverSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI UsbEcmDriverStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI UsbEcmDriverStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS LoadAllDescriptor (IN EFI_USB_IO_PROTOCOL *UsbIo, OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc)
 
BOOLEAN NextDescriptor (IN EFI_USB_CONFIG_DESCRIPTOR *Desc, IN OUT UINTN *Offset)
 
EFI_STATUS GetFunctionalDescriptor (IN EFI_USB_CONFIG_DESCRIPTOR *Config, IN UINT8 FunDescriptorType, OUT VOID *DataBuffer)
 
VOID GetEndpoint (IN EFI_USB_IO_PROTOCOL *UsbIo, IN OUT USB_ETHERNET_DRIVER *UsbEthDriver)
 
EFI_STATUS EFIAPI UsbEthEcmReceive (IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
 
EFI_STATUS EFIAPI UsbEthEcmTransmit (IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *Packet, IN OUT UINTN *PacketLength)
 
EFI_STATUS EFIAPI UsbEthEcmInterrupt (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Request)
 
EFI_STATUS EFIAPI InterruptCallback (IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
 
EFI_STATUS EFIAPI GetUsbEthMacAddress (IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
 
EFI_STATUS EFIAPI UsbEthEcmBulkSize (IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
 
EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor (IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
 
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor (IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
 
EFI_STATUS EFIAPI GetUsbEthFunDescriptor (IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
 
EFI_STATUS EFIAPI SetUsbEthMcastFilter (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
 
EFI_STATUS EFIAPI SetUsbEthPowerFilter (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
 
EFI_STATUS EFIAPI GetUsbEthPowerFilter (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, OUT BOOLEAN *PatternActive)
 
EFI_STATUS EFIAPI SetUsbEthPacketFilter (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
 
EFI_STATUS EFIAPI GetUsbEthStatistic (IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 FeatureSelector, OUT VOID *Statistic)
 

Variables

EFI_COMPONENT_NAME2_PROTOCOL gUsbEcmComponentName2
 

Detailed Description

Header file contains code for USB Ethernet Control Model driver definitions

Copyright (c) 2023, American Megatrends International LLC. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbCdcEcm.h.

Macro Definition Documentation

◆ USB_ECM_DRIVER_VERSION

#define USB_ECM_DRIVER_VERSION   1

Definition at line 36 of file UsbCdcEcm.h.

◆ USB_ETHERNET_BULK_TIMEOUT

#define USB_ETHERNET_BULK_TIMEOUT   1

Definition at line 37 of file UsbCdcEcm.h.

◆ USB_ETHERNET_DEV_FROM_THIS

#define USB_ETHERNET_DEV_FROM_THIS (   a)    CR (a, USB_ETHERNET_DRIVER, UsbEth, USB_ETHERNET_SIGNATURE)

Definition at line 41 of file UsbCdcEcm.h.

◆ USB_ETHERNET_SIGNATURE

#define USB_ETHERNET_SIGNATURE   SIGNATURE_32('u', 'e', 't', 'h')

Definition at line 40 of file UsbCdcEcm.h.

◆ USB_ETHERNET_TRANSFER_TIMEOUT

#define USB_ETHERNET_TRANSFER_TIMEOUT   200

Definition at line 38 of file UsbCdcEcm.h.

Function Documentation

◆ GetEndpoint()

VOID GetEndpoint ( IN EFI_USB_IO_PROTOCOL UsbIo,
IN OUT USB_ETHERNET_DRIVER UsbEthDriver 
)

Get USB Ethernet IO endpoint and USB CDC data IO endpoint.

Parameters
[in]UsbIoA pointer to the EFI_USB_IO_PROTOCOL instance.
[in,out]UsbEthDriverA pointer to the USB_ETHERNET_DRIVER instance.

Definition at line 157 of file UsbEcmFunction.c.

◆ GetFunctionalDescriptor()

EFI_STATUS GetFunctionalDescriptor ( IN EFI_USB_CONFIG_DESCRIPTOR Config,
IN UINT8  FunDescriptorType,
OUT VOID *  DataBuffer 
)

Read Function descriptor

Parameters
[in]ConfigA pointer to all of configuration.
[in]FunDescriptorTypeUSB CDC class descriptor SubType.
[out]DataBufferA pointer to the Data of corresponding to device capability.
Return values
EFI_SUCCESSThe device capability descriptor was retrieved successfully.
EFI_UNSUPPORTEDNo supported.
EFI_NOT_FOUNDThe device capability descriptor was not found.

Definition at line 100 of file UsbEcmFunction.c.

◆ GetUsbEthFunDescriptor()

EFI_STATUS EFIAPI GetUsbEthFunDescriptor ( IN EDKII_USB_ETHERNET_PROTOCOL This,
OUT USB_ETHERNET_FUN_DESCRIPTOR UsbEthFunDescriptor 
)

Retrieves the USB Ethernet functional Descriptor.

This function get the Mac Address, Ethernet statistics, maximum segment size, number of multicast filters, and number of pattern filters from Ethernet functional Descriptor.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[out]UsbEthFunDescriptorA pointer to the caller allocated USB Ethernet Functional Descriptor.
Return values
EFI_SUCCESSThe USB Ethernet Functional descriptor was retrieved successfully.
EFI_INVALID_PARAMETERUsbEthFunDescriptor is NULL.
EFI_NOT_FOUNDThe USB Ethernet Functional descriptor was not found.

Definition at line 577 of file UsbEcmFunction.c.

◆ GetUsbEthMacAddress()

EFI_STATUS EFIAPI GetUsbEthMacAddress ( IN EDKII_USB_ETHERNET_PROTOCOL This,
OUT EFI_MAC_ADDRESS MacAddress 
)

Retrieves the USB Ethernet Mac Address.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[out]MacAddressA pointer to the caller allocated USB Ethernet Mac Address.
Return values
EFI_SUCCESSThe USB Header Functional descriptor was retrieved successfully.
EFI_INVALID_PARAMETERUsbHeaderFunDescriptor is NULL.
EFI_NOT_FOUNDThe USB Header Functional descriptor was not found.

Definition at line 421 of file UsbEcmFunction.c.

◆ GetUsbEthPowerFilter()

EFI_STATUS EFIAPI GetUsbEthPowerFilter ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN UINT16  Value,
OUT BOOLEAN *  PatternActive 
)

This request retrieves the status of the specified Ethernet power management pattern filter from the device.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]ValueThe filter number.
[out]PatternActiveA pointer to the pattern active boolean.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_UNSUPPORTEDNot supported.

Definition at line 717 of file UsbEcmFunction.c.

◆ GetUsbEthStatistic()

EFI_STATUS EFIAPI GetUsbEthStatistic ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN UINT16  FeatureSelector,
OUT VOID *  Statistic 
)

This request is used to retrieve a statistic based on the feature selector.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]FeatureSelectorValue of the feature selector.
[out]StatisticA pointer to the 32 bit unsigned integer.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_UNSUPPORTEDNot supported.

Definition at line 842 of file UsbEcmFunction.c.

◆ GetUsbHeaderFunDescriptor()

EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor ( IN EDKII_USB_ETHERNET_PROTOCOL This,
OUT USB_HEADER_FUN_DESCRIPTOR UsbHeaderFunDescriptor 
)

Retrieves the USB Header functional Descriptor.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[out]UsbHeaderFunDescriptorA pointer to the caller allocated USB Header Functional Descriptor.
Return values
EFI_SUCCESSThe USB Header Functional descriptor was retrieved successfully.
EFI_INVALID_PARAMETERUsbHeaderFunDescriptor is NULL.
EFI_NOT_FOUNDThe USB Header Functional descriptor was not found.

Definition at line 511 of file UsbEcmFunction.c.

◆ GetUsbUnionFunDescriptor()

EFI_STATUS EFIAPI GetUsbUnionFunDescriptor ( IN EDKII_USB_ETHERNET_PROTOCOL This,
OUT USB_UNION_FUN_DESCRIPTOR UsbUnionFunDescriptor 
)

Retrieves the USB Union functional Descriptor.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[out]UsbUnionFunDescriptorA pointer to the caller allocated USB Union Functional Descriptor.
Return values
EFI_SUCCESSThe USB Union Functional descriptor was retrieved successfully.
EFI_INVALID_PARAMETERUsbUnionFunDescriptor is NULL.
EFI_NOT_FOUNDThe USB Union Functional descriptor was not found.

Definition at line 542 of file UsbEcmFunction.c.

◆ InterruptCallback()

EFI_STATUS EFIAPI InterruptCallback ( IN VOID *  Data,
IN UINTN  DataLength,
IN VOID *  Context,
IN UINT32  Status 
)

Async USB transfer callback routine.

Parameters
[in]DataData received or sent via the USB Asynchronous Transfer, if the transfer completed successfully.
[in]DataLengthThe length of Data received or sent via the Asynchronous Transfer, if transfer successfully completes.
[in]ContextData passed from UsbAsyncInterruptTransfer() request.
[in]StatusIndicates the result of the asynchronous transfer.
Return values
EFI_SUCCESSThe asynchronous USB transfer request has been successfully executed.
EFI_DEVICE_ERRORThe asynchronous USB transfer request failed.

Definition at line 327 of file UsbEcmFunction.c.

◆ LoadAllDescriptor()

EFI_STATUS LoadAllDescriptor ( IN EFI_USB_IO_PROTOCOL UsbIo,
OUT EFI_USB_CONFIG_DESCRIPTOR **  ConfigDesc 
)

Load All of device descriptor.

Parameters
[in]UsbIoA pointer to the EFI_USB_IO_PROTOCOL instance.
[out]ConfigDescA pointer to the configuration descriptor.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_OUT_OF_RESOURCESThe request could not be completed because the buffer specified by DescriptorLength and Descriptor is not large enough to hold the result of the request.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error. The transfer status is returned in Status.

Definition at line 27 of file UsbEcmFunction.c.

◆ NextDescriptor()

BOOLEAN NextDescriptor ( IN EFI_USB_CONFIG_DESCRIPTOR Desc,
IN OUT UINTN Offset 
)

Returns pointer to the next descriptor for the pack of USB descriptors located in continues memory segment

Parameters
[in]DescA pointer to the CONFIG_DESCRIPTOR instance.
[in,out]OffsetA pointer to the sum of descriptor length.
Return values
TRUEThe request executed successfully.
FALSENo next descriptor.

Definition at line 65 of file UsbEcmFunction.c.

◆ SetUsbEthMcastFilter()

EFI_STATUS EFIAPI SetUsbEthMcastFilter ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN UINT16  Value,
IN VOID *  McastAddr 
)

This request sets the Ethernet device multicast filters as specified in the sequential list of 48 bit Ethernet multicast addresses.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]ValueNumber of filters.
[in]McastAddrA pointer to the value of the multicast addresses.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_UNSUPPORTEDNot supported.

Definition at line 612 of file UsbEcmFunction.c.

◆ SetUsbEthPacketFilter()

EFI_STATUS EFIAPI SetUsbEthPacketFilter ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN UINT16  Value 
)

This request is used to configure device Ethernet packet filter settings.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]ValuePacket Filter Bitmap.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_UNSUPPORTEDNot supported.

Definition at line 794 of file UsbEcmFunction.c.

◆ SetUsbEthPowerFilter()

EFI_STATUS EFIAPI SetUsbEthPowerFilter ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN UINT16  Value,
IN UINT16  Length,
IN VOID *  PatternFilter 
)

This request sets up the specified Ethernet power management pattern filter as described in the data structure.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]ValueNumber of filters.
[in]LengthSize of the power management pattern filter data.
[in]PatternFilterA pointer to the power management pattern filter structure.
Return values
EFI_SUCCESSThe request executed successfully.
EFI_TIMEOUTA timeout occurred executing the request.
EFI_DEVICE_ERRORThe request failed due to a device error.
EFI_INVALID_PARAMETEROne of the parameters has an invalid value.
EFI_UNSUPPORTEDNot supported.

Definition at line 670 of file UsbEcmFunction.c.

◆ UsbEcmDriverStart()

EFI_STATUS EFIAPI UsbEcmDriverStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

USB ECM Driver Binding Start.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to bind driver to.
[in]RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver is added to ControllerHandle
EFI_DEVICE_ERRORThis driver could not be started due to a device error
EFI_OUT_OF_RESOURCESThe driver could not install successfully due to a lack of resources.
otherThis driver does not support this device

Definition at line 292 of file UsbCdcEcm.c.

◆ UsbEcmDriverStop()

EFI_STATUS EFIAPI UsbEcmDriverStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

USB ECM Driver Binding Stop.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to stop driver on
[in]NumberOfChildrenNumber of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver.
[in]ChildHandleBufferList of Child Handles to Stop.
Return values
EFI_SUCCESSThis driver is removed ControllerHandle
otherThis driver was not removed from this device

Definition at line 427 of file UsbCdcEcm.c.

◆ UsbEcmDriverSupported()

EFI_STATUS EFIAPI UsbEcmDriverSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

USB ECM Driver Binding Support.

Parameters
[in]ThisProtocol instance pointer.
[in]ControllerHandleHandle of device to test.
[in]RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver supports this device.
EFI_ALREADY_STARTEDThis driver is already running on this device.
otherThis driver does not support this device.

Definition at line 66 of file UsbCdcEcm.c.

◆ UsbEthEcmBulkSize()

EFI_STATUS EFIAPI UsbEthEcmBulkSize ( IN EDKII_USB_ETHERNET_PROTOCOL This,
OUT UINTN BulkSize 
)

Retrieves the USB Ethernet Bulk transfer data size.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[out]BulkSizeA pointer to the Bulk transfer data size.
Return values
EFI_SUCCESSThe bulk transfer data size was retrieved successfully.
otherFailed to retrieve the bulk transfer data size.

Definition at line 481 of file UsbEcmFunction.c.

◆ UsbEthEcmInterrupt()

EFI_STATUS EFIAPI UsbEthEcmInterrupt ( IN EDKII_USB_ETHERNET_PROTOCOL This,
IN BOOLEAN  IsNewTransfer,
IN UINTN  PollingInterval,
IN EFI_USB_DEVICE_REQUEST Request 
)

This function is used to manage a USB device with an interrupt transfer pipe.

Parameters
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]IsNewTransferIf TRUE, a new transfer will be submitted to USB controller. If FALSE, the interrupt transfer is deleted from the device's interrupt transfer queue.
[in]PollingIntervalIndicates the periodic rate, in milliseconds, that the transfer is to be executed.This parameter is required when IsNewTransfer is TRUE. The value must be between 1 to 255, otherwise EFI_INVALID_PARAMETER is returned. The units are in milliseconds.
[in]RequestA pointer to the EFI_USB_DEVICE_REQUEST data.
Return values
EFI_SUCCESSThe asynchronous USB transfer request transfer has been successfully executed.
EFI_DEVICE_ERRORThe asynchronous USB transfer request failed.

Definition at line 368 of file UsbEcmFunction.c.

◆ UsbEthEcmReceive()

EFI_STATUS EFIAPI UsbEthEcmReceive ( IN PXE_CDB Cdb,
IN EDKII_USB_ETHERNET_PROTOCOL This,
IN OUT VOID *  Packet,
IN OUT UINTN PacketLength 
)

This function is used to manage a USB device with the bulk transfer pipe. The endpoint is Bulk in.

Parameters
[in]CdbA pointer to the command descriptor block.
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in,out]PacketA pointer to the buffer of data that will be transmitted to USB device or received from USB device.
[in,out]PacketLengthA pointer to the PacketLength.
Return values
EFI_SUCCESSThe bulk transfer has been successfully executed.
EFI_DEVICE_ERRORThe transfer failed. The transfer status is returned in status.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe request could not be submitted due to a lack of resources.
EFI_TIMEOUTThe control transfer fails due to timeout.

Definition at line 217 of file UsbEcmFunction.c.

◆ UsbEthEcmTransmit()

EFI_STATUS EFIAPI UsbEthEcmTransmit ( IN PXE_CDB Cdb,
IN EDKII_USB_ETHERNET_PROTOCOL This,
IN VOID *  Packet,
IN OUT UINTN PacketLength 
)

This function is used to manage a USB device with the bulk transfer pipe. The endpoint is Bulk out.

Parameters
[in]CdbA pointer to the command descriptor block.
[in]ThisA pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
[in]PacketA pointer to the buffer of data that will be transmitted to USB device or received from USB device.
[in,out]PacketLengthA pointer to the PacketLength.
Return values
EFI_SUCCESSThe bulk transfer has been successfully executed.
EFI_DEVICE_ERRORThe transfer failed. The transfer status is returned in status.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe request could not be submitted due to a lack of resources.
EFI_TIMEOUTThe control transfer fails due to timeout.

Definition at line 273 of file UsbEcmFunction.c.

Variable Documentation

◆ gUsbEcmComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gUsbEcmComponentName2
extern

Definition at line 44 of file ComponentName.c.