WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [5/11] [NET] back: Replace netif->active with netif_carrier_

To: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>, Xen Development Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [5/11] [NET] back: Replace netif->active with netif_carrier_ok
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 8 Jul 2006 00:19:02 +1000
Delivery-date: Fri, 07 Jul 2006 07:20:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060707141634.GA12031@xxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060707141634.GA12031@xxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
Hi:

[NET] back: Replace netif->active with netif_carrier_ok

The connection status to the frontend can be represented using
netif_carrier_ok instead of netif->active.  As a result, we delay
the construction of the dev qdisc until the carrier comes on.  This
is a prerequisite for adding a tx queue.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r d398fb29e84a -r 9fa8689fc0e9 
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Fri Jul 07 23:36:12 
2006 +1000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Fri Jul 07 23:36:16 
2006 +1000
@@ -87,7 +87,7 @@ typedef struct netif_st {
 
        /* Miscellaneous private stuff. */
        enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
-       int active;
+
        struct list_head list;  /* scheduling list */
        atomic_t         refcnt;
        struct net_device *dev;
diff -r d398fb29e84a -r 9fa8689fc0e9 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Fri Jul 07 
23:36:12 2006 +1000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Fri Jul 07 
23:36:16 2006 +1000
@@ -37,9 +37,7 @@ static void __netif_up(netif_t *netif)
 static void __netif_up(netif_t *netif)
 {
        struct net_device *dev = netif->dev;
-       netif_tx_lock_bh(dev);
-       netif->active = 1;
-       netif_tx_unlock_bh(dev);
+       netif_carrier_on(dev);
        enable_irq(netif->irq);
        netif_schedule_work(netif);
 }
@@ -49,7 +47,7 @@ static void __netif_down(netif_t *netif)
        struct net_device *dev = netif->dev;
        disable_irq(netif->irq);
        netif_tx_lock_bh(dev);
-       netif->active = 0;
+       netif_carrier_off(dev);
        netif_tx_unlock_bh(dev);
        netif_deschedule_work(netif);
 }
@@ -91,6 +89,8 @@ netif_t *netif_alloc(domid_t domid, unsi
                DPRINTK("Could not create netif: out of memory\n");
                return ERR_PTR(-ENOMEM);
        }
+
+       netif_carrier_off(dev);
 
        netif = netdev_priv(dev);
        memset(netif, 0, sizeof(*netif));
diff -r d398fb29e84a -r 9fa8689fc0e9 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri Jul 07 
23:36:12 2006 +1000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Fri Jul 07 
23:36:16 2006 +1000
@@ -143,7 +143,7 @@ int netif_be_start_xmit(struct sk_buff *
        BUG_ON(skb->dev != dev);
 
        /* Drop the packet if the target domain has no receive buffers. */
-       if (!netif->active || 
+       if (unlikely(!netif_carrier_ok(dev)) ||
            (netif->rx_req_cons_peek == netif->rx.sring->req_prod) ||
            ((netif->rx_req_cons_peek - netif->rx.rsp_prod_pvt) ==
             NET_RX_RING_SIZE))
@@ -404,7 +404,8 @@ static void add_to_net_schedule_list_tai
                return;
 
        spin_lock_irq(&net_schedule_list_lock);
-       if (!__on_net_schedule_list(netif) && netif->active) {
+       if (!__on_net_schedule_list(netif) &&
+           likely(netif_carrier_ok(netif->dev))) {
                list_add_tail(&netif->list, &net_schedule_list);
                netif_get(netif);
        }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>