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:
Jason A. Donenfeld 2019-07-03 08:41:37 +00:00
parent b2182e0e90
commit 09dc9324d1

View File

@ -909,7 +909,6 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
InterlockedAdd64(&Ctx->ActiveNBLCount, NblCount);
InterlockedExchange(IRP_REFCOUNT(Irp), NblCount);
IoMarkIrpPending(Irp);
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)
{
@ -920,12 +919,13 @@ TunDispatchWrite(_Inout_ TUN_CTX *Ctx, _Inout_ IRP *Irp)
NblQueue[Index].Head,
NDIS_DEFAULT_PORT_NUMBER,
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);
TunCompletePause(Ctx, TRUE);
return STATUS_PENDING;
return STATUS_SUCCESS;
cleanup_nbl_queues:
for (EtherTypeIndex Index = EtherTypeIndexStart; Index < EtherTypeIndexEnd; Index++)