From: Ben Hutchings <bhutchings@solarflare.com>
To: Jonas Bonn <jonas@southpole.se>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 4/8] ethoc: prevent overflow of rx counter
Date: Wed, 24 Nov 2010 16:30:13 +0000 [thread overview]
Message-ID: <1290616213.3013.600.camel@localhost> (raw)
In-Reply-To: <1290606058-26703-5-git-send-email-jonas@southpole.se>
On Wed, 2010-11-24 at 14:40 +0100, Jonas Bonn wrote:
> Rewind cur_rx to prevent it from overflowing.
>
> Signed-off-by: Jonas Bonn <jonas@southpole.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;
> +
Division is expensive; you should either use masking (if priv->num_rx is
guaranteed to be a power of 2) or check for overflow whenever you
increment priv->cur_rx:
if (++priv->cur_rx == priv->num_rx)
priv->cur_rx = 0;
Ben.
> for (count = 0; count < limit; ++count) {
> unsigned int entry;
> struct ethoc_bd bd;
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2010-11-24 16:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 13:40 ethoc driver updates Jonas Bonn
2010-11-24 13:40 ` [PATCH 1/8] ethoc: Add device tree configuration Jonas Bonn
2010-11-24 19:35 ` David Miller
2010-11-24 13:40 ` [PATCH 2/8] ethoc: remove unused spinlock Jonas Bonn
2010-11-24 13:40 ` [PATCH 3/8] ethoc: enable interrupts after napi_complete Jonas Bonn
2010-11-24 18:45 ` Laurent Chavey
[not found] ` <AANLkTim=Y6NGk8MSq=hJTrBKaYuk4SJ_7wA=f+UBy3d0@mail.gmail.com>
2010-11-24 19:33 ` Laurent Chavey
2010-11-24 13:40 ` [PATCH 4/8] ethoc: prevent overflow of rx counter Jonas Bonn
2010-11-24 16:30 ` Ben Hutchings [this message]
2010-11-24 17:34 ` Eric Dumazet
2010-11-24 19:36 ` David Miller
2010-11-24 13:40 ` [PATCH 5/8] ethoc: Double check pending RX packet Jonas Bonn
2010-11-24 19:37 ` David Miller
2010-11-24 13:40 ` [PATCH 6/8] ethoc: rework interrupt handling Jonas Bonn
2010-11-24 19:38 ` David Miller
2010-11-24 13:40 ` [PATCH 7/8] ethoc: rework mdio read/write Jonas Bonn
2010-11-24 13:40 ` [PATCH 8/8] ethoc: fix function return type Jonas Bonn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290616213.3013.600.camel@localhost \
--to=bhutchings@solarflare.com \
--cc=jonas@southpole.se \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).