Browse Prior Art Database

A method for efficient ethernet device driver buffer management

IP.com Disclosure Number: IPCOM000012003D
Original Publication Date: 2003-Apr-01
Included in the Prior Art Database: 2003-Apr-01
Document File: 2 page(s) / 58K

Publishing Venue

IBM

Abstract

Disclosed is a method for managing network receive buffers in a device driver for a network adapter device. This method can be used to efficiently manage buffers for a network interface card (NIC) that does not have buffer management structures, such as rings, that are shared between the device driver and the device. The method described only requires that the NIC provide the ability to pass the device an opaque token when giving it a receive buffer and receive the token back from the NIC when the buffer is returned to the device driver.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 53% of the total text.

Page 1 of 2

A method for efficient ethernet device driver buffer management

Data Structures:

This method of receive buffer management uses two software managed circular buffer structures. Both circular buffers contain a number of entries equal to the maximum number of receive buffers the network interface card (NIC) will be given at any point in time. One circular buffer is called the control data ring. Each entry contains control data for a receive buffer. The other circular buffer is called the free ring. Each entry on the free ring contains the index of an entry on the control data ring that is currently not used. The free ring also has two index variables and a counter associated with it. One variable tracks the last entry placed on the free ring. The other variable tracks the last valid entry taken off the free ring. The counter is called the valid entries counter and tracks the number of valid entries currently on the free ring.

Control Data Ring Free Ring

Ring Entry 0 Ring Entry 1 Ring Entry 2

....

Ring Entry N

Buffer A Control Data Buffer B Control Data Buffer C Control Data

Buffer X Control Data

unused

unused

N

M

unused

<- last used

<- last added

Note: N & M refer to entries on the Control Data Ring

valid entries = 2

The control data and free rings are managed by two threads of execution. One thread is responsible for allocating new receive buffers and giving them to the NIC. This thread is called the replenishment thread. The other thread is responsible for processing receive buffers that have been processed by the NIC and returned to the device driver.

Initialization:

When the NIC is first activated, the control data ring contains no valid entries. The index of each entry on the control data ring is placed in an entry on the free ring. The last used and last added indexes are then set to the first entry on the free ring and the valid entries counter is set to the number of entries on the ring. The replenishment thread is then signaled that replenishment is needed.

Replenishment Thread Processing:

The replenishment thread is responsible for allocating new receive buffers and giving them to the device driver. The replenishment thread remains idle until it is signaled that more receive buffers are needed. When the thread is signaled, the following process is performed.

1. The thread checks the valid entries counter. If the counter is equal to zero, the thread returns to the idle state until it is signaled again. If the counter is greater than zero, it continues onto the next step.
2. The valid entries counter is decrement by one. The free ring entry indexed by the

1

Page 2 of 2

last u...