EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE callback function (netreceivescaling.h)
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(
[_In_] NETADAPTER Adapter,
[_In_] NET_ADAPTER_RECEIVE_SCALING_HASH_TYPE HashType,
[_In_] NET_ADAPTER_RECEIVE_SCALING_PROTOCOL_TYPE ProtocolType
)
{...}
Parameters
[_In_] Adapter
The NETADAPTER object the client driver obtained in a previous call to NetAdapterCreate.
[_In_] 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.
[_In_] 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
Requirement | Value |
---|---|
Target Platform | Universal |
Minimum KMDF version | 1.27 |
Minimum UMDF version | 2.33 |
Header | netreceivescaling.h (include netadaptercx.h) |
IRQL | PASSIVE_LEVEL |