blob: 88aa1ff01e3fe61cdcbc26be00c41376bfba9a72 [file] [log] [blame]
Ben Hutchings8ceee662008-04-27 12:55:59 +01001/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
Ben Hutchings0a6f40c2011-02-25 00:01:34 +00004 * Copyright 2005-2011 Solarflare Communications Inc.
Ben Hutchings8ceee662008-04-27 12:55:59 +01005 *
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 Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Ben Hutchings8ceee662008-04-27 12:55:59 +010014#include <linux/ip.h>
15#include <linux/tcp.h>
16#include <linux/udp.h>
Paul Gortmaker70c71602011-05-22 16:47:17 -040017#include <linux/prefetch.h>
Paul Gortmaker6eb07ca2011-09-15 19:46:05 -040018#include <linux/moduleparam.h>
Ben Hutchings8ceee662008-04-27 12:55:59 +010019#include <net/ip.h>
20#include <net/checksum.h>
21#include "net_driver.h"
Ben Hutchings8ceee662008-04-27 12:55:59 +010022#include "efx.h"
Ben Hutchings744093c2009-11-29 15:12:08 +000023#include "nic.h"
Ben Hutchings3273c2e2008-05-07 13:36:19 +010024#include "selftest.h"
Ben Hutchings8ceee662008-04-27 12:55:59 +010025#include "workarounds.h"
26
27/* Number of RX descriptors pushed at once. */
28#define EFX_RX_BATCH 8
29
Ben Hutchings272baee2013-01-29 23:33:14 +000030/* Maximum length for an RX descriptor sharing a page */
31#define EFX_RX_HALF_PAGE ((PAGE_SIZE >> 1) - sizeof(struct efx_rx_page_state) \
32 - EFX_PAGE_IP_ALIGN)
Steve Hodgson62b330b2010-06-01 11:20:53 +000033
Ben Hutchings8ceee662008-04-27 12:55:59 +010034/* Size of buffer allocated for skb header area. */
35#define EFX_SKB_HEADERS 64u
36
Ben Hutchings8ceee662008-04-27 12:55:59 +010037/* This is the percentage fill level below which new RX descriptors
38 * will be added to the RX descriptor ring.
39 */
David Riddoch64235182012-04-11 13:12:41 +010040static unsigned int rx_refill_threshold;
Ben Hutchings8ceee662008-04-27 12:55:59 +010041
Ben Hutchings85740cdf2013-01-29 23:33:15 +000042/* Each packet can consume up to ceil(max_frame_len / buffer_size) buffers */
43#define EFX_RX_MAX_FRAGS DIV_ROUND_UP(EFX_MAX_FRAME_LEN(EFX_MAX_MTU), \
44 EFX_RX_USR_BUF_SIZE)
45
Ben Hutchings8ceee662008-04-27 12:55:59 +010046/*
47 * RX maximum head room required.
48 *
Ben Hutchings85740cdf2013-01-29 23:33:15 +000049 * This must be at least 1 to prevent overflow, plus one packet-worth
50 * to allow pipelined receives.
Ben Hutchings8ceee662008-04-27 12:55:59 +010051 */
Ben Hutchings85740cdf2013-01-29 23:33:15 +000052#define EFX_RXD_HEAD_ROOM (1 + EFX_RX_MAX_FRAGS)
Ben Hutchings8ceee662008-04-27 12:55:59 +010053
Ben Hutchingsb184f162013-01-29 23:33:15 +000054static inline u8 *efx_rx_buf_va(struct efx_rx_buffer *buf)
Ben Hutchings39c9cf02010-06-23 11:31:28 +000055{
Ben Hutchingsb184f162013-01-29 23:33:15 +000056 return page_address(buf->page) + buf->page_offset;
Steve Hodgsona526f142011-02-24 23:45:16 +000057}
58
59static inline u32 efx_rx_buf_hash(const u8 *eh)
60{
61 /* The ethernet header is always directly after any hash. */
Ben Hutchings39c9cf02010-06-23 11:31:28 +000062#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0
Steve Hodgsona526f142011-02-24 23:45:16 +000063 return __le32_to_cpup((const __le32 *)(eh - 4));
Ben Hutchings39c9cf02010-06-23 11:31:28 +000064#else
Steve Hodgsona526f142011-02-24 23:45:16 +000065 const u8 *data = eh - 4;
Ben Hutchings0beaca22012-01-05 18:54:04 +000066 return (u32)data[0] |
67 (u32)data[1] << 8 |
68 (u32)data[2] << 16 |
69 (u32)data[3] << 24;
Ben Hutchings39c9cf02010-06-23 11:31:28 +000070#endif
71}
72
Ben Hutchings85740cdf2013-01-29 23:33:15 +000073static inline struct efx_rx_buffer *
74efx_rx_buf_next(struct efx_rx_queue *rx_queue, struct efx_rx_buffer *rx_buf)
75{
76 if (unlikely(rx_buf == efx_rx_buffer(rx_queue, rx_queue->ptr_mask)))
77 return efx_rx_buffer(rx_queue, 0);
78 else
79 return rx_buf + 1;
80}
81
Ben Hutchings8ceee662008-04-27 12:55:59 +010082/**
Alexandre Rames97d48a12013-01-11 12:26:21 +000083 * efx_init_rx_buffers - create EFX_RX_BATCH page-based RX buffers
Ben Hutchings8ceee662008-04-27 12:55:59 +010084 *
85 * @rx_queue: Efx RX queue
Ben Hutchings8ceee662008-04-27 12:55:59 +010086 *
Steve Hodgsonf7d6f372010-06-01 11:33:17 +000087 * This allocates memory for EFX_RX_BATCH receive buffers, maps them for DMA,
88 * and populates struct efx_rx_buffers for each one. Return a negative error
89 * code or 0 on success. If a single page can be split between two buffers,
90 * then the page will either be inserted fully, or not at at all.
Ben Hutchings8ceee662008-04-27 12:55:59 +010091 */
Alexandre Rames97d48a12013-01-11 12:26:21 +000092static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue)
Ben Hutchings8ceee662008-04-27 12:55:59 +010093{
94 struct efx_nic *efx = rx_queue->efx;
Steve Hodgsonf7d6f372010-06-01 11:33:17 +000095 struct efx_rx_buffer *rx_buf;
96 struct page *page;
Ben Hutchingsb590ace2013-01-10 23:51:54 +000097 unsigned int page_offset;
Steve Hodgson62b330b2010-06-01 11:20:53 +000098 struct efx_rx_page_state *state;
Steve Hodgsonf7d6f372010-06-01 11:33:17 +000099 dma_addr_t dma_addr;
100 unsigned index, count;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100101
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000102 /* We can split a page between two buffers */
103 BUILD_BUG_ON(EFX_RX_BATCH & 1);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100104
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000105 for (count = 0; count < EFX_RX_BATCH; ++count) {
106 page = alloc_pages(__GFP_COLD | __GFP_COMP | GFP_ATOMIC,
107 efx->rx_buffer_order);
108 if (unlikely(page == NULL))
Ben Hutchings8ceee662008-04-27 12:55:59 +0100109 return -ENOMEM;
Ben Hutchings0e33d872012-05-17 17:46:55 +0100110 dma_addr = dma_map_page(&efx->pci_dev->dev, page, 0,
Ben Hutchings272baee2013-01-29 23:33:14 +0000111 PAGE_SIZE << efx->rx_buffer_order,
Ben Hutchings0e33d872012-05-17 17:46:55 +0100112 DMA_FROM_DEVICE);
113 if (unlikely(dma_mapping_error(&efx->pci_dev->dev, dma_addr))) {
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000114 __free_pages(page, efx->rx_buffer_order);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100115 return -EIO;
116 }
Ben Hutchingsb8e02512012-09-06 23:54:15 +0100117 state = page_address(page);
Steve Hodgson62b330b2010-06-01 11:20:53 +0000118 state->refcnt = 0;
119 state->dma_addr = dma_addr;
120
Steve Hodgson62b330b2010-06-01 11:20:53 +0000121 dma_addr += sizeof(struct efx_rx_page_state);
Ben Hutchingsb590ace2013-01-10 23:51:54 +0000122 page_offset = sizeof(struct efx_rx_page_state);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100123
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000124 split:
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000125 index = rx_queue->added_count & rx_queue->ptr_mask;
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000126 rx_buf = efx_rx_buffer(rx_queue, index);
Steve Hodgson62b330b2010-06-01 11:20:53 +0000127 rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000128 rx_buf->page = page;
Ben Hutchingsc73e7872013-03-05 17:49:39 +0000129 rx_buf->page_offset = page_offset + EFX_PAGE_IP_ALIGN;
Ben Hutchings272baee2013-01-29 23:33:14 +0000130 rx_buf->len = efx->rx_dma_len;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000131 rx_buf->flags = 0;
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000132 ++rx_queue->added_count;
Steve Hodgson62b330b2010-06-01 11:20:53 +0000133 ++state->refcnt;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100134
Ben Hutchings272baee2013-01-29 23:33:14 +0000135 if ((~count & 1) && (efx->rx_dma_len <= EFX_RX_HALF_PAGE)) {
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000136 /* Use the second half of the page */
137 get_page(page);
138 dma_addr += (PAGE_SIZE >> 1);
Ben Hutchingsb590ace2013-01-10 23:51:54 +0000139 page_offset += (PAGE_SIZE >> 1);
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000140 ++count;
141 goto split;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100142 }
143 }
144
Ben Hutchings8ceee662008-04-27 12:55:59 +0100145 return 0;
146}
147
Ben Hutchings4d566062008-09-01 12:47:12 +0100148static void efx_unmap_rx_buffer(struct efx_nic *efx,
Ben Hutchings3a68f192012-12-20 18:48:20 +0000149 struct efx_rx_buffer *rx_buf,
150 unsigned int used_len)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100151{
Alexandre Rames97d48a12013-01-11 12:26:21 +0000152 if (rx_buf->page) {
Steve Hodgson62b330b2010-06-01 11:20:53 +0000153 struct efx_rx_page_state *state;
154
Alexandre Rames97d48a12013-01-11 12:26:21 +0000155 state = page_address(rx_buf->page);
Steve Hodgson62b330b2010-06-01 11:20:53 +0000156 if (--state->refcnt == 0) {
Ben Hutchings0e33d872012-05-17 17:46:55 +0100157 dma_unmap_page(&efx->pci_dev->dev,
Steve Hodgson62b330b2010-06-01 11:20:53 +0000158 state->dma_addr,
Ben Hutchings272baee2013-01-29 23:33:14 +0000159 PAGE_SIZE << efx->rx_buffer_order,
Ben Hutchings0e33d872012-05-17 17:46:55 +0100160 DMA_FROM_DEVICE);
Ben Hutchings3a68f192012-12-20 18:48:20 +0000161 } else if (used_len) {
162 dma_sync_single_for_cpu(&efx->pci_dev->dev,
163 rx_buf->dma_addr, used_len,
164 DMA_FROM_DEVICE);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100165 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100166 }
167}
168
Ben Hutchings4d566062008-09-01 12:47:12 +0100169static void efx_free_rx_buffer(struct efx_nic *efx,
170 struct efx_rx_buffer *rx_buf)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100171{
Alexandre Rames97d48a12013-01-11 12:26:21 +0000172 if (rx_buf->page) {
173 __free_pages(rx_buf->page, efx->rx_buffer_order);
174 rx_buf->page = NULL;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100175 }
176}
177
Ben Hutchings4d566062008-09-01 12:47:12 +0100178static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue,
179 struct efx_rx_buffer *rx_buf)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100180{
Ben Hutchings3a68f192012-12-20 18:48:20 +0000181 efx_unmap_rx_buffer(rx_queue->efx, rx_buf, 0);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100182 efx_free_rx_buffer(rx_queue->efx, rx_buf);
183}
184
Steve Hodgson24455802010-06-01 11:20:34 +0000185/* Attempt to resurrect the other receive buffer that used to share this page,
186 * which had previously been passed up to the kernel and freed. */
187static void efx_resurrect_rx_buffer(struct efx_rx_queue *rx_queue,
188 struct efx_rx_buffer *rx_buf)
189{
Alexandre Rames97d48a12013-01-11 12:26:21 +0000190 struct efx_rx_page_state *state = page_address(rx_buf->page);
Steve Hodgson24455802010-06-01 11:20:34 +0000191 struct efx_rx_buffer *new_buf;
Steve Hodgson62b330b2010-06-01 11:20:53 +0000192 unsigned fill_level, index;
Steve Hodgson24455802010-06-01 11:20:34 +0000193
Steve Hodgson62b330b2010-06-01 11:20:53 +0000194 /* +1 because efx_rx_packet() incremented removed_count. +1 because
195 * we'd like to insert an additional descriptor whilst leaving
196 * EFX_RXD_HEAD_ROOM for the non-recycle path */
197 fill_level = (rx_queue->added_count - rx_queue->removed_count + 2);
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000198 if (unlikely(fill_level > rx_queue->max_fill)) {
Steve Hodgson62b330b2010-06-01 11:20:53 +0000199 /* We could place "state" on a list, and drain the list in
200 * efx_fast_push_rx_descriptors(). For now, this will do. */
201 return;
202 }
203
204 ++state->refcnt;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000205 get_page(rx_buf->page);
Steve Hodgson24455802010-06-01 11:20:34 +0000206
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000207 index = rx_queue->added_count & rx_queue->ptr_mask;
Steve Hodgson24455802010-06-01 11:20:34 +0000208 new_buf = efx_rx_buffer(rx_queue, index);
Steve Hodgson62b330b2010-06-01 11:20:53 +0000209 new_buf->dma_addr = rx_buf->dma_addr ^ (PAGE_SIZE >> 1);
Alexandre Rames97d48a12013-01-11 12:26:21 +0000210 new_buf->page = rx_buf->page;
Steve Hodgson24455802010-06-01 11:20:34 +0000211 new_buf->len = rx_buf->len;
212 ++rx_queue->added_count;
213}
214
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000215/* Recycle buffers directly back into the rx_queue. There is always
216 * room to add these buffer, because we've just popped them.
217 */
218static void efx_recycle_rx_buffers(struct efx_channel *channel,
219 struct efx_rx_buffer *rx_buf,
220 unsigned int n_frags)
Steve Hodgson24455802010-06-01 11:20:34 +0000221{
222 struct efx_nic *efx = channel->efx;
Ben Hutchingsf7d12cd2010-09-10 06:41:47 +0000223 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);
Steve Hodgson24455802010-06-01 11:20:34 +0000224 struct efx_rx_buffer *new_buf;
225 unsigned index;
226
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000227 do {
228 rx_buf->flags = 0;
Ben Hutchingsdb339562011-08-26 18:05:11 +0100229
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000230 if (efx->rx_dma_len <= EFX_RX_HALF_PAGE &&
231 page_count(rx_buf->page) == 1)
232 efx_resurrect_rx_buffer(rx_queue, rx_buf);
Steve Hodgson24455802010-06-01 11:20:34 +0000233
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000234 index = rx_queue->added_count & rx_queue->ptr_mask;
235 new_buf = efx_rx_buffer(rx_queue, index);
Steve Hodgson24455802010-06-01 11:20:34 +0000236
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000237 memcpy(new_buf, rx_buf, sizeof(*new_buf));
238 rx_buf->page = NULL;
239 ++rx_queue->added_count;
240
241 rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
242 } while (--n_frags);
Steve Hodgson24455802010-06-01 11:20:34 +0000243}
244
Ben Hutchings8ceee662008-04-27 12:55:59 +0100245/**
246 * efx_fast_push_rx_descriptors - push new RX descriptors quickly
247 * @rx_queue: RX descriptor queue
Ben Hutchings49ce9c22012-07-10 10:56:00 +0000248 *
Ben Hutchings8ceee662008-04-27 12:55:59 +0100249 * This will aim to fill the RX descriptor queue up to
David Riddochda9ca502012-04-11 13:09:24 +0100250 * @rx_queue->@max_fill. If there is insufficient atomic
Steve Hodgson90d683a2010-06-01 11:19:39 +0000251 * memory to do so, a slow fill will be scheduled.
252 *
253 * The caller must provide serialisation (none is used here). In practise,
254 * this means this function must run from the NAPI handler, or be called
255 * when NAPI is disabled.
Ben Hutchings8ceee662008-04-27 12:55:59 +0100256 */
Steve Hodgson90d683a2010-06-01 11:19:39 +0000257void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100258{
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000259 unsigned fill_level;
260 int space, rc = 0;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100261
Steve Hodgson90d683a2010-06-01 11:19:39 +0000262 /* Calculate current fill level, and exit if we don't need to fill */
Ben Hutchings8ceee662008-04-27 12:55:59 +0100263 fill_level = (rx_queue->added_count - rx_queue->removed_count);
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000264 EFX_BUG_ON_PARANOID(fill_level > rx_queue->efx->rxq_entries);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100265 if (fill_level >= rx_queue->fast_fill_trigger)
Steve Hodgson24455802010-06-01 11:20:34 +0000266 goto out;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100267
268 /* Record minimum fill level */
Ben Hutchingsb3475642008-05-16 21:15:49 +0100269 if (unlikely(fill_level < rx_queue->min_fill)) {
Ben Hutchings8ceee662008-04-27 12:55:59 +0100270 if (fill_level)
271 rx_queue->min_fill = fill_level;
Ben Hutchingsb3475642008-05-16 21:15:49 +0100272 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100273
David Riddochda9ca502012-04-11 13:09:24 +0100274 space = rx_queue->max_fill - fill_level;
David Riddoch64235182012-04-11 13:12:41 +0100275 EFX_BUG_ON_PARANOID(space < EFX_RX_BATCH);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100276
Ben Hutchings62776d02010-06-23 11:30:07 +0000277 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev,
278 "RX queue %d fast-filling descriptor ring from"
Alexandre Rames97d48a12013-01-11 12:26:21 +0000279 " level %d to level %d\n",
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000280 efx_rx_queue_index(rx_queue), fill_level,
Alexandre Rames97d48a12013-01-11 12:26:21 +0000281 rx_queue->max_fill);
282
Ben Hutchings8ceee662008-04-27 12:55:59 +0100283
284 do {
Alexandre Rames97d48a12013-01-11 12:26:21 +0000285 rc = efx_init_rx_buffers(rx_queue);
Steve Hodgsonf7d6f372010-06-01 11:33:17 +0000286 if (unlikely(rc)) {
287 /* Ensure that we don't leave the rx queue empty */
288 if (rx_queue->added_count == rx_queue->removed_count)
289 efx_schedule_slow_fill(rx_queue);
290 goto out;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100291 }
292 } while ((space -= EFX_RX_BATCH) >= EFX_RX_BATCH);
293
Ben Hutchings62776d02010-06-23 11:30:07 +0000294 netif_vdbg(rx_queue->efx, rx_status, rx_queue->efx->net_dev,
295 "RX queue %d fast-filled descriptor ring "
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000296 "to level %d\n", efx_rx_queue_index(rx_queue),
Ben Hutchings62776d02010-06-23 11:30:07 +0000297 rx_queue->added_count - rx_queue->removed_count);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100298
299 out:
Steve Hodgson24455802010-06-01 11:20:34 +0000300 if (rx_queue->notified_count != rx_queue->added_count)
301 efx_nic_notify_rx_desc(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100302}
303
Steve Hodgson90d683a2010-06-01 11:19:39 +0000304void efx_rx_slow_fill(unsigned long context)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100305{
Steve Hodgson90d683a2010-06-01 11:19:39 +0000306 struct efx_rx_queue *rx_queue = (struct efx_rx_queue *)context;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100307
Steve Hodgson90d683a2010-06-01 11:19:39 +0000308 /* Post an event to cause NAPI to run and refill the queue */
Ben Hutchings2ae75da2012-02-07 23:49:52 +0000309 efx_nic_generate_fill_event(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100310 ++rx_queue->slow_fill_count;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100311}
312
Ben Hutchings4d566062008-09-01 12:47:12 +0100313static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
314 struct efx_rx_buffer *rx_buf,
Alexandre Rames97d48a12013-01-11 12:26:21 +0000315 int len)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100316{
317 struct efx_nic *efx = rx_queue->efx;
318 unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding;
319
320 if (likely(len <= max_len))
321 return;
322
323 /* The packet must be discarded, but this is only a fatal error
324 * if the caller indicated it was
325 */
Ben Hutchingsdb339562011-08-26 18:05:11 +0100326 rx_buf->flags |= EFX_RX_PKT_DISCARD;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100327
328 if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) {
Ben Hutchings62776d02010-06-23 11:30:07 +0000329 if (net_ratelimit())
330 netif_err(efx, rx_err, efx->net_dev,
331 " RX queue %d seriously overlength "
332 "RX event (0x%x > 0x%x+0x%x). Leaking\n",
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000333 efx_rx_queue_index(rx_queue), len, max_len,
Ben Hutchings62776d02010-06-23 11:30:07 +0000334 efx->type->rx_buffer_padding);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100335 efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY);
336 } else {
Ben Hutchings62776d02010-06-23 11:30:07 +0000337 if (net_ratelimit())
338 netif_err(efx, rx_err, efx->net_dev,
339 " RX queue %d overlength RX event "
340 "(0x%x > 0x%x)\n",
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000341 efx_rx_queue_index(rx_queue), len, max_len);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100342 }
343
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000344 efx_rx_queue_channel(rx_queue)->n_rx_overlength++;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100345}
346
Ben Hutchings61321d92012-02-25 01:58:35 +0000347/* Pass a received packet up through GRO. GRO can handle pages
348 * regardless of checksum state and skbs with a good checksum.
Ben Hutchings8ceee662008-04-27 12:55:59 +0100349 */
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000350static void
351efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf,
352 unsigned int n_frags, u8 *eh)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100353{
Herbert Xuda3bc072009-01-18 21:50:16 -0800354 struct napi_struct *napi = &channel->napi_str;
Ben Hutchings18e1d2b2009-10-29 07:21:24 +0000355 gro_result_t gro_result;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000356 struct efx_nic *efx = channel->efx;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000357 struct sk_buff *skb;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100358
Alexandre Rames97d48a12013-01-11 12:26:21 +0000359 skb = napi_get_frags(napi);
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000360 if (unlikely(!skb)) {
361 while (n_frags--) {
362 put_page(rx_buf->page);
363 rx_buf->page = NULL;
364 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf);
365 }
Alexandre Rames97d48a12013-01-11 12:26:21 +0000366 return;
367 }
Ben Hutchings1241e952009-11-23 16:02:25 +0000368
Alexandre Rames97d48a12013-01-11 12:26:21 +0000369 if (efx->net_dev->features & NETIF_F_RXHASH)
370 skb->rxhash = efx_rx_buf_hash(eh);
Alexandre Rames97d48a12013-01-11 12:26:21 +0000371 skb->ip_summed = ((rx_buf->flags & EFX_RX_PKT_CSUMMED) ?
372 CHECKSUM_UNNECESSARY : CHECKSUM_NONE);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100373
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000374 for (;;) {
375 skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags,
376 rx_buf->page, rx_buf->page_offset,
377 rx_buf->len);
378 rx_buf->page = NULL;
379 skb->len += rx_buf->len;
380 if (skb_shinfo(skb)->nr_frags == n_frags)
381 break;
382
383 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf);
384 }
385
386 skb->data_len = skb->len;
387 skb->truesize += n_frags * efx->rx_buffer_truesize;
388
Alexandre Rames97d48a12013-01-11 12:26:21 +0000389 skb_record_rx_queue(skb, channel->rx_queue.core_index);
Ben Hutchings3eadb7b2009-11-23 16:02:40 +0000390
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000391 gro_result = napi_gro_frags(napi);
Alexandre Rames97d48a12013-01-11 12:26:21 +0000392 if (gro_result != GRO_DROP)
Ben Hutchings18e1d2b2009-10-29 07:21:24 +0000393 channel->irq_mod_score += 2;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000394}
395
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000396/* Allocate and construct an SKB around page fragments */
Alexandre Rames97d48a12013-01-11 12:26:21 +0000397static struct sk_buff *efx_rx_mk_skb(struct efx_channel *channel,
398 struct efx_rx_buffer *rx_buf,
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000399 unsigned int n_frags,
Alexandre Rames97d48a12013-01-11 12:26:21 +0000400 u8 *eh, int hdr_len)
401{
402 struct efx_nic *efx = channel->efx;
403 struct sk_buff *skb;
404
405 /* Allocate an SKB to store the headers */
406 skb = netdev_alloc_skb(efx->net_dev, hdr_len + EFX_PAGE_SKB_ALIGN);
407 if (unlikely(skb == NULL))
408 return NULL;
409
410 EFX_BUG_ON_PARANOID(rx_buf->len < hdr_len);
411
412 skb_reserve(skb, EFX_PAGE_SKB_ALIGN);
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000413 memcpy(__skb_put(skb, hdr_len), eh, hdr_len);
Alexandre Rames97d48a12013-01-11 12:26:21 +0000414
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000415 /* Append the remaining page(s) onto the frag list */
Alexandre Rames97d48a12013-01-11 12:26:21 +0000416 if (rx_buf->len > hdr_len) {
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000417 rx_buf->page_offset += hdr_len;
418 rx_buf->len -= hdr_len;
419
420 for (;;) {
421 skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags,
422 rx_buf->page, rx_buf->page_offset,
423 rx_buf->len);
424 rx_buf->page = NULL;
425 skb->len += rx_buf->len;
426 skb->data_len += rx_buf->len;
427 if (skb_shinfo(skb)->nr_frags == n_frags)
428 break;
429
430 rx_buf = efx_rx_buf_next(&channel->rx_queue, rx_buf);
431 }
Alexandre Rames97d48a12013-01-11 12:26:21 +0000432 } else {
433 __free_pages(rx_buf->page, efx->rx_buffer_order);
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000434 rx_buf->page = NULL;
435 n_frags = 0;
Ben Hutchings18e1d2b2009-10-29 07:21:24 +0000436 }
Alexandre Rames97d48a12013-01-11 12:26:21 +0000437
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000438 skb->truesize += n_frags * efx->rx_buffer_truesize;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000439
440 /* Move past the ethernet header */
441 skb->protocol = eth_type_trans(skb, efx->net_dev);
442
443 return skb;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100444}
445
Ben Hutchings8ceee662008-04-27 12:55:59 +0100446void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000447 unsigned int n_frags, unsigned int len, u16 flags)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100448{
449 struct efx_nic *efx = rx_queue->efx;
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000450 struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100451 struct efx_rx_buffer *rx_buf;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100452
453 rx_buf = efx_rx_buffer(rx_queue, index);
Ben Hutchingsdb339562011-08-26 18:05:11 +0100454 rx_buf->flags |= flags;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100455
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000456 /* Validate the number of fragments and completed length */
457 if (n_frags == 1) {
458 efx_rx_packet__check_len(rx_queue, rx_buf, len);
459 } else if (unlikely(n_frags > EFX_RX_MAX_FRAGS) ||
460 unlikely(len <= (n_frags - 1) * EFX_RX_USR_BUF_SIZE) ||
461 unlikely(len > n_frags * EFX_RX_USR_BUF_SIZE) ||
462 unlikely(!efx->rx_scatter)) {
463 /* If this isn't an explicit discard request, either
464 * the hardware or the driver is broken.
465 */
466 WARN_ON(!(len == 0 && rx_buf->flags & EFX_RX_PKT_DISCARD));
467 rx_buf->flags |= EFX_RX_PKT_DISCARD;
468 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100469
Ben Hutchings62776d02010-06-23 11:30:07 +0000470 netif_vdbg(efx, rx_status, efx->net_dev,
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000471 "RX queue %d received ids %x-%x len %d %s%s\n",
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000472 efx_rx_queue_index(rx_queue), index,
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000473 (index + n_frags - 1) & rx_queue->ptr_mask, len,
Ben Hutchingsdb339562011-08-26 18:05:11 +0100474 (rx_buf->flags & EFX_RX_PKT_CSUMMED) ? " [SUMMED]" : "",
475 (rx_buf->flags & EFX_RX_PKT_DISCARD) ? " [DISCARD]" : "");
Ben Hutchings8ceee662008-04-27 12:55:59 +0100476
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000477 /* Discard packet, if instructed to do so. Process the
478 * previous receive first.
479 */
Ben Hutchingsdb339562011-08-26 18:05:11 +0100480 if (unlikely(rx_buf->flags & EFX_RX_PKT_DISCARD)) {
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000481 efx_rx_flush_packet(channel);
482 efx_recycle_rx_buffers(channel, rx_buf, n_frags);
483 return;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100484 }
485
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000486 if (n_frags == 1)
487 rx_buf->len = len;
488
Ben Hutchings3a68f192012-12-20 18:48:20 +0000489 /* Release and/or sync DMA mapping - assumes all RX buffers
490 * consumed in-order per RX queue
Ben Hutchings8ceee662008-04-27 12:55:59 +0100491 */
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000492 efx_unmap_rx_buffer(efx, rx_buf, rx_buf->len);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100493
494 /* Prefetch nice and early so data will (hopefully) be in cache by
495 * the time we look at it.
496 */
Ben Hutchings5036b7c2013-01-29 23:33:15 +0000497 prefetch(efx_rx_buf_va(rx_buf));
Ben Hutchings8ceee662008-04-27 12:55:59 +0100498
Ben Hutchingsb74e3e82013-01-29 23:33:15 +0000499 rx_buf->page_offset += efx->type->rx_buffer_hash_size;
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000500 rx_buf->len -= efx->type->rx_buffer_hash_size;
501
502 if (n_frags > 1) {
503 /* Release/sync DMA mapping for additional fragments.
504 * Fix length for last fragment.
505 */
506 unsigned int tail_frags = n_frags - 1;
507
508 for (;;) {
509 rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
510 if (--tail_frags == 0)
511 break;
512 efx_unmap_rx_buffer(efx, rx_buf, EFX_RX_USR_BUF_SIZE);
513 }
514 rx_buf->len = len - (n_frags - 1) * EFX_RX_USR_BUF_SIZE;
515 efx_unmap_rx_buffer(efx, rx_buf, rx_buf->len);
516 }
Ben Hutchingsb74e3e82013-01-29 23:33:15 +0000517
Ben Hutchings8ceee662008-04-27 12:55:59 +0100518 /* Pipeline receives so that we give time for packet headers to be
519 * prefetched into cache.
520 */
Ben Hutchingsff734ef2013-01-29 23:33:14 +0000521 efx_rx_flush_packet(channel);
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000522 channel->rx_pkt_n_frags = n_frags;
523 channel->rx_pkt_index = index;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100524}
525
Alexandre Rames97d48a12013-01-11 12:26:21 +0000526static void efx_rx_deliver(struct efx_channel *channel, u8 *eh,
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000527 struct efx_rx_buffer *rx_buf,
528 unsigned int n_frags)
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000529{
530 struct sk_buff *skb;
Alexandre Rames97d48a12013-01-11 12:26:21 +0000531 u16 hdr_len = min_t(u16, rx_buf->len, EFX_SKB_HEADERS);
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000532
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000533 skb = efx_rx_mk_skb(channel, rx_buf, n_frags, eh, hdr_len);
Alexandre Rames97d48a12013-01-11 12:26:21 +0000534 if (unlikely(skb == NULL)) {
535 efx_free_rx_buffer(channel->efx, rx_buf);
536 return;
537 }
538 skb_record_rx_queue(skb, channel->rx_queue.core_index);
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000539
540 /* Set the SKB flags */
541 skb_checksum_none_assert(skb);
542
Stuart Hodgsonc31e5f92012-07-18 09:52:11 +0100543 if (channel->type->receive_skb)
Ben Hutchings4a74dc652013-03-05 20:13:54 +0000544 if (channel->type->receive_skb(channel, skb))
Alexandre Rames97d48a12013-01-11 12:26:21 +0000545 return;
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000546
Ben Hutchings4a74dc652013-03-05 20:13:54 +0000547 /* Pass the packet up */
548 netif_receive_skb(skb);
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000549}
550
Ben Hutchings8ceee662008-04-27 12:55:59 +0100551/* Handle a received packet. Second half: Touches packet payload. */
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000552void __efx_rx_packet(struct efx_channel *channel)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100553{
554 struct efx_nic *efx = channel->efx;
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000555 struct efx_rx_buffer *rx_buf =
556 efx_rx_buffer(&channel->rx_queue, channel->rx_pkt_index);
Ben Hutchingsb74e3e82013-01-29 23:33:15 +0000557 u8 *eh = efx_rx_buf_va(rx_buf);
Ben Hutchings604f6042010-06-25 07:05:33 +0000558
Ben Hutchings3273c2e2008-05-07 13:36:19 +0100559 /* If we're in loopback test, then pass the packet directly to the
560 * loopback layer, and free the rx_buf here
561 */
562 if (unlikely(efx->loopback_selftest)) {
Steve Hodgsona526f142011-02-24 23:45:16 +0000563 efx_loopback_rx_packet(efx, eh, rx_buf->len);
Ben Hutchings3273c2e2008-05-07 13:36:19 +0100564 efx_free_rx_buffer(efx, rx_buf);
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000565 goto out;
Ben Hutchings3273c2e2008-05-07 13:36:19 +0100566 }
567
Ben Hutchingsabfe9032011-04-05 15:00:02 +0100568 if (unlikely(!(efx->net_dev->features & NETIF_F_RXCSUM)))
Ben Hutchingsdb339562011-08-26 18:05:11 +0100569 rx_buf->flags &= ~EFX_RX_PKT_CSUMMED;
Ben Hutchingsab3cf6d2011-04-01 22:20:06 +0100570
Alexandre Rames97d48a12013-01-11 12:26:21 +0000571 if (!channel->type->receive_skb)
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000572 efx_rx_packet_gro(channel, rx_buf, channel->rx_pkt_n_frags, eh);
Ben Hutchings1ddceb42012-01-23 22:41:30 +0000573 else
Ben Hutchings85740cdf2013-01-29 23:33:15 +0000574 efx_rx_deliver(channel, eh, rx_buf, channel->rx_pkt_n_frags);
575out:
576 channel->rx_pkt_n_frags = 0;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100577}
578
579int efx_probe_rx_queue(struct efx_rx_queue *rx_queue)
580{
581 struct efx_nic *efx = rx_queue->efx;
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000582 unsigned int entries;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100583 int rc;
584
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000585 /* Create the smallest power-of-two aligned ring */
586 entries = max(roundup_pow_of_two(efx->rxq_entries), EFX_MIN_DMAQ_SIZE);
587 EFX_BUG_ON_PARANOID(entries > EFX_MAX_DMAQ_SIZE);
588 rx_queue->ptr_mask = entries - 1;
589
Ben Hutchings62776d02010-06-23 11:30:07 +0000590 netif_dbg(efx, probe, efx->net_dev,
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000591 "creating RX queue %d size %#x mask %#x\n",
592 efx_rx_queue_index(rx_queue), efx->rxq_entries,
593 rx_queue->ptr_mask);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100594
595 /* Allocate RX buffers */
Thomas Meyerc2e4e252011-12-02 12:36:13 +0000596 rx_queue->buffer = kcalloc(entries, sizeof(*rx_queue->buffer),
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000597 GFP_KERNEL);
Ben Hutchings8831da72008-09-01 12:47:48 +0100598 if (!rx_queue->buffer)
599 return -ENOMEM;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100600
Ben Hutchings152b6a62009-11-29 03:43:56 +0000601 rc = efx_nic_probe_rx(rx_queue);
Ben Hutchings8831da72008-09-01 12:47:48 +0100602 if (rc) {
603 kfree(rx_queue->buffer);
604 rx_queue->buffer = NULL;
605 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100606 return rc;
607}
608
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +0100609void efx_init_rx_queue(struct efx_rx_queue *rx_queue)
Ben Hutchings8ceee662008-04-27 12:55:59 +0100610{
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000611 struct efx_nic *efx = rx_queue->efx;
David Riddoch64235182012-04-11 13:12:41 +0100612 unsigned int max_fill, trigger, max_trigger;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100613
Ben Hutchings62776d02010-06-23 11:30:07 +0000614 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev,
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000615 "initialising RX queue %d\n", efx_rx_queue_index(rx_queue));
Ben Hutchings8ceee662008-04-27 12:55:59 +0100616
617 /* Initialise ptr fields */
618 rx_queue->added_count = 0;
619 rx_queue->notified_count = 0;
620 rx_queue->removed_count = 0;
621 rx_queue->min_fill = -1U;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100622
623 /* Initialise limit fields */
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000624 max_fill = efx->rxq_entries - EFX_RXD_HEAD_ROOM;
David Riddoch64235182012-04-11 13:12:41 +0100625 max_trigger = max_fill - EFX_RX_BATCH;
626 if (rx_refill_threshold != 0) {
627 trigger = max_fill * min(rx_refill_threshold, 100U) / 100U;
628 if (trigger > max_trigger)
629 trigger = max_trigger;
630 } else {
631 trigger = max_trigger;
632 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100633
634 rx_queue->max_fill = max_fill;
635 rx_queue->fast_fill_trigger = trigger;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100636
637 /* Set up RX descriptor ring */
Ben Hutchings9f2cb712012-02-08 00:11:20 +0000638 rx_queue->enabled = true;
Ben Hutchings152b6a62009-11-29 03:43:56 +0000639 efx_nic_init_rx(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100640}
641
642void efx_fini_rx_queue(struct efx_rx_queue *rx_queue)
643{
644 int i;
645 struct efx_rx_buffer *rx_buf;
646
Ben Hutchings62776d02010-06-23 11:30:07 +0000647 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev,
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000648 "shutting down RX queue %d\n", efx_rx_queue_index(rx_queue));
Ben Hutchings8ceee662008-04-27 12:55:59 +0100649
Ben Hutchings9f2cb712012-02-08 00:11:20 +0000650 /* A flush failure might have left rx_queue->enabled */
651 rx_queue->enabled = false;
652
Steve Hodgson90d683a2010-06-01 11:19:39 +0000653 del_timer_sync(&rx_queue->slow_fill);
Ben Hutchings152b6a62009-11-29 03:43:56 +0000654 efx_nic_fini_rx(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100655
656 /* Release RX buffers NB start at index 0 not current HW ptr */
657 if (rx_queue->buffer) {
Steve Hodgsonecc910f2010-09-10 06:42:22 +0000658 for (i = 0; i <= rx_queue->ptr_mask; i++) {
Ben Hutchings8ceee662008-04-27 12:55:59 +0100659 rx_buf = efx_rx_buffer(rx_queue, i);
660 efx_fini_rx_buffer(rx_queue, rx_buf);
661 }
662 }
Ben Hutchings8ceee662008-04-27 12:55:59 +0100663}
664
665void efx_remove_rx_queue(struct efx_rx_queue *rx_queue)
666{
Ben Hutchings62776d02010-06-23 11:30:07 +0000667 netif_dbg(rx_queue->efx, drv, rx_queue->efx->net_dev,
Ben Hutchingsba1e8a32010-09-10 06:41:36 +0000668 "destroying RX queue %d\n", efx_rx_queue_index(rx_queue));
Ben Hutchings8ceee662008-04-27 12:55:59 +0100669
Ben Hutchings152b6a62009-11-29 03:43:56 +0000670 efx_nic_remove_rx(rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100671
672 kfree(rx_queue->buffer);
673 rx_queue->buffer = NULL;
Ben Hutchings8ceee662008-04-27 12:55:59 +0100674}
675
Ben Hutchings8ceee662008-04-27 12:55:59 +0100676
Ben Hutchings8ceee662008-04-27 12:55:59 +0100677module_param(rx_refill_threshold, uint, 0444);
678MODULE_PARM_DESC(rx_refill_threshold,
David Riddoch64235182012-04-11 13:12:41 +0100679 "RX descriptor ring refill threshold (%)");
Ben Hutchings8ceee662008-04-27 12:55:59 +0100680