ia64/xen-unstable

changeset 2569:e9d6f07d0e52

bitkeeper revision 1.1159.96.1 (415ab5b3EClFFrtIHoI6XpNdO3uguQ)

Reduce burstiness of allocations in netfront driver. Also set a
fill traget for the receive ring which is as small as possible without
dropping packets.
author kaf24@freefall.cl.cam.ac.uk
date Wed Sep 29 13:16:35 2004 +0000 (2004-09-29)
parents 3f0a9708178b
children 3af1c3b54760 5109394e871c
files linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Mon Sep 27 17:35:52 2004 +0000
     1.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/netfront/netfront.c	Wed Sep 29 13:16:35 2004 +0000
     1.3 @@ -31,22 +31,6 @@
     1.4  
     1.5  #define DEBUG 0
     1.6  
     1.7 -#if DEBUG
     1.8 -#define DPRINTK(fmt, args...) \
     1.9 -    printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args)
    1.10 -#else
    1.11 -#define DPRINTK(fmt, args...) ((void)0)
    1.12 -#endif
    1.13 -
    1.14 -#define IPRINTK(fmt, args...) \
    1.15 -    printk(KERN_INFO "[XEN]" fmt, ##args)
    1.16 -
    1.17 -#define WPRINTK(fmt, args...) \
    1.18 -    printk(KERN_WARNING "[XEN]" fmt, ##args)
    1.19 -
    1.20 -#define EPRINTK(fmt, args...) \
    1.21 -    printk(KERN_ERROR "[XEN]" fmt, ##args)
    1.22 -
    1.23  #ifndef __GFP_NOWARN
    1.24  #define __GFP_NOWARN 0
    1.25  #endif
    1.26 @@ -114,6 +98,12 @@ struct net_private
    1.27  #define UST_OPEN          1
    1.28      unsigned int user_state;
    1.29  
    1.30 +    /* Receive-ring batched refills. */
    1.31 +#define RX_MIN_TARGET 8
    1.32 +#define RX_MAX_TARGET NETIF_RX_RING_SIZE
    1.33 +    int rx_target;
    1.34 +    struct sk_buff_head rx_batch;
    1.35 +
    1.36      /*
    1.37       * {tx,rx}_skbs store outstanding skbuffs. The first entry in each
    1.38       * array is an index into a chain of free entries.
    1.39 @@ -122,24 +112,6 @@ struct net_private
    1.40      struct sk_buff *rx_skbs[NETIF_RX_RING_SIZE+1];
    1.41  };
    1.42  
    1.43 -char * status_name[] = {
    1.44 -    [NETIF_INTERFACE_STATUS_CLOSED]       = "closed",
    1.45 -    [NETIF_INTERFACE_STATUS_DISCONNECTED] = "disconnected",
    1.46 -    [NETIF_INTERFACE_STATUS_CONNECTED]    = "connected",
    1.47 -    [NETIF_INTERFACE_STATUS_CHANGED]      = "changed",
    1.48 -};
    1.49 -
    1.50 -char * be_state_name[] = {
    1.51 -    [BEST_CLOSED]       = "closed",
    1.52 -    [BEST_DISCONNECTED] = "disconnected",
    1.53 -    [BEST_CONNECTED]    = "connected",
    1.54 -};
    1.55 -
    1.56 -char * user_state_name[] = {
    1.57 -    [UST_CLOSED] = "closed",
    1.58 -    [UST_OPEN]   = "open",
    1.59 -};
    1.60 -
    1.61  /* Access macros for acquiring freeing slots in {tx,rx}_skbs[]. */
    1.62  #define ADD_ID_TO_FREELIST(_list, _id)             \
    1.63      (_list)[(_id)] = (_list)[0];                   \
    1.64 @@ -149,6 +121,30 @@ char * user_state_name[] = {
    1.65      (_list)[0]  = (_list)[_id];                    \
    1.66      (unsigned short)_id; })
    1.67  
    1.68 +static char *status_name[] = {
    1.69 +    [NETIF_INTERFACE_STATUS_CLOSED]       = "closed",
    1.70 +    [NETIF_INTERFACE_STATUS_DISCONNECTED] = "disconnected",
    1.71 +    [NETIF_INTERFACE_STATUS_CONNECTED]    = "connected",
    1.72 +    [NETIF_INTERFACE_STATUS_CHANGED]      = "changed",
    1.73 +};
    1.74 +
    1.75 +static char *be_state_name[] = {
    1.76 +    [BEST_CLOSED]       = "closed",
    1.77 +    [BEST_DISCONNECTED] = "disconnected",
    1.78 +    [BEST_CONNECTED]    = "connected",
    1.79 +};
    1.80 +
    1.81 +#if DEBUG
    1.82 +#define DPRINTK(fmt, args...) \
    1.83 +    printk(KERN_ALERT "[XEN] (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args)
    1.84 +#else
    1.85 +#define DPRINTK(fmt, args...) ((void)0)
    1.86 +#endif
    1.87 +#define IPRINTK(fmt, args...) \
    1.88 +    printk(KERN_INFO "[XEN] " fmt, ##args)
    1.89 +#define WPRINTK(fmt, args...) \
    1.90 +    printk(KERN_WARNING "[XEN] " fmt, ##args)
    1.91 +
    1.92  static struct net_device *find_dev_by_handle(unsigned int handle)
    1.93  {
    1.94      struct list_head *ent;
    1.95 @@ -185,9 +181,8 @@ static void netctrl_init(void)
    1.96   */
    1.97  static int netctrl_err(int err)
    1.98  {
    1.99 -    if ( (err < 0) && !netctrl.err ){
   1.100 +    if ( (err < 0) && !netctrl.err )
   1.101          netctrl.err = err;
   1.102 -    }
   1.103      return netctrl.err;
   1.104  }
   1.105  
   1.106 @@ -197,13 +192,15 @@ static int netctrl_err(int err)
   1.107   */
   1.108  static int netctrl_connected(void)
   1.109  {
   1.110 -    int ok = 0;
   1.111 +    int ok;
   1.112  
   1.113 -    if(netctrl.err){
   1.114 +    if ( netctrl.err )
   1.115          ok = netctrl.err;
   1.116 -    } else if(netctrl.up == NETIF_DRIVER_STATUS_UP){
   1.117 +    else if ( netctrl.up == NETIF_DRIVER_STATUS_UP )
   1.118          ok = (netctrl.connected_n == netctrl.interface_n);
   1.119 -    }
   1.120 +    else
   1.121 +        ok = 0;
   1.122 +
   1.123      return ok;
   1.124  }
   1.125  
   1.126 @@ -222,9 +219,8 @@ static int netctrl_connected_count(void)
   1.127      
   1.128      list_for_each(ent, &dev_list) {
   1.129          np = list_entry(ent, struct net_private, list);
   1.130 -        if (np->backend_state == BEST_CONNECTED){
   1.131 +        if (np->backend_state == BEST_CONNECTED)
   1.132              connected++;
   1.133 -        }
   1.134      }
   1.135  
   1.136      netctrl.connected_n = connected;
   1.137 @@ -326,17 +322,34 @@ static void network_alloc_rx_buffers(str
   1.138      unsigned short id;
   1.139      struct net_private *np = dev->priv;
   1.140      struct sk_buff *skb;
   1.141 -    NETIF_RING_IDX i = np->rx->req_prod;
   1.142 -    int nr_pfns = 0;
   1.143 +    int i, batch_target;
   1.144 +    NETIF_RING_IDX req_prod = np->rx->req_prod;
   1.145  
   1.146 -    /* Make sure the batch is large enough to be worthwhile (1/2 ring). */
   1.147 -    if ( unlikely((i - np->rx_resp_cons) > (NETIF_RX_RING_SIZE/2)) || 
   1.148 -         unlikely(np->backend_state != BEST_CONNECTED) )
   1.149 +    if ( unlikely(np->backend_state != BEST_CONNECTED) )
   1.150          return;
   1.151  
   1.152 -    do {
   1.153 +    /*
   1.154 +     * Allocate skbuffs greedily, even though we batch updates to the
   1.155 +     * receive ring. This creates a less bursty demand on the memory allocator,
   1.156 +     * so should reduce the chance of failed allocation requests both for
   1.157 +     * ourself and for other kernel subsystems.
   1.158 +     */
   1.159 +    batch_target = np->rx_target - (req_prod - np->rx_resp_cons);
   1.160 +    for ( i = skb_queue_len(&np->rx_batch); i < batch_target; i++ )
   1.161 +    {
   1.162          if ( unlikely((skb = alloc_xen_skb(dev->mtu + RX_HEADROOM)) == NULL) )
   1.163              break;
   1.164 +        __skb_queue_tail(&np->rx_batch, skb);
   1.165 +    }
   1.166 +
   1.167 +    /* Is the batch large enough to be worthwhile? */
   1.168 +    if ( i < (np->rx_target/2)  )
   1.169 +        return;
   1.170 +
   1.171 +    for ( i = 0; ; i++ )
   1.172 +    {
   1.173 +        if ( (skb = __skb_dequeue(&np->rx_batch)) == NULL )
   1.174 +            break;
   1.175  
   1.176          skb->dev = dev;
   1.177  
   1.178 @@ -344,25 +357,19 @@ static void network_alloc_rx_buffers(str
   1.179  
   1.180          np->rx_skbs[id] = skb;
   1.181          
   1.182 -        np->rx->ring[MASK_NETIF_RX_IDX(i)].req.id = id;
   1.183 +        np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id;
   1.184          
   1.185 -        rx_pfn_array[nr_pfns] = virt_to_machine(skb->head) >> PAGE_SHIFT;
   1.186 +        rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
   1.187  
   1.188  	/* Remove this page from pseudo phys map before passing back to Xen. */
   1.189  	phys_to_machine_mapping[virt_to_phys(skb->head) >> PAGE_SHIFT] 
   1.190  	    = INVALID_P2M_ENTRY;
   1.191  
   1.192 -        rx_mcl[nr_pfns].op = __HYPERVISOR_update_va_mapping;
   1.193 -        rx_mcl[nr_pfns].args[0] = (unsigned long)skb->head >> PAGE_SHIFT;
   1.194 -        rx_mcl[nr_pfns].args[1] = 0;
   1.195 -        rx_mcl[nr_pfns].args[2] = 0;
   1.196 -
   1.197 -        nr_pfns++;
   1.198 +        rx_mcl[i].op = __HYPERVISOR_update_va_mapping;
   1.199 +        rx_mcl[i].args[0] = (unsigned long)skb->head >> PAGE_SHIFT;
   1.200 +        rx_mcl[i].args[1] = 0;
   1.201 +        rx_mcl[i].args[2] = 0;
   1.202      }
   1.203 -    while ( (++i - np->rx_resp_cons) != NETIF_RX_RING_SIZE );
   1.204 -
   1.205 -    if ( unlikely(nr_pfns == 0) )
   1.206 -        return;
   1.207  
   1.208      /*
   1.209       * We may have allocated buffers which have entries outstanding in the page
   1.210 @@ -371,25 +378,30 @@ static void network_alloc_rx_buffers(str
   1.211      flush_page_update_queue();
   1.212  
   1.213      /* After all PTEs have been zapped we blow away stale TLB entries. */
   1.214 -    rx_mcl[nr_pfns-1].args[2] = UVMF_FLUSH_TLB;
   1.215 +    rx_mcl[i-1].args[2] = UVMF_FLUSH_TLB;
   1.216  
   1.217      /* Give away a batch of pages. */
   1.218 -    rx_mcl[nr_pfns].op = __HYPERVISOR_dom_mem_op;
   1.219 -    rx_mcl[nr_pfns].args[0] = MEMOP_decrease_reservation;
   1.220 -    rx_mcl[nr_pfns].args[1] = (unsigned long)rx_pfn_array;
   1.221 -    rx_mcl[nr_pfns].args[2] = (unsigned long)nr_pfns;
   1.222 -    rx_mcl[nr_pfns].args[3] = 0;
   1.223 -    rx_mcl[nr_pfns].args[4] = DOMID_SELF;
   1.224 +    rx_mcl[i].op = __HYPERVISOR_dom_mem_op;
   1.225 +    rx_mcl[i].args[0] = MEMOP_decrease_reservation;
   1.226 +    rx_mcl[i].args[1] = (unsigned long)rx_pfn_array;
   1.227 +    rx_mcl[i].args[2] = (unsigned long)i;
   1.228 +    rx_mcl[i].args[3] = 0;
   1.229 +    rx_mcl[i].args[4] = DOMID_SELF;
   1.230  
   1.231      /* Zap PTEs and give away pages in one big multicall. */
   1.232 -    (void)HYPERVISOR_multicall(rx_mcl, nr_pfns+1);
   1.233 +    (void)HYPERVISOR_multicall(rx_mcl, i+1);
   1.234  
   1.235      /* Check return status of HYPERVISOR_dom_mem_op(). */
   1.236 -    if ( rx_mcl[nr_pfns].args[5] != nr_pfns )
   1.237 +    if ( unlikely(rx_mcl[i].args[5] != i) )
   1.238          panic("Unable to reduce memory reservation\n");
   1.239  
   1.240      /* Above is a suitable barrier to ensure backend will see requests. */
   1.241 -    np->rx->req_prod = i;
   1.242 +    np->rx->req_prod = req_prod + i;
   1.243 +
   1.244 +    /* Adjust our floating fill target if we risked running out of buffers. */
   1.245 +    if ( ((req_prod - np->rx->resp_prod) < (np->rx_target / 4)) &&
   1.246 +         ((np->rx_target *= 2) > RX_MAX_TARGET) )
   1.247 +        np->rx_target = RX_MAX_TARGET;
   1.248  }
   1.249  
   1.250  
   1.251 @@ -627,6 +639,12 @@ static int netif_poll(struct net_device 
   1.252  
   1.253      np->rx_resp_cons = i;
   1.254  
   1.255 +    /* If we get a callback with very few responses, reduce fill target. */
   1.256 +    /* NB. Note exponential increase, linear decrease. */
   1.257 +    if ( ((np->rx->req_prod - np->rx->resp_prod) > ((3*np->rx_target) / 4)) &&
   1.258 +         (--np->rx_target < RX_MIN_TARGET) )
   1.259 +        np->rx_target = RX_MIN_TARGET;
   1.260 +
   1.261      network_alloc_rx_buffers(dev);
   1.262  
   1.263      *pbudget   -= work_done;
   1.264 @@ -755,10 +773,10 @@ static void vif_show(struct net_private 
   1.265  {
   1.266  #if DEBUG
   1.267      if (np) {
   1.268 -        IPRINTK(" <vif handle=%u %s(%s) evtchn=%u irq=%u tx=%p rx=%p>\n",
   1.269 +        IPRINTK("<vif handle=%u %s(%s) evtchn=%u irq=%u tx=%p rx=%p>\n",
   1.270                 np->handle,
   1.271                 be_state_name[np->backend_state],
   1.272 -               user_state_name[np->user_state],
   1.273 +               np->user_state ? "open" : "closed",
   1.274                 np->evtchn,
   1.275                 np->irq,
   1.276                 np->tx,
   1.277 @@ -806,13 +824,13 @@ static int send_driver_status(int ok)
   1.278  
   1.279  /* Stop network device and free tx/rx queues and irq.
   1.280   */
   1.281 -static void vif_release(struct net_private *np){
   1.282 -
   1.283 +static void vif_release(struct net_private *np)
   1.284 +{
   1.285      /* Stop old i/f to prevent errors whilst we rebuild the state. */
   1.286      spin_lock_irq(&np->tx_lock);
   1.287      spin_lock(&np->rx_lock);
   1.288      netif_stop_queue(np->dev);
   1.289 -    //np->backend_state = BEST_DISCONNECTED;
   1.290 +    /* np->backend_state = BEST_DISCONNECTED; */
   1.291      spin_unlock(&np->rx_lock);
   1.292      spin_unlock_irq(&np->tx_lock);
   1.293      
   1.294 @@ -827,18 +845,18 @@ static void vif_release(struct net_priva
   1.295          np->tx = NULL;
   1.296          np->rx = NULL;
   1.297      }
   1.298 -
   1.299  }
   1.300  
   1.301  /* Release vif resources and close it down completely.
   1.302   */
   1.303 -static void vif_close(struct net_private *np){
   1.304 +static void vif_close(struct net_private *np)
   1.305 +{
   1.306      DPRINTK(">\n"); vif_show(np);
   1.307 -    WPRINTK(" Unexpected netif-CLOSED message in state %s\n",
   1.308 +    WPRINTK("Unexpected netif-CLOSED message in state %s\n",
   1.309              be_state_name[np->backend_state]);
   1.310      vif_release(np);
   1.311      np->backend_state = BEST_CLOSED;
   1.312 -    //todo: take dev down and free.
   1.313 +    /* todo: take dev down and free. */
   1.314      vif_show(np); DPRINTK("<\n");
   1.315  }
   1.316  
   1.317 @@ -873,11 +891,13 @@ static void vif_disconnect(struct net_pr
   1.318   * is initiated by a special "RESET" message - disconnect could
   1.319   * just mean we're not allowed to use this interface any more.
   1.320   */
   1.321 -static void vif_reset(struct net_private *np){
   1.322 +static void 
   1.323 +vif_reset(
   1.324 +    struct net_private *np)
   1.325 +{
   1.326      DPRINTK(">\n");
   1.327 -    IPRINTK(" Attempting to reconnect network interface: handle=%u\n",
   1.328 -            np->handle);
   1.329 -    
   1.330 +    IPRINTK("Attempting to reconnect network interface: handle=%u\n",
   1.331 +            np->handle);    
   1.332      vif_release(np);
   1.333      vif_disconnect(np);
   1.334      vif_show(np); DPRINTK("<\n");
   1.335 @@ -887,7 +907,10 @@ static void vif_reset(struct net_private
   1.336   * Sets the mac and event channel from the message.
   1.337   * Binds the irq to the event channel.
   1.338   */
   1.339 -static void vif_connect(struct net_private *np, netif_fe_interface_status_t *status){
   1.340 +static void
   1.341 +vif_connect(
   1.342 +    struct net_private *np, netif_fe_interface_status_t *status)
   1.343 +{
   1.344      struct net_device *dev = np->dev;
   1.345      DPRINTK(">\n");
   1.346      memcpy(dev->dev_addr, status->mac, ETH_ALEN);
   1.347 @@ -927,13 +950,14 @@ static int create_netdev(int handle, str
   1.348      spin_lock_init(&np->tx_lock);
   1.349      spin_lock_init(&np->rx_lock);
   1.350  
   1.351 +    skb_queue_head_init(&np->rx_batch);
   1.352 +    np->rx_target = RX_MIN_TARGET;
   1.353 +
   1.354      /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */
   1.355 -    for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ ){
   1.356 +    for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ )
   1.357          np->tx_skbs[i] = (void *)(i+1);
   1.358 -    }
   1.359 -    for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ ){
   1.360 +    for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ )
   1.361          np->rx_skbs[i] = (void *)(i+1);
   1.362 -    }
   1.363  
   1.364      dev->open            = network_open;
   1.365      dev->hard_start_xmit = network_start_xmit;
   1.366 @@ -951,11 +975,10 @@ static int create_netdev(int handle, str
   1.367      list_add(&np->list, &dev_list);
   1.368  
   1.369    exit:
   1.370 -    if ( (err != 0) && (dev != NULL ) ){
   1.371 +    if ( (err != 0) && (dev != NULL ) )
   1.372          kfree(dev);
   1.373 -    } else if ( val != NULL ) {
   1.374 +    else if ( val != NULL )
   1.375          *val = dev;
   1.376 -    }
   1.377      return err;
   1.378  }
   1.379  
   1.380 @@ -967,44 +990,42 @@ static int create_netdev(int handle, str
   1.381   * @param np return parameter for interface state
   1.382   * @return 0 on success, error code otherwise
   1.383   */
   1.384 -static int target_vif(netif_fe_interface_status_t *status, struct net_private **np)
   1.385 +static int 
   1.386 +target_vif(
   1.387 +    netif_fe_interface_status_t *status, struct net_private **np)
   1.388  {
   1.389      int err = 0;
   1.390      struct net_device *dev;
   1.391  
   1.392      DPRINTK("> handle=%d\n", status->handle);
   1.393 -    if(status->handle < 0) {
   1.394 +    if ( status->handle < 0 )
   1.395 +    {
   1.396          err = -EINVAL;
   1.397          goto exit;
   1.398      }
   1.399 -    dev = find_dev_by_handle(status->handle);
   1.400 -    DPRINTK("> dev=%p\n", dev);
   1.401 -    if(dev) goto exit;
   1.402 -    // No good - give up.
   1.403 -    if(status->status == NETIF_INTERFACE_STATUS_CLOSED) goto exit;
   1.404 -    if(status->status == NETIF_INTERFACE_STATUS_CHANGED) goto exit;
   1.405 -    // It's a new interface in a good state - create it.
   1.406 +
   1.407 +    if ( (dev = find_dev_by_handle(status->handle)) != NULL )
   1.408 +        goto exit;
   1.409 +
   1.410 +    if ( status->status == NETIF_INTERFACE_STATUS_CLOSED )
   1.411 +        goto exit;
   1.412 +    if ( status->status == NETIF_INTERFACE_STATUS_CHANGED )
   1.413 +        goto exit;
   1.414 +
   1.415 +    /* It's a new interface in a good state - create it. */
   1.416      DPRINTK("> create device...\n");
   1.417 -    err = create_netdev(status->handle, &dev);
   1.418 -    if(err) goto exit;
   1.419 +    if ( (err = create_netdev(status->handle, &dev)) != 0 )
   1.420 +        goto exit;
   1.421 +
   1.422      netctrl.interface_n++;
   1.423 +
   1.424    exit:
   1.425 -    if(np){
   1.426 +    if ( np != NULL )
   1.427          *np = ((dev && !err) ? dev->priv : NULL);
   1.428 -    }
   1.429      DPRINTK("< err=%d\n", err);
   1.430      return err;
   1.431  }
   1.432  
   1.433 -/* Warn about an unexpected status. */
   1.434 -static void unexpected(struct net_private *np,
   1.435 -                       netif_fe_interface_status_t *status)
   1.436 -{
   1.437 -    WPRINTK(" Unexpected netif status %s in state %s\n",
   1.438 -            status_name[status->status],
   1.439 -            be_state_name[np->backend_state]);
   1.440 -}
   1.441 -
   1.442  /* Handle an interface status message. */
   1.443  static void netif_interface_status(netif_fe_interface_status_t *status)
   1.444  {
   1.445 @@ -1012,22 +1033,25 @@ static void netif_interface_status(netif
   1.446      struct net_private *np = NULL;
   1.447      
   1.448      DPRINTK(">\n");
   1.449 -    DPRINTK("> status=%s handle=%d\n", status_name[status->status], status->handle);
   1.450 +    DPRINTK("> status=%s handle=%d\n",
   1.451 +            status_name[status->status], status->handle);
   1.452  
   1.453 -    err = target_vif(status, &np);
   1.454 -    if(err){
   1.455 -        WPRINTK(" Invalid netif: handle=%u\n", status->handle);
   1.456 +    if ( (err = target_vif(status, &np)) != 0 )
   1.457 +    {
   1.458 +        WPRINTK("Invalid netif: handle=%u\n", status->handle);
   1.459          return;
   1.460      }
   1.461 -    if(np == NULL){
   1.462 +
   1.463 +    if ( np == NULL )
   1.464 +    {
   1.465          DPRINTK("> no vif\n");
   1.466          return;
   1.467      }
   1.468  
   1.469      DPRINTK(">\n"); vif_show(np);
   1.470  
   1.471 -    switch (status->status) {
   1.472 -
   1.473 +    switch ( status->status )
   1.474 +    {
   1.475      case NETIF_INTERFACE_STATUS_CLOSED:
   1.476          switch ( np->backend_state )
   1.477          {
   1.478 @@ -1056,7 +1080,9 @@ static void netif_interface_status(netif
   1.479          switch ( np->backend_state )
   1.480          {
   1.481          case BEST_CLOSED:
   1.482 -            unexpected(np, status);
   1.483 +            WPRINTK("Unexpected netif status %s in state %s\n",
   1.484 +                    status_name[status->status],
   1.485 +                    be_state_name[np->backend_state]);
   1.486              vif_disconnect(np);
   1.487              vif_connect(np, status);
   1.488              break;
   1.489 @@ -1074,7 +1100,7 @@ static void netif_interface_status(netif
   1.490          break;
   1.491  
   1.492      default:
   1.493 -        WPRINTK(" Invalid netif status code %d\n", status->status);
   1.494 +        WPRINTK("Invalid netif status code %d\n", status->status);
   1.495          break;
   1.496      }
   1.497      vif_show(np);
   1.498 @@ -1135,7 +1161,8 @@ static int probe_interfaces(void)
   1.499  
   1.500      DPRINTK(">\n");
   1.501  
   1.502 -    for ( wait_i = 0; wait_i < wait_n; wait_i++) { 
   1.503 +    for ( wait_i = 0; wait_i < wait_n; wait_i++)
   1.504 +    { 
   1.505          DPRINTK("> wait_i=%d\n", wait_i);
   1.506          conn = netctrl_connected();
   1.507          if(conn) break;
   1.508 @@ -1145,9 +1172,10 @@ static int probe_interfaces(void)
   1.509      }
   1.510  
   1.511      DPRINTK("> wait finished...\n");
   1.512 -    if ( conn <= 0 ) {
   1.513 +    if ( conn <= 0 )
   1.514 +    {
   1.515          err = netctrl_err(-ENETDOWN);
   1.516 -        WPRINTK(" Failed to connect all virtual interfaces: err=%d\n", err);
   1.517 +        WPRINTK("Failed to connect all virtual interfaces: err=%d\n", err);
   1.518      }
   1.519  
   1.520      DPRINTK("< err=%d\n", err);
   1.521 @@ -1177,7 +1205,8 @@ static int probe_interfaces(void)
   1.522      DPRINTK(">\n");
   1.523  
   1.524      netctrl.interface_n = 0;
   1.525 -    for (wait_i = 0; wait_i < wait_n; wait_i++) { 
   1.526 +    for ( wait_i = 0; wait_i < wait_n; wait_i++ )
   1.527 +    { 
   1.528          DPRINTK("> wait_i=%d query=%d\n", wait_i, query);
   1.529          msg.handle = query;
   1.530          memcpy(cmsg.msg, &msg, sizeof(msg));
   1.531 @@ -1199,9 +1228,10 @@ static int probe_interfaces(void)
   1.532      }
   1.533  
   1.534    exit:
   1.535 -    if (err) {
   1.536 +    if ( err )
   1.537 +    {
   1.538          err = netctrl_err(-ENETDOWN);
   1.539 -        WPRINTK(" Connecting virtual network interfaces failed: err=%d\n", err);
   1.540 +        WPRINTK("Connecting virtual network interfaces failed: err=%d\n", err);
   1.541      }
   1.542  
   1.543      DPRINTK("< err=%d\n", err);
   1.544 @@ -1218,7 +1248,7 @@ static int __init netif_init(void)
   1.545           (start_info.flags & SIF_NET_BE_DOMAIN) )
   1.546          return 0;
   1.547  
   1.548 -    IPRINTK(" Initialising virtual ethernet driver.\n");
   1.549 +    IPRINTK("Initialising virtual ethernet driver.\n");
   1.550      INIT_LIST_HEAD(&dev_list);
   1.551      netctrl_init();
   1.552      (void)ctrl_if_register_receiver(CMSG_NETIF_FE, netif_ctrlif_rx,
   1.553 @@ -1277,7 +1307,8 @@ void netif_resume(void)
   1.554      struct net_private *np;
   1.555  
   1.556      DPRINTK(">\n");
   1.557 -    list_for_each(ent, &dev_list){
   1.558 +    list_for_each ( ent, &dev_list )
   1.559 +    {
   1.560          np = list_entry(ent, struct net_private, list);
   1.561          vif_resume(np);
   1.562      }