From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by mx.groups.io with SMTP id smtpd.web10.76259.1669488440794024842 for ; Sat, 26 Nov 2022 10:47:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=dBbEEsy8; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: quicinc.com, ip: 199.106.114.38, mailfrom: quic_rcran@quicinc.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1669488440; x=1701024440; h=from:message-id:date:mime-version:subject:to:cc: references:in-reply-to:content-transfer-encoding; bh=XcHspWN7IfZpupLDnKl9up6Baaz0NCZ5u5e6SpIj1bw=; b=dBbEEsy81+otDDcUxccsJXEcNFoKL3BpOiivaZ3uoSElb6XdFDVIt+02 0f/o1tmSCsKdro7pW25he8mto5v3wcclryqdisBIS0cwzq+OPDB60y7/F a+7uwNVDfqtxJwbv0TOORXlqg2r5WXBX/GkeQvqF8m0bxydWBr0AMqhLu Y=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 26 Nov 2022 10:47:20 -0800 From: "Rebecca Cran" X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Nov 2022 10:47:20 -0800 Received: from [10.110.115.186] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sat, 26 Nov 2022 10:47:19 -0800 Message-ID: <7b0c266e-76cb-5879-2cd2-7f7551980e84@quicinc.com> Date: Sat, 26 Nov 2022 11:47:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [edk2-devel] [PATCH 2/3] UsbNetworkPkg/UsbCdcEcm: Add USB Cdc ECM devices support To: , CC: Andrew Fish , Leif Lindholm , Michael D Kinney , Michael Kubacki , Zhiguang Liu , Liming Gao , =?UTF-8?B?VG9ueUxvIFvnvoXph5Hmnb5d?= References: <20221003092721.5083-1-richardho@ami.com> In-Reply-To: <20221003092721.5083-1-richardho@ami.com> Return-Path: rebecca@quicinc.com X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01b.na.qualcomm.com (10.46.141.250) Content-Language: en-US Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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