aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2010-06-25 03:05:33 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-26 00:03:30 -0400
commit604f6049ba2af86fe361d4cc320443d35b232df1 (patch)
tree21c5cc57e19fb477f86b67170c0eb1c0ff0fe1cf
parent29046f9b1e36f6e3332ce2d8e366005fd177b37a (diff)
sfc: Fix reading of inserted hash
The hash appears immediately before the packet data, not at the beginning of the buffer. This means we can easily use negative offsets from the start of packet data, so adjust the data and length at the top of __efx_rx_packet() instead of wherever we consume the hash. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/sfc/rx.c11
-rw-r--r--drivers/net/sfc/selftest.c3
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 0fb98355a092..799c461ce7b8 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -104,9 +104,9 @@ static inline unsigned int efx_rx_buf_size(struct efx_nic *efx)
104static inline u32 efx_rx_buf_hash(struct efx_rx_buffer *buf) 104static inline u32 efx_rx_buf_hash(struct efx_rx_buffer *buf)
105{ 105{
106#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0 106#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) || NET_IP_ALIGN % 4 == 0
107 return __le32_to_cpup((const __le32 *)buf->data); 107 return __le32_to_cpup((const __le32 *)(buf->data - 4));
108#else 108#else
109 const u8 *data = (const u8 *)buf->data; 109 const u8 *data = (const u8 *)(buf->data - 4);
110 return ((u32)data[0] | 110 return ((u32)data[0] |
111 (u32)data[1] << 8 | 111 (u32)data[1] << 8 |
112 (u32)data[2] << 16 | 112 (u32)data[2] << 16 |
@@ -469,8 +469,6 @@ static void efx_rx_packet_lro(struct efx_channel *channel,
469 469
470 if (efx->net_dev->features & NETIF_F_RXHASH) 470 if (efx->net_dev->features & NETIF_F_RXHASH)
471 skb->rxhash = efx_rx_buf_hash(rx_buf); 471 skb->rxhash = efx_rx_buf_hash(rx_buf);
472 rx_buf->data += efx->type->rx_buffer_hash_size;
473 rx_buf->len -= efx->type->rx_buffer_hash_size;
474 472
475 skb_shinfo(skb)->frags[0].page = page; 473 skb_shinfo(skb)->frags[0].page = page;
476 skb_shinfo(skb)->frags[0].page_offset = 474 skb_shinfo(skb)->frags[0].page_offset =
@@ -577,6 +575,9 @@ void __efx_rx_packet(struct efx_channel *channel,
577 struct efx_nic *efx = channel->efx; 575 struct efx_nic *efx = channel->efx;
578 struct sk_buff *skb; 576 struct sk_buff *skb;
579 577
578 rx_buf->data += efx->type->rx_buffer_hash_size;
579 rx_buf->len -= efx->type->rx_buffer_hash_size;
580
580 /* If we're in loopback test, then pass the packet directly to the 581 /* If we're in loopback test, then pass the packet directly to the
581 * loopback layer, and free the rx_buf here 582 * loopback layer, and free the rx_buf here
582 */ 583 */
@@ -589,11 +590,11 @@ void __efx_rx_packet(struct efx_channel *channel,
589 if (rx_buf->skb) { 590 if (rx_buf->skb) {
590 prefetch(skb_shinfo(rx_buf->skb)); 591 prefetch(skb_shinfo(rx_buf->skb));
591 592
593 skb_reserve(rx_buf->skb, efx->type->rx_buffer_hash_size);
592 skb_put(rx_buf->skb, rx_buf->len); 594 skb_put(rx_buf->skb, rx_buf->len);
593 595
594 if (efx->net_dev->features & NETIF_F_RXHASH) 596 if (efx->net_dev->features & NETIF_F_RXHASH)
595 rx_buf->skb->rxhash = efx_rx_buf_hash(rx_buf); 597 rx_buf->skb->rxhash = efx_rx_buf_hash(rx_buf);
596 skb_pull(rx_buf->skb, efx->type->rx_buffer_hash_size);
597 598
598 /* Move past the ethernet header. rx_buf->data still points 599 /* Move past the ethernet header. rx_buf->data still points
599 * at the ethernet header */ 600 * at the ethernet header */
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 0399be21c122..85f015f005d5 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -258,9 +258,6 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
258 258
259 payload = &state->payload; 259 payload = &state->payload;
260 260
261 buf_ptr += efx->type->rx_buffer_hash_size;
262 pkt_len -= efx->type->rx_buffer_hash_size;
263
264 received = (struct efx_loopback_payload *) buf_ptr; 261 received = (struct efx_loopback_payload *) buf_ptr;
265 received->ip.saddr = payload->ip.saddr; 262 received->ip.saddr = payload->ip.saddr;
266 if (state->offload_csum) 263 if (state->offload_csum)