ia64/xen-unstable

changeset 10093:6f957675015d

[NET] front: Give netfront a procectomy. The existing /proc interface
for tuning is buggy (network device names can change), and would
not be accepted in mainline.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 10:15:14 2006 +0100 (2006-05-18)
parents 843b9ef21352
children b9b316bfab15
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:12:07 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:15:14 2006 +0100
     1.3 @@ -181,16 +181,6 @@ static int send_fake_arp(struct net_devi
     1.4  
     1.5  static irqreturn_t netif_int(int irq, void *dev_id, struct pt_regs *ptregs);
     1.6  
     1.7 -#ifdef CONFIG_PROC_FS
     1.8 -static int xennet_proc_init(void);
     1.9 -static int xennet_proc_addif(struct net_device *dev);
    1.10 -static void xennet_proc_delif(struct net_device *dev);
    1.11 -#else
    1.12 -#define xennet_proc_init()   (0)
    1.13 -#define xennet_proc_addif(d) (0)
    1.14 -#define xennet_proc_delif(d) ((void)0)
    1.15 -#endif
    1.16 -
    1.17  
    1.18  /**
    1.19   * Entry point to this code when a new device is created.  Allocate the basic
    1.20 @@ -1173,11 +1163,6 @@ static int __devinit create_netdev(int h
    1.21  		goto exit_free_rx;
    1.22  	}
    1.23  
    1.24 -	if ((err = xennet_proc_addif(netdev)) != 0) {
    1.25 -		unregister_netdev(netdev);
    1.26 -		goto exit_free_rx;
    1.27 -	}
    1.28 -
    1.29  	np->netdev = netdev;
    1.30  	if (val)
    1.31  		*val = netdev;
    1.32 @@ -1248,10 +1233,6 @@ static int __devexit netfront_remove(str
    1.33  
    1.34  static void close_netdev(struct netfront_info *info)
    1.35  {
    1.36 -#ifdef CONFIG_PROC_FS
    1.37 -	xennet_proc_delif(info->netdev);
    1.38 -#endif
    1.39 -
    1.40  	del_timer_sync(&info->rx_refill_timer);
    1.41  
    1.42  	unregister_netdev(info->netdev);
    1.43 @@ -1328,9 +1309,6 @@ static int __init netif_init(void)
    1.44  	if (xen_start_info->flags & SIF_INITDOMAIN)
    1.45  		return 0;
    1.46  
    1.47 -	if ((err = xennet_proc_init()) != 0)
    1.48 -		return err;
    1.49 -
    1.50  	IPRINTK("Initialising virtual ethernet driver.\n");
    1.51  
    1.52  	(void)register_inetaddr_notifier(&notifier_inetdev);
    1.53 @@ -1349,156 +1327,3 @@ static void __exit netif_exit(void)
    1.54  module_exit(netif_exit);
    1.55  
    1.56  MODULE_LICENSE("Dual BSD/GPL");
    1.57 -
    1.58 -
    1.59 -/* ** /proc **/
    1.60 -
    1.61 -
    1.62 -#ifdef CONFIG_PROC_FS
    1.63 -
    1.64 -#define TARGET_MIN 0UL
    1.65 -#define TARGET_MAX 1UL
    1.66 -#define TARGET_CUR 2UL
    1.67 -
    1.68 -static int xennet_proc_read(
    1.69 -	char *page, char **start, off_t off, int count, int *eof, void *data)
    1.70 -{
    1.71 -	struct net_device *dev =
    1.72 -		(struct net_device *)((unsigned long)data & ~3UL);
    1.73 -	struct netfront_info *np = netdev_priv(dev);
    1.74 -	int len = 0, which_target = (long)data & 3;
    1.75 -
    1.76 -	switch (which_target) {
    1.77 -	case TARGET_MIN:
    1.78 -		len = sprintf(page, "%d\n", np->rx_min_target);
    1.79 -		break;
    1.80 -	case TARGET_MAX:
    1.81 -		len = sprintf(page, "%d\n", np->rx_max_target);
    1.82 -		break;
    1.83 -	case TARGET_CUR:
    1.84 -		len = sprintf(page, "%d\n", np->rx_target);
    1.85 -		break;
    1.86 -	}
    1.87 -
    1.88 -	*eof = 1;
    1.89 -	return len;
    1.90 -}
    1.91 -
    1.92 -static int xennet_proc_write(
    1.93 -	struct file *file, const char __user *buffer,
    1.94 -	unsigned long count, void *data)
    1.95 -{
    1.96 -	struct net_device *dev =
    1.97 -		(struct net_device *)((unsigned long)data & ~3UL);
    1.98 -	struct netfront_info *np = netdev_priv(dev);
    1.99 -	int which_target = (long)data & 3;
   1.100 -	char string[64];
   1.101 -	long target;
   1.102 -
   1.103 -	if (!capable(CAP_SYS_ADMIN))
   1.104 -		return -EPERM;
   1.105 -
   1.106 -	if (count <= 1)
   1.107 -		return -EBADMSG; /* runt */
   1.108 -	if (count > sizeof(string))
   1.109 -		return -EFBIG;   /* too long */
   1.110 -
   1.111 -	if (copy_from_user(string, buffer, count))
   1.112 -		return -EFAULT;
   1.113 -	string[sizeof(string)-1] = '\0';
   1.114 -
   1.115 -	target = simple_strtol(string, NULL, 10);
   1.116 -	if (target < RX_MIN_TARGET)
   1.117 -		target = RX_MIN_TARGET;
   1.118 -	if (target > RX_MAX_TARGET)
   1.119 -		target = RX_MAX_TARGET;
   1.120 -
   1.121 -	spin_lock(&np->rx_lock);
   1.122 -
   1.123 -	switch (which_target) {
   1.124 -	case TARGET_MIN:
   1.125 -		if (target > np->rx_max_target)
   1.126 -			np->rx_max_target = target;
   1.127 -		np->rx_min_target = target;
   1.128 -		if (target > np->rx_target)
   1.129 -			np->rx_target = target;
   1.130 -		break;
   1.131 -	case TARGET_MAX:
   1.132 -		if (target < np->rx_min_target)
   1.133 -			np->rx_min_target = target;
   1.134 -		np->rx_max_target = target;
   1.135 -		if (target < np->rx_target)
   1.136 -			np->rx_target = target;
   1.137 -		break;
   1.138 -	case TARGET_CUR:
   1.139 -		break;
   1.140 -	}
   1.141 -
   1.142 -	network_alloc_rx_buffers(dev);
   1.143 -
   1.144 -	spin_unlock(&np->rx_lock);
   1.145 -
   1.146 -	return count;
   1.147 -}
   1.148 -
   1.149 -static int xennet_proc_init(void)
   1.150 -{
   1.151 -	if (proc_mkdir("xen/net", NULL) == NULL)
   1.152 -		return -ENOMEM;
   1.153 -	return 0;
   1.154 -}
   1.155 -
   1.156 -static int xennet_proc_addif(struct net_device *dev)
   1.157 -{
   1.158 -	struct proc_dir_entry *dir, *min, *max, *cur;
   1.159 -	char name[30];
   1.160 -
   1.161 -	sprintf(name, "xen/net/%s", dev->name);
   1.162 -
   1.163 -	dir = proc_mkdir(name, NULL);
   1.164 -	if (!dir)
   1.165 -		goto nomem;
   1.166 -
   1.167 -	min = create_proc_entry("rxbuf_min", 0644, dir);
   1.168 -	max = create_proc_entry("rxbuf_max", 0644, dir);
   1.169 -	cur = create_proc_entry("rxbuf_cur", 0444, dir);
   1.170 -	if (!min || !max || !cur)
   1.171 -		goto nomem;
   1.172 -
   1.173 -	min->read_proc  = xennet_proc_read;
   1.174 -	min->write_proc = xennet_proc_write;
   1.175 -	min->data       = (void *)((unsigned long)dev | TARGET_MIN);
   1.176 -
   1.177 -	max->read_proc  = xennet_proc_read;
   1.178 -	max->write_proc = xennet_proc_write;
   1.179 -	max->data       = (void *)((unsigned long)dev | TARGET_MAX);
   1.180 -
   1.181 -	cur->read_proc  = xennet_proc_read;
   1.182 -	cur->write_proc = xennet_proc_write;
   1.183 -	cur->data       = (void *)((unsigned long)dev | TARGET_CUR);
   1.184 -
   1.185 -	return 0;
   1.186 -
   1.187 - nomem:
   1.188 -	xennet_proc_delif(dev);
   1.189 -	return -ENOMEM;
   1.190 -}
   1.191 -
   1.192 -static void xennet_proc_delif(struct net_device *dev)
   1.193 -{
   1.194 -	char name[30];
   1.195 -
   1.196 -	sprintf(name, "xen/net/%s/rxbuf_min", dev->name);
   1.197 -	remove_proc_entry(name, NULL);
   1.198 -
   1.199 -	sprintf(name, "xen/net/%s/rxbuf_max", dev->name);
   1.200 -	remove_proc_entry(name, NULL);
   1.201 -
   1.202 -	sprintf(name, "xen/net/%s/rxbuf_cur", dev->name);
   1.203 -	remove_proc_entry(name, NULL);
   1.204 -
   1.205 -	sprintf(name, "xen/net/%s", dev->name);
   1.206 -	remove_proc_entry(name, NULL);
   1.207 -}
   1.208 -
   1.209 -#endif