public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Rebecca Cran" <quic_rcran@quicinc.com>
To: <devel@edk2.groups.io>, <richardho@ami.com>
Cc: "Andrew Fish" <afish@apple.com>,
	"Leif Lindholm" <quic_llindhol@quicinc.com>,
	"Michael D Kinney" <michael.d.kinney@intel.com>,
	"Michael Kubacki" <michael.kubacki@microsoft.com>,
	"Zhiguang Liu" <zhiguang.liu@intel.com>,
	"Liming Gao" <gaoliming@byosoft.com.cn>,
	"TonyLo [羅金松]" <TonyLo@ami.com>
Subject: Re: [edk2-devel] [PATCH 2/3] UsbNetworkPkg/UsbCdcEcm: Add USB Cdc ECM devices support
Date: Sat, 26 Nov 2022 11:47:18 -0700	[thread overview]
Message-ID: <7b0c266e-76cb-5879-2cd2-7f7551980e84@quicinc.com> (raw)
In-Reply-To: <20221003092721.5083-1-richardho@ami.com>

On 10/3/22 03:27, RichardHo [何明忠] via groups.io wrote:
> diff --git a/UsbNetworkPkg/UsbCdcEcm/UsbCdcEcm.c b/UsbNetworkPkg/UsbCdcEcm/UsbCdcEcm.c
> +  UsbEthDriver->Signature                          = USB_ETHERNET_SIGNATURE;
> +  UsbEthDriver->NumOfInterface                     = Interface.InterfaceNumber;
> +  UsbEthDriver->UsbCdcDataHandle                   = UsbCdcDataHandle;
> +  UsbEthDriver->UsbIo                              = UsbIo;
> +  UsbEthDriver->UsbEth.UsbEthReceive               = UsbEthReceive;
> +  UsbEthDriver->UsbEth.UsbEthTransmit              = UsbEthTransmit;
> +  UsbEthDriver->UsbEth.UsbEthInterrupt             = UsbEthInterrupt;
> +  UsbEthDriver->UsbEth.UsbEthMacAddress            = GetUsbEthMacAddress;
> +  UsbEthDriver->UsbEth.UsbEthMaxBulkSize           = UsbEthBulkSize;
> +  UsbEthDriver->UsbEth.UsbHeaderFunDescriptor      = GetUsbHeaderFunDescriptor;
> +  UsbEthDriver->UsbEth.UsbUnionFunDescriptor       = GetUsbUnionFunDescriptor;
> +  UsbEthDriver->UsbEth.UsbEthFunDescriptor         = GetUsbEthFunDescriptor;
> +  UsbEthDriver->UsbEth.SetUsbEthMcastFilter        = SetUsbEthMcastFilter;
> +  UsbEthDriver->UsbEth.SetUsbEthPowerPatternFilter = SetUsbEthPowerFilter
> +  UsbEthDriver->UsbEth.GetUsbEthPoewrPatternFilter = GetUsbEthPowerFilter;

Typo of "Power".


 > diff --git a/UsbNetworkPkg/UsbCdcEcm/UsbEcmFunction.c 
b/UsbNetworkPkg/UsbCdcEcm/UsbEcmFunction.c
 > new file mode 100644
 > index 0000000000..ae1afc512a
 > --- /dev/null
 > +++ b/UsbNetworkPkg/UsbCdcEcm/UsbEcmFunction.c

> +/**
> +  Get USB Ethernet IO endpoint and USB CDC data IO endpoint.
> +
> +  @param[in]      UsbIo         A pointer to the EFI_USB_IO_PROTOCOL instance.
> +  @param[in, out] UsbEthDriver  A pointer to the USB_ETHERNET_DRIVER instance.

There shouldn't be a space between "in," and "out"

> +/**
> +  This function is used to manage a USB device with the bulk transfer pipe. The endpoint is Bulk in.
> +
> +  @param[in]      Cdb           A pointer to the command descriptor block.
> +  @param[in]      This          A pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
> +  @param[in, out] Packet        A pointer to the buffer of data that will be transmitted to USB
> +                                device or received from USB device.
> +  @param[in, out] PacketLength  A pointer to the PacketLength.
> +
> +  @retval EFI_SUCCESS           The bulk transfer has been successfully executed.
> +  @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in status.
> +  @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.

Missing 'R' - should be EFI_INVALID_PARAMETER.

> +  @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
> +  @retval EFI_TIMEOUT           The control transfer fails due to timeout.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +UsbEthReceive (
> +  IN     PXE_CDB                      *Cdb,
> +  IN     EDKII_USB_ETHERNET_PROTOCOL  *This,
> +  IN OUT VOID                         *Packet,
> +  IN OUT UINTN                        *PacketLength
> +  )
> +{
> +  EFI_STATUS           Status;
> +  USB_ETHERNET_DRIVER  *UsbEthDriver;
> +  EFI_USB_IO_PROTOCOL  *UsbIo;
> +  UINT32               TransStatus;
> +
> +  UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
> +
> +  Status = gBS->HandleProtocol (
> +                  UsbEthDriver->UsbCdcDataHandle,
> +                  &gEfiUsbIoProtocolGuid,
> +                  (VOID **)&UsbIo
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  if (UsbEthDriver->BulkInEndpoint == 0) {
> +    GetEndpoint (UsbIo, UsbEthDriver);
> +  }
> +
> +  Status = UsbIo->UsbBulkTransfer (
> +                    UsbIo,
> +                    UsbEthDriver->BulkInEndpoint,
> +                    Packet,
> +                    PacketLength,
> +                    USB_ETHERNET_BULK_TIMEOUT,
> +                    &TransStatus
> +                    );

Have you made any changes to the USB network stack? I'm finding this 
slows down the system substantially, to the point where it can often 
look like it's hung. I'm wondering if we maybe need to change the 
timeout type to microseconds?

> +  return Status;
> +}
> +
> +/**
> +  This function is used to manage a USB device with the bulk transfer pipe. The endpoint is Bulk out.
> +
> +  @param[in]      Cdb           A pointer to the command descriptor block.
> +  @param[in]      This          A pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
> +  @param[in]      Packet        A pointer to the buffer of data that will be transmitted to USB
> +                                device or received from USB device.
> +  @param[in, out] PacketLength  A pointer to the PacketLength.
> +
> +  @retval EFI_SUCCESS           The bulk transfer has been successfully executed.
> +  @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in status.
> +  @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.

Missing 'R' - should be EFI_INVALID_PARAMETER.

> +/**
> +  This request sets the Ethernet device multicast filters as specified in the
> +  sequential list of 48 bit Ethernet multicast addresses.
> +
> +  @param[in]  This                   A pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
> +  @param[in]  Value                  Number of filters.
> +  @param[in]  McastAddr              A pointer to the value of the multicast addresses.
> +
> +  @retval EFI_SUCCESS           The request executed successfully.
> +  @retval EFI_TIMEOUT           A timeout occurred executing the request.
> +  @retval EFI_DEVICE_ERROR      The request failed due to a device error.
> +  @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
> +  @retval EFI_UNSUPPORTED       Not supported.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SetUsbEthMcastFilter (
> +  IN EDKII_USB_ETHERNET_PROTOCOL  *This,
> +  IN UINT16                       Value,
> +  IN VOID                         *McastAddr
> +  )
> +{
> +  EFI_STATUS                   Status;
> +  EFI_USB_DEVICE_REQUEST       Request;
> +  UINT32                       TransStatus;
> +  USB_ETHERNET_FUN_DESCRIPTOR  UsbEthFunDescriptor;
> +  USB_ETHERNET_DRIVER          *UsbEthDriver;
> +
> +  UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
> +
> +  Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +
> +  if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  Request.RequestType = USB_ETHRTNET_SET_REQ_TYPE;

Typo - should be "USB_ETHERNET_SET_REQ_TYPE".

> +  Request.Request     = SET_ETH_MULTICAST_FILTERS_REQ;
> +  Request.Value       = Value;
> +  Request.Index       = UsbEthDriver->NumOfInterface;
> +  Request.Length      = Value * 6;
> +
> +  return UsbEthDriver->UsbIo->UsbControlTransfer (
> +                                UsbEthDriver->UsbIo,
> +                                &Request,
> +                                EfiUsbDataOut,
> +                                USB_ETHERNET_TRANSFER_TIMEOUT,
> +                                McastAddr,
> +                                Request.Length,
> +                                &TransStatus
> +                                );
> +}
> +
> +/**
> +  This request sets up the specified Ethernet power management pattern filter as
> +  described in the data structure.
> +
> +  @param[in]  This                  A pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
> +  @param[in]  Value                 Number of filters.
> +  @param[in]  Length                Size of the power management pattern filter data.
> +  @param[in]  PatternFilter         A pointer to the power management pattern filter structure.
> +
> +  @retval EFI_SUCCESS           The request executed successfully.
> +  @retval EFI_TIMEOUT           A timeout occurred executing the request.
> +  @retval EFI_DEVICE_ERROR      The request failed due to a device error.
> +  @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
> +  @retval EFI_UNSUPPORTED       Not supported.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SetUsbEthPowerFilter (
> +  IN EDKII_USB_ETHERNET_PROTOCOL  *This,
> +  IN UINT16                       Value,
> +  IN UINT16                       Length,
> +  IN VOID                         *PatternFilter
> +  )
> +{
> +  EFI_USB_DEVICE_REQUEST  Request;
> +  UINT32                  TransStatus;
> +  USB_ETHERNET_DRIVER     *UsbEthDriver;
> +
> +  UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
> +
> +  Request.RequestType = USB_ETHRTNET_SET_REQ_TYPE;

Typo - should be "USB_ETHERNET_SET_REQ_TYPE".

> +/**
> +  This request is used to configure device Ethernet packet filter settings.
> +
> +  @param[in]  This              A pointer to the EDKII_USB_ETHERNET_PROTOCOL instance.
> +  @param[in]  Value             Packet Filter Bitmap.
> +
> +  @retval EFI_SUCCESS           The request executed successfully.
> +  @retval EFI_TIMEOUT           A timeout occurred executing the request.
> +  @retval EFI_DEVICE_ERROR      The request failed due to a device error.
> +  @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
> +  @retval EFI_UNSUPPORTED       Not supported.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SetUsbEthPacketFilter (
> +  IN EDKII_USB_ETHERNET_PROTOCOL  *This,
> +  IN UINT16                       Value
> +  )
> +{
> +  EFI_USB_DEVICE_REQUEST  Request;
> +  UINT32                  TransStatus;
> +  USB_ETHERNET_DRIVER     *UsbEthDriver;
> +  UINT16                  CommandFilter = 0;
> +
> +  UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
> +
> +  ConvertFilter (Value, &CommandFilter);
> +
> +  Request.RequestType = USB_ETHRTNET_SET_REQ_TYPE;

Typo.

-- 
Rebecca Cran

      reply	other threads:[~2022-11-26 18:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03  9:27 [PATCH 2/3] UsbNetworkPkg/UsbCdcEcm: Add USB Cdc ECM devices support RichardHo [何明忠]
2022-11-26 18:47 ` Rebecca Cran [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b0c266e-76cb-5879-2cd2-7f7551980e84@quicinc.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox