diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-10 13:47:09 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-10 13:47:09 +0100 |
commit | 2c48ac78fe7332574c0025947f577762f116ef61 (patch) | |
tree | 737079a194447bd7f566a0991c111e5a9bd93d8c | |
parent | 9fd20b06664b0f51c720173825cd3725a8c8d2f8 (diff) | |
download | xen-2c48ac78fe7332574c0025947f577762f116ef61.tar.gz xen-2c48ac78fe7332574c0025947f577762f116ef61.tar.bz2 xen-2c48ac78fe7332574c0025947f577762f116ef61.zip |
[NET] back: Fix netif rate limiting.
Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/netback/interface.c | 1 | ||||
-rw-r--r-- | linux-2.6-xen-sparse/drivers/xen/netback/netback.c | 22 |
2 files changed, 20 insertions, 3 deletions
diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c index 2785f4d895..d70955fd1b 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c @@ -153,6 +153,7 @@ netif_t *netif_alloc(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]) netif->credit_bytes = netif->remaining_credit = ~0UL; netif->credit_usec = 0UL; init_timer(&netif->credit_timeout); + netif->credit_timeout.expires = jiffies; dev->hard_start_xmit = netif_be_start_xmit; dev->get_stats = netif_be_get_stats; diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c index 49f6013d44..f50577eb35 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c @@ -793,10 +793,27 @@ void netif_deschedule_work(netif_t *netif) } +static void tx_add_credit(netif_t *netif) +{ + unsigned long max_burst; + + /* + * Allow a burst big enough to transmit a jumbo packet of up to 128kB. + * Otherwise the interface can seize up due to insufficient credit. + */ + max_burst = RING_GET_REQUEST(&netif->tx, netif->tx.req_cons)->size; + max_burst = min(max_burst, 131072UL); + max_burst = max(max_burst, netif->credit_bytes); + + netif->remaining_credit = min(netif->remaining_credit + + netif->credit_bytes, + max_burst); +} + static void tx_credit_callback(unsigned long data) { netif_t *netif = (netif_t *)data; - netif->remaining_credit = netif->credit_bytes; + tx_add_credit(netif); netif_schedule_work(netif); } @@ -1119,12 +1136,11 @@ static void net_tx_action(unsigned long unused) /* Passed the point where we can replenish credit? */ if (time_after_eq(now, next_credit)) { netif->credit_timeout.expires = now; - netif->remaining_credit = netif->credit_bytes; + tx_add_credit(netif); } /* Still too big to send right now? Set a callback. */ if (txreq.size > netif->remaining_credit) { - netif->remaining_credit = 0; netif->credit_timeout.data = (unsigned long)netif; netif->credit_timeout.function = |