Commit ae8509b1 authored by Brice Goglin's avatar Brice Goglin Committed by Jeff Garzik

myri10ge: fix management of the firmware 4KB boundary crossing restriction

Simpler way of dealing with the firmware 4KB boundary crossing
restriction for rx buffers.  This fixes a variety of memory
corruption issues when using an "uncommon" MTU with a 16KB
page size.
Signed-off-by: default avatarBrice Goglin <brice@myri.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 6cdbd77e
...@@ -900,19 +900,9 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, ...@@ -900,19 +900,9 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
/* try to refill entire ring */ /* try to refill entire ring */
while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) { while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) {
idx = rx->fill_cnt & rx->mask; idx = rx->fill_cnt & rx->mask;
if (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE) {
if ((bytes < MYRI10GE_ALLOC_SIZE / 2) &&
(rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE)) {
/* we can use part of previous page */ /* we can use part of previous page */
get_page(rx->page); get_page(rx->page);
#if MYRI10GE_ALLOC_SIZE > 4096
/* Firmware cannot cross 4K boundary.. */
if ((rx->page_offset >> 12) !=
((rx->page_offset + bytes - 1) >> 12)) {
rx->page_offset =
(rx->page_offset + bytes) & ~4095;
}
#endif
} else { } else {
/* we need a new page */ /* we need a new page */
page = page =
...@@ -941,6 +931,13 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, ...@@ -941,6 +931,13 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
/* start next packet on a cacheline boundary */ /* start next packet on a cacheline boundary */
rx->page_offset += SKB_DATA_ALIGN(bytes); rx->page_offset += SKB_DATA_ALIGN(bytes);
#if MYRI10GE_ALLOC_SIZE > 4096
/* don't cross a 4KB boundary */
if ((rx->page_offset >> 12) !=
((rx->page_offset + bytes - 1) >> 12))
rx->page_offset = (rx->page_offset + 4096) & ~4095;
#endif
rx->fill_cnt++; rx->fill_cnt++;
/* copy 8 descriptors to the firmware at a time */ /* copy 8 descriptors to the firmware at a time */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment