From 8bd14260c1a6d6f6b0b7c0dd106408b563e7dfee Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 25 Aug 2003 05:06:04 -0500 Subject: [PATCH] make scsi logging level a sysctl The logging level is now controlled by a /proc/sys/dev/scsi/logging_level sysctl instead of /proc/scsi/scsi. The format is the same as the logging_level module parameter. --- include/linux/sysctl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index c48edf4a551e..38c43d95a616 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -603,7 +603,8 @@ enum { DEV_HWMON=2, DEV_PARPORT=3, DEV_RAID=4, - DEV_MAC_HID=5 + DEV_MAC_HID=5, + DEV_SCSI=6, }; /* /proc/sys/dev/cdrom */ @@ -664,6 +665,11 @@ enum { DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES=6 }; +/* /proc/sys/dev/scsi */ +enum { + DEV_SCSI_LOGGING_LEVEL=1, +}; + /* /proc/sys/abi */ enum { -- cgit v1.2.3 From db390c0eaee3da6990b39810c3cb811c724f6299 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 3 Sep 2003 10:35:52 -0700 Subject: [NET]: DLCI driver cleanups for 2.6.x - keep list of arrays for devices and use a lock - make sure header is contiguous before overlaying data structure - dynamically allocate dev->priv with alloc_netdev - get rid of MOD_INC/DEC - free devices on module unload - keep refcount on slave device's since holding a ptr --- drivers/net/wan/dlci.c | 129 +++++++++++++++++++++++------------------------- include/linux/if_frad.h | 4 +- 2 files changed, 66 insertions(+), 67 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c index 5aab67436cc7..380bb830d738 100644 --- a/drivers/net/wan/dlci.c +++ b/drivers/net/wan/dlci.c @@ -55,14 +55,13 @@ #include #include -static const char devname[] = "dlci"; static const char version[] = "DLCI driver v0.35, 4 Jan 1997, mike.mclagan@linux.org"; -static struct net_device *open_dev[CONFIG_DLCI_COUNT]; - +static LIST_HEAD(dlci_devs); +static spinlock_t dlci_dev_lock = SPIN_LOCK_UNLOCKED; static char *basename[16]; -int dlci_init(struct net_device *dev); +static void dlci_setup(struct net_device *); /* allow FRAD's to register their name as a valid FRAD */ int register_frad(const char *name) @@ -115,6 +114,7 @@ int unregister_frad(const char *name) return(0); } +EXPORT_SYMBOL(unregister_frad); /* * these encapsulate the RFC 1490 requirements as well as @@ -168,6 +168,14 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev) int process, header; dlp = dev->priv; + if (!pskb_may_pull(skb, sizeof(*hdr))) { + printk(KERN_NOTICE "%s: invalid data no header\n", + dev->name); + dlp->stats.rx_errors++; + kfree_skb(skb); + return; + } + hdr = (struct frhdr *) skb->data; process = 0; header = 0; @@ -277,7 +285,7 @@ static int dlci_transmit(struct sk_buff *skb, struct net_device *dev) return(ret); } -int dlci_config(struct net_device *dev, struct dlci_conf *conf, int get) +static int dlci_config(struct net_device *dev, struct dlci_conf *conf, int get) { struct dlci_conf config; struct dlci_local *dlp; @@ -311,7 +319,7 @@ int dlci_config(struct net_device *dev, struct dlci_conf *conf, int get) return(0); } -int dlci_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +static int dlci_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct dlci_local *dlp; @@ -401,21 +409,23 @@ static struct net_device_stats *dlci_get_stats(struct net_device *dev) return(&dlp->stats); } -int dlci_add(struct dlci_add *dlci) +static int dlci_add(struct dlci_add *dlci) { - struct net_device *master, *slave; + struct net_device *master, *slave; struct dlci_local *dlp; struct frad_local *flp; int err, i; - char buf[10]; + /* validate slave device */ - slave = __dev_get_by_name(dlci->devname); + slave = dev_get_by_name(dlci->devname); if (!slave) return(-ENODEV); - if (slave->type != ARPHRD_FRAD) + if (slave->type != ARPHRD_FRAD) { + dev_put(slave); return(-EINVAL); + } /* check for registration */ for (i=0;idevname) > strlen(basename[i]))) break; - if (i == sizeof(basename) / sizeof(char *)) + if (i == sizeof(basename) / sizeof(char *)) { + dev_put(slave); return(-EINVAL); - - /* check for too many open devices : should this be dynamic ? */ - for(i=0;iname, buf); - master->init = dlci_init; - master->flags = 0; + } err = register_netdev(master); - if (err < 0) - { + if (err < 0) { + dev_put(slave); kfree(master); return(err); } @@ -459,64 +458,65 @@ int dlci_add(struct dlci_add *dlci) dlp = (struct dlci_local *) master->priv; dlp->slave = slave; + dlp->master = master; flp = slave->priv; err = flp ? (*flp->assoc)(slave, master) : -EINVAL; if (err < 0) { unregister_netdev(master); - kfree(master->priv); - kfree(master); + dev_put(slave); + free_netdev(master); return(err); } - strcpy(dlci->devname, buf); - open_dev[i] = master; - MOD_INC_USE_COUNT; + strcpy(dlci->devname, master->name); + + spin_lock_bh(&dlci_dev_lock); + list_add(&dlp->list, &dlci_devs); + spin_unlock_bh(&dlci_dev_lock); + return(0); } -int dlci_del(struct dlci_add *dlci) +static int dlci_del(struct dlci_add *dlci) { struct dlci_local *dlp; struct frad_local *flp; - struct net_device *master, *slave; - int i, err; + struct net_device *master, *slave; + int err; /* validate slave device */ master = __dev_get_by_name(dlci->devname); if (!master) return(-ENODEV); - if (netif_running(master)) + if (netif_running(master)) { return(-EBUSY); + } dlp = master->priv; slave = dlp->slave; flp = slave->priv; err = (*flp->deassoc)(slave, master); - if (err) + if (err) return(err); - unregister_netdev(master); - for(i=0;ilist); + spin_unlock_bh(&dlci_dev_lock); - if (ipriv); + dev_put(slave); free_netdev(master); - MOD_DEC_USE_COUNT; - return(0); } -int dlci_ioctl(unsigned int cmd, void *arg) +static int dlci_ioctl(unsigned int cmd, void *arg) { struct dlci_add add; int err; @@ -548,16 +548,9 @@ int dlci_ioctl(unsigned int cmd, void *arg) return(err); } -int dlci_init(struct net_device *dev) +static void dlci_setup(struct net_device *dev) { - struct dlci_local *dlp; - - dev->priv = kmalloc(sizeof(struct dlci_local), GFP_KERNEL); - if (!dev->priv) - return(-ENOMEM); - - memset(dev->priv, 0, sizeof(struct dlci_local)); - dlp = dev->priv; + struct dlci_local *dlp = dev->priv; dev->flags = 0; dev->open = dlci_open; @@ -573,9 +566,7 @@ int dlci_init(struct net_device *dev) dev->type = ARPHRD_DLCI; dev->hard_header_len = sizeof(struct frhdr); dev->addr_len = sizeof(short); - memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); - return(0); } int __init init_dlci(void) @@ -584,9 +575,6 @@ int __init init_dlci(void) dlci_ioctl_set(dlci_ioctl); printk("%s.\n", version); - - for(i=0;imaster); + dev_put(dlp->slave); + free_netdev(dlp->master); + } + } module_init(init_dlci); diff --git a/include/linux/if_frad.h b/include/linux/if_frad.h index 975aad03d762..3d9fc5d43803 100644 --- a/include/linux/if_frad.h +++ b/include/linux/if_frad.h @@ -155,9 +155,11 @@ struct frhdr struct dlci_local { struct net_device_stats stats; - struct net_device *slave; + struct net_device *master; + struct net_device *slave; struct dlci_conf config; int configured; + struct list_head list; /* callback function */ void (*receive)(struct sk_buff *skb, struct net_device *); -- cgit v1.2.3 From 775b235696ae07bf126a355ebe3b9d7fb7fa3aa0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 3 Sep 2003 10:37:09 -0700 Subject: [NET]: Add probe_old_netdevs() hook. This set of patches is a mixture of Al's work to device initialization, and some of my own to complete it for all the ether, tr, sbni, and loopback devices. The first patch adds the hook for converting old driver initialization code over to dynamic allocation. This part extracted from Al viro's set of net driver changes for ethertap. --- drivers/net/Space.c | 6 ++++++ include/linux/netdevice.h | 1 + net/core/dev.c | 2 ++ 3 files changed, 9 insertions(+) (limited to 'include/linux') diff --git a/drivers/net/Space.c b/drivers/net/Space.c index 46777c8dcf18..275c32627507 100644 --- a/drivers/net/Space.c +++ b/drivers/net/Space.c @@ -382,6 +382,12 @@ static int __init ethif_probe(struct net_device *dev) return -ENODEV; } +/* Statically configured drivers -- order matters here. */ +void probe_old_netdevs(void) +{ + +} + #ifdef CONFIG_SDLA extern int sdla_init(struct net_device *); static struct net_device sdla0_dev = { diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index dfc1aa47f35c..f2a63e8004d6 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -498,6 +498,7 @@ extern struct net_device loopback_dev; /* The loopback */ extern struct net_device *dev_base; /* All devices */ extern rwlock_t dev_base_lock; /* Device list lock */ +extern void probe_old_netdevs(void); extern int netdev_boot_setup_add(char *name, struct ifmap *map); extern int netdev_boot_setup_check(struct net_device *dev); extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr); diff --git a/net/core/dev.c b/net/core/dev.c index fe8976f4e757..1ac07dc5077e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3098,6 +3098,8 @@ static int __init net_dev_init(void) dev_boot_phase = 0; + probe_old_netdevs(); + open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL); open_softirq(NET_RX_SOFTIRQ, net_rx_action, NULL); -- cgit v1.2.3 From d2231420643587755cd8b6135865b4365e43037c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 3 Sep 2003 10:51:33 -0700 Subject: [NET]: Kill NET_PROFILE, has not built for years. --- include/linux/netdevice.h | 3 - include/net/profile.h | 312 ---------------------------------------------- net/Kconfig | 1 - net/core/Makefile | 1 - net/core/dev.c | 10 -- net/core/profile.c | 294 ------------------------------------------- 6 files changed, 621 deletions(-) delete mode 100644 include/net/profile.h delete mode 100644 net/core/profile.c (limited to 'include/linux') diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f2a63e8004d6..c99e53fed30e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -37,9 +37,6 @@ #ifdef __KERNEL__ #include -#ifdef CONFIG_NET_PROFILE -#include -#endif struct divert_blk; struct vlan_group; diff --git a/include/net/profile.h b/include/net/profile.h deleted file mode 100644 index fd6a3b346990..000000000000 --- a/include/net/profile.h +++ /dev/null @@ -1,312 +0,0 @@ -#include /* for CONFIG_NET_PROFILE */ -#ifndef _NET_PROFILE_H_ -#define _NET_PROFILE_H_ 1 - -#ifdef CONFIG_NET_PROFILE - -#include -#include -#include -#include - -#ifdef CONFIG_X86_TSC -#include -#endif - -struct net_profile_slot -{ - char id[16]; - struct net_profile_slot *next; - struct timeval entered; - struct timeval accumulator; - struct timeval irq; - int hits; - int active; - int underflow; -}; - -extern atomic_t net_profile_active; -extern struct timeval net_profile_adjust; -extern void net_profile_irq_adjust(struct timeval *entered, struct timeval* leaved); - -#ifdef CONFIG_X86_TSC - -static inline void net_profile_stamp(struct timeval *pstamp) -{ - rdtsc(pstamp->tv_usec, pstamp->tv_sec); -} - -static inline void net_profile_accumulate(struct timeval *entered, - struct timeval *leaved, - struct timeval *acc) -{ - __asm__ __volatile__ ("subl %2,%0\n\t" - "sbbl %3,%1\n\t" - "addl %4,%0\n\t" - "adcl %5,%1\n\t" - "subl net_profile_adjust+4,%0\n\t" - "sbbl $0,%1\n\t" - : "=r" (acc->tv_usec), "=r" (acc->tv_sec) - : "g" (entered->tv_usec), "g" (entered->tv_sec), - "g" (leaved->tv_usec), "g" (leaved->tv_sec), - "0" (acc->tv_usec), "1" (acc->tv_sec)); -} - -static inline void net_profile_sub(struct timeval *sub, - struct timeval *acc) -{ - __asm__ __volatile__ ("subl %2,%0\n\t" - "sbbl %3,%1\n\t" - : "=r" (acc->tv_usec), "=r" (acc->tv_sec) - : "g" (sub->tv_usec), "g" (sub->tv_sec), - "0" (acc->tv_usec), "1" (acc->tv_sec)); -} - -static inline void net_profile_add(struct timeval *add, - struct timeval *acc) -{ - __asm__ __volatile__ ("addl %2,%0\n\t" - "adcl %3,%1\n\t" - : "=r" (acc->tv_usec), "=r" (acc->tv_sec) - : "g" (add->tv_usec), "g" (add->tv_sec), - "0" (acc->tv_usec), "1" (acc->tv_sec)); -} - - -#elif defined (__alpha__) - -extern __u32 alpha_lo; -extern long alpha_hi; - -/* On alpha cycle counter has only 32 bits :-( :-( */ - -static inline void net_profile_stamp(struct timeval *pstamp) -{ - __u32 result; - __asm__ __volatile__ ("rpcc %0" : "r="(result)); - if (result <= alpha_lo) - alpha_hi++; - alpha_lo = result; - pstamp->tv_sec = alpha_hi; - pstamp->tv_usec = alpha_lo; -} - -static inline void net_profile_accumulate(struct timeval *entered, - struct timeval *leaved, - struct timeval *acc) -{ - time_t usecs = acc->tv_usec + leaved->tv_usec - entered->tv_usec - - net_profile_adjust.tv_usec; - time_t secs = acc->tv_sec + leaved->tv_sec - entered->tv_sec; - - if (usecs >= 0x100000000L) { - usecs -= 0x100000000L; - secs++; - } else if (usecs < -0x100000000L) { - usecs += 0x200000000L; - secs -= 2; - } else if (usecs < 0) { - usecs += 0x100000000L; - secs--; - } - acc->tv_sec = secs; - acc->tv_usec = usecs; -} - -static inline void net_profile_sub(struct timeval *entered, - struct timeval *leaved) -{ - time_t usecs = leaved->tv_usec - entered->tv_usec; - time_t secs = leaved->tv_sec - entered->tv_sec; - - if (usecs < 0) { - usecs += 0x100000000L; - secs--; - } - leaved->tv_sec = secs; - leaved->tv_usec = usecs; -} - -static inline void net_profile_add(struct timeval *entered, struct timeval *leaved) -{ - time_t usecs = leaved->tv_usec + entered->tv_usec; - time_t secs = leaved->tv_sec + entered->tv_sec; - - if (usecs >= 0x100000000L) { - usecs -= 0x100000000L; - secs++; - } - leaved->tv_sec = secs; - leaved->tv_usec = usecs; -} - - -#else - -static inline void net_profile_stamp(struct timeval *pstamp) -{ - /* Not "fast" counterpart! On architectures without - cpu clock "fast" routine is absolutely useless in this - situation. do_gettimeofday still says something on slow-slow-slow - boxes, though it eats more cpu time than the subject of - investigation :-) :-) - */ - do_gettimeofday(pstamp); -} - -static inline void net_profile_accumulate(struct timeval *entered, - struct timeval *leaved, - struct timeval *acc) -{ - time_t usecs = acc->tv_usec + leaved->tv_usec - entered->tv_usec - - net_profile_adjust.tv_usec; - time_t secs = acc->tv_sec + leaved->tv_sec - entered->tv_sec; - - if (usecs >= 1000000) { - usecs -= 1000000; - secs++; - } else if (usecs < -1000000) { - usecs += 2000000; - secs -= 2; - } else if (usecs < 0) { - usecs += 1000000; - secs--; - } - acc->tv_sec = secs; - acc->tv_usec = usecs; -} - -static inline void net_profile_sub(struct timeval *entered, - struct timeval *leaved) -{ - time_t usecs = leaved->tv_usec - entered->tv_usec; - time_t secs = leaved->tv_sec - entered->tv_sec; - - if (usecs < 0) { - usecs += 1000000; - secs--; - } - leaved->tv_sec = secs; - leaved->tv_usec = usecs; -} - -static inline void net_profile_add(struct timeval *entered, struct timeval *leaved) -{ - time_t usecs = leaved->tv_usec + entered->tv_usec; - time_t secs = leaved->tv_sec + entered->tv_sec; - - if (usecs >= 1000000) { - usecs -= 1000000; - secs++; - } - leaved->tv_sec = secs; - leaved->tv_usec = usecs; -} - - - -#endif - -static inline void net_profile_enter(struct net_profile_slot *s) -{ - unsigned long flags; - - save_flags(flags); - cli(); - if (s->active++ == 0) { - net_profile_stamp(&s->entered); - atomic_inc(&net_profile_active); - } - restore_flags(flags); -} - -static inline void net_profile_leave_irq(struct net_profile_slot *s) -{ - unsigned long flags; - - save_flags(flags); - cli(); - if (--s->active <= 0) { - if (s->active == 0) { - struct timeval curr_pstamp; - net_profile_stamp(&curr_pstamp); - net_profile_accumulate(&s->entered, &curr_pstamp, &s->accumulator); - if (!atomic_dec_and_test(&net_profile_active)) - net_profile_irq_adjust(&s->entered, &curr_pstamp); - } else { - s->underflow++; - } - } - s->hits++; - restore_flags(flags); -} - -static inline void net_profile_leave(struct net_profile_slot *s) -{ - unsigned long flags; - save_flags(flags); - cli(); - if (--s->active <= 0) { - if (s->active == 0) { - struct timeval curr_pstamp; - net_profile_stamp(&curr_pstamp); - net_profile_accumulate(&s->entered, &curr_pstamp, &s->accumulator); - atomic_dec(&net_profile_active); - } else { - s->underflow++; - } - } - s->hits++; - restore_flags(flags); -} - - -#define NET_PROFILE_ENTER(slot) net_profile_enter(&net_prof_##slot) -#define NET_PROFILE_LEAVE(slot) net_profile_leave(&net_prof_##slot) -#define NET_PROFILE_LEAVE_IRQ(slot) net_profile_leave_irq(&net_prof_##slot) - -#define NET_PROFILE_SKB_CLEAR(skb) ({ \ - skb->pstamp.tv_usec = 0; \ -}) - -#define NET_PROFILE_SKB_INIT(skb) ({ \ - net_profile_stamp(&skb->pstamp); \ -}) - -#define NET_PROFILE_SKB_PASSED(skb, slot) ({ \ - if (skb->pstamp.tv_usec) { \ - struct timeval cur_pstamp = skb->pstamp; \ - net_profile_stamp(&skb->pstamp); \ - net_profile_accumulate(&cur_pstamp, &skb->pstamp, &net_prof_##slot.accumulator); \ - net_prof_##slot.hits++; \ - }}) - -#define NET_PROFILE_DECL(slot) \ - extern struct net_profile_slot net_prof_##slot; - -#define NET_PROFILE_DEFINE(slot) \ - struct net_profile_slot net_prof_##slot = { #slot, }; - -#define NET_PROFILE_REGISTER(slot) net_profile_register(&net_prof_##slot) -#define NET_PROFILE_UNREGISTER(slot) net_profile_unregister(&net_prof_##slot) - -extern int net_profile_init(void); -extern int net_profile_register(struct net_profile_slot *); -extern int net_profile_unregister(struct net_profile_slot *); - -#else - -#define NET_PROFILE_ENTER(slot) do { /* nothing */ } while(0) -#define NET_PROFILE_LEAVE(slot) do { /* nothing */ } while(0) -#define NET_PROFILE_LEAVE_IRQ(slot) do { /* nothing */ } while(0) -#define NET_PROFILE_SKB_CLEAR(skb) do { /* nothing */ } while(0) -#define NET_PROFILE_SKB_INIT(skb) do { /* nothing */ } while(0) -#define NET_PROFILE_SKB_PASSED(skb, slot) do { /* nothing */ } while(0) -#define NET_PROFILE_DECL(slot) -#define NET_PROFILE_DEFINE(slot) -#define NET_PROFILE_REGISTER(slot) do { /* nothing */ } while(0) -#define NET_PROFILE_UNREGISTER(slot) do { /* nothing */ } while(0) - -#endif - -#endif diff --git a/net/Kconfig b/net/Kconfig index 4c3474604a0c..7d76574a9cc3 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -676,7 +676,6 @@ config NET_SCHED source "net/sched/Kconfig" -#bool 'Network code profiler' CONFIG_NET_PROFILE endmenu menu "Network testing" diff --git a/net/core/Makefile b/net/core/Makefile index 28ec942019e8..22e715cbdeb2 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -11,6 +11,5 @@ obj-y += flow.o dev.o ethtool.o net-sysfs.o dev_mcast.o dst.o \ obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NET_DIVERT) += dv.o -obj-$(CONFIG_NET_PROFILE) += profile.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_NET_RADIO) += wireless.o diff --git a/net/core/dev.c b/net/core/dev.c index 8a598f7f300c..2cf887cee6d7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -99,7 +99,6 @@ #include #include #include -#include #include #include #include @@ -128,9 +127,6 @@ extern int plip_init(void); */ #undef OFFLINE_SAMPLE -NET_PROFILE_DEFINE(dev_queue_xmit) -NET_PROFILE_DEFINE(softnet_process) - /* * The list of packet types we will receive (as opposed to discard) * and the routines to invoke. @@ -3015,12 +3011,6 @@ static int __init net_dev_init(void) atomic_set(&queue->backlog_dev.refcnt, 1); } -#ifdef CONFIG_NET_PROFILE - net_profile_init(); - NET_PROFILE_REGISTER(dev_queue_xmit); - NET_PROFILE_REGISTER(softnet_process); -#endif - #ifdef OFFLINE_SAMPLE samp_timer.expires = jiffies + (10 * HZ); add_timer(&samp_timer); diff --git a/net/core/profile.c b/net/core/profile.c deleted file mode 100644 index 0caedda13842..000000000000 --- a/net/core/profile.c +++ /dev/null @@ -1,294 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#ifdef CONFIG_NET_PROFILE - -atomic_t net_profile_active; -struct timeval net_profile_adjust; - -NET_PROFILE_DEFINE(total); - -struct net_profile_slot *net_profile_chain = &net_prof_total; - -#ifdef __alpha__ -__u32 alpha_lo; -long alpha_hi; - -static void alpha_tick(unsigned long); - -static struct timer_list alpha_timer = TIMER_INITIALIZER(alpha_tick, 0, 0); - -void alpha_tick(unsigned long dummy) -{ - struct timeval dummy_stamp; - net_profile_stamp(&dummy_stamp); - alpha_timer.expires = jiffies + 4*HZ; - add_timer(&alpha_timer); -} - -#endif - -void net_profile_irq_adjust(struct timeval *entered, struct timeval* leaved) -{ - struct net_profile_slot *s; - - net_profile_sub(entered, leaved); - for (s = net_profile_chain; s; s = s->next) { - if (s->active) - net_profile_add(leaved, &s->irq); - } -} - - -#ifdef CONFIG_PROC_FS -static int profile_read_proc(char *buffer, char **start, off_t offset, - int length, int *eof, void *data) -{ - off_t pos=0; - off_t begin=0; - int len=0; - struct net_profile_slot *s; - - len+= sprintf(buffer, "Slot Hits Hi Lo OnIrqHi OnIrqLo Ufl\n"); - - if (offset == 0) { - cli(); - net_prof_total.active = 1; - atomic_inc(&net_profile_active); - NET_PROFILE_LEAVE(total); - sti(); - } - for (s = net_profile_chain; s; s = s->next) { - struct net_profile_slot tmp; - - cli(); - tmp = *s; - - /* Wrong, but pretty close to truth */ - - s->accumulator.tv_sec = 0; - s->accumulator.tv_usec = 0; - s->irq.tv_sec = 0; - s->irq.tv_usec = 0; - s->hits = 0; - s->underflow = 0; - /* Repair active count, it is possible, only if code has a bug */ - if (s->active) { - s->active = 0; - atomic_dec(&net_profile_active); - } - sti(); - - net_profile_sub(&tmp.irq, &tmp.accumulator); - - len += sprintf(buffer+len,"%-15s %-10d %-10ld %-10lu %-10lu %-10lu %d/%d", - tmp.id, - tmp.hits, - tmp.accumulator.tv_sec, - tmp.accumulator.tv_usec, - tmp.irq.tv_sec, - tmp.irq.tv_usec, - tmp.underflow, tmp.active); - - buffer[len++]='\n'; - - pos=begin+len; - if(posoffset+length) - goto done; - } - *eof = 1; - -done: - *start=buffer+(offset-begin); - len-=(offset-begin); - if(len>length) - len=length; - if (len < 0) - len = 0; - if (offset == 0) { - cli(); - net_prof_total.active = 0; - net_prof_total.hits = 0; - net_profile_stamp(&net_prof_total.entered); - sti(); - } - return len; -} -#endif - -struct iphdr whitehole_iph; -int whitehole_count; - -static int whitehole_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct net_device_stats *stats; - - stats = (struct net_device_stats *)dev->priv; - stats->tx_packets++; - stats->tx_bytes+=skb->len; - - dev_kfree_skb(skb); - return 0; -} - -static void whitehole_inject(unsigned long); -int whitehole_init(struct net_device *dev); - -static struct timer_list whitehole_timer = - TIMER_INITIALIZER(whitehole_inject, 0, 0); - -static struct net_device whitehole_dev = { - .name = "whitehole", - .init = whitehole_init, -}; - -static int whitehole_open(struct net_device *dev) -{ - whitehole_count = 100000; - whitehole_timer.expires = jiffies + 5*HZ; - add_timer(&whitehole_timer); - return 0; -} - -static int whitehole_close(struct net_device *dev) -{ - del_timer(&whitehole_timer); - return 0; -} - -static void whitehole_inject(unsigned long dummy) -{ - struct net_device_stats *stats = (struct net_device_stats *)whitehole_dev.priv; - extern int netdev_dropping; - - do { - struct iphdr *iph; - struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC); - if (!skb) - break; - skb_reserve(skb, 32); - iph = (struct iphdr*)skb_put(skb, sizeof(*iph)); - skb->mac.raw = ((u8*)iph) - 14; - memcpy(iph, &whitehole_iph, sizeof(*iph)); - skb->protocol = __constant_htons(ETH_P_IP); - skb->dev = &whitehole_dev; - skb->pkt_type = PACKET_HOST; - stats->rx_packets++; - stats->rx_bytes += skb->len; - netif_rx(skb); - whitehole_count--; - } while (netdev_dropping == 0 && whitehole_count>0); - if (whitehole_count > 0) { - whitehole_timer.expires = jiffies + 1; - add_timer(&whitehole_timer); - } -} - -static struct net_device_stats *whitehole_get_stats(struct net_device *dev) -{ - struct net_device_stats *stats = (struct net_device_stats *) dev->priv; - return stats; -} - -int __init whitehole_init(struct net_device *dev) -{ - dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL); - if (dev->priv == NULL) - return -ENOBUFS; - memset(dev->priv, 0, sizeof(struct net_device_stats)); - dev->get_stats = whitehole_get_stats; - dev->hard_start_xmit = whitehole_xmit; - dev->open = whitehole_open; - dev->stop = whitehole_close; - ether_setup(dev); - dev->tx_queue_len = 0; - dev->flags |= IFF_NOARP; - dev->flags &= ~(IFF_BROADCAST|IFF_MULTICAST); - dev->iflink = 0; - whitehole_iph.ihl = 5; - whitehole_iph.version = 4; - whitehole_iph.ttl = 2; - whitehole_iph.saddr = in_aton("193.233.7.21"); - whitehole_iph.daddr = in_aton("193.233.7.10"); - whitehole_iph.tot_len = htons(20); - whitehole_iph.check = ip_compute_csum((void *)&whitehole_iph, 20); - return 0; -} - -int net_profile_register(struct net_profile_slot *slot) -{ - cli(); - slot->next = net_profile_chain; - net_profile_chain = slot; - sti(); - return 0; -} - -int net_profile_unregister(struct net_profile_slot *slot) -{ - struct net_profile_slot **sp, *s; - - for (sp = &net_profile_chain; (s = *sp) != NULL; sp = &s->next) { - if (s == slot) { - cli(); - *sp = s->next; - sti(); - return 0; - } - } - return -ESRCH; -} - - -int __init net_profile_init(void) -{ - int i; - -#ifdef CONFIG_PROC_FS - create_proc_read_entry("net/profile", 0, 0, profile_read_proc, NULL); -#endif - - register_netdevice(&whitehole_dev); - - printk("Evaluating net profiler cost ..."); -#ifdef __alpha__ - alpha_tick(0); -#endif - for (i=0; i<1024; i++) { - NET_PROFILE_ENTER(total); - NET_PROFILE_LEAVE(total); - } - if (net_prof_total.accumulator.tv_sec) { - printk(" too high!\n"); - } else { - net_profile_adjust.tv_usec = net_prof_total.accumulator.tv_usec>>10; - printk("%ld units\n", net_profile_adjust.tv_usec); - } - net_prof_total.hits = 0; - net_profile_stamp(&net_prof_total.entered); - return 0; -} - -#endif -- cgit v1.2.3 From 80c2442e30dc6bf798a8b414cc02fcac375b39b4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 3 Sep 2003 14:10:08 -0700 Subject: [USB]: hiddev_exit() can no longer be __exit, called from init code now. --- drivers/usb/input/hiddev.c | 2 +- include/linux/hiddev.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index c85528623cfa..4205682ea286 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -798,7 +798,7 @@ int __init hiddev_init(void) return usb_register(&hiddev_driver); } -void __exit hiddev_exit(void) +void hiddev_exit(void) { usb_deregister(&hiddev_driver); devfs_remove("usb/hid"); diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h index dc6d8dd843b5..9e6d27476a74 100644 --- a/include/linux/hiddev.h +++ b/include/linux/hiddev.h @@ -207,7 +207,7 @@ void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs); void hiddev_report_event(struct hid_device *hid, struct hid_report *report); int __init hiddev_init(void); -void __exit hiddev_exit(void); +void hiddev_exit(void); #else static inline int hiddev_connect(struct hid_device *hid) { return -1; } static inline void hiddev_disconnect(struct hid_device *hid) { } -- cgit v1.2.3 From b2a5082def730397f381dc5d0125c5889bd667fb Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 3 Sep 2003 19:43:03 -0700 Subject: [PATCH] Don't #ifdef prototypes It seems that changing CONFIG_BLK_DEV_INITRD causes the whole kernel to rebuild due to an inappropriate ifdef in linux/fs.h - we should not conditionalise prototypes. In addition, real_root_dev is only used by two files (kernel/sysctl.c and init/do_mounts_initrd.c) so it makes even less sense that it was in linux/fs.h --- include/linux/fs.h | 4 ---- include/linux/initrd.h | 2 ++ kernel/sysctl.c | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/fs.h b/include/linux/fs.h index 936f34c469dd..87ae270bf96c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1391,10 +1391,6 @@ extern int simple_fill_super(struct super_block *, int, struct tree_descr *); extern int simple_pin_fs(char *name, struct vfsmount **mount, int *count); extern void simple_release_fs(struct vfsmount **mount, int *count); -#ifdef CONFIG_BLK_DEV_INITRD -extern unsigned int real_root_dev; -#endif - extern int inode_change_ok(struct inode *, struct iattr *); extern int inode_setattr(struct inode *, struct iattr *); diff --git a/include/linux/initrd.h b/include/linux/initrd.h index 32452d53dac3..55289d261b4f 100644 --- a/include/linux/initrd.h +++ b/include/linux/initrd.h @@ -16,3 +16,5 @@ extern int initrd_below_start_ok; /* free_initrd_mem always gets called with the next two as arguments.. */ extern unsigned long initrd_start, initrd_end; extern void free_initrd_mem(unsigned long, unsigned long); + +extern unsigned int real_root_dev; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 142ccfcf835b..3180fa00d248 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef CONFIG_ROOT_NFS -- cgit v1.2.3 From ad425cf493fb719430154b5db87242ef3ea6c463 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Wed, 3 Sep 2003 20:11:54 -0700 Subject: [PATCH] ide: remove supports_dma field from ide_driver_t driver->supports_dma was used together with CONFIG_IDEDMA_ONLYDISK to limit DMA access to disk devices only. However Alan introduced new scheme in 2.5.63 and this field is not needed any longer because all ide drivers support DMA. --- drivers/ide/ide-cd.c | 1 - drivers/ide/ide-default.c | 6 ------ drivers/ide/ide-disk.c | 1 - drivers/ide/ide-floppy.c | 1 - drivers/ide/ide-tape.c | 1 - drivers/ide/ide.c | 5 ----- drivers/scsi/ide-scsi.c | 1 - include/linux/ide.h | 1 - 8 files changed, 17 deletions(-) (limited to 'include/linux') diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 578476e1e931..fd5874b891db 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -3318,7 +3318,6 @@ static ide_driver_t ide_cdrom_driver = { .version = IDECD_VERSION, .media = ide_cdrom, .busy = 0, - .supports_dma = 1, .supports_dsc_overlap = 1, .cleanup = ide_cdrom_cleanup, .do_request = ide_do_rw_cdrom, diff --git a/drivers/ide/ide-default.c b/drivers/ide/ide-default.c index 40ecc4de0c05..0c251121a740 100644 --- a/drivers/ide/ide-default.c +++ b/drivers/ide/ide-default.c @@ -40,18 +40,12 @@ static int idedefault_attach(ide_drive_t *drive); /* * IDE subdriver functions, registered with ide.c - * - * idedefault *must* support DMA because it will be - * attached before the other drivers are loaded and - * we don't want to lose the DMA status at probe - * time. */ ide_driver_t idedefault_driver = { .name = "ide-default", .version = IDEDEFAULT_VERSION, .attach = idedefault_attach, - .supports_dma = 1, .drives = LIST_HEAD_INIT(idedefault_driver.drives) }; diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 1217e840ac02..39693bcc7d0f 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -1716,7 +1716,6 @@ static ide_driver_t idedisk_driver = { .version = IDEDISK_VERSION, .media = ide_disk, .busy = 0, - .supports_dma = 1, .supports_dsc_overlap = 0, .cleanup = idedisk_cleanup, .flushcache = do_idedisk_flushcache, diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 112dc8b8676d..4a2a7273b8b4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -1854,7 +1854,6 @@ static ide_driver_t idefloppy_driver = { .version = IDEFLOPPY_VERSION, .media = ide_floppy, .busy = 0, - .supports_dma = 1, .supports_dsc_overlap = 0, .cleanup = idefloppy_cleanup, .do_request = idefloppy_do_request, diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index e2bdaa457727..6c8c067df5a7 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -6316,7 +6316,6 @@ static ide_driver_t idetape_driver = { .version = IDETAPE_VERSION, .media = ide_tape, .busy = 1, - .supports_dma = 1, .supports_dsc_overlap = 1, .cleanup = idetape_cleanup, .do_request = idetape_do_request, diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index dfb03f9a423f..b6b7c97bf090 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1359,8 +1359,6 @@ static int set_io_32bit(ide_drive_t *drive, int arg) static int set_using_dma (ide_drive_t *drive, int arg) { - if (!DRIVER(drive)->supports_dma) - return -EPERM; if (!drive->id || !(drive->id->capability & 1)) return -EPERM; if (HWIF(drive)->ide_dma_check == NULL) @@ -2452,9 +2450,6 @@ int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int versio if ((drive->autotune == IDE_TUNE_DEFAULT) || (drive->autotune == IDE_TUNE_AUTO)) { /* DMA timings and setup moved to ide-probe.c */ - if (!driver->supports_dma && HWIF(drive)->ide_dma_off_quietly) -// HWIF(drive)->ide_dma_off_quietly(drive); - HWIF(drive)->ide_dma_off(drive); drive->dsc_overlap = (drive->next != drive && driver->supports_dsc_overlap); drive->nice1 = 1; } diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index b270dac4e2d2..b631105fbdb2 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -627,7 +627,6 @@ static ide_driver_t idescsi_driver = { .version = IDESCSI_VERSION, .media = ide_scsi, .busy = 0, - .supports_dma = 1, .supports_dsc_overlap = 0, .attach = idescsi_attach, .cleanup = idescsi_cleanup, diff --git a/include/linux/ide.h b/include/linux/ide.h index 4664fd44a986..e7c50528e10e 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1218,7 +1218,6 @@ typedef struct ide_driver_s { const char *version; u8 media; unsigned busy : 1; - unsigned supports_dma : 1; unsigned supports_dsc_overlap : 1; int (*cleanup)(ide_drive_t *); int (*shutdown)(ide_drive_t *); -- cgit v1.2.3