# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/01/09 06:47:00-05:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# include/linux/netdevice.h
#   2004/01/09 06:46:56-05:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/01/09 06:43:13-05:00 jeffpc@optonline.net 
#   [WATCH64] Use u64 instead of u_int64_t
# 
# kernel/watch64.c
#   2004/01/09 06:43:06-05:00 jeffpc@optonline.net +4 -4
#   Use u64 instead of u_int64_t
# 
# include/linux/watch64.h
#   2004/01/09 06:43:06-05:00 jeffpc@optonline.net +2 -2
#   Use u64 instead of u_int64_t
# 
# Documentation/watch64.txt
#   2004/01/09 06:43:06-05:00 jeffpc@optonline.net +1 -1
#   Use u64 instead of u_int64_t
# 
# ChangeSet
#   2004/01/03 23:11:07-05:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# net/core/dev.c
#   2004/01/03 23:11:02-05:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/12/28 22:35:24-05:00 jeffpc@optonline.net 
#   Manual Merge
# 
# include/linux/netdevice.h
#   2003/12/28 22:35:18-05:00 jeffpc@optonline.net +1 -0
#   Extra space
# 
# net/core/net-sysfs.c
#   2003/12/28 22:31:34-05:00 jeffpc@optonline.net +0 -0
#   Auto merged
# 
# net/core/dev.c
#   2003/12/28 22:31:34-05:00 jeffpc@optonline.net +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/10/20 06:56:02-04:00 jeffpc@jeff.home 
#   Added watch64 API description (Documentation/watch64.txt)
# 
# Documentation/00-INDEX
#   2003/10/20 06:55:56-04:00 jeffpc@jeff.home +2 -0
#   watch64 API description added
# 
# Documentation/watch64.txt
#   2003/10/20 06:55:03-04:00 jeffpc@jeff.home +35 -0
# 
# Documentation/watch64.txt
#   2003/10/20 06:55:03-04:00 jeffpc@jeff.home +0 -0
#   BitKeeper file /home/jeffpc/linux/linux-watch64-work/Documentation/watch64.txt
# 
# ChangeSet
#   2003/10/16 22:43:47-04:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# net/core/dev.c
#   2003/10/16 22:43:42-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# include/linux/netdevice.h
#   2003/10/16 22:43:42-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/10/16 22:13:56-04:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-2.5
#   into jeff.home:/home/jeffpc/linux/linux-watch64
# 
# kernel/Makefile
#   2003/10/16 22:13:51-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/10/03 21:13:10-04:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# net/core/dev.c
#   2003/10/03 21:13:05-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/09/27 23:00:40-04:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# net/core/net-sysfs.c
#   2003/09/27 23:00:27-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# net/core/dev.c
#   2003/09/27 23:00:27-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# include/linux/netdevice.h
#   2003/09/27 23:00:26-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/09/27 20:54:43-04:00 jeffpc@optonline.net 
#   __foo() for watch64_find(), watch64_disable(), watch64_enable()
#   Removed unneeded error check (from very old code)
#   Fix rcu_read_{un,}lock() bugs
# 
# kernel/watch64.c
#   2003/09/27 20:54:35-04:00 jeffpc@optonline.net +84 -21
#   __foo() for watch64_find(), watch64_disable(), watch64_enable()
#   Removed unneeded error check (from very old code)
#   Fix rcu_read_{un,}lock() bugs
# 
# include/linux/watch64.h
#   2003/09/27 20:54:35-04:00 jeffpc@optonline.net +3 -0
#   __foo() for watch64_find(), watch64_disable(), watch64_enable()
# 
# ChangeSet
#   2003/09/27 18:44:16-04:00 jeffpc@optonline.net 
#   RCU
# 
# kernel/watch64.c
#   2003/09/27 18:44:08-04:00 jeffpc@optonline.net +25 -15
#   RCU
# 
# include/linux/watch64.h
#   2003/09/27 18:44:08-04:00 jeffpc@optonline.net +3 -1
#   RCU
# 
# ChangeSet
#   2003/09/25 22:52:20-04:00 jeffpc@jeff.home 
#   #include is a good thing (tm)
# 
# net/core/net-sysfs.c
#   2003/09/25 22:52:13-04:00 jeffpc@jeff.home +1 -0
#   #include is a good thing (tm)
# 
# ChangeSet
#   2003/09/25 22:40:03-04:00 jeffpc@jeff.home 
#   FIX: need to return a pointer not the value itself
# 
# net/core/net-sysfs.c
#   2003/09/25 22:39:55-04:00 jeffpc@jeff.home +1 -1
#   FIX: need to return a pointer not the value itself
# 
# ChangeSet
#   2003/09/23 17:45:39-04:00 jeffpc@jeff.home 
#   sysfs support
# 
# net/core/net-sysfs.c
#   2003/09/23 17:45:29-04:00 jeffpc@jeff.home +3 -2
#   sysfs support
# 
# ChangeSet
#   2003/09/23 06:56:37-04:00 jeffpc@jeff.home 
#   Merge jeff.home:/home/jeffpc/linux/linux-watch64
#   into jeff.home:/home/jeffpc/linux/linux-64network
# 
# net/core/dev.c
#   2003/09/23 06:56:33-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# include/linux/netdevice.h
#   2003/09/23 06:56:33-04:00 jeffpc@jeff.home +0 -0
#   Auto merged
# 
# ChangeSet
#   2003/09/21 11:42:14-04:00 jeffpc@jeff.home 
#   Added copyright notice
# 
# net/core/dev.c
#   2003/09/21 11:42:07-04:00 jeffpc@jeff.home +2 -0
#   Added copyright notice
# 
# include/linux/netdevice.h
#   2003/09/21 11:42:07-04:00 jeffpc@jeff.home +1 -0
#   Added copyright notice
# 
# ChangeSet
#   2003/09/21 11:27:35-04:00 jeffpc@jeff.home 
#   Added copyright notice
# 
# kernel/watch64.c
#   2003/09/21 11:27:27-04:00 jeffpc@jeff.home +11 -0
#   Added copyright notice
# 
# include/linux/watch64.h
#   2003/09/21 11:27:27-04:00 jeffpc@jeff.home +11 -0
#   Added copyright notice
# 
# ChangeSet
#   2003/09/21 11:08:57-04:00 jeffpc@jeff.home 
#   64network.patch
# 
# net/core/dev.c
#   2003/09/20 23:10:18-04:00 jeffpc@jeff.home +125 -18
#   Import patch 64network.patch
# 
# include/linux/netdevice.h
#   2003/09/20 23:12:39-04:00 jeffpc@jeff.home +3 -0
#   Import patch 64network.patch
# 
# ChangeSet
#   2003/09/21 11:05:26-04:00 jeffpc@jeff.home 
#   watch64.patch
# 
# kernel/watch64.c
#   2003/09/20 23:09:22-04:00 jeffpc@jeff.home +308 -0
#   Import patch watch64.patch
# 
# kernel/watch64.c
#   2003/09/20 23:09:22-04:00 jeffpc@jeff.home +0 -0
#   BitKeeper file /home/jeffpc/linux/linux-watch64/kernel/watch64.c
# 
# kernel/Makefile
#   2003/09/20 23:07:26-04:00 jeffpc@jeff.home +2 -1
#   Import patch watch64.patch
# 
# include/linux/watch64.h
#   2003/09/20 23:13:02-04:00 jeffpc@jeff.home +47 -0
#   Import patch watch64.patch
# 
# include/linux/watch64.h
#   2003/09/20 23:13:02-04:00 jeffpc@jeff.home +0 -0
#   BitKeeper file /home/jeffpc/linux/linux-watch64/include/linux/watch64.h
# 
diff -Nru a/Documentation/00-INDEX b/Documentation/00-INDEX
--- a/Documentation/00-INDEX	Fri Jan  9 03:48:49 2004
+++ b/Documentation/00-INDEX	Fri Jan  9 03:48:49 2004
@@ -230,6 +230,8 @@
 	- directory with info regarding video/TV/radio cards and linux.
 vm/
 	- directory with info on the Linux vm code.
+watch64.txt
+	- watch64 API description
 watchdog.txt
 	- how to auto-reboot Linux if it has "fallen and can't get up". ;-)
 x86_64/
diff -Nru a/Documentation/watch64.txt b/Documentation/watch64.txt
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/Documentation/watch64.txt	Fri Jan  9 03:48:49 2004
@@ -0,0 +1,35 @@
+int watch64_register(unsigned long* ptr, unsigned int interval);
+
+	- Registers *ptr to be monitored every interval jiffies.
+	- If interval==0, WATCH64_INTERVAL will be used (HZ/10 by default)
+
+int watch64_unregister(unsigned long* ptr, struct watch64* st);
+
+	- Unregister *ptr
+	- st is optional pointer to the struct containing the registration
+		information
+	- if st==NULL, it will be looked up automatically
+
+struct watch64* watch64_find(unsigned long* ptr);
+
+	- Return struct with registration information of *ptr
+
+int watch64_disable(unsigned long* ptr, struct watch64* st);
+
+	- Disable *ptr from being monitored, without removing it from the list
+	- st is optional (see watch64_unregister for more information)
+
+int watch64_enable(unsigned long* ptr, struct watch64* st);
+
+	- Enable *ptr from being monitored (opposite of watch64_disable)
+	- st is optional (see watch64_unregister for more information)
+
+int watch64_toggle(unsigned long* ptr, struct watch64* st);
+
+	- Toggle the enable/disable status
+	- st is optional (see watch64_unregister for more information)
+
+inline u64 watch64_getval(unsigned long* ptr, struct watch64* st);
+
+	- Return the whole 64-bit counter
+	- st is optional (see watch64_unregister for more information)
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
--- a/include/linux/netdevice.h	Fri Jan  9 03:48:49 2004
+++ b/include/linux/netdevice.h	Fri Jan  9 03:48:49 2004
@@ -14,6 +14,7 @@
  *		Alan Cox, <Alan.Cox@linux.org>
  *		Bjorn Ekwall. <bj0rn@blox.se>
  *              Pekka Riikonen <priikone@poseidon.pspt.fi>
+ *		Josef "Jeff" Sipek <jeffpc@optonline.net>
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -910,6 +911,10 @@
 #ifdef CONFIG_SYSCTL
 extern char *net_sysctl_strdup(const char *s);
 #endif
+
+/* Register/unregister all the members of struct net_device_stats with watch64 */
+inline void		net_register_stats64(struct net_device_stats* stats);
+inline void		net_unregister_stats64(struct net_device_stats* stats);
 
 #endif /* __KERNEL__ */
 
diff -Nru a/include/linux/watch64.h b/include/linux/watch64.h
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/include/linux/watch64.h	Fri Jan  9 03:48:49 2004
@@ -0,0 +1,63 @@
+/*
+ *  inclue/linux/watch64.h
+ *
+ *  Copyright (C) 2003 Josef "Jeff" Sipek <jeffpc@optonline.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _LINUX_64WATCH_H
+#define _LINUX_64WATCH_H
+
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/kernel.h>
+#include <linux/seqlock.h>
+#include <linux/rcupdate.h>
+
+#define WATCH64_INTERVAL	(HZ/10)
+#define WATCH64_MINIMUM		(HZ/20)
+#define WATCH64_MAGIC		0x573634
+
+#if (BITS_PER_LONG == 64)
+
+struct watch64 {
+};
+
+#else
+
+struct watch64 {
+	struct list_head list;
+	unsigned long *ptr;
+	unsigned long oldval;
+	u64 total;
+	unsigned int interval;
+	int active;
+	seqlock_t lock;
+	struct rcu_head rcuhead;
+};
+
+#endif /* (BITS_PER_LONG == 64) */
+
+/*
+ *   Prototypes
+ */
+
+void watch64_init(void);
+void watch64_run(unsigned long var);
+int watch64_register(unsigned long* ptr, unsigned int interval);
+int watch64_unregister(unsigned long* ptr, struct watch64* st);
+void watch64_rcufree(void* p);
+struct watch64* watch64_find(unsigned long* ptr);
+inline struct watch64* __watch64_find(unsigned long* ptr);
+int watch64_disable(unsigned long* ptr, struct watch64* st);
+inline int __watch64_disable(unsigned long* ptr, struct watch64* st);
+int watch64_enable(unsigned long* ptr, struct watch64* st);
+inline int __watch64_enable(unsigned long* ptr, struct watch64* st);
+int watch64_toggle(unsigned long* ptr, struct watch64* st);
+inline u64 watch64_getval(unsigned long* ptr, struct watch64* st);
+
+#endif /* _LINUX_WATCH64_H */
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile	Fri Jan  9 03:48:49 2004
+++ b/kernel/Makefile	Fri Jan  9 03:48:49 2004
@@ -6,7 +6,8 @@
 	    exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
-	    rcupdate.o intermodule.o extable.o params.o posix-timers.o
+	    rcupdate.o intermodule.o extable.o params.o posix-timers.o \
+	    watch64.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
diff -Nru a/kernel/watch64.c b/kernel/watch64.c
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ b/kernel/watch64.c	Fri Jan  9 03:48:49 2004
@@ -0,0 +1,392 @@
+/*
+ *  kernel/watch64.c
+ *
+ *  Copyright (C) 2003 Josef "Jeff" Sipek <jeffpc@optonline.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+ 
+#include <asm/param.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/kernel.h>
+#include <linux/seqlock.h>
+#include <linux/spinlock.h>
+#include <linux/rcupdate.h>
+#include <linux/watch64.h>
+
+/*
+ *   Watch64 global variables
+ */
+
+spinlock_t watch64_biglock = SPIN_LOCK_UNLOCKED;
+LIST_HEAD(watch64_head);
+struct timer_list watch64_timer;
+int watch64_setup;
+
+#if (BITS_PER_LONG == 64)
+
+void watch64_init(void)
+{
+}
+
+void watch64_run(unsigned long var)
+{
+}
+
+int watch64_register(unsigned long* ptr, unsigned int interval)
+{
+	return 0;
+}
+
+int watch64_unregister(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+void watch64_rcufree(void* p)
+{
+}
+
+struct watch64* watch64_find(unsigned long* ptr)
+{
+	return NULL;
+}
+
+struct watch64* __watch64_find(unsigned long* ptr)
+{
+	return NULL;
+}
+
+int watch64_disable(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+int __watch64_disable(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+int watch64_enable(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+int __watch64_enable(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+int watch64_toggle(unsigned long* ptr, struct watch64* st)
+{
+	return 0;
+}
+
+inline u64 watch64_getval(unsigned long* ptr, struct watch64* st)
+{
+	return (u64) *ptr;
+}
+
+#else
+
+/*
+ *   Initiate watch64 system
+ */
+
+void watch64_init(void)
+{
+	spin_lock(&watch64_biglock);
+	
+	if (watch64_setup==WATCH64_MAGIC) {
+		spin_unlock(&watch64_biglock);
+		return;
+	}
+	
+	printk(KERN_WARNING "watch64: 2003/08/22 Josef 'Jeff' Sipek <jeffpc@optonline.net>\n");
+	printk(KERN_WARNING "watch64: Enabling Watch64 extensions...");
+
+	init_timer(&watch64_timer);
+	watch64_timer.function = watch64_run;
+	watch64_timer.data = (unsigned long) NULL;
+	watch64_timer.expires = jiffies + WATCH64_MINIMUM;
+	add_timer(&watch64_timer);
+
+	printk("done.\n");
+	
+	watch64_setup = WATCH64_MAGIC;
+	
+	spin_unlock(&watch64_biglock);
+}
+
+/*
+ *   Go through the list of registered variables and check them for changes
+ */
+
+void watch64_run(unsigned long var)
+{
+	struct list_head* entry;
+	struct watch64* watch_struct;
+	unsigned long tmp;
+
+	rcu_read_lock();
+	list_for_each_rcu(entry, &watch64_head) {
+		watch_struct = list_entry(entry, struct watch64, list);
+		if (*watch_struct->ptr != watch_struct->oldval) {
+			tmp = *watch_struct->ptr;
+			if (tmp > watch_struct->oldval) {
+				write_seqlock(&watch_struct->lock);
+				watch_struct->total += tmp - watch_struct->oldval;
+				write_sequnlock(&watch_struct->lock);
+			} else if (tmp < watch_struct->oldval) {
+				write_seqlock(&watch_struct->lock);
+				watch_struct->total += ((u_int64_t) 1<<BITS_PER_LONG) - watch_struct->oldval + tmp;
+				write_sequnlock(&watch_struct->lock);
+			}
+			watch_struct->oldval = tmp;
+		}
+	}
+	rcu_read_unlock();
+	
+	mod_timer(&watch64_timer, jiffies + WATCH64_MINIMUM);
+}
+
+/*
+ *   Register a new variable with watch64
+ */
+
+int watch64_register(unsigned long* ptr, unsigned int interval)
+{
+	struct watch64* temp;
+	
+	temp = (struct watch64*) kmalloc(sizeof(struct watch64),GFP_ATOMIC);
+
+	if (!temp)
+		return -ENOMEM;
+
+	if (watch64_setup!=WATCH64_MAGIC)
+		watch64_init();
+
+	temp->ptr = ptr;
+	temp->oldval = 0;
+	temp->total = 0;
+	if (interval==0)
+		temp->interval = WATCH64_INTERVAL;
+	else if (interval<WATCH64_MINIMUM) {
+		temp->interval = WATCH64_MINIMUM;
+		printk("watch64: attempted to add new watch with interval below %d jiffies",WATCH64_MINIMUM);
+	} else
+		temp->interval = interval;
+
+	temp->active = 0;
+	
+	seqlock_init(&temp->lock);
+
+	list_add_rcu(&temp->list, &watch64_head);
+
+	return 0;
+}
+
+/*
+ *   Unregister a variable with watch64
+ */
+
+int watch64_unregister(unsigned long* ptr, struct watch64* st)
+{
+	rcu_read_lock();
+	if (!st)
+		st = __watch64_find(ptr); 
+
+	if (!st)
+		return -EINVAL;
+
+	__watch64_disable(ptr, st);
+	list_del_rcu(&st->list);
+	
+	call_rcu(&st->rcuhead, watch64_rcufree, st);
+	rcu_read_unlock();
+
+	return 0;
+}
+
+/*
+ *   Free memory via RCU
+ */
+ 
+void watch64_rcufree(void* p)
+{
+	kfree((struct watch64*) p);
+}
+
+/*
+ *   Find watch64 structure with RCU lock
+ */
+
+struct watch64* watch64_find(unsigned long* ptr)
+{
+	struct watch64* tmp;
+	
+	rcu_read_lock();
+	tmp = __watch64_find(ptr);
+	rcu_read_unlock();
+	
+	return tmp;
+}
+
+/*
+ *   Find watch64 structure without RCU lock
+ */
+
+inline struct watch64* __watch64_find(unsigned long* ptr)
+{
+	struct list_head* tmp;
+	struct watch64* watch64_struct;
+
+	list_for_each_rcu(tmp, &watch64_head) {
+		watch64_struct = list_entry(tmp, struct watch64, list);
+		if (watch64_struct->ptr==ptr)
+			return watch64_struct;
+	}
+
+	return NULL;
+}
+
+/*
+ *   Disable a variable watch with RCU lock
+ */
+
+int watch64_disable(unsigned long* ptr, struct watch64* st)
+{
+	int tmp;
+	
+	rcu_read_lock();
+	tmp = __watch64_disable(ptr,st);
+	rcu_read_unlock();
+	
+	return tmp;
+}
+ 
+/*
+ *   Disable a variable watch without RCU lock
+ */
+
+inline int __watch64_disable(unsigned long* ptr, struct watch64* st)
+{
+	if (!st)
+		st = watch64_find(ptr);
+
+	if (!st)
+		return -EINVAL;
+
+	st->active = 0;
+
+	return 0;
+}
+
+/*
+ *   Enable a variable watch with RCU lock
+ */
+
+int watch64_enable(unsigned long* ptr, struct watch64* st)
+{
+	int tmp;
+	
+	rcu_read_lock();
+	tmp = __watch64_enable(ptr,st);
+	rcu_read_unlock();
+	
+	return tmp;
+}
+ 
+/*
+ *   Enable a variable watch without RCU lock
+ */
+
+inline int __watch64_enable(unsigned long* ptr, struct watch64* st)
+{
+	if (!st)
+		st = __watch64_find(ptr);
+
+	if (!st)
+		return -EINVAL;
+
+	st->oldval = *ptr;
+	write_seqlock(&st->lock);
+	st->total  = (u_int64_t) st->oldval;
+	write_sequnlock(&st->lock);
+	st->active = 1;
+
+	return 0;
+}
+
+/*
+ *   Toggle a variable watch
+ */
+
+int watch64_toggle(unsigned long* ptr, struct watch64* st)
+{
+	rcu_read_lock();
+	if (!st)
+		st = __watch64_find(ptr);
+
+	if (!st) {
+		rcu_read_unlock();
+		return -EINVAL;
+	}
+
+	if (st->active)
+		__watch64_disable(ptr,st);
+	else
+		__watch64_enable(ptr,st);
+	rcu_read_unlock();
+
+	return 0;
+}
+
+/*
+ *   Return the total 64-bit value
+ */
+
+inline u64 watch64_getval(unsigned long* ptr, struct watch64* st)
+{
+	unsigned int seq;
+	u64 total;
+
+	rcu_read_lock();
+	if (!st)
+		st = __watch64_find(ptr);
+
+	if (!st) {
+		rcu_read_unlock();
+		return *ptr;
+	}
+
+	do {
+		seq = read_seqbegin(&st->lock);
+		total = st->total;
+	} while (read_seqretry(&st->lock, seq));
+	rcu_read_unlock();
+	
+	return total;
+}
+
+#endif /* (BITS_PER_LONG == 64) */
+
+/*
+ *   Export all the necessary symbols
+ */
+
+EXPORT_SYMBOL(watch64_register);
+EXPORT_SYMBOL(watch64_unregister);
+EXPORT_SYMBOL(watch64_find);
+EXPORT_SYMBOL(watch64_disable);
+EXPORT_SYMBOL(watch64_enable);
+EXPORT_SYMBOL(watch64_toggle);
+EXPORT_SYMBOL(watch64_getval);
diff -Nru a/net/core/dev.c b/net/core/dev.c
--- a/net/core/dev.c	Fri Jan  9 03:48:49 2004
+++ b/net/core/dev.c	Fri Jan  9 03:48:49 2004
@@ -18,6 +18,7 @@
  *		Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
  *		Adam Sulmicki <adam@cfar.umd.edu>
  *              Pekka Riikonen <priikone@poesidon.pspt.fi>
+ *		Josef "Jeff" Sipek <jeffpc@optonline.net>
  *
  *	Changes:
  *              D.J. Barrow     :       Fixed bug where dev->refcnt gets set
@@ -70,6 +71,7 @@
  *              			indefinitely on dev->refcnt
  * 		J Hadi Salim	:	- Backlog queue sampling
  *				        - netif_rx() feedback
+ *	Josef "Jeff" Sipek	:	Added watch64 calls for network statistics
  */
 
 #include <asm/uaccess.h>
@@ -105,6 +107,7 @@
 #include <linux/kmod.h>
 #include <linux/module.h>
 #include <linux/kallsyms.h>
+#include <linux/watch64.h>
 #ifdef CONFIG_NET_RADIO
 #include <linux/wireless.h>		/* Note : will define WIRELESS_EXT */
 #include <net/iw_handler.h>
@@ -1875,23 +1878,31 @@
 	struct net_device_stats *stats = dev->get_stats ? dev->get_stats(dev) :
 							  NULL;
 	if (stats)
-		seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
-				"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
-			   dev->name, stats->rx_bytes, stats->rx_packets,
-			   stats->rx_errors,
-			   stats->rx_dropped + stats->rx_missed_errors,
-			   stats->rx_fifo_errors,
-			   stats->rx_length_errors + stats->rx_over_errors +
-			     stats->rx_crc_errors + stats->rx_frame_errors,
-			   stats->rx_compressed, stats->multicast,
-			   stats->tx_bytes, stats->tx_packets,
-			   stats->tx_errors, stats->tx_dropped,
-			   stats->tx_fifo_errors, stats->collisions,
-			   stats->tx_carrier_errors +
-			     stats->tx_aborted_errors +
-			     stats->tx_window_errors +
-			     stats->tx_heartbeat_errors,
-			   stats->tx_compressed);
+		seq_printf(seq, "%6s:%8llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
+				"%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
+			   dev->name, watch64_getval(&stats->rx_bytes,NULL),
+			   watch64_getval(&stats->rx_packets,NULL),
+			   watch64_getval(&stats->rx_errors,NULL),
+			   watch64_getval(&stats->rx_dropped,NULL) +
+			     watch64_getval(&stats->rx_missed_errors,NULL),
+			   watch64_getval(&stats->rx_fifo_errors,NULL),
+			   watch64_getval(&stats->rx_length_errors,NULL) + 
+			     watch64_getval(&stats->rx_over_errors,NULL) +
+			     watch64_getval(&stats->rx_crc_errors,NULL) +
+			     watch64_getval(&stats->rx_frame_errors,NULL),
+			   watch64_getval(&stats->rx_compressed,NULL),
+			   watch64_getval(&stats->multicast,NULL),
+			   watch64_getval(&stats->tx_bytes,NULL),
+			   watch64_getval(&stats->tx_packets,NULL),
+			   watch64_getval(&stats->tx_errors,NULL),
+			   watch64_getval(&stats->tx_dropped,NULL),
+			   watch64_getval(&stats->tx_fifo_errors,NULL),
+			   watch64_getval(&stats->collisions,NULL),
+			   watch64_getval(&stats->tx_carrier_errors,NULL) +
+			     watch64_getval(&stats->tx_aborted_errors,NULL) +
+			     watch64_getval(&stats->tx_window_errors,NULL) +
+			     watch64_getval(&stats->tx_heartbeat_errors,NULL),
+			   watch64_getval(&stats->tx_compressed,NULL));
 	else
 		seq_printf(seq, "%6s: No statistics available.\n", dev->name);
 }
@@ -2703,6 +2714,9 @@
 	 *	device is present.
 	 */
 
+	if (dev->get_stats)
+		net_register_stats64(dev->get_stats(dev));
+	
 	set_bit(__LINK_STATE_PRESENT, &dev->state);
 
 	dev->next = NULL;
@@ -2712,7 +2726,7 @@
 	dev_hold(dev);
 	dev->reg_state = NETREG_REGISTERING;
 	write_unlock_bh(&dev_base_lock);
-
+	
 	/* Notify protocols, that a new device appeared. */
 	notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
 
@@ -2925,6 +2939,9 @@
 	/* If device is running, close it first. */
 	if (dev->flags & IFF_UP)
 		dev_close(dev);
+		
+	if (dev->get_stats)
+		net_unregister_stats64(dev->get_stats(dev));
 
 	/* And unlink it from device chain. */
 	for (dp = &dev_base; (d = *dp) != NULL; dp = &d->next) {
@@ -2978,6 +2995,98 @@
 	return 0;
 }
 
+/*
+ *	Register all the members of the net_device_stats structure
+ *
+ */
+ 
+inline void net_register_stats64(struct net_device_stats* stats)
+{
+	if (!stats)
+		return;
+
+	watch64_register(&stats->tx_packets,0);
+	watch64_enable  (&stats->tx_packets,NULL);
+	watch64_register(&stats->rx_packets,0);
+	watch64_enable  (&stats->rx_packets,NULL);
+	watch64_register(&stats->tx_bytes,0);
+	watch64_enable  (&stats->tx_bytes,NULL);
+	watch64_register(&stats->rx_bytes,0);
+	watch64_enable  (&stats->rx_bytes,NULL);
+	watch64_register(&stats->tx_errors,0);
+	watch64_enable  (&stats->tx_errors,NULL);
+	watch64_register(&stats->rx_errors,0);
+	watch64_enable  (&stats->rx_errors,NULL);
+	watch64_register(&stats->tx_dropped,0);
+	watch64_enable  (&stats->tx_dropped,NULL);
+	watch64_register(&stats->rx_dropped,0);
+	watch64_enable  (&stats->rx_dropped,NULL);
+	watch64_register(&stats->multicast,0);
+	watch64_enable  (&stats->multicast,NULL);
+	watch64_register(&stats->collisions,0);
+	watch64_enable  (&stats->collisions,NULL);
+	watch64_register(&stats->rx_length_errors,0);
+	watch64_enable  (&stats->rx_length_errors,NULL);
+	watch64_register(&stats->rx_over_errors,0);
+	watch64_enable  (&stats->rx_over_errors,NULL);
+	watch64_register(&stats->rx_crc_errors,0);
+	watch64_enable  (&stats->rx_crc_errors,NULL);
+	watch64_register(&stats->rx_frame_errors,0);
+	watch64_enable  (&stats->rx_frame_errors,NULL);
+	watch64_register(&stats->rx_fifo_errors,0);
+	watch64_enable  (&stats->rx_fifo_errors,NULL);
+	watch64_register(&stats->rx_missed_errors,0);
+	watch64_enable  (&stats->rx_missed_errors,NULL);
+	watch64_register(&stats->tx_aborted_errors,0);
+	watch64_enable  (&stats->tx_aborted_errors,NULL);
+	watch64_register(&stats->tx_carrier_errors,0);
+	watch64_enable  (&stats->tx_carrier_errors,NULL);
+	watch64_register(&stats->tx_fifo_errors,0);
+	watch64_enable  (&stats->tx_fifo_errors,NULL);
+	watch64_register(&stats->tx_heartbeat_errors,0);
+	watch64_enable  (&stats->tx_heartbeat_errors,NULL);
+	watch64_register(&stats->tx_window_errors,0);
+	watch64_enable  (&stats->tx_window_errors,NULL);
+	watch64_register(&stats->rx_compressed,0);
+	watch64_enable  (&stats->rx_compressed,NULL);
+	watch64_register(&stats->tx_compressed,0);
+	watch64_enable  (&stats->tx_compressed,NULL);
+}
+
+/*
+ *	Unregister all the members of the net_device_stats structure
+ *
+ */
+ 
+inline void net_unregister_stats64(struct net_device_stats* stats)
+{
+	if (!stats)
+		return;
+
+	watch64_unregister(&stats->tx_packets,0);
+	watch64_unregister(&stats->rx_packets,0);
+	watch64_unregister(&stats->tx_bytes,0);
+	watch64_unregister(&stats->rx_bytes,0);
+	watch64_unregister(&stats->tx_errors,0);
+	watch64_unregister(&stats->rx_errors,0);
+	watch64_unregister(&stats->tx_dropped,0);
+	watch64_unregister(&stats->rx_dropped,0);
+	watch64_unregister(&stats->multicast,0);
+	watch64_unregister(&stats->collisions,0);
+	watch64_unregister(&stats->rx_length_errors,0);
+	watch64_unregister(&stats->rx_over_errors,0);
+	watch64_unregister(&stats->rx_crc_errors,0);
+	watch64_unregister(&stats->rx_frame_errors,0);
+	watch64_unregister(&stats->rx_fifo_errors,0);
+	watch64_unregister(&stats->rx_missed_errors,0);
+	watch64_unregister(&stats->tx_aborted_errors,0);
+	watch64_unregister(&stats->tx_carrier_errors,0);
+	watch64_unregister(&stats->tx_fifo_errors,0);
+	watch64_unregister(&stats->tx_heartbeat_errors,0);
+	watch64_unregister(&stats->tx_window_errors,0);
+	watch64_unregister(&stats->rx_compressed,0);
+	watch64_unregister(&stats->tx_compressed,0);
+}
 
 /*
  *	Initialize the DEV module. At boot time this walks the device list and
diff -Nru a/net/core/net-sysfs.c b/net/core/net-sysfs.c
--- a/net/core/net-sysfs.c	Fri Jan  9 03:48:49 2004
+++ b/net/core/net-sysfs.c	Fri Jan  9 03:48:49 2004
@@ -16,6 +16,7 @@
 #include <net/sock.h>
 #include <linux/rtnetlink.h>
 #include <linux/wireless.h>
+#include <linux/watch64.h>
 
 #define to_class_dev(obj) container_of(obj,struct class_device,kobj)
 #define to_net_dev(class) container_of(class, struct net_device, class_dev)
@@ -23,6 +24,7 @@
 static const char *fmt_hex = "%#x\n";
 static const char *fmt_dec = "%d\n";
 static const char *fmt_ulong = "%lu\n";
+static const char *fmt_ullong = "%llu\n";
 
 static inline int dev_isalive(const struct net_device *dev) 
 {
@@ -204,8 +206,8 @@
 	read_lock(&dev_base_lock);
 	if (dev_isalive(dev) && dev->get_stats &&
 	    (stats = (*dev->get_stats)(dev))) 
-		ret = sprintf(buf, fmt_ulong,
-			      *(unsigned long *)(((u8 *) stats) + offset));
+		ret = sprintf(buf, fmt_ullong,
+			      watch64_getval((unsigned long *)(((u8 *) stats) + offset),NULL));
 
 	read_unlock(&dev_base_lock);
 	return ret;
