ia64/xen-unstable

changeset 11780:cb337b2f817b

[NET] back: Fix netif rate limiting.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Oct 10 13:47:09 2006 +0100 (2006-10-10)
parents f028e3732803
children 4d1af7ebf676
files linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Oct 10 10:06:56 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Tue Oct 10 13:47:09 2006 +0100
     1.3 @@ -153,6 +153,7 @@ netif_t *netif_alloc(domid_t domid, unsi
     1.4  	netif->credit_bytes = netif->remaining_credit = ~0UL;
     1.5  	netif->credit_usec  = 0UL;
     1.6  	init_timer(&netif->credit_timeout);
     1.7 +	netif->credit_timeout.expires = jiffies;
     1.8  
     1.9  	dev->hard_start_xmit = netif_be_start_xmit;
    1.10  	dev->get_stats       = netif_be_get_stats;
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Oct 10 10:06:56 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Oct 10 13:47:09 2006 +0100
     2.3 @@ -793,10 +793,27 @@ void netif_deschedule_work(netif_t *neti
     2.4  }
     2.5  
     2.6  
     2.7 +static void tx_add_credit(netif_t *netif)
     2.8 +{
     2.9 +	unsigned long max_burst;
    2.10 +
    2.11 +	/*
    2.12 +	 * Allow a burst big enough to transmit a jumbo packet of up to 128kB.
    2.13 +	 * Otherwise the interface can seize up due to insufficient credit.
    2.14 +	 */
    2.15 +	max_burst = RING_GET_REQUEST(&netif->tx, netif->tx.req_cons)->size;
    2.16 +	max_burst = min(max_burst, 131072UL);
    2.17 +	max_burst = max(max_burst, netif->credit_bytes);
    2.18 +
    2.19 +	netif->remaining_credit = min(netif->remaining_credit +
    2.20 +				      netif->credit_bytes,
    2.21 +				      max_burst);
    2.22 +}
    2.23 +
    2.24  static void tx_credit_callback(unsigned long data)
    2.25  {
    2.26  	netif_t *netif = (netif_t *)data;
    2.27 -	netif->remaining_credit = netif->credit_bytes;
    2.28 +	tx_add_credit(netif);
    2.29  	netif_schedule_work(netif);
    2.30  }
    2.31  
    2.32 @@ -1119,12 +1136,11 @@ static void net_tx_action(unsigned long 
    2.33  			/* Passed the point where we can replenish credit? */
    2.34  			if (time_after_eq(now, next_credit)) {
    2.35  				netif->credit_timeout.expires = now;
    2.36 -				netif->remaining_credit = netif->credit_bytes;
    2.37 +				tx_add_credit(netif);
    2.38  			}
    2.39  
    2.40  			/* Still too big to send right now? Set a callback. */
    2.41  			if (txreq.size > netif->remaining_credit) {
    2.42 -				netif->remaining_credit = 0;
    2.43  				netif->credit_timeout.data     =
    2.44  					(unsigned long)netif;
    2.45  				netif->credit_timeout.function =