ia64/xen-unstable

changeset 669:734baea3a436

bitkeeper revision 1.384 (3f2811d05XH-ocmJE7ybblgMy3Q92A)

network.c, dev.c, perfc_defn.h:
Networking fixes.
author kaf24@scramble.cl.cam.ac.uk
date Wed Jul 30 18:43:28 2003 +0000 (2003-07-30)
parents e924f1dd98f3
children 0e5f8fd98576
files xen/include/xeno/perfc_defn.h xen/net/dev.c xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c
line diff
     1.1 --- a/xen/include/xeno/perfc_defn.h	Wed Jul 30 18:27:29 2003 +0000
     1.2 +++ b/xen/include/xeno/perfc_defn.h	Wed Jul 30 18:43:28 2003 +0000
     1.3 @@ -9,6 +9,7 @@ PERFCOUNTER_CPU( sched_run1,   "sched: c
     1.4  PERFCOUNTER_CPU( sched_run2,   "sched: runs through scheduler" )
     1.5  PERFCOUNTER_CPU( sched_ctx,    "sched: context switches" )
     1.6  
     1.7 +PERFCOUNTER( net_hypercalls, "network hypercalls" )
     1.8  PERFCOUNTER( net_rx_capacity_drop, "net rx capacity drop" )
     1.9  PERFCOUNTER( net_rx_delivered, "net rx delivered" )
    1.10  PERFCOUNTER( net_rx_tlbflush, "net rx tlb flushes" )
     2.1 --- a/xen/net/dev.c	Wed Jul 30 18:27:29 2003 +0000
     2.2 +++ b/xen/net/dev.c	Wed Jul 30 18:43:28 2003 +0000
     2.3 @@ -1811,6 +1811,8 @@ long do_net_update(void)
     2.4      u8 *g_data;
     2.5      unsigned short protocol;
     2.6  
     2.7 +    perfc_incr(net_hypercalls);
     2.8 +
     2.9      for ( idx = 0; idx < MAX_DOMAIN_VIFS; idx++ )
    2.10      {
    2.11          if ( (vif = current->net_vif_list[idx]) == NULL )
     3.1 --- a/xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c	Wed Jul 30 18:27:29 2003 +0000
     3.2 +++ b/xenolinux-2.4.21-sparse/arch/xeno/drivers/network/network.c	Wed Jul 30 18:43:28 2003 +0000
     3.3 @@ -64,6 +64,8 @@ struct net_private
     3.4      spinlock_t tx_lock;
     3.5      unsigned int idx; /* Domain-specific index of this VIF. */
     3.6  
     3.7 +    unsigned int rx_bufs_to_notify;
     3.8 +
     3.9      /*
    3.10       * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
    3.11       * array is an index into a chain of free entries.
    3.12 @@ -111,6 +113,7 @@ static int network_open(struct net_devic
    3.13          return 0;
    3.14      }
    3.15  
    3.16 +    np->rx_bufs_to_notify = 0;
    3.17      np->rx_resp_cons = np->tx_resp_cons = np->tx_full = 0;
    3.18      memset(&np->stats, 0, sizeof(np->stats));
    3.19      spin_lock_init(&np->tx_lock);
    3.20 @@ -165,12 +168,9 @@ static void network_tx_buf_gc(struct net
    3.21      unsigned int i;
    3.22      struct net_private *np = dev->priv;
    3.23      struct sk_buff *skb;
    3.24 -    unsigned long flags;
    3.25      unsigned int prod;
    3.26      tx_entry_t *tx_ring = np->net_ring->tx_ring;
    3.27  
    3.28 -    spin_lock_irqsave(&np->tx_lock, flags);
    3.29 -
    3.30      do {
    3.31          prod = np->net_idx->tx_resp_prod;
    3.32  
    3.33 @@ -196,8 +196,6 @@ static void network_tx_buf_gc(struct net
    3.34          np->tx_full = 0;
    3.35          netif_wake_queue(dev);
    3.36      }
    3.37 -
    3.38 -    spin_unlock_irqrestore(&np->tx_lock, flags);
    3.39  }
    3.40  
    3.41  
    3.42 @@ -230,19 +228,26 @@ static void network_alloc_rx_buffers(str
    3.43          np->net_ring->rx_ring[i].req.id   = (unsigned short)id;
    3.44          np->net_ring->rx_ring[i].req.addr = 
    3.45              virt_to_machine(get_ppte(skb->head));
    3.46 +
    3.47 +        np->rx_bufs_to_notify++;
    3.48      }
    3.49  
    3.50 -    /*
    3.51 -     * We may have allocated buffers which have entries outstanding in
    3.52 -     * the page update queue -- make sure we flush those first!
    3.53 -     */
    3.54 -    flush_page_update_queue();
    3.55 +    if ( np->rx_bufs_to_notify > (RX_MAX_ENTRIES/4) )
    3.56 +    {
    3.57 +        /*
    3.58 +         * We may have allocated buffers which have entries outstanding in the 
    3.59 +         * page update queue -- make sure we flush those first!
    3.60 +         */
    3.61 +        flush_page_update_queue();
    3.62  
    3.63 -    np->net_idx->rx_req_prod = i;
    3.64 +        np->net_idx->rx_req_prod = i;
    3.65 +        
    3.66 +        np->net_idx->rx_event = RX_RING_INC(np->rx_resp_cons);
    3.67 +        
    3.68 +        HYPERVISOR_net_update();
    3.69  
    3.70 -    np->net_idx->rx_event = RX_RING_INC(np->rx_resp_cons);
    3.71 -
    3.72 -    HYPERVISOR_net_update();
    3.73 +        np->rx_bufs_to_notify = 0;
    3.74 +    }
    3.75  }
    3.76  
    3.77  
    3.78 @@ -272,7 +277,6 @@ static int network_start_xmit(struct sk_
    3.79          netif_stop_queue(dev);
    3.80          return -ENOBUFS;
    3.81      }
    3.82 -    i = np->net_idx->tx_req_prod;
    3.83  
    3.84      if ( (((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >= PAGE_SIZE )
    3.85      {
    3.86 @@ -284,6 +288,10 @@ static int network_start_xmit(struct sk_
    3.87          skb = new_skb;
    3.88      }   
    3.89      
    3.90 +    spin_lock_irq(&np->tx_lock);
    3.91 +
    3.92 +    i = np->net_idx->tx_req_prod;
    3.93 +
    3.94      id = GET_ID_FROM_FREELIST(np->tx_skbs);
    3.95      np->tx_skbs[id] = skb;
    3.96  
    3.97 @@ -294,18 +302,18 @@ static int network_start_xmit(struct sk_
    3.98      np->net_idx->tx_req_prod = TX_RING_INC(i);
    3.99      atomic_inc(&np->tx_entries);
   3.100  
   3.101 -    np->stats.tx_bytes += skb->len;
   3.102 -    np->stats.tx_packets++;
   3.103 +    network_tx_buf_gc(dev);
   3.104  
   3.105 -    spin_lock_irq(&np->tx_lock);
   3.106      if ( atomic_read(&np->tx_entries) >= TX_MAX_ENTRIES )
   3.107      {
   3.108          np->tx_full = 1;
   3.109          netif_stop_queue(dev);
   3.110      }
   3.111 +
   3.112      spin_unlock_irq(&np->tx_lock);
   3.113  
   3.114 -    network_tx_buf_gc(dev);
   3.115 +    np->stats.tx_bytes += skb->len;
   3.116 +    np->stats.tx_packets++;
   3.117  
   3.118      HYPERVISOR_net_update();
   3.119  
   3.120 @@ -316,12 +324,15 @@ static int network_start_xmit(struct sk_
   3.121  static void network_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
   3.122  {
   3.123      unsigned int i;
   3.124 +    unsigned long flags;
   3.125      struct net_device *dev = (struct net_device *)dev_id;
   3.126      struct net_private *np = dev->priv;
   3.127      struct sk_buff *skb;
   3.128      rx_resp_entry_t *rx;
   3.129      
   3.130 +    spin_lock_irqsave(&np->tx_lock, flags);
   3.131      network_tx_buf_gc(dev);
   3.132 +    spin_unlock_irqrestore(&np->tx_lock, flags);
   3.133  
   3.134   again:
   3.135      for ( i  = np->rx_resp_cons;