aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/sfc/net_driver.h
diff options
context:
space:
mode:
authorDaniel Pieczko <dpieczko@solarflare.com>2013-02-13 05:54:41 -0500
committerBen Hutchings <bhutchings@solarflare.com>2013-03-07 15:22:13 -0500
commit2768935a46603bb9bdd121864b1f2b2e8a71cccc (patch)
tree4d5704c97f096cdf0d160bc18694b89927639cfd /drivers/net/ethernet/sfc/net_driver.h
parent85740cdf0b84224a9fce62dc9150008ef8d6ab4e (diff)
sfc: reuse pages to avoid DMA mapping/unmapping costs
On POWER systems, DMA mapping/unmapping operations are very expensive. These changes reduce these costs by trying to reuse DMA mapped pages. After all the buffers associated with a page have been processed and passed up, the page is placed into a ring (if there is room). For each page that is required for a refill operation, a page in the ring is examined to determine if its page count has fallen to 1, ie. the kernel has released its reference to these packets. If this is the case, the page can be immediately added back into the RX descriptor ring, without having to re-map it for DMA. If the kernel is still holding a reference to this page, it is removed from the ring and unmapped for DMA. Then a new page, which can immediately be used by RX buffers in the descriptor ring, is allocated and DMA mapped. The time a page needs to spend in the recycle ring before the kernel has released its page references is based on the number of buffers that use this page. As large pages can hold more RX buffers, the RX recycle ring can be shorter. This reduces memory usage on POWER systems, while maintaining the performance gain achieved by recycling pages, following the driver change to pack more than two RX buffers into large pages. When an IOMMU is not present, the recycle ring can be small to reduce memory usage, since DMA mapping operations are inexpensive. With a small recycle ring, attempting to refill the descriptor queue with more buffers than the equivalent size of the recycle ring could ultimately lead to memory leaks if page entries in the recycle ring were overwritten. To prevent this, the check to see if the recycle ring is full is changed to check if the next entry to be written is NULL. [bwh: Combine and rebase several commits so this is complete before the following buffer-packing changes. Remove module parameter.] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc/net_driver.h')
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index e41b54bada7c..370c5bcebad9 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -264,12 +264,22 @@ struct efx_rx_page_state {
264 * @notified_count: Number of buffers given to NIC (<= @added_count). 264 * @notified_count: Number of buffers given to NIC (<= @added_count).
265 * @removed_count: Number of buffers removed from the receive queue. 265 * @removed_count: Number of buffers removed from the receive queue.
266 * @scatter_n: Number of buffers used by current packet 266 * @scatter_n: Number of buffers used by current packet
267 * @page_ring: The ring to store DMA mapped pages for reuse.
268 * @page_add: Counter to calculate the write pointer for the recycle ring.
269 * @page_remove: Counter to calculate the read pointer for the recycle ring.
270 * @page_recycle_count: The number of pages that have been recycled.
271 * @page_recycle_failed: The number of pages that couldn't be recycled because
272 * the kernel still held a reference to them.
273 * @page_recycle_full: The number of pages that were released because the
274 * recycle ring was full.
275 * @page_ptr_mask: The number of pages in the RX recycle ring minus 1.
267 * @max_fill: RX descriptor maximum fill level (<= ring size) 276 * @max_fill: RX descriptor maximum fill level (<= ring size)
268 * @fast_fill_trigger: RX descriptor fill level that will trigger a fast fill 277 * @fast_fill_trigger: RX descriptor fill level that will trigger a fast fill
269 * (<= @max_fill) 278 * (<= @max_fill)
270 * @min_fill: RX descriptor minimum non-zero fill level. 279 * @min_fill: RX descriptor minimum non-zero fill level.
271 * This records the minimum fill level observed when a ring 280 * This records the minimum fill level observed when a ring
272 * refill was triggered. 281 * refill was triggered.
282 * @recycle_count: RX buffer recycle counter.
273 * @slow_fill: Timer used to defer efx_nic_generate_fill_event(). 283 * @slow_fill: Timer used to defer efx_nic_generate_fill_event().
274 */ 284 */
275struct efx_rx_queue { 285struct efx_rx_queue {
@@ -285,10 +295,18 @@ struct efx_rx_queue {
285 unsigned int notified_count; 295 unsigned int notified_count;
286 unsigned int removed_count; 296 unsigned int removed_count;
287 unsigned int scatter_n; 297 unsigned int scatter_n;
298 struct page **page_ring;
299 unsigned int page_add;
300 unsigned int page_remove;
301 unsigned int page_recycle_count;
302 unsigned int page_recycle_failed;
303 unsigned int page_recycle_full;
304 unsigned int page_ptr_mask;
288 unsigned int max_fill; 305 unsigned int max_fill;
289 unsigned int fast_fill_trigger; 306 unsigned int fast_fill_trigger;
290 unsigned int min_fill; 307 unsigned int min_fill;
291 unsigned int min_overfill; 308 unsigned int min_overfill;
309 unsigned int recycle_count;
292 struct timer_list slow_fill; 310 struct timer_list slow_fill;
293 unsigned int slow_fill_count; 311 unsigned int slow_fill_count;
294}; 312};
@@ -806,6 +824,7 @@ struct efx_nic {
806 unsigned int rx_dma_len; 824 unsigned int rx_dma_len;
807 unsigned int rx_buffer_order; 825 unsigned int rx_buffer_order;
808 unsigned int rx_buffer_truesize; 826 unsigned int rx_buffer_truesize;
827 unsigned int rx_bufs_per_page;
809 u8 rx_hash_key[40]; 828 u8 rx_hash_key[40];
810 u32 rx_indir_table[128]; 829 u32 rx_indir_table[128];
811 bool rx_scatter; 830 bool rx_scatter;