Net ring element management
Follow the guidance in this topic to manage your NET_RING structures and their elements during network data transfer. The rules in this topic describe which members of the net ring elements client drivers can modify and when, depending on the data path scenario, as well as general information client drivers should keep in mind for these structures.
Important
Client drivers should adhere to these directions during all phases of development. If a client driver does not adhere to these directions while testing with Driver Verifier, Driver Verifier reports a violation and triggers a bug check on the device under test.
NET_RING
When the NET_RING's parent packet queue is started, all indices in the ring are initialized to 0.
The following table describes which members of the net ring that client drivers can modify.
Field | Client driver is allowed to modify |
---|---|
OSReserved1 | No |
ElementStride | No |
NumberOfElements | No |
ElementIndexMask | No |
EndIndex | No |
OSReserved0 | No |
OSReserved2 | No |
BeginIndex | Yes (Required) |
NextIndex | Yes (Optional) Note: The framework never reads NextIndex. |
Scratch | Yes (Optional) Note: The framework never reads Scratch. |
Buffer | No |
Client drivers must not modify any read only members of this structure, nor should they ever increment BeginIndex past EndIndex during a call to EvtPacketQueueAdvance.
For more information about index ownership in net rings, see Introduction to net rings.
NET_PACKET
The fields in a NET_PACKET are sensitive to the different contexts in which the data path operates. Whether the packet's Ignore field is set and whether the driver is receiving (Rx) or transmitting (Tx) the packet change the ruleset that is applied to the packet.
The following table provides directions for drivers in each scenario.
Rx or Tx | Ignore field is set by... | Notes |
---|---|---|
Rx | Client driver |
|
Tx | NetAdapterCx |
|
NET_PACKET_LAYOUT
During Rx operations, the Layout field of the NET_PACKET is subject to the following rules:
- All fields except for Reserved0 must be initialized by the client driver.
- If Layer2Type is set to NetPacketLayer2TypeEthernet, then Layer2HeaderLength must be 14 or greater.
- If Layer2Type is set to NetPacketLayer2TypeNull, then Layer2HeaderLength must be set to 0.
- If Layer3Type is an IPv4 type, then Layer3HeaderLength must be 20 or greater.
- If Layer3Type is an IPv6 type, then Layer3HeaderLength must be 40 or greater.
- If Layer4Type is set to Tcp, then Layer4HeaderLength must be 40 or greater.
- If Layer4Type is set to Udp, then Layer4HeaderLength must be 8 or greater.
- The layer type fields must be within the appropriate enum range.
Layout is not used during Tx.
NET_FRAGMENT
NET_FRAGMENT field rules depend on whether the driver is receiving or transmitting, and on whether the fragment buffers are attached to the packets by the driver or by the framework.
Rx or Tx | Notes |
---|---|
Rx |
|
Tx |
|