Commit 5176da7e authored by Baruch Siach's avatar Baruch Siach Committed by David S. Miller

enc28j60: Fix sporadic packet loss (corrected again)

Packet data read from the RX buffer the when the RSV is at the end of the RX
buffer does not warp around. This causes packet loss, as the actual data is
never read. Fix this by calculating the right packet data location.

Thanks to Shachar Shemesh for suggesting the fix.
Signed-off-by: default avatarBaruch Siach <baruch@tkos.co.il>
Acked-by: default avatarClaudio Lanconelli <lanconelli.claudio@eptar.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd091410
...@@ -568,6 +568,17 @@ static u16 erxrdpt_workaround(u16 next_packet_ptr, u16 start, u16 end) ...@@ -568,6 +568,17 @@ static u16 erxrdpt_workaround(u16 next_packet_ptr, u16 start, u16 end)
return erxrdpt; return erxrdpt;
} }
/*
* Calculate wrap around when reading beyond the end of the RX buffer
*/
static u16 rx_packet_start(u16 ptr)
{
if (ptr + RSV_SIZE > RXEND_INIT)
return (ptr + RSV_SIZE) - (RXEND_INIT - RXSTART_INIT + 1);
else
return ptr + RSV_SIZE;
}
static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end) static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end)
{ {
u16 erxrdpt; u16 erxrdpt;
...@@ -938,7 +949,8 @@ static void enc28j60_hw_rx(struct net_device *ndev) ...@@ -938,7 +949,8 @@ static void enc28j60_hw_rx(struct net_device *ndev)
skb->dev = ndev; skb->dev = ndev;
skb_reserve(skb, NET_IP_ALIGN); skb_reserve(skb, NET_IP_ALIGN);
/* copy the packet from the receive buffer */ /* copy the packet from the receive buffer */
enc28j60_mem_read(priv, priv->next_pk_ptr + sizeof(rsv), enc28j60_mem_read(priv,
rx_packet_start(priv->next_pk_ptr),
len, skb_put(skb, len)); len, skb_put(skb, len));
if (netif_msg_pktdata(priv)) if (netif_msg_pktdata(priv))
dump_packet(__func__, skb->len, skb->data); dump_packet(__func__, skb->len, skb->data);
......
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