Skip to content

Commit

Permalink
netkvm: init-time decide about maximum RX buffer size
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ybendito authored and YanVugenfirer committed Nov 28, 2024
1 parent 8860475 commit 48cdf5f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions NetKVM/Common/ParaNdis_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,15 +863,6 @@ NDIS_STATUS ParaNdis_InitializeContext(
return status;
}

pContext->MaxPacketSize.nMaxFullSizeOS = pContext->MaxPacketSize.nMaxDataSize + ETH_HEADER_SIZE;
pContext->MaxPacketSize.nMaxFullSizeHwTx = pContext->MaxPacketSize.nMaxFullSizeOS;
#if PARANDIS_SUPPORT_RSC
pContext->MaxPacketSize.nMaxDataSizeHwRx = MAX_HW_RX_PACKET_SIZE;
pContext->MaxPacketSize.nMaxFullSizeOsRx = MAX_OS_RX_PACKET_SIZE;
#else
pContext->MaxPacketSize.nMaxDataSizeHwRx = pContext->MaxPacketSize.nMaxFullSizeOS + ETH_PRIORITY_HEADER_SIZE;
pContext->MaxPacketSize.nMaxFullSizeOsRx = pContext->MaxPacketSize.nMaxFullSizeOS;
#endif
if (pContext->ulPriorityVlanSetting)
pContext->MaxPacketSize.nMaxFullSizeHwTx = pContext->MaxPacketSize.nMaxFullSizeOS + ETH_PRIORITY_HEADER_SIZE;

Expand Down Expand Up @@ -930,6 +921,20 @@ NDIS_STATUS ParaNdis_InitializeContext(

InitializeRSCState(pContext);

pContext->MaxPacketSize.nMaxFullSizeOS = pContext->MaxPacketSize.nMaxDataSize + ETH_HEADER_SIZE;
pContext->MaxPacketSize.nMaxFullSizeHwTx = pContext->MaxPacketSize.nMaxFullSizeOS;

if (pContext->RSC.bIPv4SupportedHW || pContext->RSC.bIPv6SupportedHW)
{
pContext->MaxPacketSize.nMaxDataSizeHwRx = MAX_HW_RX_PACKET_SIZE;
pContext->MaxPacketSize.nMaxFullSizeOsRx = MAX_OS_RX_PACKET_SIZE;
}
else
{
pContext->MaxPacketSize.nMaxDataSizeHwRx = pContext->MaxPacketSize.nMaxFullSizeOS + ETH_PRIORITY_HEADER_SIZE;
pContext->MaxPacketSize.nMaxFullSizeOsRx = pContext->MaxPacketSize.nMaxFullSizeOS;
}

// now, after we checked the capabilities, we can initialize current
// configuration of offload tasks
ParaNdis_ResetOffloadSettings(pContext, NULL, NULL);
Expand Down

0 comments on commit 48cdf5f

Please sign in to comment.