mirror of
https://github.com/arehnman/yttrium-virtio-gpu.git
synced 2026-11-07 02:06:32 +00:00
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]>
65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
#pragma once
|
|
#include "ParaNdis-VirtQueue.h"
|
|
#include "ParaNdis-AbstractPath.h"
|
|
|
|
class CParaNdisRX : public CParaNdisTemplatePath<CVirtQueue>, public CNdisAllocatable < CParaNdisRX, 'XRHR' > {
|
|
public:
|
|
CParaNdisRX();
|
|
~CParaNdisRX();
|
|
|
|
bool Create(PPARANDIS_ADAPTER Context, UINT DeviceQueueIndex);
|
|
|
|
BOOLEAN AddRxBufferToQueue(pRxNetDescriptor pBufferDescriptor);
|
|
|
|
void PopulateQueue();
|
|
|
|
void FreeRxDescriptorsFromList();
|
|
|
|
void ReuseReceiveBuffer(pRxNetDescriptor pBuffersDescriptor)
|
|
{
|
|
TPassiveSpinLocker autoLock(m_Lock);
|
|
|
|
ReuseReceiveBufferNoLock(pBuffersDescriptor);
|
|
}
|
|
|
|
BOOLEAN IsRxBuffersShortage() { return m_NetNofReceiveBuffers < m_MinRxBufferLimit; }
|
|
|
|
VOID ProcessRxRing(CCHAR nCurrCpuReceiveQueue);
|
|
|
|
BOOLEAN RestartQueue();
|
|
|
|
void Shutdown()
|
|
{
|
|
TPassiveSpinLocker autoLock(m_Lock);
|
|
|
|
m_VirtQueue.Shutdown();
|
|
m_Reinsert = false;
|
|
}
|
|
|
|
void KickRXRing();
|
|
|
|
PARANDIS_RECEIVE_QUEUE &UnclassifiedPacketsQueue() { return m_UnclassifiedPacketsQueue; }
|
|
|
|
private:
|
|
/* list of Rx buffers available for data (under VIRTIO management) */
|
|
LIST_ENTRY m_NetReceiveBuffers;
|
|
UINT m_NetNofReceiveBuffers;
|
|
UINT m_MinRxBufferLimit;
|
|
|
|
UINT m_nReusedRxBuffersCounter, m_nReusedRxBuffersLimit = 0;
|
|
|
|
bool m_Reinsert = true;
|
|
|
|
PARANDIS_RECEIVE_QUEUE m_UnclassifiedPacketsQueue;
|
|
|
|
void ReuseReceiveBufferNoLock(pRxNetDescriptor pBuffersDescriptor);
|
|
private:
|
|
int PrepareReceiveBuffers();
|
|
pRxNetDescriptor CreateRxDescriptorOnInit();
|
|
};
|
|
|
|
#ifdef PARANDIS_SUPPORT_RSS
|
|
VOID ParaNdis_ResetRxClassification(
|
|
PARANDIS_ADAPTER *pContext);
|
|
#endif
|