Herbert Xu
2006-May-17 11:33 UTC
[Xen-devel] [XEN 1/2] [NET] front: Remove tx_full and unnecessary queue operations
Hi: [NET] front: Remove tx_full and unnecessary queue operations The tx_full variable merely mirrors information already present in the XOFF bit on the net device. The net device architecture itself is quite mature and can be trusted by Xen to maintain its state correctly. Also, it''s pointless to stop the queue in close_netdev since it can be waken up anyway since there could be a softirq running on another CPU. All of this is handled by unregister_netdev anyway. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- diff -r 7cbc1fc8dbea -r 588516fce414 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Tue May 16 19:54:41 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17 17:16:17 2006 +1000 @@ -81,7 +81,6 @@ struct netfront_info struct net_device *netdev; struct net_device_stats stats; - unsigned int tx_full; netif_tx_front_ring_t tx; netif_rx_front_ring_t rx; @@ -506,10 +505,9 @@ static void network_tx_buf_gc(struct net } while (prod != np->tx.sring->rsp_prod); out: - if ((np->tx_full) && + if (unlikely(netif_queue_stopped(dev)) && ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) && !gnttab_empty_grant_references(&np->gref_tx_head)) { - np->tx_full = 0; if (np->user_state == UST_OPEN) netif_wake_queue(dev); } @@ -650,13 +648,6 @@ static int network_start_xmit(struct sk_ unsigned long mfn; int notify; - if (unlikely(np->tx_full)) { - printk(KERN_ALERT "%s: full queue wasn''t stopped!\n", - dev->name); - netif_stop_queue(dev); - goto drop; - } - if (unlikely((((unsigned long)skb->data & ~PAGE_MASK) + skb->len) > PAGE_SIZE)) { struct sk_buff *nskb; @@ -712,7 +703,6 @@ static int network_start_xmit(struct sk_ if (RING_FULL(&np->tx) || gnttab_empty_grant_references(&np->gref_tx_head)) { - np->tx_full = 1; netif_stop_queue(dev); } @@ -987,11 +977,8 @@ static void network_connect(struct net_d /* Recovery procedure: */ - /* Step 1: Reinitialise variables. */ - np->tx_full = 0; - /* - * Step 2: Rebuild the RX and TX ring contents. + * Step 1: Rebuild the RX and TX ring contents. * NB. We could just free the queued TX packets now but we hope * that sending them out might do some good. We have to rebuild * the RX ring because some of our pages are currently flipped out @@ -1055,7 +1042,7 @@ static void network_connect(struct net_d RING_PUSH_REQUESTS(&np->rx); /* - * Step 3: All public and private state should now be sane. Get + * Step 2: All public and private state should now be sane. Get * ready to start sending and receiving packets and give the driver * domain a kick because we''ve probably just requeued some * packets. @@ -1266,10 +1253,6 @@ static int netfront_remove(struct xenbus static void close_netdev(struct netfront_info *info) { - spin_lock_irq(&info->netdev->xmit_lock); - netif_stop_queue(info->netdev); - spin_unlock_irq(&info->netdev->xmit_lock); - #ifdef CONFIG_PROC_FS xennet_proc_delif(info->netdev); #endif _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Herbert Xu
2006-May-17 11:34 UTC
[Xen-devel] [XEN 2/2] [NET] front: Replace user_state with netif_running
Hi: [NET] front: Replace user_state with netif_running The user_state variable is simply replicating information that''s already present through netif_running. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- diff -r 588516fce414 -r 8cd36acf7609 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17 17:16:17 2006 +1000 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17 17:32:31 2006 +1000 @@ -97,11 +97,6 @@ struct netfront_info #define BEST_CONNECTED 2 unsigned int backend_state; - /* Is this interface open or closed (down or up)? */ -#define UST_CLOSED 0 -#define UST_OPEN 1 - unsigned int user_state; - /* Receive-ring batched refills. */ #define RX_MIN_TARGET 8 #define RX_DFL_MIN_TARGET 64 @@ -445,8 +440,6 @@ static int network_open(struct net_devic struct netfront_info *np = netdev_priv(dev); memset(&np->stats, 0, sizeof(np->stats)); - - np->user_state = UST_OPEN; network_alloc_rx_buffers(dev); np->rx.sring->rsp_event = np->rx.rsp_cons + 1; @@ -508,7 +501,7 @@ static void network_tx_buf_gc(struct net if (unlikely(netif_queue_stopped(dev)) && ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) && !gnttab_empty_grant_references(&np->gref_tx_head)) { - if (np->user_state == UST_OPEN) + if (likely(netif_running(dev))) netif_wake_queue(dev); } } @@ -730,7 +723,7 @@ static irqreturn_t netif_int(int irq, vo spin_unlock_irqrestore(&np->tx_lock, flags); if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) && - (np->user_state == UST_OPEN)) + likely(netif_running(dev))) netif_rx_schedule(dev); return IRQ_HANDLED; @@ -952,7 +945,6 @@ static int network_close(struct net_devi static int network_close(struct net_device *dev) { struct netfront_info *np = netdev_priv(dev); - np->user_state = UST_CLOSED; netif_stop_queue(np->netdev); return 0; } @@ -1051,7 +1043,7 @@ static void network_connect(struct net_d notify_remote_via_irq(np->irq); network_tx_buf_gc(dev); - if (np->user_state == UST_OPEN) + if (netif_running(dev)) netif_start_queue(dev); spin_unlock(&np->rx_lock); @@ -1065,7 +1057,7 @@ static void show_device(struct netfront_ IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n", np->handle, be_state_name[np->backend_state], - np->user_state ? "open" : "closed", + netif_running(np->netdev) ? "open" : "closed", np->evtchn, np->tx, np->rx); @@ -1116,7 +1108,6 @@ static int create_netdev(int handle, str np = netdev_priv(netdev); np->backend_state = BEST_CLOSED; - np->user_state = UST_CLOSED; np->handle = handle; np->xbdev = dev; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel