From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C435D740034 for ; Sat, 26 Aug 2023 01:58:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=38IQqc00iVZz65ioTp7Yu8kPouSuWNavpuNL+HUFB/U=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1693015100; v=1; b=JATEobSrWI2OATeduOMJC2DgsmuMNixJYubG/kp2q2oQZQM/f6OmGEZrXdxzMgm5D0Oy+7xq vJd8GWZ0EsUaNBlXjjmTBfnCc/az4DObNpA9ZIw3YmiUXs+r/Datv/x8tMxNfrdlWj9/GV8+B24 hfkqbAYpML+PuWrwn19ZtCBs= X-Received: by 127.0.0.2 with SMTP id PjSKYY7687511xgRc3IfmqkE; Fri, 25 Aug 2023 18:58:20 -0700 X-Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web11.1673.1693015098758793516 for ; Fri, 25 Aug 2023 18:58:19 -0700 X-Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-4ff8cf11b90so2334163e87.1 for ; Fri, 25 Aug 2023 18:58:18 -0700 (PDT) X-Gm-Message-State: 8MdJ1NlTXyzCwZpGdwfEAxZ7x7686176AA= X-Google-Smtp-Source: AGHT+IHVssFj5YMsP9ifZ8arhlvBlnXsiQzfLqmKxfZBgHQBdRKySq1YVjKp3R/tSAAjDjPx/0apbw== X-Received: by 2002:ac2:4e89:0:b0:4ff:8a04:b251 with SMTP id o9-20020ac24e89000000b004ff8a04b251mr14010438lfr.50.1693015096826; Fri, 25 Aug 2023 18:58:16 -0700 (PDT) X-Received: from localhost.localdomain ([79.164.221.98]) by smtp.gmail.com with ESMTPSA id a5-20020a19f805000000b0050078c9b53asm509879lff.231.2023.08.25.18.58.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 25 Aug 2023 18:58:16 -0700 (PDT) From: "Mike Maslenkin" To: devel@edk2.groups.io Cc: richardho@ami.com, rebecca@bsdio.com, Mike Maslenkin Subject: [edk2-devel] [PATCH 2/2] MdeModulePkg: UsbRndis: get rid of magic values Date: Sat, 26 Aug 2023 04:58:00 +0300 Message-Id: <20230826015800.74524-3-mike.maslenkin@gmail.com> In-Reply-To: <20230826015800.74524-1-mike.maslenkin@gmail.com> References: <20230826015800.74524-1-mike.maslenkin@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=JATEobSr; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Replace magic values used for checking Base Class, SubClass and Protocol fields of USB Interface Descriptor. Add definitions for Base Class EFh (Miscellaneous) and RNDIS subclass. These definitions were taken from https://www.usb.org/defined-class-codes Cc: Richard Ho Cc: Rebecca Cran Signed-off-by: Mike Maslenkin --- .../Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c | 42 +++++++++---------- .../Include/Protocol/UsbEthernetProtocol.h | 4 ++ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c b/MdeModul= ePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c index 056b0ff0fd8e..cc8e076c0a12 100644 --- a/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c +++ b/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c @@ -40,15 +40,15 @@ IsSupportedDevice ( }=0D =0D // Check specific device/RNDIS and CDC-DATA=0D - if (((InterfaceDescriptor.InterfaceClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0xFF)) || \=0D - ((InterfaceDescriptor.InterfaceClass =3D=3D 0xEF) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x4) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0x1)) || \=0D - ((InterfaceDescriptor.InterfaceClass =3D=3D 0xA) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x0) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0x00))=0D + if (((InterfaceDescriptor.InterfaceClass =3D=3D USB_CDC_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_CDC_ACM_SUBCLASS)= &&=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_VENDOR_PROTOCOL))= || \=0D + ((InterfaceDescriptor.InterfaceClass =3D=3D USB_MISC_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_RNDIS_SUBCLASS) &= &=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_RNDIS_ETHERNET_PR= OTOCOL)) || \=0D + ((InterfaceDescriptor.InterfaceClass =3D=3D USB_CDC_DATA_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_CDC_DATA_SUBCLASS= ) &&=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_NO_CLASS_PROTOCOL= ))=0D )=0D {=0D return TRUE;=0D @@ -79,12 +79,12 @@ IsRndisInterface ( }=0D =0D // Check for specific device/RNDIS and CDC-DATA=0D - if (((InterfaceDescriptor.InterfaceClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0xFF)) || \=0D - ((InterfaceDescriptor.InterfaceClass =3D=3D 0xEF) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x4) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0x1))=0D + if (((InterfaceDescriptor.InterfaceClass =3D=3D USB_CDC_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_CDC_ACM_SUBCLASS)= &&=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_VENDOR_PROTOCOL))= || \=0D + ((InterfaceDescriptor.InterfaceClass =3D=3D USB_MISC_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_RNDIS_SUBCLASS) &= &=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_RNDIS_ETHERNET_PR= OTOCOL))=0D )=0D {=0D return TRUE;=0D @@ -155,9 +155,9 @@ IsUsbCdcData ( }=0D =0D // Check for CDC-DATA=0D - if ((InterfaceDescriptor.InterfaceClass =3D=3D 0xA) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x0) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0x0))=0D + if ((InterfaceDescriptor.InterfaceClass =3D=3D USB_CDC_DATA_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_CDC_DATA_SUBCLASS)= &&=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_NO_CLASS_PROTOCOL)= )=0D {=0D return TRUE;=0D }=0D @@ -188,9 +188,9 @@ IsUsbRndis ( }=0D =0D // Check for Rndis=0D - if ((InterfaceDescriptor.InterfaceClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceSubClass =3D=3D 0x2) &&=0D - (InterfaceDescriptor.InterfaceProtocol =3D=3D 0xFF))=0D + if ((InterfaceDescriptor.InterfaceClass =3D=3D USB_CDC_CLASS) &&=0D + (InterfaceDescriptor.InterfaceSubClass =3D=3D USB_CDC_ACM_SUBCLASS) = &&=0D + (InterfaceDescriptor.InterfaceProtocol =3D=3D USB_VENDOR_PROTOCOL))= =0D {=0D return TRUE;=0D }=0D diff --git a/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h b/MdeModul= ePkg/Include/Protocol/UsbEthernetProtocol.h index 4cc2cee1167d..f65674c91ba9 100644 --- a/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h +++ b/MdeModulePkg/Include/Protocol/UsbEthernetProtocol.h @@ -24,6 +24,10 @@ typedef struct _EDKII_USB_ETHERNET_PROTOCOL EDKII_USB_ET= HERNET_PROTOCOL; #define USB_NCM_NTB_PROTOCOL 0x01=0D #define USB_VENDOR_PROTOCOL 0xFF=0D =0D +#define USB_MISC_CLASS 0xEF=0D +#define USB_RNDIS_SUBCLASS 0x04=0D +#define USB_RNDIS_ETHERNET_PROTOCOL 0x01=0D +=0D // Type Values for the DescriptorType Field=0D #define CS_INTERFACE 0x24=0D #define CS_ENDPOINT 0x25=0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108041): https://edk2.groups.io/g/devel/message/108041 Mute This Topic: https://groups.io/mt/100968488/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-