]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/log
pvdrivers/win/xenvif.git
7 years agoMake use of possible XENBUS_EVTCHN Unmask failure
Paul Durrant [Fri, 20 Oct 2017 17:14:28 +0000 (18:14 +0100)]
Make use of possible XENBUS_EVTCHN Unmask failure

Bump up to the latest version of XENBUS_EVTCHN and specify the option
to Unmask that allows it to fail. In this circumstance it is possible to
avoid dropping out of the DPC and thus avoid a context switch and re-queue.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoMove the Receiver and Transmitter event and DPC processing...
Paul Durrant [Wed, 18 Oct 2017 14:02:52 +0000 (15:02 +0100)]
Move the Receiver and Transmitter event and DPC processing...

...into the new Poller sub-system.

For efficiency it is desirable to have a single DPC handle both Receiver
and Transmitter polling, even if there are separate event channels for
the shared rings.

This patch moves all the basic event and DPC code into the Poller
subsystem, which calls back into the Transmitter and Receiver sub-systems
(to poll the shared rings) from its single per-CPU DPC.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd the boilerplate for a new Poller sub-system
Paul Durrant [Mon, 16 Oct 2017 10:20:17 +0000 (11:20 +0100)]
Add the boilerplate for a new Poller sub-system

The intention is that the separate Receiver and Transmitter event and DPC
handling be combined into a single sub-system. This patch lays the ground-
work for that to be done.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRemove ZwFlushKey() from registry code
Paul Durrant [Thu, 3 Aug 2017 10:14:11 +0000 (11:14 +0100)]
Remove ZwFlushKey() from registry code

Attempting to flush registry keys early in boot causes an error to be
logged.

This patch therefore removes the explicit flushes from the registry code.
There is no option but to trust Windows lazy flush.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoMake use of updated XENBUS_EVTCHN interface
Paul Durrant [Tue, 30 May 2017 15:24:45 +0000 (16:24 +0100)]
Make use of updated XENBUS_EVTCHN interface

The latest version of the interface has modified the semantics of the
Wait method to avoid races. The patch takes advantage of these new
semantics.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRemove VS2012 and VS2013 build scripts
Paul Durrant [Thu, 18 May 2017 13:52:47 +0000 (14:52 +0100)]
Remove VS2012 and VS2013 build scripts

This patch removes the scripts for building under VS2013 and VS2013 and
also fixes the package destination when building using VS2015.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoReboot request keys should be volatile
Paul Durrant [Mon, 8 May 2017 16:10:48 +0000 (17:10 +0100)]
Reboot request keys should be volatile

When a driver makes a reboot request it should use a volatile registry key.
The monitor service will explicitly remove the key prior to reboot but,
if the reboot is initiated in some other way and the key is non-volatile,
the monitor service will then needlessly prompt for a second reboot.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix SDV
Paul Durrant [Tue, 10 Jan 2017 17:15:58 +0000 (17:15 +0000)]
Fix SDV

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't use Packet->Offset when stripping VLAN tags
Paul Durrant [Tue, 10 Jan 2017 16:53:08 +0000 (16:53 +0000)]
Don't use Packet->Offset when stripping VLAN tags

The WHQL tests have always been buggy when dealing with packet data that
is offset into the NET_BUFFER MDL chain. Instead, adjust the MappedSystemVa
of the initial MDL.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDeferring transmit completion causes MPE_Ethernet test failures
Paul Durrant [Tue, 10 Jan 2017 16:51:12 +0000 (16:51 +0000)]
Deferring transmit completion causes MPE_Ethernet test failures

The test imposes a strict timeout on transmit completion so unfortunately
we have to complete eagerly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix kdfiles.py
Paul Durrant [Tue, 10 Jan 2017 11:15:09 +0000 (11:15 +0000)]
Fix kdfiles.py

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoClean up use of MmGetSystemAddressForMdlSafe()
Paul Durrant [Tue, 10 Jan 2017 11:10:32 +0000 (11:10 +0000)]
Clean up use of MmGetSystemAddressForMdlSafe()

It is not necessary in most cases, because we can ASSERT that the MDL
is already mapped to a system address for anything locally allocated.

Also this patch substitutes use of local variable name StartVa with BaseVa,
to avoid confusion with Mdl->StartVa.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't try to __FreePages() with local copy of MDL
Paul Durrant [Tue, 10 Jan 2017 10:29:53 +0000 (10:29 +0000)]
Don't try to __FreePages() with local copy of MDL

The XENVIF_RECEIVER_PACKET structure contains an embedded MDL so that
multi-fragment packets can be properly chained together. However this
structure should not be passed to __FreePages() as:

a) It appears to create problems with system PTE tracking
b) It results in memory corruption now that __FreePages() calls
   ExFreePool()

This patch therefore extends the packet structure with a pointer to the
original system MDL such that it can be passed to __FreePages() when the
packet destructor is called.

The patch also bypasses some calls to MmGetSystemAddressForMdlSafe() since
we can ASSERT that the MDL is already mapped to a system address.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove the explicit ExFreePool(Mdl) in TransmitterBufferDtor()
Paul Durrant [Mon, 9 Jan 2017 11:45:21 +0000 (11:45 +0000)]
Remove the explicit ExFreePool(Mdl) in TransmitterBufferDtor()

It should no longer be there as of commit f529058c since it now
constitutes a double-free.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix memory leak in __FreePage()
Paul Durrant [Fri, 6 Jan 2017 15:44:00 +0000 (15:44 +0000)]
Fix memory leak in __FreePage()

The pool memory for the MDL also needs to be freed.

Also, generalise __AllocatePage() and __FreePage() to __AllocatePages()
and __FreePages() to allow for multi-page allocations in future.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove unnecessary complexity from the controller frontend
Paul Durrant [Thu, 15 Dec 2016 14:00:42 +0000 (14:00 +0000)]
Remove unnecessary complexity from the controller frontend

The controller ring is driven much like the store ring in XENBUS for
request/response but, unlike the store ring, there are no asynchronous
events (like watches) so we really don't need a DPC and an asynchronous
poll, or a watchdog.

This patch removes that code, and also shortens the poll timeout when
waiting for a response since use of XENBUS_EVTCHN(...Wait...) is
inherently racey.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDrop all pre-8.2 revisions
Paul Durrant [Thu, 15 Dec 2016 11:56:07 +0000 (11:56 +0000)]
Drop all pre-8.2 revisions

Version 9.0 drivers only need to be backwards compatible as far as 8.2, so
we can drop any interface versions that pre-date the 8.2 branch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate BUILD.md with VS2015/WDK10 information
Paul Durrant [Wed, 14 Dec 2016 16:32:58 +0000 (16:32 +0000)]
Update BUILD.md with VS2015/WDK10 information

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFixes for VS2015/WDK10 build
Paul Durrant [Wed, 14 Dec 2016 15:52:52 +0000 (15:52 +0000)]
Fixes for VS2015/WDK10 build

The package build was not working correctly and caused the overall build
to fail.
At least part of the reason for this is that Microsoft, in their infinite
wisdom, have removed the DIFx redist from WDK10. This patch makes use of
a new environment variable 'DPINST_REDIST' to find the copy of dpinst.exe
to package such that this can be pointed at an older WDK or alternative
location where dpinst.exe can be found.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd support for building under VS2015/WDK10
Paul Durrant [Mon, 12 Dec 2016 16:31:50 +0000 (16:31 +0000)]
Add support for building under VS2015/WDK10

Moving to the new toolchain also threw up a few new warnings, which this
patch either fixes or squashes. Also, SDV appears to be fragile in new
ways (and whinge about some new things) so there are fixes for that too.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate driver version from 8.2.0 to 9.0.0
Paul Durrant [Mon, 12 Dec 2016 15:51:13 +0000 (15:51 +0000)]
Update driver version from 8.2.0 to 9.0.0

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix last commit... 8.2.0-rc1
Paul Durrant [Mon, 7 Nov 2016 16:46:59 +0000 (16:46 +0000)]
Fix last commit...

Missing 'git add'.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAvoid calculating a hash if it is not necessary
Paul Durrant [Mon, 7 Nov 2016 16:20:16 +0000 (16:20 +0000)]
Avoid calculating a hash if it is not necessary

If there is only a single queue then we do not need to calculate a hash.
There is only one choice in how to steer the packet!

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDisallow RSS configuration if there is only a single vCPU
Paul Durrant [Mon, 7 Nov 2016 16:15:24 +0000 (16:15 +0000)]
Disallow RSS configuration if there is only a single vCPU

It's not going to be useful and having RSS enabled in a single vCPU
VM seems to confuse a Windows Domain Controller installed in that VM.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoProvide registry override for disabling RSS
Paul Durrant [Mon, 7 Nov 2016 11:35:09 +0000 (11:35 +0000)]
Provide registry override for disabling RSS

For diagnostic purposes it is useful to be able to simulate the situation
where XENVIF does not support RSS (because the backend does not support
it).

This patch adds code to check a REG_DWORD value called
'FrontendDisableToeplitz' and will not allow the Toeplitz hash algorithm
to be configured if the value is non-zero. This prevents XENNET from
advertizing the RSS capability to the network stack.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd more diagnostic messages
Paul Durrant [Fri, 4 Nov 2016 16:15:09 +0000 (16:15 +0000)]
Add more diagnostic messages

Log a message at start and end of both transmitter and receiver
ring enable and disable functions. Testing has thrown up some hangs
that appear to be in one of these functions.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd registry override to disable multicast control
Paul Durrant [Fri, 4 Nov 2016 15:13:25 +0000 (15:13 +0000)]
Add registry override to disable multicast control

The patch adds a registry parameter 'TransmitterDisableMulticastControl'.
This is a REG_DWORD which, if set to a non-zero value, will prevent
XENVIF from using the dynamic-multicast-control feature of the backend.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAlways select queue using the packet hash algorithm
Paul Durrant [Fri, 4 Nov 2016 10:51:54 +0000 (10:51 +0000)]
Always select queue using the packet hash algorithm

There may be a mismatch between the configured receive hash algorithm
and the actual algorithm present in a transmit-side packet.
E.g. Toeplitz may be configured but a transmitted packet may have no
hash information.

It makes no sense to use a hash mapping table configured for a Toeplitz
hash if the packet hash is not Toeplitz, therefore the code should pass
the actual packet hash algorithm into the FrontendGetQueue(). This patch
makes the that change.

Suggested-by: Owen Smith <owen.smith@citrite.net>
This patch also makes sure we cannot attempt to indirect through a zero-
sized mapping table (thereby incurring a divide-by-zero exception).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix build warnings
Paul Durrant [Thu, 3 Nov 2016 10:11:05 +0000 (10:11 +0000)]
Fix build warnings

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoChange where transmitter packet cache is created
Paul Durrant [Thu, 3 Nov 2016 09:48:23 +0000 (09:48 +0000)]
Change where transmitter packet cache is created

The transmitter packet cache suffers from a similar issue as the
receiver packet cache did before commit 0dda5aa8 "Partially revert
commit ab655bb1...". If the VM goes through a suspend/resume cycle
with queued transmits then the cache would be torn down before all
objects had been freed, leading to ASSERTion failures in checked
builds and memory corruption in free builds.

This patch moves creation of the packet cache from the 'connect'
phase to the 'initialization' phase to avoid this problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd Ring Index to ring-related Info messages
Paul Durrant [Wed, 2 Nov 2016 12:58:18 +0000 (12:58 +0000)]
Add Ring Index to ring-related Info messages

This patch adds the Ring Index to all calls to Info() issued in ring-
related functions so that the specific Ring is identified in the log.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoLog how many packets are aborted
Paul Durrant [Wed, 2 Nov 2016 12:02:37 +0000 (12:02 +0000)]
Log how many packets are aborted

When the transmitter rings are shut down, packets in the queues are
aborted. This patch adds a log line saying how many packets were
aborted in each queue.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd an extra transmitter ring poll
Paul Durrant [Wed, 2 Nov 2016 11:51:54 +0000 (11:51 +0000)]
Add an extra transmitter ring poll

If we are trying to post fragments into the ring and find it full then
do a single poll to try to free up the space, rather than bailing and
waiting for the DPC to run.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoPartially revert commit ab655bb1 "Make sure XENBUS interfaces...
Paul Durrant [Wed, 2 Nov 2016 11:05:47 +0000 (11:05 +0000)]
Partially revert commit ab655bb1 "Make sure XENBUS interfaces...

...are released when going into S4".

Not all interfaces need to be released (since they don't all depend on
Xen) and crucially the receiver packet caches CANNOT be destroyed (and
hence the CACHE interface CANNOT be released) because there may be packets
outstanding in the stack... not necessarily in an S4 transtion, but
across a suspend/resume (which involves the same frontend state
transitions).

This patch also increases the log level of a couple of messages
emitted during frontend state transtions from 'trace' to 'info'.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoLogging and barrier changes in ReceiverWaitForPackets()
Paul Durrant [Tue, 25 Oct 2016 10:34:51 +0000 (11:34 +0100)]
Logging and barrier changes in ReceiverWaitForPackets()

Modifications for bug diagnosis

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix some logical stupidity
Paul Durrant [Tue, 25 Oct 2016 10:34:09 +0000 (11:34 +0100)]
Fix some logical stupidity

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoIncorporate revision ids from staging-8.1
Paul Durrant [Mon, 3 Oct 2016 14:10:38 +0000 (15:10 +0100)]
Incorporate revision ids from staging-8.1

Since it should be possible to upgrade from an 8.1 version of XENVIF
to an 8.2 version, at least the release revision of the 8.1 version
(0x0800000A) should be present in the 8.2 revision table, otherwise
driver upgrade will be vetoed by the co-installer if an 8.1 XENNET
is bound.

This patch incorporates all missing 8.1 revision ids.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAvoid possible NULL pointer dereference
Owen Smith [Mon, 3 Oct 2016 12:03:37 +0000 (13:03 +0100)]
Avoid possible NULL pointer dereference

If the packet cache is exhausted and unable to allocate more items, fail
before attempting to use the pointer. Moves the check to after
attempting to get a packet cache item.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Slight re-structuring of the error check.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove watchdog affinitisation on Windows 2008
Ben Chalmers [Wed, 28 Sep 2016 15:05:34 +0000 (16:05 +0100)]
Remove watchdog affinitisation on Windows 2008

Despite the presence of a compatability library, the
Windows 2008 calls to affinitise the watchdog thread
to a particular processor group are leading to lockups.

So detect if we are running on a version prior to
Windows 7 (or 2008 R2), and don't try to affinitise if
we are.

Signed-off-by: Ben Chalmers <ben.chalmers@citrix.com>
8 years agoMinor logging improvements
Paul Durrant [Thu, 22 Sep 2016 11:14:00 +0000 (12:14 +0100)]
Minor logging improvements

In the situation where the receiver is waiting for loaned packets to
be returned emit a log message every 10s so that progress can be
observed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix a couple of issues picked up by Windows 10 verifier
Paul Durrant [Wed, 21 Sep 2016 12:46:14 +0000 (13:46 +0100)]
Fix a couple of issues picked up by Windows 10 verifier

- It's possible for MmAllocatePagesForMdlEx() not to satisfy the
  full allocation request, but not fail. Thus AllocatePage() should
  check that the completed allocation actually matches what it
  asks for.

- RegistryCreateKey() has a memory leak.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRevert commit 272428b6
Paul Durrant [Wed, 21 Sep 2016 12:18:24 +0000 (13:18 +0100)]
Revert commit 272428b6

The ASSERTion fix in this commit was wrong and lead to NIC unplugs being
missed. This fix simply makes sure the PDO flag is set to FALSE to
avoid tripping over the zero-memory ASSERTion later on in PdoDestroy().

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoStep through hardware revision list in reverse order
Owen Smith [Tue, 20 Sep 2016 17:06:14 +0000 (18:06 +0100)]
Step through hardware revision list in reverse order

Windows treats the HardwareID list as a decending order of specialization
where the first entry is the most specific, and last entry is least
specific. This can lead to install issues when the newer driver has a
less-specific HardwareID, as the older ("more-specific") HardwareID is
used for the match. Reordering the HardwareID list, so that the newest
revision is first, will stop Windows selecting the wrong driver package
to install.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Re-factored slightly for code consistency.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd statistics for checksum validation
Paul Durrant [Tue, 20 Sep 2016 16:43:27 +0000 (17:43 +0100)]
Add statistics for checksum validation

For the transmit side this also entails added code to perform checksum
validation. However, since this may affect performance, validation is
only performed if the registry parameter TransmitterValidateChecksums
(REG_DWORD) is present and set a non-zero value.

Since the index values of the statistics used by XENNET are left
unchanged by this patch, there is no need to bump the XENVIF_VIF
interface version.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoiFix another ASSERTion failure
Paul Durrant [Tue, 20 Sep 2016 15:19:30 +0000 (16:19 +0100)]
iFix another ASSERTion failure

Because of code changes in the previous patch the ASSERT is now in-
correct.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoPass the receive queue index to XENNET
Paul Durrant [Tue, 20 Sep 2016 13:15:06 +0000 (14:15 +0100)]
Pass the receive queue index to XENNET

Update the XENVIF_VIF interface to version 8 to include an extra 'Index'
parameter to the XENVIF_RECEIVER_QUEUE_PACKET callback. This means
XENNET no longer has to use current CPU to decide which queue is which.

This patch also fixes a couple of ASSERTion failures seen in debugging.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't restore settings from emulated device more than once
Paul Durrant [Thu, 8 Sep 2016 10:09:17 +0000 (11:09 +0100)]
Don't restore settings from emulated device more than once

If, for some reason, the VM boots with emulated networking then network
settings will be saved from the emulated network device. Then, when the
VM reboots with PV networking, those settings are restored to the PV
network device regardless of whether it was freshly installed or has
been around for some time.

This patch makes sure that settings are restored only to a freshly
installed PV device.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRevert all settings stealing patches
Paul Durrant [Wed, 7 Sep 2016 15:25:52 +0000 (16:25 +0100)]
Revert all settings stealing patches

Windows has completely defeated me. There appears to be no way to
duplicate the stack binding of the emulated device without that binding
being removed if XENNET is un-installed, despite clearing all the
relevant registry keys in the DIF_REMOVE pre-process phase.

So, this patch reverts the code back to using the settings copy
mechanism employed in the 8.1 source.

The patches reverted (with some fix-up) are:

32bd2878 "Remove settings code"
70f4bb96 "Re-work identity stealing code"
04c391d9 "Replace copying network settings with identity stealing"

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoThe SOFTWARE registry hive is not accessible at boot time
Paul Durrant [Mon, 22 Aug 2016 07:44:15 +0000 (08:44 +0100)]
The SOFTWARE registry hive is not accessible at boot time

Hence it cannot be used for the monitor request key, otherwise XENVBD
cannot necessarily access it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate registry code
Paul Durrant [Fri, 19 Aug 2016 10:56:41 +0000 (11:56 +0100)]
Update registry code

Bring in new registry code from XENBUS to fix RegistryCreateKey()'s
semantics.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix SDV build
Paul Durrant [Wed, 17 Aug 2016 14:04:55 +0000 (15:04 +0100)]
Fix SDV build

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoCreate, rather than open, the RequestKey
Paul Durrant [Wed, 17 Aug 2016 13:32:52 +0000 (14:32 +0100)]
Create, rather than open, the RequestKey

It's possible that, on upgrade, XENVIF is installed before XENBUS and so
the RequestKey may not exist.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd batching support
Paul Durrant [Mon, 15 Aug 2016 13:06:30 +0000 (14:06 +0100)]
Add batching support

If a NET_BUFFER_LIST comprising multiple NET_BUFFERs is handled by XENNET
then this will result in multiple calls to VifTransmitterQueuePacket().
There is no need to attempt to process the transmit queue after every single
one of these calls, it suffices to just do it after the last of them. Hence
this patch adds an extra argument such that XENNET can notify XENVIF when
the last call of a batch is made.

Similarly on the receive side, it is useful notify XENNET when the last of
a batch of calls to the XENVIF_RECEIVER_QUEUE_PACKET callback is made, since
XENNET can then batch received packet indications to the NDIS stack.

These changes are made in XENVIF_VIF_INTERACE version 7.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRevert commit 03dd4642 "Avoid transmitting on the wrong CPU"
Paul Durrant [Mon, 15 Aug 2016 13:24:00 +0000 (14:24 +0100)]
Revert commit 03dd4642 "Avoid transmitting on the wrong CPU"

It severely impacts performance. The latency of waking up a different CPU
more than defeats the cost of one CPU blocking waiting on another.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdvertise MAC address information in the registry
Paul Durrant [Thu, 11 Aug 2016 10:03:42 +0000 (11:03 +0100)]
Advertise MAC address information in the registry

Because XENNET's co-installer is again taking responsibility for messing
with network settings it needs to be able to figure out which VIF instance
corresponds to which emulated device, and the only way it can do that is
by MAC address.

This patch therefore restores the old 'Addresses' subkey under XENVIF's
service key and populates it with REG_SZ values named with PDO names and
containing hex encoded ':' separated MAC address octets.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRemove settings code
Paul Durrant [Wed, 10 Aug 2016 12:51:22 +0000 (13:51 +0100)]
Remove settings code

Unfortunately, after extensive testing of different scenarios, it seems to
be impossible to properly steal and restore network stack bindings from
within the XENVIF driver. Windows has already sampled some of the values
we need to modify and thus we cannot successfully modify them.

It appears the only way we can successfully use settings from an emulated
device is to do what the settings code was attempting to do, but do it
in XENNET's co-installer during the pre-install and pre-removal phases.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix typo in INF file
Paul Durrant [Wed, 10 Aug 2016 11:11:06 +0000 (12:11 +0100)]
Fix typo in INF file

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUse new monitor request key
Paul Durrant [Tue, 9 Aug 2016 13:01:19 +0000 (14:01 +0100)]
Use new monitor request key

The monitor service now uses a request key in registry under HKLM/SOFTWARE.
This patch modifies __DriverRequestReboot() to use the new key, which is
now set as a parameter by the INF file.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix logging format string
Paul Durrant [Tue, 9 Aug 2016 10:59:25 +0000 (11:59 +0100)]
Fix logging format string

Should have been %Z rather than %s since the argument is ANSI_STRING.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRe-work identity stealing code
Paul Durrant [Mon, 8 Aug 2016 12:03:25 +0000 (13:03 +0100)]
Re-work identity stealing code

The change introduced by patch 04c391d9 "Replace copying network
settings with identity stealing" had a flaw...

If a PV device that aliases an emulated device is installed then it
will only steal linkage if that emulated device is operational at the
time. This works on initial driver install, but not if the PV network
device driver is removed and then re-installed without an interim
reboot (which would make the emulated device operational). Instead,
after re-installation, the PV device has a brand new stack binding and
thus any network settings changes that were previously made are
apparently lost.

To fix this problem, this patch breaks the process of stealing the
emulated device's stack binding into two phases:

1) Discovery: When the PV device driver is installed, if an aliasing
   emulated device is operational, a DWORD value called "VIF" is
   created under the emulated devices software key. The value is set
   to the PV device instance.

2) Theft: When the PV device is being brought online, the registry is
   checked to see if any network device has a software key containing
   a "VIF" value that patches the PV device instance.
   If such an entry is found then the stack binding is stolen from
   that device. Since the "VIF" value is in the *emulated* device's
   software key, it will not be removed if the PV device driver is
   removed and re-installed and so the problem described above will
   not occur.

Because this patch avoids stealing the emulated device's stack bindings
if it is actually operational (i.e. we're in phase 1) this results in the
class installer building a new set of stack bindings for the PV device
during initial installation.
These are then restored any time a PV device with a stolen stack binding
is offlined. So, when a PV device is offline there is no evidence that
any stack binding has been stolen and hence, during driver removal, there
is no risk of an emulated device's stack binding being torn down.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDon't qualify the check for the backend being online...
Paul Durrant [Thu, 28 Jul 2016 09:07:53 +0000 (10:07 +0100)]
Don't qualify the check for the backend being online...

...with whether an eject request for the frontend has been issued. It's
either online or it's not.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoMake sure the NICS unplug count does not run away
Paul Durrant [Thu, 28 Jul 2016 09:04:44 +0000 (10:04 +0100)]
Make sure the NICS unplug count does not run away

In a tight loop of network attach/detach it's possible for a mismatch in
the number of unplug requests and revocations to occur, leading to a
run-away unplug count.

This patch adjusts the location of the requests and revocations to make
sure this does not happen.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoMake sure we don't end up with duplicate PDOs
Paul Durrant [Thu, 28 Jul 2016 09:00:51 +0000 (10:00 +0100)]
Make sure we don't end up with duplicate PDOs

In a tight loop of network attach/detach it's possible to end up with
duplicate PDOs because, as soon as a PDO gets set to 'missing' a new one
with the same name can be created. This leads to races in accessing the
vif areas in xenstore and things can get very confused.

This patch makes sure that a new PDO cannot be created until a previous
incarnation is in the 'deleted' state, which means there will definitely
be no conflict in interactions with xenstore.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix locking and teardown bugs in controller frontend
Paul Durrant [Wed, 27 Jul 2016 12:33:56 +0000 (13:33 +0100)]
Fix locking and teardown bugs in controller frontend

If the backend does not implement the control ring then the frontend will
eventually deadlock. Also, by inspection, the teardown code does not
release interfaces if the control ring was not present.

This patch fixes both issues.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix compatibility with older backends
Paul Durrant [Wed, 27 Jul 2016 09:04:55 +0000 (10:04 +0100)]
Fix compatibility with older backends

There was a problem when XENVIF was brought up on backends that don't
implement a control ring. This patch fixes the issue.

Reported-by: Rafal Wojdyla <omeg@invisiblethingslab.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUse XENBUS_MONITOR service to request reboot rather than SetupAPI
Paul Durrant [Thu, 21 Jul 2016 10:58:31 +0000 (11:58 +0100)]
Use XENBUS_MONITOR service to request reboot rather than SetupAPI

This means more code can be removed from XENNET's co-installer and we get a
more meaningful message displayed to the user.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd missing names to the INF file
Paul Durrant [Thu, 21 Jul 2016 10:56:08 +0000 (11:56 +0100)]
Add missing names to the INF file

The package should have a name and the XENVIF driver should also have a
DisplayName.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix function name
Paul Durrant [Mon, 18 Jul 2016 14:15:45 +0000 (15:15 +0100)]
Fix function name

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix SDV warnings
Paul Durrant [Mon, 18 Jul 2016 14:06:47 +0000 (15:06 +0100)]
Fix SDV warnings

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoDefer transmit response event until the last possible moment
Paul Durrant [Wed, 18 May 2016 15:33:14 +0000 (16:33 +0100)]
Defer transmit response event until the last possible moment

When sending packets, there is no need to enable a transmit reponse
event until the ring fills or there are no more packets to send.

This patch therefore defers advancing the ring event count until just
before a batch of packets are pushed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAvoid transmitting on the wrong CPU
Paul Durrant [Wed, 18 May 2016 15:23:51 +0000 (16:23 +0100)]
Avoid transmitting on the wrong CPU

The transmit and receive rings have DPCs and event channels affinitized
to a particular CPU. Thus, when XENNET queues a new packet at the
transmit side, make sure the packet is prepared and posted from the
CPU to which the DPC and event channel are bound to avoid lock contention.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAffinitize watchdog threads
Paul Durrant [Wed, 18 May 2016 14:47:07 +0000 (15:47 +0100)]
Affinitize watchdog threads

To avoid bouncing locks between CPUs, affinitize the ring watchdog thread
to the same CPU as the event channel and DPC.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoRe-introduce mistakenly dropped frontend state logic...
Eytan Heidingsfeld [Mon, 18 Jul 2016 12:28:04 +0000 (13:28 +0100)]
Re-introduce mistakenly dropped frontend state logic...

...from commit c9b6e56e "Cope with unexpected initial backend states" to
handle a backend that is already connected (for cases where Windows is
booted via iSCSI).

Signed-off-by: Eytan Heidingsfeld <eytanh@gmail.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSend transmit side hash value to the backend
Paul Durrant [Thu, 7 Jan 2016 15:06:48 +0000 (15:06 +0000)]
Send transmit side hash value to the backend

Backends capable of supporting packet hashing on the guest receive side
are also capable of accepting hash values in an extra info fragment on
the guest transmit side. This patch adds code to construct and send the
extra info fragment if the packet metadata contains hash information and
the backend is able to process it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd new functionality to VIF interface to support RSS
Paul Durrant [Wed, 6 Jan 2016 16:22:32 +0000 (16:22 +0000)]
Add new functionality to VIF interface to support RSS

This patch adds the necessary extra functionality into the VIF interface
to make use of the new control ring to support NDIS RSS in XENNET.

The VIF interface version is bumped to 6 and the PDO revision adjusted
accordingly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd frontend code for the new netif control ring
Paul Durrant [Fri, 20 Nov 2015 16:56:49 +0000 (16:56 +0000)]
Add frontend code for the new netif control ring

My recent patches to Xen's netif.h specify a control ring that can be
used by a frontend driver to configure packet hashing and steering in
a backend.
This patch adds the necessary code to XENVIF to drive this new ring,
however the rest of the code to link this up to new VIF interface
functionality (so that it may be used by XENNET) is deferred to a
subsequent patch.

This patch also pulls in an updated EVTCHN interface from XENBUS and
corrects the PDO binding.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate Xen headers to 4.7.0-rc2
Paul Durrant [Tue, 2 Feb 2016 16:37:37 +0000 (16:37 +0000)]
Update Xen headers to 4.7.0-rc2

This pulls in the recent changes to netif.h which are required by
subsequent patches.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoMake sure transmitter DPC does not try to unmask non-existent evtchn
Paul Durrant [Fri, 6 May 2016 08:51:30 +0000 (09:51 +0100)]
Make sure transmitter DPC does not try to unmask non-existent evtchn

In the case where the backend does not support split event channels (one
for RX and one for TX) then the transmitter code in XENVIF does not open
the combined channel; it is handled by the receiver code. So, the
transmitter DPC should not make any attempt to unmask the event channel at
the end of processing.

This patch adds the necessary check for FrontendIsSplit before doing the
unmask and also removes an unnecessary check for FrontendIsSplit in the
transmitter ring enable function.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Eytan Heidingsfeld <eytanh@gmail.com>
Tested-by: Eytan Heidingsfeld <eytanh@gmail.com>
9 years agoFix memory leak
Paul Durrant [Fri, 1 Apr 2016 14:14:57 +0000 (15:14 +0100)]
Fix memory leak

This was breaking SDV builds.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoReplace copying network settings with identity stealing
Paul Durrant [Wed, 2 Mar 2016 16:35:47 +0000 (16:35 +0000)]
Replace copying network settings with identity stealing

It is becoming increasingly hard to find all the places in the registry
that Windows uses to stash network settings and copy them from the
emulated NIC to the new PV device when it is first installed.

So, rather than fighting a losing battle, steal the identity of emulated
devices instead, The identity information is essentially contained in two
values stored in the 'software'registry key of a NIC (under Control/Class/
<NET GUID>): NetCfgInstanceId and the NET_LUID, made up of *IfType and
NetLuidIndex. By copying these values and the contents of the Linkage subkey
we can effectively impersonate the emulated NIC once it is unplugged after
reboot.

This patch amends the settings code accordingly and also does some tidying
in pdo.c and registry.c.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoBootFlags should be a parameter, not a subkey
Paul Durrant [Wed, 30 Mar 2016 10:58:58 +0000 (11:58 +0100)]
BootFlags should be a parameter, not a subkey

A misplaced comma in the INF file means that BootFlags is being created as
a subkey under the service key with a default DWORD value, rather than a
DWORD value with the name 'BootFlags'.

This patch moves the comma and fixes the problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoAvoid ASSERTion failure on VIF plug
Paul Durrant [Wed, 23 Mar 2016 14:06:27 +0000 (14:06 +0000)]
Avoid ASSERTion failure on VIF plug

If the backend is not fast enough then it's possible that the frontend
code sees the backend in state Initialising rather than InitWait. This
causes an ASSERT to be hit.
This patch simply whitelists the Initialising state to avoid the problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoPrevent VIF from being incorrectly considered offline...
Paul Durrant [Wed, 23 Mar 2016 11:50:35 +0000 (11:50 +0000)]
Prevent VIF from being incorrectly considered offline...

...one resume from suspend.

My previous reversion of 765b7a6a exposed the original reason the
reverted patch.

On resume from suspend, the backend will have been re-created by the
toolstack and hence the frontend detects it as being offline. This
causes the frontend to request ejection of the disk (thinking that
the reason for the backend going offline is because the VIF is being
unplugged).

This patch works around this problem by introducing an early suspend
callback to note that the frontend has actually gone offline, which
will prevent the ejection from being requested.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoRemove erroneous code to re-acquire backend path on resume
Paul Durrant [Tue, 22 Mar 2016 11:29:37 +0000 (11:29 +0000)]
Remove erroneous code to re-acquire backend path on resume

Commit 765b7a6a added code to release and re-acquire the backend
path (and domid) on resume from suspend. That code falsely
assumes that the frontend is not in a closed state at the time.
It's also not clear why it was added in the first place so
this patch removes it again, as it causes a BSOD when the
frontend is in the closed state.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoOnly veto PDO start when InitSafeBootMode is set
Paul Durrant [Tue, 1 Mar 2016 17:22:00 +0000 (17:22 +0000)]
Only veto PDO start when InitSafeBootMode is set

There is no need to prevent FDO or PDO creation to stop PV network devices
from coming up, we just need to prevent the PDOs from starting.

Thie patch removes the global veto and instead bails out of PdoStartDevice()
if the system is in safe mode.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoDynamic multicast control
Paul Durrant [Thu, 21 Jan 2016 09:23:27 +0000 (09:23 +0000)]
Dynamic multicast control

Only use the multicast control feature of the backend if it supported
"feature-dynamic-multicast-control" otherwise attempts to enable the 'all
multicast' filter level in XENVIF will have no effect and the NDISTest 6.5
MultiCast Address test will fail.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoMake transmitter code the canonical place where multicast control...
Paul Durrant [Wed, 20 Jan 2016 17:36:01 +0000 (17:36 +0000)]
Make transmitter code the canonical place where multicast control...

...feature is handled

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoFix memory leak in error path
Paul Durrant [Thu, 28 Jan 2016 14:40:49 +0000 (14:40 +0000)]
Fix memory leak in error path

If a malformed large packet is received then it is possible that a packet
structure is leaked on the error path.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoCancel pending timers when rings are disabled
Paul Durrant [Thu, 28 Jan 2016 14:35:53 +0000 (14:35 +0000)]
Cancel pending timers when rings are disabled

No new timers can be scheduled once rings are disabled but if the rings are
both disconnected and destroyed within the next 100us then it's possible
that the DPC might hit some unitialized data so make sure pending timers
are cancelled.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoAdd DPC watchdog avoidance to receiver and transmitter poll
Paul Durrant [Mon, 25 Jan 2016 10:24:49 +0000 (10:24 +0000)]
Add DPC watchdog avoidance to receiver and transmitter poll

Under HCK MPE testing it's possible for both receiver and transmitter
polling loops to run long enough to hit the DPC watchdog. This patch
avoids the problem by terminating the polling loops after a 'batch'
(currently 1/4 of the ring) and then checking the remaining time before the
watchdog fires. If the remaining time is still more than half the total
time then another poll is done, otherwise a timer is scheduled to complete
the work.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoAvoid evaluating assertion expressions in free builds
Paul Durrant [Fri, 22 Jan 2016 14:41:36 +0000 (14:41 +0000)]
Avoid evaluating assertion expressions in free builds

The evaluations are pointless and the warnings generated by not evaluating
can be squashed with a couple of #pragmas.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoAvoid falling foul of stupid registry values
Paul Durrant [Fri, 22 Jan 2016 14:40:11 +0000 (14:40 +0000)]
Avoid falling foul of stupid registry values

Without this patch mistakenly setting 'FrontendMaxQueues' to 0 in the
registry will cause an unobvious BSOD.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoFix DPC accounting
Paul Durrant [Fri, 22 Jan 2016 13:57:58 +0000 (13:57 +0000)]
Fix DPC accounting

The DPC count is not zeroed when the event count is zeroed leading to some
odd looking stats. Also the DPC count should really be incremented by the
DPC itself to ensure serialization.

While in the neighbourhood, the ring notify functions in transmitter and
receiver look a little superfluous; they can easily be folded directly
into the DPC if the receiver code triggers the transmmitter DPC in the case
of a combined event channel.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoFix WHQL InvalidPackets test
Paul Durrant [Tue, 19 Jan 2016 16:31:44 +0000 (16:31 +0000)]
Fix WHQL InvalidPackets test

Because the transmit code now parses packets before queueing (for the
purposes of maybe needing to hash) the operation can fail of the headers
are invalid. The WHQL test does not expect this to happen.

This patch ignores the parse failure but instead fails the packet when it
is de-queued but only if absolutely no header (i.e. even the ethernet
header) could be parsed. This seems to be enough to keep the test happy.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoStop using prefix GSO
Paul Durrant [Wed, 7 Oct 2015 08:54:03 +0000 (09:54 +0100)]
Stop using prefix GSO

Since acknowledging that the netif response id is meaningless in the code,
we no longer need to use the prefix flavour of GSO.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoCentralize compatibility code
Paul Durrant [Tue, 15 Dec 2015 14:26:55 +0000 (14:26 +0000)]
Centralize compatibility code

This patch moves the code that maintains compatibility with older
VIF interface versions into the vif.c module, rather than having it
distributed amongst vif.c, transmitter.c and receiver.c.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoFix revision number to avoid collision with staging-8.1
Paul Durrant [Mon, 4 Jan 2016 13:34:48 +0000 (13:34 +0000)]
Fix revision number to avoid collision with staging-8.1

My previous patch incorrectly used a PDO revision that was already in use
on the staging-8.1 branch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoUpdate VIF interface to version 5
Paul Durrant [Mon, 4 Jan 2016 13:09:14 +0000 (13:09 +0000)]
Update VIF interface to version 5

Unfortunately VIF interface version 4 suffers from a shutdown race with
the TransmitterQueuePacket method. If a call to this races with the Disable
method then a NULL callback function pointer can be invoked.
This patch fixes the race by having TransmitterQueuePacket return a status
code to indicate whether a packet has been queued (rather than invoking the
completion callback if it has not), but this necessitates a interface change
so the VIF interface version is also updated to 5 and a new PDO revision is
added.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoRe-synchrinize registry.c with XENBUS
Paul Durrant [Thu, 10 Dec 2015 11:24:08 +0000 (11:24 +0000)]
Re-synchrinize registry.c with XENBUS

The registry code in XENBUS has some fixes that are not present in the
XENVIF copy, so import the updated code from XENBUS.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
9 years agoRe-synchronize util.h with XENBUS and use __toupper()
Paul Durrant [Thu, 10 Dec 2015 11:17:05 +0000 (11:17 +0000)]
Re-synchronize util.h with XENBUS and use __toupper()

A recent patch introduced __tolower() and __toupper() into util.h as
replacements for tolower() and toupper() respectively as the latter do
a hidden conversion to Unicode which make then unsafe at any IRQL other
than PASSIVE_LEVEL.
This patch imports util.h from XENBUS and fixes other code to be compatible.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>