Commit Graph
199 Commits
Author SHA1 Message Date
Yuri Benditovich e941c70b75 netkvm: make ParaNdis_PerformPacketAnalysis static inline
The procedure was in glocal scope without a reason. Moving
it to RX area and making static inline.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich c69786e3c2 netkvm: make ParaNdis_GetScalingDataForPacket inline
The procedure was in global scope, but used only with RX/RSS.
Making it static inline.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich e16e6e6e8e netkvm: make ParaNdis_QueueRSSDpc static inline
This procedure was placed in global scope without a reason.
Making it static and inline. It is required and used only
with RSS, so removing the body if no RSS.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich 1f29c5c4ee netkvm: move ParaNdis_SetupRSSQueueMap to RSS scope
Due to historical reasons the procedure was placed
in common scope. Moving it to RSS area.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich fde22b8423 netkvm: assume 'any layout' for version 1 device
VIRTIO_F_ANY_LAYOUT is only for legacy devices. For devices
with VIRTIO_F_VERSION_1 we do not need to use separate SG
entry for virtio-net header on TX.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich 6edb2bc92a netkvm: small optimization in RX path
Currently in RX patch processing we do RX queue reset unconditionally
even if we already know that we need to respawn the RX DPC.
Queue reset tries to enable interrupts/event for the queue, which is
redundant if we anyway are going to respawn the DPC.
Do it only in case we did not recognize pending packets yet.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich e5c1c0f049 netkvm(arm64): Turn off the control queue for ARM64
Due to unknown reason, on real ARM64 machines it is found
that the control queue does not function correctly. Until
it is investigated, we turn off the control queue for ARM64.
This disables also related features like dynamic offloads
and multiqueue.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich dc06366b32 netkvm: move ParaNdis_ReceiveQueueAddBuffer to RX area
The procedure is used only inside RX, making it static inline.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich fc16d5878e netkvm: move ParaNdis_ResetRxClassification to RX area
Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich 465161ca3b netkvm: make ParaNdis_FreeRxBufferDescriptor static
The procedure is used only inside RX, no reason to publish.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-23 09:57:33 +02:00
Yuri Benditovich 27d4c3029a netkvm: RSC support according to virtio spec
Removed support for RSC implemented in private qemu patch.
Now the driver supports RSC according to the virtio spec
and upstream qemu code. The RSC feature is supported for
V1 device and for legacy device as well.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-06-01 22:12:55 +03:00
Yuri Benditovich 8a54920763 netkvm: fix unaligned access when comparing ethernet address
The macro ETH_COMPARE_NETWORK_ADDRESSES_EQ causes unaligned
access exception on ARM64. To solve this, we will use this
macro on non-ARM systems and on ARM64 systems will use
byte-by-byte comparison.
2019-04-23 16:40:12 +03:00
Yuri Benditovich 8a7005b1cf netkvm: Fix functionality with single MSIX vector
https://bugzilla.redhat.com/show_bug.cgi?id=1666940
Set clear and simple rule for assignment of vectors to queues
and translation of MSIX messages to queues:
in case of one or two vectors they are assigned
to TX/RX queues and CX reuses the last vector. In this case
we do not spawn DPC for CX and process it during regular
RX/TX processing. For case of 3 and more vectors the processing
is the same as before.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-01-30 12:47:35 +02:00
Yuri Benditovich eca70d3528 netkvm: fix support for speed/duplex configuration
WHCK requires adapter speed to be equal to maximal speed, so
it fails with default run of qemu.
In addition, it is easy to have meaningless speed report
with parameters provided in qemu command line, as there is
almost no validation of values received from the configuration.
Current commit sets following order of assignment and report:
At the beginning we set adapter speed as default=100 Gbps.
We do not assign invalid values from device configuration.
We always use the same value for reports of current speed
and of maximal speed.

Signed-off-by: Yuri Benditovich <[email protected]>
2018-10-18 10:46:58 +03:00
Yuri Benditovich efcadfc983 netkvm: use const qualifier for const string
Signed-off-by: Yuri Benditovich <[email protected]>
2018-10-18 10:46:58 +03:00
Yuri Benditovich f81cf0050c netkvm: fix error flow on power on
If power on procedure fails, it still must resume the
state machine, otherwise following pause flow never
completes.

Signed-off-by: Yuri Benditovich <[email protected]>
2018-09-26 11:53:05 +03:00
Sameeh Jubran fc8a5735e3 NetKVM: Interrupts: Drop unneeded report interrupt logic
Now that in MSI interrupts we have a separate DPC for CX, we don't need
to check if an interrupt was reported or report an interrupt for any of
the paths as we already used this flag for CX only when MSI interrupts
are used.

For legacy interrupt we always set the report interrupt flag and then
clear it in CX handling, this work is superfluous as we always want to
check if CX has any work to do with legacy interrupts. Setting and
unsetting this flag constantly is a good example of race conditions that
might lead us to miss some interrupts for cx.

These race conditions were initially reported and discussed in the
following pull request:

https://github.com/virtio-win/kvm-guest-drivers-windows/pull/281

Signed-off-by: Sameeh Jubran <[email protected]>
2018-09-17 16:58:51 +03:00
Sameeh Jubran 861e27206e NetKVM: CX: Use separate DPC
This commit separates the CX path handeling to a standalone DPC, the
motive to do this is that sometimes we can miss Control interrupts due to
the way it is implemented today.

The issue is disscussed in great detail here:
https://github.com/virtio-win/kvm-guest-drivers-windows/pull/281

Signed-off-by: Sameeh Jubran <[email protected]>
2018-09-17 16:58:51 +03:00
Yuri Benditovich fa1cf3dd46 netkvm: add printout for RSC related features
Indicate presence of host features:
VIRTIO_NET_F_GUEST_RSC4
VIRTIO_NET_F_GUEST_RSC6
VIRTIO_NET_F_CTRL_GUEST_OFFLOADS

Signed-off-by: Yuri Benditovich <[email protected]>
2018-09-17 15:23:02 +03:00
Yuri Benditovich 9e8405f6a3 netkvm: fix compilation problem without WPP
Use FIELD_OFFSET instead of offsetof

Signed-off-by: Yuri Benditovich <[email protected]>
2018-09-17 15:22:50 +03:00
Basil Salman 01b109c534 NetKVM: added VIRTIO_CONFIG_S_NEEDS_RESET event to debug log
In case of a Reset event, the driver now prints a message
to debug log.

Signed-off-by: Basil Salman <[email protected]>
2018-09-12 18:56:38 +03:00
Sameeh Jubran 1741d661d8 NetKVM: Implement VIRTIO_CONFIG_S_NEEDS_RESET as needed by spec
The VIRTIO 1.0 spec adds the DEVICE_NEEDS_RESET bit to the device's
status. This commit enables the driver to respods appropriately to
RESET request by the device.

Upon receiving such notification from the device in the control queue we
do the following steps in the following order:

* On Control interrupt read the device status and check that
  VIRTIO_CONFIG_S_NEEDS_RESET bit is set and VIRTIO 1.0 is supported.
* Update the state machine that the device needs a reset, the state
  machine updates all queues using the obervee/oberver logic that they
  can't touch the hardware.
* Lastly the flag bDeviceNeedsReset is set to true. By setting this flag
  to true we inform Windows that the ParaNdis6_Reset should be called by
  NDIS. This happens beacuse in ParaNdis6_CheckForHang we return the value
  of the bDeviceNeedsReset flag which if set instructs Windows to call
  reset function. The ParaNdis6_CheckForHang is called periodically by
  NDIS every few seconds.

Signed-off-by: Sameeh Jubran <[email protected]>
Signed-off-by: Basil Salman <[email protected]>
2018-09-12 18:56:38 +03:00
Sameeh Jubran 70439e79d6 NetKVM: Add ReadDeviceStatus function
Signed-off-by: Sameeh Jubran <[email protected]>
2018-09-12 18:56:38 +03:00
Sameeh Jubran 99199cfa7e NetKVM: Guest Announce: Make sure CX exists
In the CX DPC path we execute the GuestAnnounce feature without checking
if CX was actually acked. This commit adds this check.

Signed-off-by: Sameeh Jubran <[email protected]>
2018-08-15 09:42:00 +03:00
Sameeh Jubran 29b62b2f9e NetKVM: TX: Drop heavy DPC scheduling
In commit e8f319fdc0 the lock free queue was
introduced as an alternative implementation to the previous one which
required acquiring the TX's path lock for NBLs sent by Windows. The
intention for the implementation introduced was that this lock acquirement
would be dropped in favour of scheduling a DPC upon sending an NBL instead.

While this DPC scheduling approach works it does introduce a heavy DPC
scheduling on the environment, the overhead can be as high as executing a
DPC for each NBL sent by Windows in the worst case scenario. In general
Windows should drop duplicate DPCs but it seems that it is not doing so
efficiently or else it is executing a DPC upon each schedule request by us
in a heavy load environment.

An alternative implementation which would probably allow us to keep the
DPC scheduling implementation is adding a mechanism to identify bursts and
forecast when we are receiving a high packet rate and adapt (lower) the
DPC scheduling accordingly.

This commit enables the HCK/HLK 1c_Mini6PerfSend test to pass as it was
stuck due to this heavy DPC load environment.

Signed-off-by: Sameeh Jubran <[email protected]>
2018-06-06 21:42:55 +03:00
Bishara AbuHattoum dd5ea53172 NetKVM: Fixing behaviour when VIRTIO_NET_F_STATUS is off
VIRTIO_NET_F_STATUS off misbehaviours fixed:
  1. Reading the current link state,
     fix: ReadLinkState is not to be called in this case.
  2. Link state is not initialized,
     fix: pContext->bConnected initialized to TRUE.

Signed-off-by: Bishara AbuHattoum <[email protected]>
2018-05-24 16:50:20 +03:00
Yan Vugenfirer eac3270d10 [NetKVM] BZ#1549587: NetKVM to support ACK of VIRTIO_F_IOMMU_PLATFORM
Background: https://issues.oasis-open.org/browse/VIRTIO-154

According to MS documentation to ensure the usage of IOMMU DMA memory API
should be used. NetKVM driver already uses DMA API for memory allocation
related to data transfer. VIRTIO_F_IOMMU_PLATFORM will be enabled for
Windows 10 and Windows Server 2016

Signed-off-by: Yan Vugenfirer <[email protected]>
2018-03-20 11:31:39 +02:00
Bishara AbuHattoum 1adaf6ffb2 NetKVM: LinkSpeed updates, default is 10 Gbps, max is 100 Gbps
Signed-off-by: Bishara AbuHattoum <[email protected]>
2018-02-19 17:54:06 +02:00
Bishara AbuHattoum aecbd2dfb3 NetKVM: Fixed wrong LinkSpeed multiplication result
Signed-off-by: Bishara AbuHattoum <[email protected]>
2018-02-19 17:54:06 +02:00
Sameeh Jubran aea9ad14df NetKVM: SM: Add Suprise Removal state
Signed-off-by: Sameeh Jubran <[email protected]>
2018-02-08 14:34:43 +02:00
Bishara AbuHattoum 23d536f618 NetKVM: BZ#1537430 Import LinkSpeed/Duplex configs from the hypervisor
Changes following the introduction of virtio's flag, VIRTIO_NET_F_SPEED_DUPLEX,
which allows the host to set the LinkSpeed/Duplex values.

Up until this stage the configurations of LinkSpeed/Duplex used were hardcoded,
with default LinkSpeed=10Gbits/s, Duplex=full.
But uppon the introduction of VIRTIO_NET_F_SPEED_DUPLEX, it'll be more useful to
import them from the host and apply them if the VIRTIO_NET_F_SPEED_DUPLEX is on,
or, use the default configurations if it is off:
(LinkSpeed=10Gbits/s, Duplex=full).

Changes also includes removing the ConnectRate parameter from the inf file as we
never saw that it was used.

Qemu patches:

  1. [v4,2/3] qemu: virtio-net: use 64-bit values for feature flags:
     https://patchwork.ozlabs.org/patch/856266/
  2. [v4,3/3] qemu: add linkspeed and duplex settings to virtio-net:
     https://patchwork.ozlabs.org/patch/856226/

Signed-off-by: Bishara AbuHattoum <[email protected]>
2018-01-24 18:26:09 +02:00
zhengrong.lzr 00f499c0a3 netkvm: Driver should not indicate MQ support when RSS isn't supported
The bug was caused by a bug in the backend where the driver allocates more
than one hardqueue and doesn't enable all of the hardqueues which leads the
backend to crash.

When RSS is not enabled in compilation the driver enables one queue only
even though it allocates more. This commit drops MQ support when the
driver has RSS disabled which prevents these unnecessary allocations.

Signed-off-by: jackli <[email protected]>
Signed-off-by: Sameeh Jubran <[email protected]>
2018-01-11 11:24:22 +02:00
Yan Vugenfirer 1edd4dfd07 netkvm: BZ#1351089: Don't set MAC address using configuration space in
virtio 1.0 device

In virtio 1.0 MAC address in virtio configuration space is read-only. For
virtio 1.0 device, If VIRTIO_NET_F_CTRL_MAC_ADDR flag is disabled (setting
MAC address using control queue), the driver shouldn't attempt to use
configuration space to set MAC address.

Signed-off-by: Yan Vugenfirer <[email protected]>
2018-01-09 13:52:41 +02:00
Yan Vugenfirer 79f515bb0f netkvm: BZ#1351089: Control queue should be acked before MAC address
configuration is attempted

VIRTIO_NET_F_CTRL_MAC_ADDR feature depends on control queue availability.
Before the fix control queue was acked after MAC address was initialized.
The behaviour caused the driver to always use MAC configuration through
virtio configuration space (VIRTIO_NET_F_MAC).

Signed-off-by: Yan Vugenfirer <[email protected]>
2018-01-09 13:52:41 +02:00
Yan Vugenfirer d3b344a9a9 netkvm: BZ#1351089: DumpMac to print caller function name
To comply with debug printouts convention function name should be
printed.

Signed-off-by: Yan Vugenfirer <[email protected]>
2018-01-09 13:52:41 +02:00
Yan Vugenfirer a4848598f3 netkvm: driver should fail initialization if PCI resources init failed
This bug caused by historical refactoring done in
ParaNdis_InitializeContext function. If PCI resource initialization failed
driver should not continue execution of ParaNdis_InitializeContext
function.

Signed-off-by: Yan Vugenfirer <[email protected]>
2018-01-08 18:23:33 +02:00
Sameeh Jubran 2cc38bac81 NetKVM: Integrate WPP Tracing
This commit integrates wpp tracing into builds higher than Vista as
Windows Vista requires much more configuration for wpp integration,
however, this integration may be introduced in the future.

The old style of Dprintf is still preserved by this commit and can be
enabled by disabling WPP tracing. This can be accomplished by commenting
the following line in WPPTrace.h:

Signed-off-by: Sameeh Jubran <[email protected]>
2017-12-12 21:53:43 +02:00
Sameeh Jubran 7250654152 NetKVM: Dprintf: Use suitable casting and modifiers
Signed-off-by: Sameeh Jubran <[email protected]>
2017-12-12 21:53:43 +02:00
Sameeh Jubran 6f40e43999 NetKVM: DPrintf: Match number of arguments to modifiers
Signed-off-by: Sameeh Jubran <[email protected]>
2017-12-12 21:53:43 +02:00
Sameeh Jubran 699a3c6d1c NetKVM: DPrintf: Use variadic arguments and fmt
This should be the appropriate for handling variadic arguments in a
MACRO.

Signed-off-by: Sameeh Jubran <[email protected]>
2017-12-12 21:53:43 +02:00
Sameeh Jubran 42f683e08c NetKVM: SM: Integrate CX path into state machine
Signed-off-by: Sameeh Jubran <[email protected]>
2017-12-05 14:55:44 +02:00
Ladi Prosek b90465a268 netkvm/NDIS6: Remove all uses of virtio_set_queue_event_suppression()
The function has no effect and will be removed.

Also deleting the defunct "PublishIndices" config entry.

Signed-off-by: Ladi Prosek <[email protected]>
2017-12-04 09:56:59 +01:00
Sameeh Jubran 99520ebde1 NetKVM: Handle case where we have 2 msi vectors
Currently when there are two msi vectors assigned to the device the driver
doesn't run. This bug occured because of the "round towards zero" behaviour of
division in C/C++.

Signed-off-by: Sameeh Jubran <[email protected]>
2017-11-07 21:24:12 +02:00
Sameeh Jubran 1fe9d77a8b NetKVM: Use correct function name in debug print
Signed-off-by: Sameeh Jubran <[email protected]>
2017-11-07 21:24:12 +02:00
Sameeh Jubran d5987949a5 NetKVM: Remove unused DPrintf parameter
Signed-off-by: Sameeh Jubran <[email protected]>
2017-11-07 21:24:12 +02:00
Sameeh Jubran 8bcdda0e2d Net-KVM: Fix a typo in the configuration entry settings
Suggested-by: Yan Vugenfirer <[email protected]>
Signed-off-by: Sameeh Jubran <[email protected]>
2017-09-27 06:39:00 -07:00
Sameeh Jubran 5eb813024e Net-KVM: Fix a typo
Signed-off-by: Sameeh Jubran <[email protected]>
2017-09-27 15:27:54 +03:00
Ladi Prosek 83e9f437a6 netkvm/NDIS6: Switch to BSD license
The project is switching from GPL to BSD.

Signed-off-by: Ladi Prosek <[email protected]>
2017-08-08 11:28:16 +03:00
Ladi Prosek 9988783a0d netkvm: Remove #pragma warnings
Warning suppression #pragma's are no longer necessary and can be
deleted.

Signed-off-by: Ladi Prosek <[email protected]>
2017-08-07 11:39:20 +03:00
Yuri Benditovich 9c2399391e netkvm: Avoid using uninitialized variable
Regression from commit 976828bd46,
earlier each received packet was tested with recheck of packet
protocol after stripping VLAN tags.
When the result of checksum check has random value, the driver
can erroneously report packet as one with invalid checksum.
If due to some reason the packet was not recognized by the driver
as IP one, it shall report the checksum as not tested.

Signed-off-by: Yuri Benditovich <[email protected]>
2017-07-03 10:55:38 +03:00