Create copies of NBLs to complete them faster
It turns out that waiting for them to come back in the return function introduces extremely high latency. We need to eventually stop doing this and move to a proper ring buffer. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
b2182e0e90
commit
09dc9324d1
6
wintun.c
6
wintun.c
@ -909,7 +909,6 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
|
|||||||
|
|
||||||
InterlockedAdd64(&Ctx->ActiveNBLCount, NblCount);
|
InterlockedAdd64(&Ctx->ActiveNBLCount, NblCount);
|
||||||
InterlockedExchange(IRP_REFCOUNT(Irp), NblCount);
|
InterlockedExchange(IRP_REFCOUNT(Irp), NblCount);
|
||||||
IoMarkIrpPending(Irp);
|
|
||||||
|
|
||||||
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
||||||
{
|
{
|
||||||
@ -920,12 +919,13 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
|
|||||||
NblQueue[Index].Head,
|
NblQueue[Index].Head,
|
||||||
NDIS_DEFAULT_PORT_NUMBER,
|
NDIS_DEFAULT_PORT_NUMBER,
|
||||||
NblQueue[Index].Count,
|
NblQueue[Index].Count,
|
||||||
NDIS_RECEIVE_FLAGS_SINGLE_ETHER_TYPE | NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL);
|
NDIS_RECEIVE_FLAGS_SINGLE_ETHER_TYPE | NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL | NDIS_RECEIVE_FLAGS_RESOURCES);
|
||||||
|
TunReturnNetBufferLists((NDIS_HANDLE)Ctx, NblQueue[Index].Head, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
ExReleaseSpinLockShared(&Ctx->TransitionLock, Irql);
|
||||||
TunCompletePause(Ctx, TRUE);
|
TunCompletePause(Ctx, TRUE);
|
||||||
return STATUS_PENDING;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
cleanup_nbl_queues:
|
cleanup_nbl_queues:
|
||||||
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
|
||||||
|
Loading…
Reference in New Issue
Block a user