ia64/xen-unstable

changeset 10088:4bd332f2bb1e

[NET] front: clean up transmit queue waking

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 10:02:32 2006 +0100 (2006-05-18)
parents 64fbdbc31dba
children 898426a79d5a
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 09:41:29 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:02:32 2006 +0100
     1.3 @@ -449,9 +449,20 @@ static int network_open(struct net_devic
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 +static inline void network_maybe_wake_tx(struct net_device *dev)
     1.8 +{
     1.9 +	struct netfront_info *np = netdev_priv(dev);
    1.10 +
    1.11 +	if (unlikely(netif_queue_stopped(dev)) &&
    1.12 +	    !RING_FULL(&np->tx) &&
    1.13 +	    !gnttab_empty_grant_references(&np->gref_tx_head) &&
    1.14 +	    likely(netif_running(dev)))
    1.15 +		netif_wake_queue(dev);
    1.16 +}
    1.17 +
    1.18  static void network_tx_buf_gc(struct net_device *dev)
    1.19  {
    1.20 -	RING_IDX i, prod;
    1.21 +	RING_IDX cons, prod;
    1.22  	unsigned short id;
    1.23  	struct netfront_info *np = netdev_priv(dev);
    1.24  	struct sk_buff *skb;
    1.25 @@ -463,15 +474,15 @@ static void network_tx_buf_gc(struct net
    1.26  		prod = np->tx.sring->rsp_prod;
    1.27  		rmb(); /* Ensure we see responses up to 'rp'. */
    1.28  
    1.29 -		for (i = np->tx.rsp_cons; i != prod; i++) {
    1.30 -			id  = RING_GET_RESPONSE(&np->tx, i)->id;
    1.31 +		for (cons = np->tx.rsp_cons; cons != prod; cons++) {
    1.32 +			id  = RING_GET_RESPONSE(&np->tx, cons)->id;
    1.33  			skb = np->tx_skbs[id];
    1.34  			if (unlikely(gnttab_query_foreign_access(
    1.35  				np->grant_tx_ref[id]) != 0)) {
    1.36  				printk(KERN_ALERT "network_tx_buf_gc: warning "
    1.37  				       "-- grant still in use by backend "
    1.38  				       "domain.\n");
    1.39 -				goto out;
    1.40 +				break; /* bail immediately */
    1.41  			}
    1.42  			gnttab_end_foreign_access_ref(
    1.43  				np->grant_tx_ref[id], GNTMAP_readonly);
    1.44 @@ -495,15 +506,9 @@ static void network_tx_buf_gc(struct net
    1.45  		np->tx.sring->rsp_event =
    1.46  			prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
    1.47  		mb();
    1.48 -	} while (prod != np->tx.sring->rsp_prod);
    1.49 +	} while ((cons == prod) && (prod != np->tx.sring->rsp_prod));
    1.50  
    1.51 - out:
    1.52 -	if (unlikely(netif_queue_stopped(dev)) &&
    1.53 -	    ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) &&
    1.54 -	    !gnttab_empty_grant_references(&np->gref_tx_head)) {
    1.55 -		if (likely(netif_running(dev)))
    1.56 -			netif_wake_queue(dev);
    1.57 -	}
    1.58 +	network_maybe_wake_tx(dev);
    1.59  }
    1.60  
    1.61  
    1.62 @@ -695,9 +700,8 @@ static int network_start_xmit(struct sk_
    1.63  	network_tx_buf_gc(dev);
    1.64  
    1.65  	if (RING_FULL(&np->tx) ||
    1.66 -	    gnttab_empty_grant_references(&np->gref_tx_head)) {
    1.67 +	    gnttab_empty_grant_references(&np->gref_tx_head))
    1.68  		netif_stop_queue(dev);
    1.69 -	}
    1.70  
    1.71  	spin_unlock_irq(&np->tx_lock);
    1.72  
    1.73 @@ -1043,8 +1047,7 @@ static void network_connect(struct net_d
    1.74  	notify_remote_via_irq(np->irq);
    1.75  	network_tx_buf_gc(dev);
    1.76  
    1.77 -	if (netif_running(dev))
    1.78 -		netif_start_queue(dev);
    1.79 +	network_maybe_wake_tx(dev);
    1.80  
    1.81  	spin_unlock(&np->rx_lock);
    1.82  	spin_unlock_irq(&np->tx_lock);