15#define TIMEOUT_DISABLED 0x00
16#define TIMEOUT_SHORTEST 0x01
17#define U1_TIMEOUT_LONGEST 0x7F
18#define U2_TIMEOUT_LONGEST 0xFE
19#define TIMEOUT_ACCEPT_ONLY 0xFF
22#define LATENCY_TIMEOUT_FACTOR 5
25#define U2_TIMEOUT_UNIT 256
28#define INTERRUPT_USAGE_PERIODIC 0x00
31#define MICROFRAME_US 125
34#define TP_DELAY_5GBPS_NS 40
35#define MAX_PACKET_FORWARD_NS 2100
36#define PING_RESPONSE_NS 400
39#define NO_PING_FIRST_PERCENT 10
40#define NO_PING_LAST_PERCENT 160
43#define MIN_LINK_SPEED_BPS 50000000ULL
46#define TP_SYMBOL_NS_SCALE 200000000000ULL
64 return (
Child->m_LpmPolicy & Bit) != 0;
76 Child->m_LinkFlags |= Bit;
78 Child->m_LinkFlags &= ~Bit;
191 :
Child->m_HostU1ExitLatency;
248 if (
Child->m_Hub->HasFlag(HubFlag::DisallowU2AcceptOnly) &&
249 Child->HasProperty(ChildProperty::IsHub) &&
286 *PeriodicInterrupt =
FALSE;
300 :
Child->m_HostU2ExitLatency;
320 *PeriodicInterrupt =
TRUE;
323 NoHostInitiate =
TRUE;
363 else if (
Child->HasProperty(ChildProperty::IsHub) ||
380 if (
Verdict == HubU2Verdict::Off)
385 else if (
Verdict == HubU2Verdict::AcceptOnly)
403 if (
Child->m_Hub->HasFlag(HubFlag::DisallowU2AcceptOnly) &&
404 !
Child->HasProperty(ChildProperty::IsHub) &&
445 Child->m_TargetExitLatency = 0;
449 HostLatency = (U2Off ?
Child->m_HostU1ExitLatency :
Child->m_HostU2ExitLatency) * 1000UL;
456 Latency += Latency *
Child->m_LatencyAdjustPercent / 100;
458 Child->m_TargetExitLatency = (
USHORT)((Latency + 500) / 1000);
459 DPRINT(
"Device %p target exit latency %u us\n",
Child,
Child->m_TargetExitLatency);
561 DPRINT1(
"Device %p exit latency still too large with U1 and U2 off\n",
m_Device);
572 if (
Child->m_LatencyAdjustPercent == 0)
578 Doubled =
Child->m_LatencyAdjustPercent * 2UL;
581 Child->m_LatencyAdjustPercent = (
UCHAR)Doubled;
587 DPRINT1(
"Device %p misses pings with link power already off\n",
Child);
591 DPRINT1(
"Device %p misses pings, turning U1 and U2 off\n",
Child);
605 static const ULONG64 Scale[] = { 1, 1000, 1000000, 1000000000 };
608 Speed = Scale[Attribute->LaneSpeedExponent] * Attribute->LaneSpeedMantissa * (LaneCount + 1);
630 Attribute = &
Port->m_Info.SublinkSpeedAttr[
Index];
651 if (!
Port->HasProperty(PortProperty::EnhancedSuperSpeed))
BOOLEAN ExitLatencyMayDrop()
DSM_FEATURE_CHANGE U2Change()
BOOLEAN U1TimeoutChanged()
BOOLEAN ExitLatencyMustRise()
VOID ComputeExitLatency()
DSM_FEATURE_CHANGE U1Change()
BOOLEAN DisableLinkStatesForLatency()
BOOLEAN AdjustLatencyForNoPing()
BOOLEAN U2TimeoutChanged()
BOOLEAN U2NeededForEnumerated()
USHORT m_TargetExitLatency
VOID ClearState(_In_ ChildState Flag)
UCHAR m_LatencyAdjustPercent
VOID SetState(_In_ ChildState Flag)
USHORT m_EffectiveExitLatency
BOOLEAN HasState(_In_ ChildState Flag) const
HubParentInfo m_ParentInfo
USB_30_HUB_DESCRIPTOR Usb30
union HubFdo::@1628 m_HubDescriptor
BOOLEAN NTAPI HubChildU2ForEnumerated(_In_ HubChild *Child)
#define HUB_LINK_OFF_FOR_NO_PING
#define HUB_LPM_POLICY_U1_INITIATE
#define HUB_LPM_POLICY_U1_ACCEPT
#define HUB_LPM_POLICY_U2_ENABLED
#define HUB_LPM_POLICY_U1_ENABLED
#define HUB_LINK_U2_OFF_FOR_LATENCY
#define HUB_LPM_POLICY_U2_ACCEPT
#define HUB_LPM_POLICY_U2_INITIATE
#define HUB_LPM_POLICY_CONSERVATIVE
#define HUB_LINK_TARGET_U1
#define HUB_LINK_U1_OFF_FOR_LATENCY
#define HUB_LPM_POLICY_AGGRESSIVE
#define HUB_LINK_TARGET_U2
static BOOLEAN NTAPI HubChildPortKeepsU2Off(_In_ HubChild *Child)
static BOOLEAN NTAPI HubTpDelayFromAttribute(_In_ const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED *Attribute, _In_ ULONG LaneCount, _Out_ PUSHORT Delay)
BOOLEAN NTAPI HubChildU2ForEnumerated(_In_ HubChild *Child)
static BOOLEAN NTAPI HubChildLpmBlocked(_In_ HubChild *Child)
#define MIN_LINK_SPEED_BPS
static VOID NTAPI HubChildSetLink(_In_ HubChild *Child, _In_ ULONG Bit, _In_ BOOLEAN Set)
static BOOLEAN NTAPI HubChildHasPolicy(_In_ HubChild *Child, _In_ ULONG Bit)
static const USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED *NTAPI HubPortFindSpeed(_In_ HubPort *Port, _In_ ULONG SpeedId, _In_ ULONG Direction)
static BOOLEAN NTAPI HubLinkStateOff(_In_ UCHAR Timeout, _In_ BOOLEAN Target)
#define NO_PING_LAST_PERCENT
#define U2_TIMEOUT_LONGEST
#define MAX_PACKET_FORWARD_NS
static HubU2Verdict NTAPI HubChildU2FromPipes(_In_ HubChild *Child, _Out_ PUSHORT Longest, _Out_ PBOOLEAN PeriodicInterrupt)
#define LATENCY_TIMEOUT_FACTOR
static BOOLEAN NTAPI HubChildU1FromPipes(_In_ HubChild *Child, _Out_ PUCHAR Timeout)
#define INTERRUPT_USAGE_PERIODIC
#define TP_DELAY_5GBPS_NS
#define TIMEOUT_ACCEPT_ONLY
#define NO_PING_FIRST_PERCENT
static DSM_FEATURE_CHANGE NTAPI HubLinkChange(_In_ BOOLEAN Wanted, _In_ BOOLEAN Enabled)
#define U1_TIMEOUT_LONGEST
static BOOLEAN NTAPI HubChildHasNonControlPipe(_In_ HubConfiguration *Config)
#define TP_SYMBOL_NS_SCALE
enum _DSM_FEATURE_CHANGE DSM_FEATURE_CHANGE
#define HUB_TUNNEL_STATE_TUNNELED
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
USHORT TotalTpPropagationDelay
struct _LIST_ENTRY * Flink
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
#define USB_ENDPOINT_TYPE_INTERRUPT
#define USB_ENDPOINT_TYPE_CONTROL
#define USB_ENDPOINT_TYPE_ISOCHRONOUS
#define USB_ENDPOINT_TYPE_MASK
#define USB_ENDPOINT_DIRECTION_IN(x)
#define USB_30_ENDPOINT_TYPE_INTERRUPT_USAGE_MASK
#define USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_RX
#define USB_DEVICE_CAPABILITY_SUPERSPEEDPLUS_SPEED_DIR_TX
_In_ WDFCOLLECTION _In_ ULONG Index
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value