Mbuf pools are intended to help drivers for interface cards that need huge amounts of receive buffers, and additionally provides a mapping between these buffers and 32-bit handles.
An example of these cards are the Fore/Marconi ForeRunnerHE cards. These employ up to 8 receive groups, each with two buffer pools, each of which can contain up to 8192. This gives a total maximum number of more than 100000 buffers. Even with a more moderate configuration the card eats several thousand buffers. Each of these buffers must be mapped for DMA. While for machines without an IOMMU and with lesser than 4GByte memory this is not a problem, for other machines this may quickly eat up all available IOMMU address space and/or bounce buffers. On sparc64, the default I/O page size is 16k, so mapping a simple mbuf wastes 31/32 of the address space.
Another problem with most of these cards is that they support putting a 32-bit handle into the buffer descriptor together with the physical address. This handle is reflected back to the driver when the buffer is filled, and assists the driver in finding the buffer in host memory. For 32-bit machines, the virtual address of the buffer is usually used as the handle. This does not work for 64-bit machines for obvious reasons, so a mapping is needed between these handles and the buffers. This mapping should be possible without searching lists and the like.
An mbuf pool overcomes both problems by allocating DMA-able memory page wise with a per-pool configurable page size. Each page is divided into a number of equally-sized chunks, the last MBPOOL_TRAILER_SIZE of which are used by the pool code (4 bytes). The rest of each chunk is usable as a buffer. There is a per-pool limit on pages that will be allocated.
Additionally, the code manages two flags for each buffer: "on-card" and "used". A buffer may be in one of three states: