ia64/xen-unstable

changeset 169:f5723f60515a

bitkeeper revision 1.35 (3e4d181eHU8B1tJyF-e99y8w9BL6og)

interface boot option and little bug fix.
author akw27@boulderdash.cl.cam.ac.uk
date Fri Feb 14 16:23:58 2003 +0000 (2003-02-14)
parents 1b51468b4a9c
children ac77b60e57a6
files xen-2.4.16/common/kernel.c xen-2.4.16/net/dev.c xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c
line diff
     1.1 --- a/xen-2.4.16/common/kernel.c	Fri Feb 14 14:27:45 2003 +0000
     1.2 +++ b/xen-2.4.16/common/kernel.c	Fri Feb 14 16:23:58 2003 +0000
     1.3 @@ -45,6 +45,7 @@ unsigned long opt_ipbase=0, opt_nfsserv=
     1.4  unsigned char opt_nfsroot[50]="";
     1.5  unsigned int opt_dom0_mem = 16000; /* default kbytes for DOM0 */
     1.6  unsigned int opt_ne_base = 0; /* NE2k NICs cannot be probed */
     1.7 +unsigned char opt_ifname[10] = "eth0";
     1.8  enum { OPT_IP, OPT_STR, OPT_UINT };
     1.9  static struct {
    1.10      unsigned char *name;
    1.11 @@ -58,6 +59,7 @@ static struct {
    1.12      { "nfsroot",  OPT_STR,  &opt_nfsroot },
    1.13      { "dom0_mem", OPT_UINT, &opt_dom0_mem }, 
    1.14      { "ne_base",  OPT_UINT, &opt_ne_base },
    1.15 +    { "ifname",   OPT_STR,  &opt_ifname },
    1.16      { NULL,       0,        NULL     }
    1.17  };
    1.18  
     2.1 --- a/xen-2.4.16/net/dev.c	Fri Feb 14 14:27:45 2003 +0000
     2.2 +++ b/xen-2.4.16/net/dev.c	Fri Feb 14 16:23:58 2003 +0000
     2.3 @@ -2221,17 +2221,13 @@ long do_net_update(void)
     2.4              if ( copy_from_user(&tx, net_ring->tx_ring+i, sizeof(tx)) )
     2.5                  continue;
     2.6  
     2.7 -            if ( tx.size < PKT_PROT_LEN ) continue; // This should be reasonable.
     2.8 -            
     2.9 -            // Packets must not cross page boundaries.  For now, this is a 
    2.10 -            // kernel panic, later it may become a continue -- silent fail.
    2.11 +            if ( tx.size < PKT_PROT_LEN ) continue; 
    2.12              
    2.13              if ( ((tx.addr & ~PAGE_MASK) + tx.size) >= PAGE_SIZE ) 
    2.14              {
    2.15                  DPRINTK("tx.addr: %lx, size: %lu, end: %lu\n", tx.addr, tx.size,
    2.16                      (tx.addr &~PAGE_MASK) + tx.size);
    2.17                  continue;
    2.18 -                //BUG();
    2.19              }
    2.20              
    2.21              if ( TX_RING_INC(i) == net_ring->tx_event )
    2.22 @@ -2244,7 +2240,6 @@ long do_net_update(void)
    2.23              
    2.24              g_data = map_domain_mem(tx.addr);
    2.25  
    2.26 -//print_range2(g_data, PKT_PROT_LEN);                
    2.27              protocol = __constant_htons(init_tx_header(g_data, tx.size, the_dev));
    2.28              if ( protocol == 0 )
    2.29              {
    2.30 @@ -2253,13 +2248,14 @@ long do_net_update(void)
    2.31              }
    2.32  
    2.33              target = __net_get_target_vif(g_data, tx.size, current_vif->id);
    2.34 -//printk("Send to target: %d\n", target); 
    2.35 +
    2.36              if (target > VIF_PHYSICAL_INTERFACE )
    2.37              {
    2.38                  // Local delivery: Allocate an skb off the domain free list
    2.39                  // fil it, and pass it to netif_rx as if it came off the NIC.
    2.40 -//printk("LOCAL! (%d) \n", target);
    2.41 +
    2.42                  skb = dev_alloc_skb(tx.size);
    2.43 +
    2.44                  if (skb == NULL) 
    2.45                  {
    2.46                      unmap_domain_mem(g_data);
    2.47 @@ -2269,7 +2265,7 @@ long do_net_update(void)
    2.48                  skb->src_vif = current_vif->id;
    2.49                  skb->dst_vif = target;
    2.50                  skb->protocol = protocol;
    2.51 -
    2.52 +                
    2.53                  skb->head = (u8 *)map_domain_mem(((skb->pf - frame_table) << PAGE_SHIFT));
    2.54                  skb->data = skb->head + 16;
    2.55                  skb_reserve(skb,2);
    2.56 @@ -2289,38 +2285,26 @@ long do_net_update(void)
    2.57                  // Set a frag link to the remaining data, and we will scatter-gather
    2.58                  // in the device driver to send the two bits later.
    2.59                  
    2.60 -                /*unmap_domain_mem(g_data);*/
    2.61 -                    
    2.62                  skb = alloc_skb(PKT_PROT_LEN, GFP_KERNEL); // Eth header + two IP addrs.
    2.63                  if (skb == NULL) 
    2.64 -                {
    2.65 -printk("Alloc skb failed!\n");
    2.66                      continue;
    2.67 -                }
    2.68              
    2.69                  skb_put(skb, PKT_PROT_LEN);
    2.70 -                /*if ( copy_from_user(skb->data, (void *)tx.addr, PKT_PROT_LEN) )
    2.71 -                {
    2.72 -printk("Copy from user failed!\n");
    2.73 -                    kfree_skb(skb);
    2.74 -                    continue;
    2.75 -                }
    2.76 -                */
    2.77                  memcpy(skb->data, g_data, PKT_PROT_LEN);
    2.78                  unmap_domain_mem(g_data);
    2.79 -//print_range2(g_data, PKT_PROT_LEN);                
    2.80 +
    2.81                  skb->dev = the_dev;
    2.82                  skb->src_vif = current_vif->id;
    2.83                  skb->dst_vif = target;
    2.84 -                skb->protocol = protocol; // These next two lines abbreviate the call 
    2.85 -                                          // to eth_type_trans as we already have our
    2.86 -                                          // protocol.
    2.87 -                //skb_pull(skb, skb->dev->hard_header_len);
    2.88 +                skb->protocol = protocol; 
    2.89                  skb->mac.raw=skb->data; 
    2.90  
    2.91                  // set tot_count++ in the guest data pfn.
    2.92                  page = (tx.addr >> PAGE_SHIFT) + frame_table;
    2.93                  page->tot_count++;
    2.94 +                
    2.95 +                // assign a destructor to the skb that will unlink and dec the tot_count
    2.96 +                skb->destructor = &tx_skb_release;
    2.97  
    2.98                  // place the remainder of the packet (which is in guest memory) into an
    2.99                  // skb frag.
   2.100 @@ -2332,10 +2316,6 @@ printk("Copy from user failed!\n");
   2.101                  skb->data_len = tx.size - skb->len;
   2.102                  skb->len = tx.size;
   2.103                  
   2.104 -                // assign a destructor to the skb that will unlink and dec the tot_count
   2.105 -                skb->destructor = &tx_skb_release;
   2.106 -                //skb_push(skb, skb->dev->hard_header_len);
   2.107 -//printk("calling dev_queue_xmit!\n");
   2.108                  dev_queue_xmit(skb);
   2.109              }
   2.110              else
   2.111 @@ -2370,7 +2350,6 @@ printk("Copy from user failed!\n");
   2.112  
   2.113                  if  ( page->flags != (PGT_l1_page_table | current->domain) ) 
   2.114                  {
   2.115 -BUG();
   2.116                         continue;
   2.117                  }
   2.118  
   2.119 @@ -2379,7 +2358,6 @@ BUG();
   2.120  
   2.121                  if (!(*g_pte & _PAGE_PRESENT))
   2.122                  {
   2.123 -BUG();
   2.124                          unmap_domain_mem(g_pte);
   2.125                          continue;
   2.126                  }
   2.127 @@ -2388,7 +2366,6 @@ BUG();
   2.128                  
   2.129                  if (page->tot_count != 1) 
   2.130                  {
   2.131 -printk("!\n");
   2.132                          unmap_domain_mem(g_pte);
   2.133                          continue;
   2.134                  }
   2.135 @@ -2411,21 +2388,22 @@ printk("!\n");
   2.136  int setup_network_devices(void)
   2.137  {
   2.138      int ret;
   2.139 -    struct net_device *dev = dev_get_by_name("eth0");
   2.140 -
   2.141 +    extern char opt_ifname[];
   2.142 +    struct net_device *dev = dev_get_by_name(opt_ifname);
   2.143 +    
   2.144      if ( dev == NULL ) 
   2.145      {
   2.146 -        printk("Could not find device eth0\n");
   2.147 +        printk("Could not find device %s\n", opt_ifname);
   2.148          return 0;
   2.149      }
   2.150  
   2.151      ret = dev_open(dev);
   2.152      if ( ret != 0 )
   2.153      {
   2.154 -        printk("Error opening device eth0 for use (%d)\n", ret);
   2.155 +        printk("Error opening device %s for use (%d)\n", opt_ifname, ret);
   2.156          return 0;
   2.157      }
   2.158 -    printk("Device eth0 opened and ready for use\n");
   2.159 +    printk("Device %s opened and ready for use.\n", opt_ifname);
   2.160      the_dev = dev;
   2.161  
   2.162      return 1;
     3.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c	Fri Feb 14 14:27:45 2003 +0000
     3.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/network/network.c	Fri Feb 14 16:23:58 2003 +0000
     3.3 @@ -353,6 +353,16 @@ static void network_rx_int(int irq, void
     3.4  
     3.5          skb_put(skb, np->net_ring->rx_ring[i].size);
     3.6          skb->protocol = eth_type_trans(skb, dev);
     3.7 +
     3.8 +        /* Set up shinfo -- from alloc_skb */
     3.9 +        /* This was particularily nasty:  the shared info is hidden at the back of the data area
    3.10 +         * (presumably so it can be shared), but on page flip it gets very spunked.
    3.11 +         */
    3.12 +
    3.13 +        atomic_set(&(skb_shinfo(skb)->dataref), 1);
    3.14 +        skb_shinfo(skb)->nr_frags = 0;
    3.15 +        skb_shinfo(skb)->frag_list = NULL;
    3.16 +                                
    3.17          np->stats.rx_packets++;
    3.18  
    3.19          np->stats.rx_bytes += np->net_ring->rx_ring[i].size;