Skip to content

Latest commit

 

History

History
141 lines (105 loc) · 4.7 KB

nc-netreceivescaling-evt_net_adapter_receive_scaling_enable.md

File metadata and controls

141 lines (105 loc) · 4.7 KB
UID title description tech.root ms.date keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.lib req.dll req.irql req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library targetos f1_keywords topic_type api_type api_location api_name
NC:netreceivescaling.EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE
EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE (netreceivescaling.h)
The EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE callback function enables receive side scaling (RSS) for a network interface controller (NIC).
netvista
04/01/2022
EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE callback function
netreceivescaling.h
netadaptercx.h
Universal
1.27
PASSIVE_LEVEL
Windows
EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE
netreceivescaling/EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE
apiref
UserDefined
netreceivescaling.h
EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE

EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE callback function

-description

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

-parameters

-param Adapter [In]

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

-param HashType [In]

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.

-param ProtocolType [In]

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.

-returns

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

-prototype

//Declaration

EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE EvtNetAdapterReceiveScalingEnable; 

// Definition

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

typedef EVT_NET_ADAPTER_RECEIVE_SCALING_ENABLE *PFN_NET_ADAPTER_RECEIVE_SCALING_ENABLE;

-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;
}

-see-also

EvtNetAdapterReceiveScalingDisable

NetAdapterCx Receive Side Scaling