EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE callback function

Warning

Some information in this topic relates to prereleased product, which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

NetAdapterCx is preview only in Windows 10, version 1903.

The EvtNetAdapterReceiveScalingEnable callback function is implemented by the client driver to enable receive side scaling (RSS) for a network interface controller (NIC).

Syntax

EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE EvtNetAdapterReceiveScalingEnable;

NTSTATUS EvtNetAdapterReceiveScalingEnable(
  NETADAPTER Adapter,
  NET_ADAPTER_RECEIVE_SCALING_HASH_TYPE HashType,
  NET_ADAPTER_RECEIVE_SCALING_PROTOCOL_TYPE ProtocolType
)
{...}

Parameters

Adapter

The NETADAPTER object the client driver obtained in a previous call to NetAdapterCreate.

HashType

A NET_ADAPTER_RECEIVE_SCALING_HASH_TYPE value that specifies the type of receive side scaling (RSS) hash function that a NIC should use to compute the hash values for incoming packets.

ProtocolType

A NET_ADAPTER_RECEIVE_SCALING_PROTOCOL_TYPE value that specifies the portion of received network data that an RSS-capable NIC must use to calculate an RSS hash value.

Return Value

Returns STATUS_SUCCESS if RSS was successfully enabled. Otherwise, returns an appropriate NTSTATUS error code.

Remarks

Register your implementation of this callback function by setting the appropriate member of the NET_ADAPTER_RECEIVE_SCALING_CAPABILITIES structure and then calling NetAdapterSetReceiveScalingCapabilities. Client drivers typically call NetAdapterSetReceiveScalingCapabilities when starting a net adapter, before calling NetAdapterStart.

Example

In this callback, clients turn RSS on with the supplied information by setting the appropriate control bits in hardware.

Important

Client drivers should not clear or reset their indirection table from their EvtNetAdapterReceiveScalingEnable callback. The framework will set the driver's initial indirection table state.

NTSTATUS
MyEvtNetAdapterReceiveScalingEnable(
	_In_ NETADAPTER Adapter,
	_In_ NET_ADAPTER_RECEIVE_SCALING_HASH_TYPE HashType,
	_In_ NET_ADAPTER_RECEIVE_SCALING_PROTOCOL_TYPE ProtocolType
)
{
	NTSTATUS status = STATUS_SUCCESS;

	// Not using the hash type in this example
	UNREFERENCED_PARAMETER(HashType);

	UINT32 controlBitsEnable = MY_RSS_MULTI_CPU_ENABLE | MY_RSS_HASH_BITS_ENABLE;

	// Set the appropriate control bits for IPv4
	if(ProtocolType & NetAdapterReceiveScalingProtocolTypeIPv4)
	{
		controlBitsEnable |= MY_RSS_IPV4_ENABLE;

		if (ProtocolType & NetAdapterReceiveScalingProtocolTypeTcp)
        {
            controlBitsEnable |= MY_RSS_IPV4_TCP_ENABLE;
        }
	}

	// Repeat for IPv6
	...

	// Set the bits in hardware
	if(!MyHardwareRssSetControl(controlBitsEnable))
	{
		WdfDeviceSetFailed(Adapter->WdfDevice, WdfDeviceFailedAttemptRestart);
        return STATUS_UNSUCCESSFUL;
	}

	// Perform other tasks like restarting the Rx queue

	return STATUS_SUCCESS;
}

Requirements

   
Target Platform Universal
Minimum KMDF version 1.27
Header netreceivescaling.h
IRQL PASSIVE_LEVEL

See Also

EvtNetAdapterReceiveScalingDisable

NetAdapterCx Receive Side Scaling