diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-07 11:31:17 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-03-07 15:22:14 -0500 |
commit | 179ea7f039f68ae4247a340bfb59fd861e7def12 (patch) | |
tree | 1cbbfe3b56674737df34b26fff87deabe99dd800 /drivers/net/ethernet/sfc | |
parent | 2768935a46603bb9bdd121864b1f2b2e8a71cccc (diff) |
sfc: Replace efx_rx_is_last_buffer() with a flag
This condition is brittle and we have lots of flags to spare.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc')
-rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/rx.c | 17 |
2 files changed, 7 insertions, 11 deletions
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 370c5bcebad9..e22e75c8f635 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -228,6 +228,7 @@ struct efx_rx_buffer { | |||
228 | u16 len; | 228 | u16 len; |
229 | u16 flags; | 229 | u16 flags; |
230 | }; | 230 | }; |
231 | #define EFX_RX_BUF_LAST_IN_PAGE 0x0001 | ||
231 | #define EFX_RX_PKT_CSUMMED 0x0002 | 232 | #define EFX_RX_PKT_CSUMMED 0x0002 |
232 | #define EFX_RX_PKT_DISCARD 0x0004 | 233 | #define EFX_RX_PKT_DISCARD 0x0004 |
233 | 234 | ||
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index eea56f3ec81c..4cc2ba48a912 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c | |||
@@ -95,14 +95,6 @@ static inline void efx_sync_rx_buffer(struct efx_nic *efx, | |||
95 | DMA_FROM_DEVICE); | 95 | DMA_FROM_DEVICE); |
96 | } | 96 | } |
97 | 97 | ||
98 | /* Return true if this is the last RX buffer using a page. */ | ||
99 | static inline bool efx_rx_is_last_buffer(struct efx_nic *efx, | ||
100 | struct efx_rx_buffer *rx_buf) | ||
101 | { | ||
102 | return (rx_buf->page_offset >= (PAGE_SIZE >> 1) || | ||
103 | efx->rx_dma_len > EFX_RX_HALF_PAGE); | ||
104 | } | ||
105 | |||
106 | /* Check the RX page recycle ring for a page that can be reused. */ | 98 | /* Check the RX page recycle ring for a page that can be reused. */ |
107 | static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue) | 99 | static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue) |
108 | { | 100 | { |
@@ -199,11 +191,14 @@ static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue) | |||
199 | if ((~count & 1) && (efx->rx_dma_len <= EFX_RX_HALF_PAGE)) { | 191 | if ((~count & 1) && (efx->rx_dma_len <= EFX_RX_HALF_PAGE)) { |
200 | /* Use the second half of the page */ | 192 | /* Use the second half of the page */ |
201 | get_page(page); | 193 | get_page(page); |
194 | rx_buf->flags = 0; | ||
202 | dma_addr += (PAGE_SIZE >> 1); | 195 | dma_addr += (PAGE_SIZE >> 1); |
203 | page_offset += (PAGE_SIZE >> 1); | 196 | page_offset += (PAGE_SIZE >> 1); |
204 | ++count; | 197 | ++count; |
205 | goto split; | 198 | goto split; |
206 | } | 199 | } |
200 | |||
201 | rx_buf->flags = EFX_RX_BUF_LAST_IN_PAGE; | ||
207 | } | 202 | } |
208 | 203 | ||
209 | return 0; | 204 | return 0; |
@@ -247,7 +242,7 @@ static void efx_recycle_rx_page(struct efx_channel *channel, | |||
247 | unsigned index; | 242 | unsigned index; |
248 | 243 | ||
249 | /* Only recycle the page after processing the final buffer. */ | 244 | /* Only recycle the page after processing the final buffer. */ |
250 | if (!efx_rx_is_last_buffer(efx, rx_buf)) | 245 | if (!(rx_buf->flags & EFX_RX_BUF_LAST_IN_PAGE)) |
251 | return; | 246 | return; |
252 | 247 | ||
253 | index = rx_queue->page_add & rx_queue->page_ptr_mask; | 248 | index = rx_queue->page_add & rx_queue->page_ptr_mask; |
@@ -278,7 +273,7 @@ static void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue, | |||
278 | put_page(rx_buf->page); | 273 | put_page(rx_buf->page); |
279 | 274 | ||
280 | /* If this is the last buffer in a page, unmap and free it. */ | 275 | /* If this is the last buffer in a page, unmap and free it. */ |
281 | if (efx_rx_is_last_buffer(rx_queue->efx, rx_buf)) { | 276 | if (rx_buf->flags & EFX_RX_BUF_LAST_IN_PAGE) { |
282 | efx_unmap_rx_buffer(rx_queue->efx, rx_buf); | 277 | efx_unmap_rx_buffer(rx_queue->efx, rx_buf); |
283 | efx_free_rx_buffer(rx_buf); | 278 | efx_free_rx_buffer(rx_buf); |
284 | } | 279 | } |
@@ -507,7 +502,7 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, | |||
507 | struct efx_rx_buffer *rx_buf; | 502 | struct efx_rx_buffer *rx_buf; |
508 | 503 | ||
509 | rx_buf = efx_rx_buffer(rx_queue, index); | 504 | rx_buf = efx_rx_buffer(rx_queue, index); |
510 | rx_buf->flags = flags; | 505 | rx_buf->flags |= flags; |
511 | 506 | ||
512 | /* Validate the number of fragments and completed length */ | 507 | /* Validate the number of fragments and completed length */ |
513 | if (n_frags == 1) { | 508 | if (n_frags == 1) { |