netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Rabau <pr2345@gmail.com>
To: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] bnx2: Save statistics during reset.
Date: Mon, 18 Jan 2010 22:41:14 -0600	[thread overview]
Message-ID: <719756751001182041wbb1f648r3f02d1b4366b8fa1@mail.gmail.com> (raw)
In-Reply-To: <719756751001182031i50981b30y4dd9c3beea3785de@mail.gmail.com>

This patch has already been applied, but seems to have a problem.

> MTU changes, ring size changes, etc cause the chip to be reset and the
> statisctics flushed.  To keep track of the accumulated statistics, we
> add code to save the whole statistics block before reset.  We also
> modify the macros and statistics functions to return the sum of the
> saved and current counters.
>
> Based on original patch by Breno Leitao <leitao@xxxxxxxxxxxxxxxxxx>
>
> Signed-off-by: Michael Chan <mchan@xxxxxxxxxxxx>
> ---
>  drivers/net/bnx2.c |   64 +++++++++++++++++++++++++++++++++++++++++++++------
>  drivers/net/bnx2.h |    1 +
>  2 files changed, 57 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index 47fb508..d83512d 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c

...

> @@ -6542,6 +6544,30 @@ bnx2_close(struct net_device *dev)
>        return 0;
>  }
>
> +static void
> +bnx2_save_stats(struct bnx2 *bp)
> +{
> +       u32 *hw_stats = (u32 *) bp->stats_blk;
> +       u32 *temp_stats = (u32 *) bp->temp_stats_blk;
> +       int i;
> +
> +       /* The 1st 10 counters are 64-bit counters */
> +       for (i = 0; i < 20; i += 2) {
> +               u32 hi;
> +               u64 lo;
> +
> +               hi = *(temp_stats + i) + *(hw_stats + i);
> +               lo = *(temp_stats + i + 1) + *(hw_stats + i + 1);

The rhs of the assignment above will always have type u32,
because temp_stats and hw_stats have type pointer to u32.
Would need to cast before doing the addition, otherwise
declaring lo as u64 is not doing anything.

I think it would also be more readable to use array indexing
notation in various places.  For example:
  hi = temp_stats[i] + hs_stats[i];
  lo = (u64)temp_stats[i + 1] + (u64)hw_stats[i + 1];

> +               if (lo > 0xffffffff)
> +                       hi++;
> +               *(temp_stats + i) = hi;
> +               *(temp_stats + i + 1) = lo & 0xffffffff;
> +       }
> +
> +       for ( ; i < sizeof(struct statistics_block) / 4; i++)
> +               *(temp_stats + i) = *(temp_stats + i) + *(hw_stats + i);
> +}
>

-- PR

       reply	other threads:[~2010-01-19  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <719756751001182031i50981b30y4dd9c3beea3785de@mail.gmail.com>
2010-01-19  4:41 ` Patrick Rabau [this message]
2010-01-17 17:30 [PATCH net-next 1/2] bnx2: Refine statistics code Michael Chan
2010-01-17 17:30 ` [PATCH net-next 2/2] bnx2: Save statistics during reset Michael Chan
2010-01-18  3:16   ` David Miller

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=719756751001182041wbb1f648r3f02d1b4366b8fa1@mail.gmail.com \
    --to=pr2345@gmail.com \
    --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).