[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1290620067.3464.80.camel@edumazet-laptop>
Date: Wed, 24 Nov 2010 18:34:27 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Jonas Bonn <jonas@...thpole.se>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH 4/8] ethoc: prevent overflow of rx counter
Le mercredi 24 novembre 2010 à 14:40 +0100, Jonas Bonn a écrit :
> Rewind cur_rx to prevent it from overflowing.
>
> Signed-off-by: Jonas Bonn <jonas@...thpole.se>
> ---
> drivers/net/ethoc.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
> index 53c03f2..7d1b5d8 100644
> --- a/drivers/net/ethoc.c
> +++ b/drivers/net/ethoc.c
> @@ -408,6 +408,9 @@ static int ethoc_rx(struct net_device *dev, int limit)
> struct ethoc *priv = netdev_priv(dev);
> int count;
>
> + /* Prevent overflow of priv->cur_rx by rewinding it */
> + priv->cur_rx = priv->cur_rx % priv->num_rx;
> +
> for (count = 0; count < limit; ++count) {
> unsigned int entry;
> struct ethoc_bd bd;
Hmm... please try following code instead (no divides)
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index c5a2fe0..591b698 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -413,7 +413,7 @@ static int ethoc_rx(struct net_device *dev, int limit)
unsigned int entry;
struct ethoc_bd bd;
- entry = priv->num_tx + (priv->cur_rx % priv->num_rx);
+ entry = priv->num_tx + priv->cur_rx;
ethoc_read_bd(priv, entry, &bd);
if (bd.stat & RX_BD_EMPTY)
break;
@@ -446,7 +446,8 @@ static int ethoc_rx(struct net_device *dev, int limit)
bd.stat &= ~RX_BD_STATS;
bd.stat |= RX_BD_EMPTY;
ethoc_write_bd(priv, entry, &bd);
- priv->cur_rx++;
+ if (++priv->cur_rx == priv->num_rx)
+ priv->cur_rx = 0;
}
return count;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists