blob: 68b057ff84828f62201b48c71d9aaeb8cb79a11d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (c) Microsoft Corporation. All rights reserved
#include "pch.hpp"
#include "netvadapter.h"
#include "device.h"
#include "trace.h"
#include "power.h"
#include "power.tmh"
void
NetvDeviceInitializePowerManagement(
_In_ NetvDevice * Device
)
{
#ifdef _KERNEL_MODE
WDFDEVICE wdfDevice = Device->m_handle;
NetvAdapter * adapter = Device->m_adapter;
if (!adapter->S0Idle)
{
return;
}
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(
&idleSettings,
IdleCanWakeFromS0);
idleSettings.IdleTimeout = 3000;
idleSettings.IdleTimeoutType = SystemManagedIdleTimeoutWithHint;
NTSTATUS ntStatus = WdfDeviceAssignS0IdleSettings(
wdfDevice,
&idleSettings);
if (ntStatus != STATUS_SUCCESS)
{
// MSDN says we should ignore error codes from assign S0 idle settings, do that
return;
}
// Now tell NetAdapterCx we support wake on packet filter match
NET_ADAPTER_WAKE_PACKET_FILTER_CAPABILITIES wakeOnPacketFilterMatch;
NET_ADAPTER_WAKE_PACKET_FILTER_CAPABILITIES_INIT(&wakeOnPacketFilterMatch);
wakeOnPacketFilterMatch.PacketFilterMatch = TRUE;
NetAdapterWakeSetPacketFilterCapabilities(adapter->m_handle, &wakeOnPacketFilterMatch);
#else
UNREFERENCED_PARAMETER(Device);
#endif
}
_Use_decl_annotations_
NTSTATUS
EvtDeviceArmWakeFromS0(
WDFDEVICE Device
)
{
auto adapter = NetvDeviceGetContext(Device)->m_adapter;
adapter->ArmWakeFromS0();
return STATUS_SUCCESS;
}
_Use_decl_annotations_
void
EvtDeviceDisarmWakeFromS0(
WDFDEVICE Device
)
{
auto adapter = NetvDeviceGetContext(Device)->m_adapter;
adapter->DisarmWakeFromS0();
}
|