Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | * Driver for Solarflare Solarstorm network controllers and boards |
| 3 | * Copyright 2005-2006 Fen Systems Ltd. |
Ben Hutchings | 906bb26 | 2009-11-29 15:16:19 +0000 | [diff] [blame] | 4 | * Copyright 2005-2009 Solarflare Communications Inc. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation, incorporated herein by reference. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/socket.h> |
| 12 | #include <linux/in.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 14 | #include <linux/ip.h> |
| 15 | #include <linux/tcp.h> |
| 16 | #include <linux/udp.h> |
| 17 | #include <net/ip.h> |
| 18 | #include <net/checksum.h> |
| 19 | #include "net_driver.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 20 | #include "efx.h" |
Ben Hutchings | 744093c | 2009-11-29 15:12:08 +0000 | [diff] [blame] | 21 | #include "nic.h" |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 22 | #include "selftest.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 23 | #include "workarounds.h" |
| 24 | |
| 25 | /* Number of RX descriptors pushed at once. */ |
| 26 | #define EFX_RX_BATCH 8 |
| 27 | |
| 28 | /* Size of buffer allocated for skb header area. */ |
| 29 | #define EFX_SKB_HEADERS 64u |
| 30 | |
| 31 | /* |
| 32 | * rx_alloc_method - RX buffer allocation method |
| 33 | * |
| 34 | * This driver supports two methods for allocating and using RX buffers: |
| 35 | * each RX buffer may be backed by an skb or by an order-n page. |
| 36 | * |
| 37 | * When LRO is in use then the second method has a lower overhead, |
| 38 | * since we don't have to allocate then free skbs on reassembled frames. |
| 39 | * |
| 40 | * Values: |
| 41 | * - RX_ALLOC_METHOD_AUTO = 0 |
| 42 | * - RX_ALLOC_METHOD_SKB = 1 |
| 43 | * - RX_ALLOC_METHOD_PAGE = 2 |
| 44 | * |
| 45 | * The heuristic for %RX_ALLOC_METHOD_AUTO is a simple hysteresis count |
| 46 | * controlled by the parameters below. |
| 47 | * |
| 48 | * - Since pushing and popping descriptors are separated by the rx_queue |
| 49 | * size, so the watermarks should be ~rxd_size. |
| 50 | * - The performance win by using page-based allocation for LRO is less |
| 51 | * than the performance hit of using page-based allocation of non-LRO, |
| 52 | * so the watermarks should reflect this. |
| 53 | * |
| 54 | * Per channel we maintain a single variable, updated by each channel: |
| 55 | * |
| 56 | * rx_alloc_level += (lro_performed ? RX_ALLOC_FACTOR_LRO : |
| 57 | * RX_ALLOC_FACTOR_SKB) |
| 58 | * Per NAPI poll interval, we constrain rx_alloc_level to 0..MAX (which |
| 59 | * limits the hysteresis), and update the allocation strategy: |
| 60 | * |
| 61 | * rx_alloc_method = (rx_alloc_level > RX_ALLOC_LEVEL_LRO ? |
| 62 | * RX_ALLOC_METHOD_PAGE : RX_ALLOC_METHOD_SKB) |
| 63 | */ |
Ben Hutchings | c3c6336 | 2009-10-29 07:21:33 +0000 | [diff] [blame] | 64 | static int rx_alloc_method = RX_ALLOC_METHOD_AUTO; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 65 | |
| 66 | #define RX_ALLOC_LEVEL_LRO 0x2000 |
| 67 | #define RX_ALLOC_LEVEL_MAX 0x3000 |
| 68 | #define RX_ALLOC_FACTOR_LRO 1 |
| 69 | #define RX_ALLOC_FACTOR_SKB (-2) |
| 70 | |
| 71 | /* This is the percentage fill level below which new RX descriptors |
| 72 | * will be added to the RX descriptor ring. |
| 73 | */ |
| 74 | static unsigned int rx_refill_threshold = 90; |
| 75 | |
| 76 | /* This is the percentage fill level to which an RX queue will be refilled |
| 77 | * when the "RX refill threshold" is reached. |
| 78 | */ |
| 79 | static unsigned int rx_refill_limit = 95; |
| 80 | |
| 81 | /* |
| 82 | * RX maximum head room required. |
| 83 | * |
| 84 | * This must be at least 1 to prevent overflow and at least 2 to allow |
| 85 | * pipelined receives. |
| 86 | */ |
| 87 | #define EFX_RXD_HEAD_ROOM 2 |
| 88 | |
Ben Hutchings | 5566861 | 2008-05-16 21:16:10 +0100 | [diff] [blame] | 89 | static inline unsigned int efx_rx_buf_offset(struct efx_rx_buffer *buf) |
| 90 | { |
| 91 | /* Offset is always within one page, so we don't need to consider |
| 92 | * the page order. |
| 93 | */ |
Ben Hutchings | 184be0c | 2008-05-16 21:16:31 +0100 | [diff] [blame] | 94 | return (__force unsigned long) buf->data & (PAGE_SIZE - 1); |
Ben Hutchings | 5566861 | 2008-05-16 21:16:10 +0100 | [diff] [blame] | 95 | } |
| 96 | static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) |
| 97 | { |
| 98 | return PAGE_SIZE << efx->rx_buffer_order; |
| 99 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 100 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 101 | /** |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 102 | * efx_init_rx_buffers_skb - create EFX_RX_BATCH skb-based RX buffers |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 103 | * |
| 104 | * @rx_queue: Efx RX queue |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 105 | * |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 106 | * This allocates EFX_RX_BATCH skbs, maps them for DMA, and populates a |
| 107 | * struct efx_rx_buffer for each one. Return a negative error code or 0 |
| 108 | * on success. May fail having only inserted fewer than EFX_RX_BATCH |
| 109 | * buffers. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 110 | */ |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 111 | static int efx_init_rx_buffers_skb(struct efx_rx_queue *rx_queue) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 112 | { |
| 113 | struct efx_nic *efx = rx_queue->efx; |
| 114 | struct net_device *net_dev = efx->net_dev; |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 115 | struct efx_rx_buffer *rx_buf; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 116 | int skb_len = efx->rx_buffer_len; |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 117 | unsigned index, count; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 118 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 119 | for (count = 0; count < EFX_RX_BATCH; ++count) { |
| 120 | index = rx_queue->added_count & EFX_RXQ_MASK; |
| 121 | rx_buf = efx_rx_buffer(rx_queue, index); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 122 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 123 | rx_buf->skb = netdev_alloc_skb(net_dev, skb_len); |
| 124 | if (unlikely(!rx_buf->skb)) |
| 125 | return -ENOMEM; |
| 126 | rx_buf->page = NULL; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 127 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 128 | /* Adjust the SKB for padding and checksum */ |
| 129 | skb_reserve(rx_buf->skb, NET_IP_ALIGN); |
| 130 | rx_buf->len = skb_len - NET_IP_ALIGN; |
| 131 | rx_buf->data = (char *)rx_buf->skb->data; |
| 132 | rx_buf->skb->ip_summed = CHECKSUM_UNNECESSARY; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 133 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 134 | rx_buf->dma_addr = pci_map_single(efx->pci_dev, |
| 135 | rx_buf->data, rx_buf->len, |
| 136 | PCI_DMA_FROMDEVICE); |
| 137 | if (unlikely(pci_dma_mapping_error(efx->pci_dev, |
| 138 | rx_buf->dma_addr))) { |
| 139 | dev_kfree_skb_any(rx_buf->skb); |
| 140 | rx_buf->skb = NULL; |
| 141 | return -EIO; |
| 142 | } |
| 143 | |
| 144 | ++rx_queue->added_count; |
| 145 | ++rx_queue->alloc_skb_count; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | /** |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 152 | * efx_init_rx_buffers_page - create EFX_RX_BATCH page-based RX buffers |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 153 | * |
| 154 | * @rx_queue: Efx RX queue |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 155 | * |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 156 | * This allocates memory for EFX_RX_BATCH receive buffers, maps them for DMA, |
| 157 | * and populates struct efx_rx_buffers for each one. Return a negative error |
| 158 | * code or 0 on success. If a single page can be split between two buffers, |
| 159 | * then the page will either be inserted fully, or not at at all. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 160 | */ |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 161 | static int efx_init_rx_buffers_page(struct efx_rx_queue *rx_queue) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 162 | { |
| 163 | struct efx_nic *efx = rx_queue->efx; |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 164 | struct efx_rx_buffer *rx_buf; |
| 165 | struct page *page; |
| 166 | char *page_addr; |
| 167 | dma_addr_t dma_addr; |
| 168 | unsigned index, count; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 169 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 170 | /* We can split a page between two buffers */ |
| 171 | BUILD_BUG_ON(EFX_RX_BATCH & 1); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 172 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 173 | for (count = 0; count < EFX_RX_BATCH; ++count) { |
| 174 | page = alloc_pages(__GFP_COLD | __GFP_COMP | GFP_ATOMIC, |
| 175 | efx->rx_buffer_order); |
| 176 | if (unlikely(page == NULL)) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 177 | return -ENOMEM; |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 178 | dma_addr = pci_map_page(efx->pci_dev, page, 0, |
| 179 | efx_rx_buf_size(efx), |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 180 | PCI_DMA_FROMDEVICE); |
FUJITA Tomonori | 8d8bb39 | 2008-07-25 19:44:49 -0700 | [diff] [blame] | 181 | if (unlikely(pci_dma_mapping_error(efx->pci_dev, dma_addr))) { |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 182 | __free_pages(page, efx->rx_buffer_order); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 183 | return -EIO; |
| 184 | } |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 185 | EFX_BUG_ON_PARANOID(dma_addr & (PAGE_SIZE - 1)); |
| 186 | page_addr = page_address(page) + EFX_PAGE_IP_ALIGN; |
| 187 | dma_addr += EFX_PAGE_IP_ALIGN; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 188 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 189 | split: |
| 190 | index = rx_queue->added_count & EFX_RXQ_MASK; |
| 191 | rx_buf = efx_rx_buffer(rx_queue, index); |
| 192 | rx_buf->dma_addr = dma_addr; |
| 193 | rx_buf->skb = NULL; |
| 194 | rx_buf->page = page; |
| 195 | rx_buf->data = page_addr; |
| 196 | rx_buf->len = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN; |
| 197 | ++rx_queue->added_count; |
| 198 | ++rx_queue->alloc_page_count; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 199 | |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 200 | if ((~count & 1) && (efx->rx_buffer_len < (PAGE_SIZE >> 1))) { |
| 201 | /* Use the second half of the page */ |
| 202 | get_page(page); |
| 203 | dma_addr += (PAGE_SIZE >> 1); |
| 204 | page_addr += (PAGE_SIZE >> 1); |
| 205 | ++count; |
| 206 | goto split; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 210 | return 0; |
| 211 | } |
| 212 | |
Ben Hutchings | 4d56606 | 2008-09-01 12:47:12 +0100 | [diff] [blame] | 213 | static void efx_unmap_rx_buffer(struct efx_nic *efx, |
| 214 | struct efx_rx_buffer *rx_buf) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 215 | { |
| 216 | if (rx_buf->page) { |
| 217 | EFX_BUG_ON_PARANOID(rx_buf->skb); |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 218 | |
| 219 | /* Unmap the buffer if there's only one buffer per page(s), |
| 220 | * or this is the second half of a two buffer page. */ |
| 221 | if (efx->rx_buffer_order != 0 || |
| 222 | (efx_rx_buf_offset(rx_buf) & (PAGE_SIZE >> 1)) != 0) { |
| 223 | pci_unmap_page(efx->pci_dev, |
| 224 | rx_buf->dma_addr & ~(PAGE_SIZE - 1), |
Ben Hutchings | 5566861 | 2008-05-16 21:16:10 +0100 | [diff] [blame] | 225 | efx_rx_buf_size(efx), |
| 226 | PCI_DMA_FROMDEVICE); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 227 | } |
| 228 | } else if (likely(rx_buf->skb)) { |
| 229 | pci_unmap_single(efx->pci_dev, rx_buf->dma_addr, |
| 230 | rx_buf->len, PCI_DMA_FROMDEVICE); |
| 231 | } |
| 232 | } |
| 233 | |
Ben Hutchings | 4d56606 | 2008-09-01 12:47:12 +0100 | [diff] [blame] | 234 | static void efx_free_rx_buffer(struct efx_nic *efx, |
| 235 | struct efx_rx_buffer *rx_buf) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 236 | { |
| 237 | if (rx_buf->page) { |
| 238 | __free_pages(rx_buf->page, efx->rx_buffer_order); |
| 239 | rx_buf->page = NULL; |
| 240 | } else if (likely(rx_buf->skb)) { |
| 241 | dev_kfree_skb_any(rx_buf->skb); |
| 242 | rx_buf->skb = NULL; |
| 243 | } |
| 244 | } |
| 245 | |
Ben Hutchings | 4d56606 | 2008-09-01 12:47:12 +0100 | [diff] [blame] | 246 | static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, |
| 247 | struct efx_rx_buffer *rx_buf) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 248 | { |
| 249 | efx_unmap_rx_buffer(rx_queue->efx, rx_buf); |
| 250 | efx_free_rx_buffer(rx_queue->efx, rx_buf); |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * efx_fast_push_rx_descriptors - push new RX descriptors quickly |
| 255 | * @rx_queue: RX descriptor queue |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 256 | * This will aim to fill the RX descriptor queue up to |
| 257 | * @rx_queue->@fast_fill_limit. If there is insufficient atomic |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 258 | * memory to do so, a slow fill will be scheduled. |
| 259 | * |
| 260 | * The caller must provide serialisation (none is used here). In practise, |
| 261 | * this means this function must run from the NAPI handler, or be called |
| 262 | * when NAPI is disabled. |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 263 | */ |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 264 | void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 265 | { |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 266 | struct efx_channel *channel = rx_queue->channel; |
| 267 | unsigned fill_level; |
| 268 | int space, rc = 0; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 269 | |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 270 | /* Calculate current fill level, and exit if we don't need to fill */ |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 271 | fill_level = (rx_queue->added_count - rx_queue->removed_count); |
Ben Hutchings | 3ffeabd | 2009-10-23 08:30:58 +0000 | [diff] [blame] | 272 | EFX_BUG_ON_PARANOID(fill_level > EFX_RXQ_SIZE); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 273 | if (fill_level >= rx_queue->fast_fill_trigger) |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 274 | return; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 275 | |
| 276 | /* Record minimum fill level */ |
Ben Hutchings | b347564 | 2008-05-16 21:15:49 +0100 | [diff] [blame] | 277 | if (unlikely(fill_level < rx_queue->min_fill)) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 278 | if (fill_level) |
| 279 | rx_queue->min_fill = fill_level; |
Ben Hutchings | b347564 | 2008-05-16 21:15:49 +0100 | [diff] [blame] | 280 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 281 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 282 | space = rx_queue->fast_fill_limit - fill_level; |
| 283 | if (space < EFX_RX_BATCH) |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 284 | return; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 285 | |
| 286 | EFX_TRACE(rx_queue->efx, "RX queue %d fast-filling descriptor ring from" |
| 287 | " level %d to level %d using %s allocation\n", |
| 288 | rx_queue->queue, fill_level, rx_queue->fast_fill_limit, |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 289 | channel->rx_alloc_push_pages ? "page" : "skb"); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 290 | |
| 291 | do { |
Steve Hodgson | f7d6f37 | 2010-06-01 11:33:17 +0000 | [diff] [blame^] | 292 | if (channel->rx_alloc_push_pages) |
| 293 | rc = efx_init_rx_buffers_page(rx_queue); |
| 294 | else |
| 295 | rc = efx_init_rx_buffers_skb(rx_queue); |
| 296 | if (unlikely(rc)) { |
| 297 | /* Ensure that we don't leave the rx queue empty */ |
| 298 | if (rx_queue->added_count == rx_queue->removed_count) |
| 299 | efx_schedule_slow_fill(rx_queue); |
| 300 | goto out; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 301 | } |
| 302 | } while ((space -= EFX_RX_BATCH) >= EFX_RX_BATCH); |
| 303 | |
| 304 | EFX_TRACE(rx_queue->efx, "RX queue %d fast-filled descriptor ring " |
| 305 | "to level %d\n", rx_queue->queue, |
| 306 | rx_queue->added_count - rx_queue->removed_count); |
| 307 | |
| 308 | out: |
| 309 | /* Send write pointer to card. */ |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 310 | efx_nic_notify_rx_desc(rx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 313 | void efx_rx_slow_fill(unsigned long context) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 314 | { |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 315 | struct efx_rx_queue *rx_queue = (struct efx_rx_queue *)context; |
| 316 | struct efx_channel *channel = rx_queue->channel; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 317 | |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 318 | /* Post an event to cause NAPI to run and refill the queue */ |
| 319 | efx_nic_generate_fill_event(channel); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 320 | ++rx_queue->slow_fill_count; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Ben Hutchings | 4d56606 | 2008-09-01 12:47:12 +0100 | [diff] [blame] | 323 | static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, |
| 324 | struct efx_rx_buffer *rx_buf, |
| 325 | int len, bool *discard, |
| 326 | bool *leak_packet) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 327 | { |
| 328 | struct efx_nic *efx = rx_queue->efx; |
| 329 | unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding; |
| 330 | |
| 331 | if (likely(len <= max_len)) |
| 332 | return; |
| 333 | |
| 334 | /* The packet must be discarded, but this is only a fatal error |
| 335 | * if the caller indicated it was |
| 336 | */ |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 337 | *discard = true; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 338 | |
| 339 | if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) { |
| 340 | EFX_ERR_RL(efx, " RX queue %d seriously overlength " |
| 341 | "RX event (0x%x > 0x%x+0x%x). Leaking\n", |
| 342 | rx_queue->queue, len, max_len, |
| 343 | efx->type->rx_buffer_padding); |
| 344 | /* If this buffer was skb-allocated, then the meta |
| 345 | * data at the end of the skb will be trashed. So |
| 346 | * we have no choice but to leak the fragment. |
| 347 | */ |
| 348 | *leak_packet = (rx_buf->skb != NULL); |
| 349 | efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY); |
| 350 | } else { |
| 351 | EFX_ERR_RL(efx, " RX queue %d overlength RX event " |
| 352 | "(0x%x > 0x%x)\n", rx_queue->queue, len, max_len); |
| 353 | } |
| 354 | |
| 355 | rx_queue->channel->n_rx_overlength++; |
| 356 | } |
| 357 | |
| 358 | /* Pass a received packet up through the generic LRO stack |
| 359 | * |
| 360 | * Handles driverlink veto, and passes the fragment up via |
| 361 | * the appropriate LRO method |
| 362 | */ |
Ben Hutchings | 4d56606 | 2008-09-01 12:47:12 +0100 | [diff] [blame] | 363 | static void efx_rx_packet_lro(struct efx_channel *channel, |
Ben Hutchings | 345056a | 2009-10-28 03:43:49 -0700 | [diff] [blame] | 364 | struct efx_rx_buffer *rx_buf, |
| 365 | bool checksummed) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 366 | { |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 367 | struct napi_struct *napi = &channel->napi_str; |
Ben Hutchings | 18e1d2b | 2009-10-29 07:21:24 +0000 | [diff] [blame] | 368 | gro_result_t gro_result; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 369 | |
| 370 | /* Pass the skb/page into the LRO engine */ |
| 371 | if (rx_buf->page) { |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 372 | struct page *page = rx_buf->page; |
| 373 | struct sk_buff *skb; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 374 | |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 375 | EFX_BUG_ON_PARANOID(rx_buf->skb); |
| 376 | rx_buf->page = NULL; |
| 377 | |
| 378 | skb = napi_get_frags(napi); |
Herbert Xu | 76620aa | 2009-04-16 02:02:07 -0700 | [diff] [blame] | 379 | if (!skb) { |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 380 | put_page(page); |
| 381 | return; |
Herbert Xu | 76620aa | 2009-04-16 02:02:07 -0700 | [diff] [blame] | 382 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 383 | |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 384 | skb_shinfo(skb)->frags[0].page = page; |
Herbert Xu | 76620aa | 2009-04-16 02:02:07 -0700 | [diff] [blame] | 385 | skb_shinfo(skb)->frags[0].page_offset = |
| 386 | efx_rx_buf_offset(rx_buf); |
| 387 | skb_shinfo(skb)->frags[0].size = rx_buf->len; |
| 388 | skb_shinfo(skb)->nr_frags = 1; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 389 | |
Herbert Xu | 76620aa | 2009-04-16 02:02:07 -0700 | [diff] [blame] | 390 | skb->len = rx_buf->len; |
| 391 | skb->data_len = rx_buf->len; |
| 392 | skb->truesize += rx_buf->len; |
Ben Hutchings | 345056a | 2009-10-28 03:43:49 -0700 | [diff] [blame] | 393 | skb->ip_summed = |
| 394 | checksummed ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE; |
Herbert Xu | 76620aa | 2009-04-16 02:02:07 -0700 | [diff] [blame] | 395 | |
Ben Hutchings | 3eadb7b | 2009-11-23 16:02:40 +0000 | [diff] [blame] | 396 | skb_record_rx_queue(skb, channel->channel); |
| 397 | |
Ben Hutchings | 18e1d2b | 2009-10-29 07:21:24 +0000 | [diff] [blame] | 398 | gro_result = napi_gro_frags(napi); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 399 | } else { |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 400 | struct sk_buff *skb = rx_buf->skb; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 401 | |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 402 | EFX_BUG_ON_PARANOID(!skb); |
| 403 | EFX_BUG_ON_PARANOID(!checksummed); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 404 | rx_buf->skb = NULL; |
Ben Hutchings | 1241e95 | 2009-11-23 16:02:25 +0000 | [diff] [blame] | 405 | |
| 406 | gro_result = napi_gro_receive(napi, skb); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 407 | } |
Ben Hutchings | 18e1d2b | 2009-10-29 07:21:24 +0000 | [diff] [blame] | 408 | |
| 409 | if (gro_result == GRO_NORMAL) { |
| 410 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; |
| 411 | } else if (gro_result != GRO_DROP) { |
| 412 | channel->rx_alloc_level += RX_ALLOC_FACTOR_LRO; |
| 413 | channel->irq_mod_score += 2; |
| 414 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 415 | } |
| 416 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 417 | void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 418 | unsigned int len, bool checksummed, bool discard) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 419 | { |
| 420 | struct efx_nic *efx = rx_queue->efx; |
| 421 | struct efx_rx_buffer *rx_buf; |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 422 | bool leak_packet = false; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 423 | |
| 424 | rx_buf = efx_rx_buffer(rx_queue, index); |
| 425 | EFX_BUG_ON_PARANOID(!rx_buf->data); |
| 426 | EFX_BUG_ON_PARANOID(rx_buf->skb && rx_buf->page); |
| 427 | EFX_BUG_ON_PARANOID(!(rx_buf->skb || rx_buf->page)); |
| 428 | |
| 429 | /* This allows the refill path to post another buffer. |
| 430 | * EFX_RXD_HEAD_ROOM ensures that the slot we are using |
| 431 | * isn't overwritten yet. |
| 432 | */ |
| 433 | rx_queue->removed_count++; |
| 434 | |
| 435 | /* Validate the length encoded in the event vs the descriptor pushed */ |
| 436 | efx_rx_packet__check_len(rx_queue, rx_buf, len, |
| 437 | &discard, &leak_packet); |
| 438 | |
| 439 | EFX_TRACE(efx, "RX queue %d received id %x at %llx+%x %s%s\n", |
| 440 | rx_queue->queue, index, |
| 441 | (unsigned long long)rx_buf->dma_addr, len, |
| 442 | (checksummed ? " [SUMMED]" : ""), |
| 443 | (discard ? " [DISCARD]" : "")); |
| 444 | |
| 445 | /* Discard packet, if instructed to do so */ |
| 446 | if (unlikely(discard)) { |
| 447 | if (unlikely(leak_packet)) |
| 448 | rx_queue->channel->n_skbuff_leaks++; |
| 449 | else |
| 450 | /* We haven't called efx_unmap_rx_buffer yet, |
| 451 | * so fini the entire rx_buffer here */ |
| 452 | efx_fini_rx_buffer(rx_queue, rx_buf); |
| 453 | return; |
| 454 | } |
| 455 | |
| 456 | /* Release card resources - assumes all RX buffers consumed in-order |
| 457 | * per RX queue |
| 458 | */ |
| 459 | efx_unmap_rx_buffer(efx, rx_buf); |
| 460 | |
| 461 | /* Prefetch nice and early so data will (hopefully) be in cache by |
| 462 | * the time we look at it. |
| 463 | */ |
| 464 | prefetch(rx_buf->data); |
| 465 | |
| 466 | /* Pipeline receives so that we give time for packet headers to be |
| 467 | * prefetched into cache. |
| 468 | */ |
| 469 | rx_buf->len = len; |
| 470 | if (rx_queue->channel->rx_pkt) |
| 471 | __efx_rx_packet(rx_queue->channel, |
| 472 | rx_queue->channel->rx_pkt, |
| 473 | rx_queue->channel->rx_pkt_csummed); |
| 474 | rx_queue->channel->rx_pkt = rx_buf; |
| 475 | rx_queue->channel->rx_pkt_csummed = checksummed; |
| 476 | } |
| 477 | |
| 478 | /* Handle a received packet. Second half: Touches packet payload. */ |
| 479 | void __efx_rx_packet(struct efx_channel *channel, |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 480 | struct efx_rx_buffer *rx_buf, bool checksummed) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 481 | { |
| 482 | struct efx_nic *efx = channel->efx; |
| 483 | struct sk_buff *skb; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 484 | |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 485 | /* If we're in loopback test, then pass the packet directly to the |
| 486 | * loopback layer, and free the rx_buf here |
| 487 | */ |
| 488 | if (unlikely(efx->loopback_selftest)) { |
| 489 | efx_loopback_rx_packet(efx, rx_buf->data, rx_buf->len); |
| 490 | efx_free_rx_buffer(efx, rx_buf); |
Ben Hutchings | d96d7dc | 2009-11-23 16:01:44 +0000 | [diff] [blame] | 491 | return; |
Ben Hutchings | 3273c2e | 2008-05-07 13:36:19 +0100 | [diff] [blame] | 492 | } |
| 493 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 494 | if (rx_buf->skb) { |
| 495 | prefetch(skb_shinfo(rx_buf->skb)); |
| 496 | |
| 497 | skb_put(rx_buf->skb, rx_buf->len); |
| 498 | |
| 499 | /* Move past the ethernet header. rx_buf->data still points |
| 500 | * at the ethernet header */ |
| 501 | rx_buf->skb->protocol = eth_type_trans(rx_buf->skb, |
| 502 | efx->net_dev); |
Ben Hutchings | 3eadb7b | 2009-11-23 16:02:40 +0000 | [diff] [blame] | 503 | |
| 504 | skb_record_rx_queue(rx_buf->skb, channel->channel); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 505 | } |
| 506 | |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 507 | if (likely(checksummed || rx_buf->page)) { |
Ben Hutchings | 345056a | 2009-10-28 03:43:49 -0700 | [diff] [blame] | 508 | efx_rx_packet_lro(channel, rx_buf, checksummed); |
Ben Hutchings | d96d7dc | 2009-11-23 16:01:44 +0000 | [diff] [blame] | 509 | return; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 510 | } |
| 511 | |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 512 | /* We now own the SKB */ |
| 513 | skb = rx_buf->skb; |
| 514 | rx_buf->skb = NULL; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 515 | EFX_BUG_ON_PARANOID(!skb); |
| 516 | |
| 517 | /* Set the SKB flags */ |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 518 | skb->ip_summed = CHECKSUM_NONE; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 519 | |
| 520 | /* Pass the packet up */ |
| 521 | netif_receive_skb(skb); |
| 522 | |
| 523 | /* Update allocation strategy method */ |
| 524 | channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | void efx_rx_strategy(struct efx_channel *channel) |
| 528 | { |
| 529 | enum efx_rx_alloc_method method = rx_alloc_method; |
| 530 | |
| 531 | /* Only makes sense to use page based allocation if LRO is enabled */ |
Herbert Xu | da3bc07 | 2009-01-18 21:50:16 -0800 | [diff] [blame] | 532 | if (!(channel->efx->net_dev->features & NETIF_F_GRO)) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 533 | method = RX_ALLOC_METHOD_SKB; |
| 534 | } else if (method == RX_ALLOC_METHOD_AUTO) { |
| 535 | /* Constrain the rx_alloc_level */ |
| 536 | if (channel->rx_alloc_level < 0) |
| 537 | channel->rx_alloc_level = 0; |
| 538 | else if (channel->rx_alloc_level > RX_ALLOC_LEVEL_MAX) |
| 539 | channel->rx_alloc_level = RX_ALLOC_LEVEL_MAX; |
| 540 | |
| 541 | /* Decide on the allocation method */ |
| 542 | method = ((channel->rx_alloc_level > RX_ALLOC_LEVEL_LRO) ? |
| 543 | RX_ALLOC_METHOD_PAGE : RX_ALLOC_METHOD_SKB); |
| 544 | } |
| 545 | |
| 546 | /* Push the option */ |
| 547 | channel->rx_alloc_push_pages = (method == RX_ALLOC_METHOD_PAGE); |
| 548 | } |
| 549 | |
| 550 | int efx_probe_rx_queue(struct efx_rx_queue *rx_queue) |
| 551 | { |
| 552 | struct efx_nic *efx = rx_queue->efx; |
| 553 | unsigned int rxq_size; |
| 554 | int rc; |
| 555 | |
| 556 | EFX_LOG(efx, "creating RX queue %d\n", rx_queue->queue); |
| 557 | |
| 558 | /* Allocate RX buffers */ |
Ben Hutchings | 3ffeabd | 2009-10-23 08:30:58 +0000 | [diff] [blame] | 559 | rxq_size = EFX_RXQ_SIZE * sizeof(*rx_queue->buffer); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 560 | rx_queue->buffer = kzalloc(rxq_size, GFP_KERNEL); |
Ben Hutchings | 8831da7 | 2008-09-01 12:47:48 +0100 | [diff] [blame] | 561 | if (!rx_queue->buffer) |
| 562 | return -ENOMEM; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 563 | |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 564 | rc = efx_nic_probe_rx(rx_queue); |
Ben Hutchings | 8831da7 | 2008-09-01 12:47:48 +0100 | [diff] [blame] | 565 | if (rc) { |
| 566 | kfree(rx_queue->buffer); |
| 567 | rx_queue->buffer = NULL; |
| 568 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 569 | return rc; |
| 570 | } |
| 571 | |
Ben Hutchings | bc3c90a | 2008-09-01 12:48:46 +0100 | [diff] [blame] | 572 | void efx_init_rx_queue(struct efx_rx_queue *rx_queue) |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 573 | { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 574 | unsigned int max_fill, trigger, limit; |
| 575 | |
| 576 | EFX_LOG(rx_queue->efx, "initialising RX queue %d\n", rx_queue->queue); |
| 577 | |
| 578 | /* Initialise ptr fields */ |
| 579 | rx_queue->added_count = 0; |
| 580 | rx_queue->notified_count = 0; |
| 581 | rx_queue->removed_count = 0; |
| 582 | rx_queue->min_fill = -1U; |
| 583 | rx_queue->min_overfill = -1U; |
| 584 | |
| 585 | /* Initialise limit fields */ |
Ben Hutchings | 3ffeabd | 2009-10-23 08:30:58 +0000 | [diff] [blame] | 586 | max_fill = EFX_RXQ_SIZE - EFX_RXD_HEAD_ROOM; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 587 | trigger = max_fill * min(rx_refill_threshold, 100U) / 100U; |
| 588 | limit = max_fill * min(rx_refill_limit, 100U) / 100U; |
| 589 | |
| 590 | rx_queue->max_fill = max_fill; |
| 591 | rx_queue->fast_fill_trigger = trigger; |
| 592 | rx_queue->fast_fill_limit = limit; |
| 593 | |
| 594 | /* Set up RX descriptor ring */ |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 595 | efx_nic_init_rx(rx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | void efx_fini_rx_queue(struct efx_rx_queue *rx_queue) |
| 599 | { |
| 600 | int i; |
| 601 | struct efx_rx_buffer *rx_buf; |
| 602 | |
| 603 | EFX_LOG(rx_queue->efx, "shutting down RX queue %d\n", rx_queue->queue); |
| 604 | |
Steve Hodgson | 90d683a | 2010-06-01 11:19:39 +0000 | [diff] [blame] | 605 | del_timer_sync(&rx_queue->slow_fill); |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 606 | efx_nic_fini_rx(rx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 607 | |
| 608 | /* Release RX buffers NB start at index 0 not current HW ptr */ |
| 609 | if (rx_queue->buffer) { |
Ben Hutchings | 3ffeabd | 2009-10-23 08:30:58 +0000 | [diff] [blame] | 610 | for (i = 0; i <= EFX_RXQ_MASK; i++) { |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 611 | rx_buf = efx_rx_buffer(rx_queue, i); |
| 612 | efx_fini_rx_buffer(rx_queue, rx_buf); |
| 613 | } |
| 614 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | void efx_remove_rx_queue(struct efx_rx_queue *rx_queue) |
| 618 | { |
| 619 | EFX_LOG(rx_queue->efx, "destroying RX queue %d\n", rx_queue->queue); |
| 620 | |
Ben Hutchings | 152b6a6 | 2009-11-29 03:43:56 +0000 | [diff] [blame] | 621 | efx_nic_remove_rx(rx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 622 | |
| 623 | kfree(rx_queue->buffer); |
| 624 | rx_queue->buffer = NULL; |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 625 | } |
| 626 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 627 | |
| 628 | module_param(rx_alloc_method, int, 0644); |
| 629 | MODULE_PARM_DESC(rx_alloc_method, "Allocation method used for RX buffers"); |
| 630 | |
| 631 | module_param(rx_refill_threshold, uint, 0444); |
| 632 | MODULE_PARM_DESC(rx_refill_threshold, |
| 633 | "RX descriptor ring fast/slow fill threshold (%)"); |
| 634 | |