ia64/xen-unstable

changeset 686:fa3fe148e5b9

bitkeeper revision 1.398.1.1 (3f574c9bvb7h-rdW1pP-v5Bw9t2j7g)

dummy.c:
new file
dev.c, kernel.c:
Allow Xen to work when no NIC is detected.
author kaf24@scramble.cl.cam.ac.uk
date Thu Sep 04 14:30:51 2003 +0000 (2003-09-04)
parents 6137a63f86c4
children 4862078df9ac
files .rootkeys xen/common/kernel.c xen/drivers/net/dummy.c xen/net/dev.c
line diff
     1.1 --- a/.rootkeys	Fri Aug 29 12:15:33 2003 +0000
     1.2 +++ b/.rootkeys	Thu Sep 04 14:30:51 2003 +0000
     1.3 @@ -235,6 +235,7 @@ 3f0c423bjmEpn1Nbk1Q8fv8ElccwAA xen/drive
     1.4  3ddb79c0tWiE8xIFHszxipeVCGKTSA xen/drivers/net/Makefile
     1.5  3f0c4247730LYUgz3p5ziYqy-s_glw xen/drivers/net/SUPPORTED_CARDS
     1.6  3ddb79bfU-H1Hms4BuJEPPydjXUEaQ xen/drivers/net/Space.c
     1.7 +3f574c95CQT9g-GDSJJ4YqiwCEQ72Q xen/drivers/net/dummy.c
     1.8  3f0c428e41JP96bh-J0jnX59vJyUeQ xen/drivers/net/e100/LICENSE
     1.9  3f0c428es_xrZnnZQXXHhjzuqj9CTg xen/drivers/net/e100/Makefile
    1.10  3f0c428eCEnifr-r6XCZKUkzIEHdYw xen/drivers/net/e100/e100.h
     2.1 --- a/xen/common/kernel.c	Fri Aug 29 12:15:33 2003 +0000
     2.2 +++ b/xen/common/kernel.c	Thu Sep 04 14:30:51 2003 +0000
     2.3 @@ -570,7 +570,9 @@ long do_console_write(char *str, unsigne
     2.4      spin_unlock_irqrestore(&console_lock, flags);
     2.5      
     2.6      exported_str[j++]='\0';
     2.7 -    console_export(exported_str, j);
     2.8 +    
     2.9 +    if ( current->domain != 0 )
    2.10 +        console_export(exported_str, j);
    2.11      
    2.12      return(0);
    2.13  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/drivers/net/dummy.c	Thu Sep 04 14:30:51 2003 +0000
     3.3 @@ -0,0 +1,79 @@
     3.4 +/******************************************************************************
     3.5 + * dummy.c
     3.6 + * 
     3.7 + * A cut down version of Linux's dummy network driver. GPLed and all that.
     3.8 + */
     3.9 +
    3.10 +#include <xeno/config.h>
    3.11 +#include <xeno/module.h>
    3.12 +#include <xeno/kernel.h>
    3.13 +#include <xeno/netdevice.h>
    3.14 +#include <xeno/init.h>
    3.15 +
    3.16 +static int dummy_xmit(struct sk_buff *skb, struct net_device *dev);
    3.17 +static struct net_device_stats *dummy_get_stats(struct net_device *dev);
    3.18 +
    3.19 +static int __init dummy_init(struct net_device *dev)
    3.20 +{
    3.21 +    dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
    3.22 +    if ( dev->priv == NULL )
    3.23 +        return -ENOMEM;
    3.24 +    memset(dev->priv, 0, sizeof(struct net_device_stats));
    3.25 +
    3.26 +    dev->get_stats       = dummy_get_stats;
    3.27 +    dev->hard_start_xmit = dummy_xmit;
    3.28 +
    3.29 +    ether_setup(dev);
    3.30 +    dev->flags          |= IFF_NOARP;
    3.31 +    dev->features        = NETIF_F_SG | NETIF_F_HIGHDMA;
    3.32 +
    3.33 +    return 0;
    3.34 +}
    3.35 +
    3.36 +static int dummy_xmit(struct sk_buff *skb, struct net_device *dev)
    3.37 +{
    3.38 +    struct net_device_stats *stats = dev->priv;
    3.39 +
    3.40 +    stats->tx_packets++;
    3.41 +    stats->tx_bytes += skb->len;
    3.42 +
    3.43 +    dev_kfree_skb(skb);
    3.44 +
    3.45 +    return 0;
    3.46 +}
    3.47 +
    3.48 +static struct net_device_stats *dummy_get_stats(struct net_device *dev)
    3.49 +{
    3.50 +    return dev->priv;
    3.51 +}
    3.52 +
    3.53 +static struct net_device dev_dummy;
    3.54 +
    3.55 +static int __init dummy_init_module(void)
    3.56 +{
    3.57 +    int err;
    3.58 +
    3.59 +    dev_dummy.init = dummy_init;
    3.60 +    SET_MODULE_OWNER(&dev_dummy);
    3.61 +
    3.62 +    if ( (err = dev_alloc_name(&dev_dummy,"dummy")) < 0 )
    3.63 +        return err;
    3.64 +    
    3.65 +    if ( (err = register_netdev(&dev_dummy)) < 0 )
    3.66 +        return err;
    3.67 +
    3.68 +    return 0;
    3.69 +}
    3.70 +
    3.71 +static void __exit dummy_cleanup_module(void)
    3.72 +{
    3.73 +    unregister_netdev(&dev_dummy);
    3.74 +    kfree(dev_dummy.priv);
    3.75 +
    3.76 +    memset(&dev_dummy, 0, sizeof(dev_dummy));
    3.77 +    dev_dummy.init = dummy_init;
    3.78 +}
    3.79 +
    3.80 +module_init(dummy_init_module);
    3.81 +module_exit(dummy_cleanup_module);
    3.82 +MODULE_LICENSE("GPL");
     4.1 --- a/xen/net/dev.c	Fri Aug 29 12:15:33 2003 +0000
     4.2 +++ b/xen/net/dev.c	Thu Sep 04 14:30:51 2003 +0000
     4.3 @@ -2145,20 +2145,25 @@ int setup_network_devices(void)
     4.4  {
     4.5      int i, ret;
     4.6      extern char opt_ifname[];
     4.7 -    struct net_device *dev = dev_get_by_name(opt_ifname);
     4.8 +    struct net_device *dev;
     4.9  
    4.10 -    if ( dev == NULL ) 
    4.11 +    if ( (dev = dev_get_by_name(opt_ifname)) == NULL ) 
    4.12      {
    4.13 -        printk("Could not find device %s\n", opt_ifname);
    4.14 -        return 0;
    4.15 +        printk("Could not find device %s: using dummy device\n", opt_ifname);
    4.16 +        strcpy(opt_ifname, "dummy");
    4.17 +        if ( (dev = dev_get_by_name(opt_ifname)) == NULL )
    4.18 +        {
    4.19 +            printk("Failed to find the dummy device!\n");
    4.20 +            return 0;
    4.21 +        }
    4.22      }
    4.23  
    4.24 -    ret = dev_open(dev);
    4.25 -    if ( ret != 0 )
    4.26 +    if ( (ret = dev_open(dev)) != 0 )
    4.27      {
    4.28          printk("Error opening device %s for use (%d)\n", opt_ifname, ret);
    4.29          return 0;
    4.30      }
    4.31 +
    4.32      printk("Device %s opened and ready for use.\n", opt_ifname);
    4.33      the_dev = dev;
    4.34