netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: David Miller <davem@davemloft.net>, Arnd Bergmann <arnd@arndb.de>,
	netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: Re: [PATCH 1/2] net: Enable 64-bit net device statistics on 32-bit architectures
Date: Thu, 3 Jun 2010 11:47:38 -0700	[thread overview]
Message-ID: <20100603114738.41256434@nehalam> (raw)
In-Reply-To: <1275586744.2106.22.camel@achroite.uk.solarflarecom.com>

On Thu, 03 Jun 2010 18:39:04 +0100
Ben Hutchings <bhutchings@solarflare.com> wrote:

> #if BITS_PER_LONG == 64
> +#define NET_DEVICE_STATS_DEFINE(name)	u64 name
> +#define RTNL_LINK_STATS64_READ(stats, name)				\
> +	ACCESS_ONCE((stats)->name)
> +#define RTNL_LINK_STATS64_READ_OFFSET(stats, offset)			\
> +	ACCESS_ONCE((const u64 *)((const u8 *)(stats) + (offset)))
> +#define RTNL_LINK_STATS64_READ32(stats, name)				\
> +	((u32)ACCESS_ONCE((stats)->name))
> +#else
> +#if defined(__LITTLE_ENDIAN)
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 name, pad_ ## name
> +#define RTNL_LINK_STATS64_READ_OFFSET(stats, offset)			\
> +	(ACCESS_ONCE(*(const u32 *)((const u8 *)(stats) + (offset))) |	\
> +	 (u64)(*(const u32 *)((const u8 *)(stats) + (offset) + 4)) << 32)
> +#define RTNL_LINK_STATS64_READ32(stats, name)				\
> +	(((const volatile u32 *)&(stats)->name)[0])
> +#else
> +#define NET_DEVICE_STATS_DEFINE(name)	u32 pad_ ## name, name
> +#define RTNL_LINK_STATS64_READ_OFFSET(stats, offset)			\
> +	((u64)(*(const u32 *)((const u8 *)(stats) + (offset))) << 32 |	\
> +	 ACCESS_ONCE(*(const u32 *)((const u8 *)(stats) + (offset) + 4)))
> +#define RTNL_LINK_STATS64_READ32(stats, name)				\
> +	(((const volatile u32 *)&(stats)->name)[1])
> +#endif
> +#define RTNL_LINK_STATS64_READ(stats, name)				\
> +	RTNL_LINK_STATS64_READ_OFFSET(					\
> +		stats, offsetof(struct rtnl_link_stats64, name))
> +#endif

Macros... with multiple casts. Gack

-- 

  reply	other threads:[~2010-06-03 18:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-25 14:19 [PATCH] r8169: Add counters tx_bytes and rx_bytes for ethtool Junchang Wang
2010-05-25 19:56 ` Francois Romieu
2010-05-26  1:01   ` Junchang Wang
2010-05-25 23:15 ` David Miller
2010-05-26  0:51   ` Junchang Wang
2010-06-02 21:34   ` 64-bit net_device_stats Ben Hutchings
2010-06-02 21:59     ` Stephen Hemminger
2010-06-02 23:38       ` Arnd Bergmann
2010-06-03 14:51         ` Ben Hutchings
2010-06-03 17:39           ` [PATCH 1/2] net: Enable 64-bit net device statistics on 32-bit architectures Ben Hutchings
2010-06-03 18:47             ` Stephen Hemminger [this message]
2010-06-03 19:11               ` Ben Hutchings
2010-06-04 17:28                 ` Stephen Hemminger
2010-06-04 18:15                   ` Ben Hutchings
2010-06-04 20:39                     ` Stephen Hemminger
2010-06-04 20:47                       ` Ben Hutchings
2010-06-03 17:40           ` [PATCH 2/2] sfc: Implement 64-bit net device statistics on all architectures Ben Hutchings
2010-06-04  1:59     ` 64-bit net_device_stats Junchang Wang
2010-06-04  3:59       ` Eric Dumazet

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=20100603114738.41256434@nehalam \
    --to=shemminger@vyatta.com \
    --cc=arnd@arndb.de \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.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).