Commit Graph
49 Commits
Author SHA1 Message Date
Yuri Benditovich ec023725fc netkvm: fail init if failed to open NIC configuration
Under driver verifier with low resources simulation the
attempt to access NIC configuration may fail, important
fields of the context are not initialized correctly
causing driver verifier BSOD on attempt to allocate
zero bytes from memory. Fail initialization if the NIC
configuration is not accessible.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 236eea2418 netkvm: fix format of printouts in case of error
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 5f5540a3cd netkvm: fix BSOD if some queue fails to renew
https://issues.redhat.com/browse/RHEL-68725
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/1197
In such case we do not have any other option than request to
unload the driver. This can happen in 2 flows: power up (during
fast startup) or reset, both with driver verifier that simulates
low resources.
In reset flow we need to request driver unload explicitly.
Power up flow works in SET_POWER, so it will do it automatically.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 2a9f853bb1 netkvm: use per-queue max RX buffers instead of global
Global value of max RX buffers, shared among queues, is
bad idea. It is especially bad when memory allocation
during queue initialization may fail, for example in case
of driver running under driver verifier. Changing the
global field to per-queue field.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 48cdf5f8d0 netkvm: init-time decide about maximum RX buffer size
Currently the driver always assume the maximim packet size
is ~64K as it is compiled with RSC support. The initial
reason was that if the RSC is disabled by admin (registry
value of the driver), it can be turned on by command, i.e.
without disable-enable. However this depends also on host
features. If the host does not support the GUEST_TSOx,
RSC will be reported to the OS as not supported but the
buffers are still huge without any reason.
(In such case the powershell reports IPv4 and IPv6 operational
state as Off even if the RSC keywords are enabled).
The commit moves the decision to initialization time - if the
RSC is not supported, the buffers are sized accoring to MTU.
The memory consumption is lower 16 times.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich 886047541e netkvm: use optimized layout of shared memories for RX
https://issues.redhat.com/browse/RHEL-19814

Do not allocate redundant memory, use full 4K+ pages when
needed, tail of the data (usually small) allocate together
with header/indirect block and make this block smaller than
4K when possible. This reduces 10% of all the shared memory
allocated for RX buffers. For non-RSC configuration it is
possible to reduce much more (for future).

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich ec9e1f51c0 netkvm: prepare layout of RX shared buffers
Split the decisions about size of shared buffers for RXQ and
allocation of shared memories. Create optimal layout of RX shared
buffers before creation of queues; allocate the memories according
the layout. Initially optimized layout is desabled and we create
the "legacy" layout, fully compatible with what was done before.
This commit contains only creation of the layout, it is not yet
applied when allocating RX buffer's memories.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Ai Qi 6d53a2d0a9 NetKVM: ack VIRTIO_F_ORDER_PLATFORM
According to commit 48aeb261, add VIRTIO_F_ORDER_PLATFORM to NetKVM.

Signed-off-by: Ai Qi <[email protected]>
2024-09-21 14:07:21 +02:00
Yuri Benditovich d1af78d045 netkvm: disable poll mode in standby(failover) mode
Fixes: https://issues.redhat.com/browse/RHEL-32200

Supporting poll mode flows is very complicated in
case the driver acts as protocol driver above VF
device, so the driver will ignore the poll mode setting
in case it works in standby mode. If the VF driver does
not use the poll mode everything will work the same way
as in Win10. If the VF driver uses poll mode it reports
incoming packets from its poll mode handler already and
the NetKVM just indicates the packets up.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-06-25 10:30:06 +03:00
Yuri Benditovich 8b181d2c95 netkvm: possibility to test poll mode on 2022
This provides simple way to build the driver with minimal
modification and enable poll mode on any NDIS 6.85+,
for engineering testing purposes.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich dfdaec5aac netkvm: finally enable negotiation USO TX support
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich acb9ec17be netkvm: remove unused field
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich dfb56fb669 netkvm: minor comment fix
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 65a3ed9565 netkvm: add procedure for RX poll
This procedure will be called from poll handler, it retrieves
packets from RX virtqueue (if any) and gets NBLs from RSS queue
instead of indicate them to NDIS.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 89513235ce netkvm: add registration for poll handlers when needed
In existing build the (un)registration is implemented as
a stub procedure. To start function we need the define
PARANDIS_SUPPORT_POLL.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich aee168350a netkvm: read Poll Mode configuration keyword if provided
Currently this keyword is not present in the INF, it
will be added in later commits.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
junjiehua 00d2037945 [netkvm] add a workaround for rx packet loss
Implemented a workaround for rx packet loss encountered with TCP_NODELAY. By default,
this feature is turned off to minimize the impact on CPU performance and network bandwidth.

To activate the feature, go to the network card properties and set the MinRxBufferPercent
to a value above 0. A good starting point is to set MinRxBufferPercent to 25% and then monitor
for any packet loss. If packet loss continues, incrementally adjust the value to 50%, then 75%,
and if necessary, up to the maximum of 100%.

In extreme cases, it may be required to not only adjust the  MinRxBufferPercent but also to increase
the number of queues and the size of each queue (queue_size).

It is important to note that this feature is only applicable to rx packet loss.

For more details, see [this thread](https://github.com/virtio-win/kvm-guest-drivers-windows/issues/1012).

Signed-off-by: junjiehua <[email protected]>
2024-01-18 11:21:17 +02:00
zhangjianminng a9d3c71d03 netkvm: define MAX_FRAGMENTS_IN_ONE_NB macro to cap SGTableCapacity
This commit introduces the MAX_FRAGMENTS_IN_ONE_NB macro, which
defines the maximum number of fragments in a single NET_BUFFER. It
is used to constrain the SGTableCapacity value, ensuring it does
not exceed the meaningful limit set by MAX_FRAGMENTS_IN_ONE_NB.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
Yuri Benditovich 359f42c102 netkvm: filter RX packets as early as possible
https://issues.redhat.com/browse/RHEL-20575

Currently the driver get RX descriptor from the rx virtQ,
analyses it (L2/L3), calculates hash and delivers to the
proper RSS queue. Later it extract the packet from the RSS
queue and checks whether it passes RX filters.
Now we move the filtering to the earliest stage - just after
basic analysis.
Note that in case of vhost there are no receive filters
configured by the host and typically the host does not work
in promiscuous mode, so it is redundant to calculate the hash
and trigger the RSS queue for packets that should be dropped.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-16 10:17:40 +02:00
Yuri Benditovich 93015d29c4 netkvm: add statistics for TX events of interest
Adding statistics for failed TX packets
(ones that can't be mapped using available indirect area) and
minimal available TX descriptors (if one or more TX virtqueues
were completely filled by packets this field will be read as 0)
These statistics fields are printed on disable and also available
at run-time via WMI.

Signed-off-by: Yuri Benditovich <[email protected]>
2023-12-18 13:38:13 +02:00
Kfir Manor d018cb25fb netkvm: change RxCapacity maximum to 4096
resolve:
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/831

The Problem, RxCapacity of size 1024 isn't enough for some situations

Fix, add higher RxCapacity values as options

Signed-off-by: Kfir Manor <[email protected]>
2023-02-15 13:50:05 +02:00
Kfir Manor 966e23c58c HBZ#2156297 netkvm: change RxCapacity minimum to 16
resolve:https://github.com/virtio-win/kvm-guest-drivers-windows/issues/830

The problem, RxCapacity of value 16 is in the inf file. But the minimum
of defaultConfiguration is 32, meaning that setting RxCapacity to 16 in
the device manager doesn't take effect.

Fix: change the minimum of defaultConfiguration to 16

Signed-off-by: Kfir Manor <[email protected]>
2023-02-15 13:50:05 +02:00
Kostiantyn Kostiuk 45e37d579a NetKVM: Use 'enum class' instead of 'enum' (CA warning 26812)
Update _tagPacketOffloadRequest enum.

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2021-09-19 09:40:30 +03:00
Kostiantyn Kostiuk 9b4b3998c8 NetKVM: Use 'enum class' instead of 'enum' (CA warning 26812)
Update _tagppResult enum.

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2021-09-19 09:40:30 +03:00
Kostiantyn Kostiuk 119238e3d3 NetKVM: Use 'enum class' instead of 'enum' (CA warning 26812)
Update _etagHistoryLogOperation enum

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2021-09-19 09:40:30 +03:00
Viktor Prutyanov 3d54b6d5c0 NetKVM: fix possible arithmetic overflows (CA)
Value should be casted to wider type before calling operator.

Signed-off-by: Viktor Prutyanov <[email protected]>
2021-09-05 17:00:26 +03:00
Viktor Prutyanov ff9cf07442 NetKVM: fix comparison with wider type and uninitialized var (CodeQL)
- Comparison with wider type
- SM02323
- Uninitialized local variable

Signed-off-by: Viktor Prutyanov <[email protected]>
2021-09-05 17:00:26 +03:00
Yuri Benditovich 3642599e92 netkvm: preparation for NDIS 6.83 and USO support
Prepare the code to support NDIS 6.83 if such define will
be provided in a build (currently it is not).

Signed-off-by: Yuri Benditovich <[email protected]>
2021-08-04 10:45:24 +03:00
Viktor Prutyanov 52e72eb7da NetKVM: RHBZ#1979023: set NumRssQueues default value to 16
Win2022 HLK (NICStrictPropertyValidation) requires NumRssQueues
parameter default value to be 16 for 10Gbps adapters with
MSI-X support.

Signed-off-by: Viktor Prutyanov <[email protected]>
2021-07-22 10:35:18 +03:00
Viktor Prutyanov d177920610 NetKVM: RHBZ#1979024: restrict max VLAN ID to 4094
NetKVM treats VLAN ID = 4095 as well as IDs from 1-4094, that is frames
with ID = 4095 pass and others don't. According to IEEE 802.1Q, 4095
can't be valid VLAN ID. Also, Win2022 HLK assumes that NDIS accepts
ID <= 4094.

Signed-off-by: Viktor Prutyanov <[email protected]>
2021-07-19 08:45:05 +03:00
Yuri Benditovich 2212803c46 netkvm: correct the condition of send/receive possibility
Rename IsSendPossible to IsTxRxPossible and use fCurrentLinkState
instead of bConnected. Reuse this procedure in Rx path also, the
condition is the same for both directions.

Signed-off-by: Yuri Benditovich <[email protected]>
2021-04-01 15:11:46 +03:00
Yuri Benditovich 5ee294e61c netkvm: set fCurrentLinkState properly on init
Reuse ReadLinkState to obtain the link status from the device
and set properly fCurrentLinkState. When reporting the link
status on driver initialization we can't rely on bConnected
anymore as there is a possibility that we should hide the
link until VF is attached.

Signed-off-by: Yuri Benditovich <[email protected]>
2021-04-01 15:11:46 +03:00
Yuri Benditovich 251c5c81df netkvm: move ReadLinkState up for further reuse
Signed-off-by: Yuri Benditovich <[email protected]>
2021-04-01 15:11:46 +03:00
Yuri Benditovich e8d8decb27 netkvm: for failover virtio-net suppress link-up until VF bound
If the device reports standby feature but the protocol is not
installed yet or VF not present suppress the link-up indication
until the VF comes first time. After that the link-up follows
link status of the device until the driver is disabled.
Set packet filter (effectively enable the RX from the VF) after
the link-up is indicated.

Signed-off-by: Yuri Benditovich <[email protected]>
2021-04-01 15:11:46 +03:00
Yuri Benditovich 6c61bf8135 netkvm: add printouts for all the device features
Add missing printouts indicating offered device features.

Signed-off-by: Yuri Benditovich <[email protected]>
2021-02-08 11:52:00 +02:00
Basil Salman b22efbb8b8 VIRTIO_F_IOMMU_PLATFORM -> VIRTIO_F_ACCESS_PLATFORM
According to virtio v1.1 spec: https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html
VIRTIO_F_IOMMU_PLATFORM was renamed to VIRTIO_F_ACCESS_PLATFORM.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1887843
Triggered by: https://lkml.org/lkml/2020/6/28/37

Signed-off-by: Basil Salman <[email protected]>
Signed-off-by: Basil Salman <[email protected]>
2020-11-12 10:24:25 +02:00
Yuri Benditovich bfad2ce34a netkvm: add CGuestAnnouncePackets::Clear and use it
Instead of calling destructor of CGuestAnnouncePackets
out of the blue, introduce Clear procedure and use it
from the destructor of the adapter context.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 015c07143e netkvm: make adapter cleanup implicit on destruction
Unpublish cleanup procedure and call it from destructor of
adapter's context.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich c07b380014 netkvm: simplify init and cleanup of RSS parameters
Allocate RW lock in the constructor, if failed we will fail
the context initialization.
Free allocated CPU maps in the destructor, if allocated.
No need in "IsRSSinitialized" anymore.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 77ef2c1145 netkvm: remove explicit destruction of CParaNdisCX
Automatic call to destructor frees resources allocated
by the object (memory block for control commands).
If virtqueue was created it is also deleted by this call or
earlier implicitly by Shutdown().

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 123ab06eff netkvm: remove explicit destruction of PCI resources
The automatic destructor unmaps mapped bars when needed.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 3f83048062 netkvm: use ctor/dtor for initialization of queues
Delete all the explicit initialization of receive queues
and the variable that indicates whether they are initialized.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 02221b124e netkvm: create/delete the context as C++ object
Change creation/deletion from alloc/free to new/destroy.
Remove some of explicit calls to constructors/destructors
of embedded objects.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 0626f060f1 netkvm: simplify CParaNdisCX
Make all possible initializations in the constructor.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 17:19:23 +03:00
Yuri Benditovich 91594594cc nekvm: Use standard *JumboPacket instead of private MTU
*JamboPacket provides the same control over MTU.
The difference is that *JumboPacket includes ethernet header
size while the previous MTU does not.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-08-26 09:54:52 +03:00
Pedro Justo (TEIXEIRA) cc40a4c918 Force NDIS SG DMA to use HAL v3 DMA APIs.
Signed-off-by: Pedro Justo <[email protected]>
2020-07-14 17:19:04 +03:00
Mohamed Mediouni 76ef17bf98 netkvm: Arm Windows support
NdisMAllocateSharedMemory maps memory as non cacheable on Arm Windows,
Given that Windows on Arm does not support unaligned accesses on uncached memory,
this behavior does result in crashes.

As such, use MmAllocateContiguousMemorySpecifyCache for the Arm64 architecture.
This choice is safe.

It's also to be noted that NdisMAllocateSharedMemory
ignores the isCached attribute anyway, and always
maps as cached on amd64.

This also allows us to remove the need for the Rx bounce buffer.

With this fix, networking w/ netkvm for Windows on Arm works fine.
(tested with QEMU emulator version 5.0.50 (v5.0.0-1065-g9f1f264edb))

Signed-off-by: Mohamed Mediouni <[email protected]>
2020-07-09 15:19:32 +03:00
Yuri Benditovich 8743d72f52 netkvm: ack STANDBY feature if reported by device
Signed-off-by: Yuri Benditovich <[email protected]>
2020-07-07 17:53:39 +03:00
Yuri Benditovich 954753b4d8 netkvm: renaming *-*.cpp to *_*.cpp
SDV is modern mode fails without any information if there
are source files with '-' sign in the name. This is
preparation change for further work with modern SDV.

Signed-off-by: Yuri Benditovich <[email protected]>
2020-05-09 23:48:03 +03:00