Commit Graph
699 Commits
Author SHA1 Message Date
Yuri Benditovich 82909adcb1 netkvm: remove unused member 'DriverHandle'
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
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 1efdadfac2 netkvm: move RegisterFlow calls to constructor
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich ae37512cd4 netkvm: pass miniport context to constructor
Read-write lock is created with MiniportContext=NULL because
this happens in the constructor when this field in adapter
context is not populated yet. Pass miniport context as parameter
to the constructor of adapter object and propagate it to the
RSSParameters member.

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 f5e5b234c6 netkvm: apply the layout when allocating RX buffers
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
Konstantin Kostiuk e6546dc358 RHEL-65784: Fix files ending
clang-format always check one \n at the end of file.

Jira: https://issues.redhat.com/browse/RHEL-65784

Signed-off-by: Konstantin Kostiuk <[email protected]>
2024-11-20 15:48:35 +02:00
Konstantin Kostiuk 84b50b8ecb Move build/sign related tools into a separate folder
Signed-off-by: Konstantin Kostiuk <[email protected]>
2024-10-13 14:41:59 +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 657ad7efb5 netkvm: fix affinity of poll handlers
https://issues.redhat.com/browse/RHEL-33334
Fix wrong affinity assignment.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-07 10:24:24 +03:00
Yuri Benditovich dffd27a745 netkvm: add details to poll mode logs
Main thing is always understand what is the source of the
notification/trigger, this may be, for example TX, RX, RSS

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich 5a11286adf netkvm: add detection/recovery for TX stuck packets
The packets might be stuck in send queue or in waiting list.
The recovery is simple - trigger TX processing of completed
and pending packets. Can be called from any external place,
for example from CheckForHang handler.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +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 8b6f5ef6a0 netkvm: fix memory leak in TX overfragmenting flow
https://issues.redhat.com/browse/RHEL-24992
Memory leak of CNB::m_ExtraNBStorage happens if the
packet os overfragmented but we do not succeed to
allocate extra pages.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-11 10:37:33 +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 53d0f84014 netkvm: correct validation of segmentable UDP packet
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich 87632fc463 netkvm: define separate PARANDIS_MAX_USO_SIZE
There is no clear techical reason why the maximal size of
large UDP packet should be different from one of large TCP
packet. But currently (kernel mainstream, current kernel 6.9
and all earlier kernels) kernel defines UDP_MAX_SEGMENTS as 64.
Minimal MSS in Windows is 536, so we report maximal size of
UDP packet as 64 * 536, such a way we'll never get from OS
UDP packets that can't be transmitted.

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 ef9503df36 netkvm: minor changes in printouts
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +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 7304a2404b netkvm: enable poll mode support for server 2025
https://issues.redhat.com/browse/RHEL-17932
Win11 driver supports poll mode when runs on server 2025
(runtime NDIS version 6.89)
On earlier versions Win11 driver contains *NdisPoll keyword
but this keyword does not make any behavioral change.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich a0c37b2191 netkvm: add debug print on TX completion
Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 3a9c4073e9 netkvm: trigger poll handler on RSS rescheduling
In case we determine that the packet should be delivered
on from the different RSS queue than current one - we
trigger respective poll handler (if any) instead of queue DPC.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 599b313527 netkvm: trigger poll handler instread of queue DPC
If poll mode is fully enabled we do not trigger DPC for
RX and TX interrupts, we trigger respective poll handler instead.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02: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 882872b954 netkvm: add getter for current OS NDIS version
This additional getter allows to query current NDIS version
of the OS regardless whether we compile the driver for such version
or not. For example: the driver is built for NDIS 6.85, it runs on
Server 2025 (NDIS 6.89 or higher), effective version will be 6.85
but in the code we are able to check whether the OS supports 6.89.

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
Yuri Benditovich 55444204b6 netkvm: add code for poll mode support
The code is not effective, it requires PARANDIS_SUPPORT_POLL define

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 0a6c5fc482 netkvm: remove spaces at the beginning of the line
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich c21e0accd4 netkvm: report correct TX queue size via WMI
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich f25ede16eb netkvm: add metrics for allocated shared memory for RX
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 641cc937e0 netkvm: add metrics for copied Tx packets
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 634e6b4670 netkvm: rework vendor specific WMI properties
Split tx,rx and rss statistics
Add property for [initial] configuration data
Make reset of statistics selective and explicit
Add metrics for:
- minimal number of rx buffers
- indications with 'resource' flag
- amount of allocated shared memory

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +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
Yuri Benditovich c81ff1fa55 netkvm: (minor) define IsPowerOfTwo in common header
And remove the same definition from various files.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-17 15:01:17 +02:00
zhangjianminng c408c18940 netkvm: add the feature of copy mapping
for the problem description
please visit #942

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng 6c2f08a4d9 netkvm: refactor BindToDescriptor return type to use NBMappingStatus enum
This commit updates the CNB::BindToDescriptor method signature, changing
the return type from a boolean to the newly introduced NBMappingStatus
enum. The updated method now returns one of the following statuses:

    NBMappingStatus::SUCCESS
    NBMappingStatus::NO_RESOURCE
    NBMappingStatus::FAILURE

This change allows for more detailed reporting of the binding operation
outcome, enabling the caller to distinguish between different failure
reasons beyond the previous binary success/failure indication. The
NBMappingStatus enum provides a clearer, more expressive way to handle
the results of the binding process.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng 6d23a8260b netkvm: add CopyFromMdlChain function to CNB class
This commit introduces the CopyFromMdlChain function to the CNB class. The function is responsible for copying data from a Memory Descriptor List (MDL) chain to a specified destination buffer. A special focus has been given to ensuring the function handles the traversal of the MDL chain correctly, updating the Source MDL pointer and the Offset within the current MDL as it progresses through the chain.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +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
zhangjianminng 19ee48c26f netkvm: add additional pages to TXManager for upcoming copy mechanism
This commit introduces extra pages within the TXManager module,
which are intended to support the copy mechanism that will be
implemented in subsequent updates. The addition of these pages lays
the groundwork for the new functionality and ensures that the
TXManager is prepared for the enhancements.

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 1af7dfdb9d netkvm: add comments for CLockFreeDynamicQueue
Notes about procedures and synchronization

Signed-off-by: Yuri Benditovich <[email protected]>
2023-12-31 13:25:11 +02:00
Yuri Benditovich 96d0d03b40 netkvm: delete unused functions
Signed-off-by: Yuri Benditovich <[email protected]>
2023-12-31 13:25:11 +02:00