diff -r ad33b3882867 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 24 19:41:47 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu May 25 22:26:15 2006 +1000 @@ -89,12 +89,6 @@ struct netfront_info { unsigned int handle; unsigned int evtchn, irq; - /* What is the status of our connection to the remote backend? */ -#define BEST_CLOSED 0 -#define BEST_DISCONNECTED 1 -#define BEST_CONNECTED 2 - unsigned int backend_state; - /* Receive-ring batched refills. */ #define RX_MIN_TARGET 8 #define RX_DFL_MIN_TARGET 64 @@ -143,14 +137,6 @@ static inline unsigned short get_id_from list[0] = list[id]; return id; } - -#ifdef DEBUG -static const char *be_state_name[] = { - [BEST_CLOSED] = "closed", - [BEST_DISCONNECTED] = "disconnected", - [BEST_CONNECTED] = "connected", -}; -#endif #define DPRINTK(fmt, args...) pr_debug("netfront (%s:%d) " fmt, \ __FUNCTION__, __LINE__, ##args) @@ -342,7 +328,6 @@ static int setup_device(struct xenbus_de } memset(txs, 0, PAGE_SIZE); memset(rxs, 0, PAGE_SIZE); - info->backend_state = BEST_DISCONNECTED; SHARED_RING_INIT(txs); FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE); @@ -465,7 +450,7 @@ static void network_tx_buf_gc(struct net struct netfront_info *np = netdev_priv(dev); struct sk_buff *skb; - if (np->backend_state != BEST_CONNECTED) + if (unlikely(!netif_carrier_ok(dev))) return; do { @@ -527,7 +512,7 @@ static void network_alloc_rx_buffers(str struct xen_memory_reservation reservation; grant_ref_t ref; - if (unlikely(np->backend_state != BEST_CONNECTED)) + if (unlikely(!netif_carrier_ok(dev))) return; /* @@ -662,7 +647,7 @@ static int network_start_xmit(struct sk_ spin_lock_irq(&np->tx_lock); - if (np->backend_state != BEST_CONNECTED) { + if (unlikely(!netif_carrier_ok(dev))) { spin_unlock_irq(&np->tx_lock); goto drop; } @@ -748,7 +733,7 @@ static int netif_poll(struct net_device spin_lock(&np->rx_lock); - if (np->backend_state != BEST_CONNECTED) { + if (unlikely(!netif_carrier_ok(dev))) { spin_unlock(&np->rx_lock); return 0; } @@ -1041,7 +1026,7 @@ static void network_connect(struct net_d * domain a kick because we've probably just requeued some * packets. */ - np->backend_state = BEST_CONNECTED; + netif_carrier_on(dev); notify_remote_via_irq(np->irq); network_tx_buf_gc(dev); @@ -1055,7 +1040,7 @@ static void show_device(struct netfront_ if (np) { IPRINTK("\n", np->handle, - be_state_name[np->backend_state], + netif_carrier_ok(np->netdev) ? "on" : "off", netif_running(np->netdev) ? "open" : "closed", np->evtchn, np->tx, @@ -1241,9 +1226,10 @@ static struct net_device * __devinit cre } np = netdev_priv(netdev); - np->backend_state = BEST_CLOSED; np->handle = handle; np->xbdev = dev; + + netif_carrier_off(netdev); spin_lock_init(&np->tx_lock); spin_lock_init(&np->rx_lock); @@ -1392,7 +1378,7 @@ static void netif_disconnect_backend(str /* Stop old i/f to prevent errors whilst we rebuild the state. */ spin_lock_irq(&info->tx_lock); spin_lock(&info->rx_lock); - info->backend_state = BEST_DISCONNECTED; + netif_carrier_off(info->netdev); spin_unlock(&info->rx_lock); spin_unlock_irq(&info->tx_lock);