Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754570AbXEGVKg (ORCPT ); Mon, 7 May 2007 17:10:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754344AbXEGVKb (ORCPT ); Mon, 7 May 2007 17:10:31 -0400 Received: from gw.goop.org ([64.81.55.164]:57257 "EHLO mail.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbXEGVKa (ORCPT ); Mon, 7 May 2007 17:10:30 -0400 Message-ID: <463F95C3.60407@goop.org> Date: Mon, 07 May 2007 14:10:27 -0700 From: Jeremy Fitzhardinge User-Agent: Thunderbird 1.5.0.10 (X11/20070302) MIME-Version: 1.0 To: Herbert Xu CC: Christoph Hellwig , Andi Kleen , Andrew Morton , virtualization@lists.osdl.org, lkml , Chris Wright , Ian Pratt , Christian Limpach , netdev@vger.kernel.org, Jeff Garzik , Stephen Hemminger , Rusty Russell , Keir Fraser Subject: Re: [patch 25/29] xen: Add the Xen virtual network device driver. References: <20070504232051.411946839@goop.org> <20070504232121.492190579@goop.org> <20070505091624.GA8890@infradead.org> <463C56D3.8060609@goop.org> <20070505102305.GA12771@gondor.apana.org.au> In-Reply-To: <20070505102305.GA12771@gondor.apana.org.au> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4031 Lines: 131 Herbert Xu wrote: > On Sat, May 05, 2007 at 03:05:07AM -0700, Jeremy Fitzhardinge wrote: > >> Sorry, I forgot about it. I was waiting to hear back from network >> people about what this is actually for, and whether we really need it. >> > > We should just change this to use netif_device_attach and > netif_device_detach. > Like this? --- drivers/net/xen-netfront.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) =================================================================== --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -95,7 +95,6 @@ struct netfront_info { unsigned int evtchn; unsigned int copying_receiver; - unsigned int carrier; /* Receive-ring batched refills. */ #define RX_MIN_TARGET 8 @@ -142,15 +141,6 @@ struct netfront_rx_info { }; /* - * Implement our own carrier flag: the network stack's version causes delays - * when the carrier is re-enabled (in particular, dev_activate() may not - * immediately be called, which can cause packet loss). - */ -#define netfront_carrier_on(netif) ((netif)->carrier = 1) -#define netfront_carrier_off(netif) ((netif)->carrier = 0) -#define netfront_carrier_ok(netif) ((netif)->carrier) - -/* * Access macros for acquiring freeing slots in tx_skbs[]. */ @@ -241,7 +231,7 @@ static void xennet_alloc_rx_buffers(stru int nr_flips; struct xen_netif_rx_request *req; - if (unlikely(!netfront_carrier_ok(np))) + if (unlikely(!netif_device_present(dev))) return; /* @@ -380,7 +370,7 @@ static int xennet_open(struct net_device memset(&np->stats, 0, sizeof(np->stats)); spin_lock_bh(&np->rx_lock); - if (netfront_carrier_ok(np)) { + if (netif_device_present(dev)) { xennet_alloc_rx_buffers(dev); np->rx.sring->rsp_event = np->rx.rsp_cons + 1; if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)) @@ -400,7 +390,7 @@ static void xennet_tx_buf_gc(struct net_ struct netfront_info *np = netdev_priv(dev); struct sk_buff *skb; - BUG_ON(!netfront_carrier_ok(np)); + BUG_ON(!netif_device_present(dev)); do { prod = np->tx.sring->rsp_prod; @@ -540,7 +530,7 @@ static int xennet_start_xmit(struct sk_b spin_lock_irq(&np->tx_lock); - if (unlikely(!netfront_carrier_ok(np) || + if (unlikely(!netif_device_present(dev) || (frags > 1 && !xennet_can_sg(dev)) || netif_needs_gso(dev, skb))) { spin_unlock_irq(&np->tx_lock); @@ -973,7 +963,7 @@ static int xennet_poll(struct net_device spin_lock(&np->rx_lock); - if (unlikely(!netfront_carrier_ok(np))) { + if (unlikely(!netif_device_present(dev))) { spin_unlock(&np->rx_lock); return 0; } @@ -1308,7 +1298,7 @@ static struct net_device * __devinit xen np->netdev = netdev; - netfront_carrier_off(np); + netif_device_detach(netdev); return netdev; @@ -1376,7 +1366,7 @@ static void xennet_disconnect_backend(st /* Stop old i/f to prevent errors whilst we rebuild the state. */ spin_lock_bh(&info->rx_lock); spin_lock_irq(&info->tx_lock); - netfront_carrier_off(info); + netif_device_detach(info->netdev); spin_unlock_irq(&info->tx_lock); spin_unlock_bh(&info->rx_lock); @@ -1440,7 +1430,7 @@ static irqreturn_t xennet_interrupt(int spin_lock_irqsave(&np->tx_lock, flags); - if (likely(netfront_carrier_ok(np))) { + if (likely(netif_device_present(dev))) { xennet_tx_buf_gc(dev); /* Under tx_lock: protects access to rx shared-ring indexes. */ if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx)) @@ -1728,7 +1718,7 @@ static int xennet_connect(struct net_dev * domain a kick because we've probably just requeued some * packets. */ - netfront_carrier_on(np); + netif_device_attach(np->netdev); notify_remote_via_irq(np->netdev->irq); xennet_tx_buf_gc(dev); xennet_alloc_rx_buffers(dev); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/