ia64/xen-unstable

changeset 2318:959e38e07474

bitkeeper revision 1.1159.45.10 (412604827jsxItilS5gG-ddy0MGfzA)

Quieten skb alloc failures in net frontend.
author kaf24@scramble.cl.cam.ac.uk
date Fri Aug 20 14:02:42 2004 +0000 (2004-08-20)
parents 0d0b3847e406
children dfe33644e3f1 4950b4d2cf62
files linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug 20 13:11:32 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c	Fri Aug 20 14:02:42 2004 +0000
     1.3 @@ -27,12 +27,15 @@
     1.4  #include <asm/page.h>
     1.5  
     1.6  #if 0
     1.7 -#define dprintf(fmt, args...) printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args)
     1.8 +#define DPRINTK(fmt, args...) \
     1.9 +    printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args)
    1.10  #else
    1.11 -#define dprintf(fmt, args...) do {} while(0)
    1.12 +#define DPRINTK(fmt, args...) ((void)0)
    1.13  #endif
    1.14  
    1.15 -#define RX_BUF_SIZE ((PAGE_SIZE/2)+1) /* Fool the slab allocator :-) */
    1.16 +#ifndef __GFP_NOWARN
    1.17 +#define __GFP_NOWARN 0
    1.18 +#endif
    1.19  
    1.20  static void network_tx_buf_gc(struct net_device *dev);
    1.21  static void network_alloc_rx_buffers(struct net_device *dev);
    1.22 @@ -163,11 +166,22 @@ static int netctrl_connected_count(void)
    1.23      }
    1.24  
    1.25      netctrl.connected_n = connected;
    1.26 -    dprintf("> connected_n=%d interface_n=%d\n",
    1.27 +    DPRINTK("> connected_n=%d interface_n=%d\n",
    1.28              netctrl.connected_n, netctrl.interface_n);
    1.29      return connected;
    1.30  }
    1.31  
    1.32 +static inline struct sk_buff *alloc_skb_page(void)
    1.33 +{
    1.34 +    struct sk_buff *skb;
    1.35 +    skb = __dev_alloc_skb((PAGE_SIZE/2)+1, GFP_ATOMIC|__GFP_NOWARN);
    1.36 +#if 0
    1.37 +    if ( skb && unlikely(((unsigned long)skb->head & (PAGE_SIZE-1)) != 0) )
    1.38 +        panic("alloc_skb needs to provide us page-aligned buffers.");
    1.39 +#endif
    1.40 +    return skb;
    1.41 +}
    1.42 +
    1.43  static int network_open(struct net_device *dev)
    1.44  {
    1.45      struct net_private *np = dev->priv;
    1.46 @@ -246,15 +260,11 @@ static void network_alloc_rx_buffers(str
    1.47          return;
    1.48  
    1.49      do {
    1.50 -        skb = dev_alloc_skb(RX_BUF_SIZE);
    1.51 -        if ( unlikely(skb == NULL) )
    1.52 +        if ( unlikely((skb = alloc_skb_page()) == NULL) )
    1.53              break;
    1.54  
    1.55          skb->dev = dev;
    1.56  
    1.57 -        if ( unlikely(((unsigned long)skb->head & (PAGE_SIZE-1)) != 0) )
    1.58 -            panic("alloc_skb needs to provide us page-aligned buffers.");
    1.59 -
    1.60          id = GET_ID_FROM_FREELIST(np->rx_skbs);
    1.61  
    1.62          np->rx_skbs[id] = skb;
    1.63 @@ -325,8 +335,8 @@ static int network_start_xmit(struct sk_
    1.64      if ( unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) >=
    1.65                    PAGE_SIZE) )
    1.66      {
    1.67 -        struct sk_buff *new_skb = dev_alloc_skb(RX_BUF_SIZE);
    1.68 -        if ( unlikely(new_skb == NULL) )
    1.69 +        struct sk_buff *new_skb;
    1.70 +        if ( unlikely((new_skb = alloc_skb_page()) == NULL) )
    1.71              return 1;
    1.72          skb_put(new_skb, skb->len);
    1.73          memcpy(new_skb->data, skb->data, skb->len);
    1.74 @@ -628,8 +638,8 @@ static void netif_status_change(netif_fe
    1.75      struct net_device *dev;
    1.76      struct net_private *np;
    1.77      
    1.78 -    dprintf(">\n");
    1.79 -    dprintf("> status=%d handle=%d mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
    1.80 +    DPRINTK(">\n");
    1.81 +    DPRINTK("> status=%d handle=%d mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
    1.82             status->status,
    1.83             status->handle,
    1.84             status->mac[0], status->mac[1], status->mac[2],
    1.85 @@ -804,7 +814,7 @@ static void netif_driver_status_change(
    1.86      int err = 0;
    1.87      int i;
    1.88  
    1.89 -    dprintf("> nr_interfaces=%d\n", status->nr_interfaces);
    1.90 +    DPRINTK("> nr_interfaces=%d\n", status->nr_interfaces);
    1.91  
    1.92      netctrl.interface_n = status->nr_interfaces;
    1.93      netctrl.connected_n = 0;
    1.94 @@ -856,20 +866,26 @@ static int wait_for_interfaces(void)
    1.95      int err = 0, conn = 0;
    1.96      int wait_i, wait_n = 100;
    1.97  
    1.98 -    dprintf(">\n");
    1.99 +    DPRINTK(">\n");
   1.100 +
   1.101      for ( wait_i = 0; wait_i < wait_n; wait_i++)
   1.102      { 
   1.103 -        dprintf("> wait_i=%d\n", wait_i);
   1.104 +        DPRINTK("> wait_i=%d\n", wait_i);
   1.105          conn = netctrl_connected();
   1.106          if(conn) break;
   1.107          set_current_state(TASK_INTERRUPTIBLE);
   1.108          schedule_timeout(10);
   1.109      }
   1.110 -    if(conn <= 0){
   1.111 +
   1.112 +    if ( conn <= 0 )
   1.113 +    {
   1.114          err = netctrl_err(-ENETDOWN);
   1.115 -        printk(KERN_WARNING "[XEN] Failed to connect all virtual interfaces: err=%d\n", err);
   1.116 +        printk(KERN_WARNING "[XEN] Failed to connect all virtual interfaces: "
   1.117 +               "err=%d\n", err);
   1.118      }
   1.119 -    dprintf("< err=%d\n", err);
   1.120 +
   1.121 +    DPRINTK("< err=%d\n", err);
   1.122 +
   1.123      return err;
   1.124  }
   1.125