ia64/xen-unstable

changeset 861:237fc224664b

bitkeeper revision 1.537 (3f9fdaf6WHo2pALR0EKO7h2Oe_V97A)

network.c:
Fixes to xenolinux net driver.
author kaf24@scramble.cl.cam.ac.uk
date Wed Oct 29 15:21:26 2003 +0000 (2003-10-29)
parents 02306208d767
children ad1f9e4c50e1
files xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c
line diff
     1.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c	Wed Oct 29 14:43:22 2003 +0000
     1.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c	Wed Oct 29 15:21:26 2003 +0000
     1.3 @@ -40,7 +40,6 @@
     1.4  static void network_interrupt(int irq, void *dev_id, struct pt_regs *ptregs);
     1.5  static void network_tx_buf_gc(struct net_device *dev);
     1.6  static void network_alloc_rx_buffers(struct net_device *dev);
     1.7 -static void network_free_rx_buffers(struct net_device *dev);
     1.8  static void cleanup_module(void);
     1.9  
    1.10  static struct list_head dev_list;
    1.11 @@ -98,8 +97,6 @@ static void dbg_network_int(int irq, voi
    1.12             " rx_req_prod = %d, rx_resp_prod = %d, rx_event = %d\n",
    1.13             np->rx_resp_cons, np->net_idx->rx_req_prod,
    1.14             np->net_idx->rx_resp_prod, np->net_idx->rx_event);
    1.15 -
    1.16 -    show_registers(ptregs);
    1.17  }
    1.18  
    1.19  
    1.20 @@ -129,15 +126,12 @@ static int network_open(struct net_devic
    1.21      for ( i = 0; i < RX_RING_SIZE; i++ )
    1.22          np->rx_skbs[i] = (void *)(i+1);
    1.23  
    1.24 -    network_alloc_rx_buffers(dev);
    1.25 -
    1.26      error = request_irq(NET_IRQ, network_interrupt, 
    1.27                          SA_SAMPLE_RANDOM, "network", dev);
    1.28      if ( error )
    1.29      {
    1.30          printk(KERN_WARNING "%s: Could not allocate network interrupt\n",
    1.31                 dev->name);
    1.32 -        network_free_rx_buffers(dev);
    1.33          goto fail;
    1.34      }
    1.35  
    1.36 @@ -149,6 +143,8 @@ static int network_open(struct net_devic
    1.37                 dev->name);
    1.38      }
    1.39  
    1.40 +    network_alloc_rx_buffers(dev);
    1.41 +
    1.42      printk("XenoLinux Virtual Network Driver installed as %s\n", dev->name);
    1.43  
    1.44      netif_start_queue(dev);
    1.45 @@ -226,6 +222,9 @@ static void network_alloc_rx_buffers(str
    1.46          if ( skb == NULL ) break;
    1.47          skb->dev = dev;
    1.48  
    1.49 +        if ( unlikely(((unsigned long)skb->head & (PAGE_SIZE-1)) != 0) )
    1.50 +            panic("alloc_skb needs to provide us page-aligned buffers.");
    1.51 +
    1.52          id = GET_ID_FROM_FREELIST(np->rx_skbs);
    1.53          np->rx_skbs[id] = skb;
    1.54  
    1.55 @@ -255,21 +254,6 @@ static void network_alloc_rx_buffers(str
    1.56  }
    1.57  
    1.58  
    1.59 -static void network_free_rx_buffers(struct net_device *dev)
    1.60 -{
    1.61 -    unsigned int i;
    1.62 -    struct net_private *np = dev->priv;
    1.63 -    struct sk_buff *skb;    
    1.64 -
    1.65 -    for ( i  = np->rx_resp_cons; 
    1.66 -          i != np->net_idx->rx_req_prod; 
    1.67 -          i  = RX_RING_INC(i) )
    1.68 -    {
    1.69 -        skb = np->rx_skbs[np->net_ring->rx_ring[i].req.id];
    1.70 -        dev_kfree_skb_any(skb);
    1.71 -    }
    1.72 -}
    1.73 -
    1.74  static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
    1.75  {
    1.76      unsigned int i, id;
    1.77 @@ -370,15 +354,7 @@ static void network_interrupt(int irq, v
    1.78          phys_to_machine_mapping[virt_to_phys(skb->head) >> PAGE_SHIFT] =
    1.79              (*(unsigned long *)get_ppte(skb->head)) >> PAGE_SHIFT;
    1.80  
    1.81 -        if ( rx->offset < 16 )
    1.82 -        {
    1.83 -            printk(KERN_ALERT "need pkt offset >= 16 (got %d)\n", rx->offset);
    1.84 -            dev_kfree_skb_any(skb);
    1.85 -            continue;
    1.86 -        }
    1.87 -        
    1.88 -        skb_reserve(skb, rx->offset - 16);
    1.89 -
    1.90 +        skb->data = skb->tail = skb->head + rx->offset;
    1.91          skb_put(skb, rx->size);
    1.92          skb->protocol = eth_type_trans(skb, dev);
    1.93  
    1.94 @@ -402,23 +378,6 @@ static void network_interrupt(int irq, v
    1.95  int network_close(struct net_device *dev)
    1.96  {
    1.97      netif_stop_queue(dev);
    1.98 -
    1.99 -    /*
   1.100 -     * XXXX This cannot be done safely until be have a proper interface
   1.101 -     * for setting up and tearing down virtual interfaces on the fly.
   1.102 -     * Currently the receive buffers are locked down by Xen and we have
   1.103 -     * no sensible way of retrieving them.
   1.104 -     */
   1.105 -#if 0
   1.106 -    free_irq(NET_IRQ, dev);
   1.107 -
   1.108 -    network_free_rx_buffers(dev);
   1.109 -    kfree(np->net_ring->rx_ring);
   1.110 -    kfree(np->net_ring->tx_ring);
   1.111 -
   1.112 -    MOD_DEC_USE_COUNT;
   1.113 -#endif
   1.114 -
   1.115      return 0;
   1.116  }
   1.117