[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [NET] front: Use netif_carrier to model backend-connection state.
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID c9c40f6baba00f8fbc3fe6bb3338fb975e31849c # Parent e0bbba2b9850f258197ea5df59d6e7c53cbb0398 [NET] front: Use netif_carrier to model backend-connection state. The tristate backend_state really only needs to be a boolean. In fact other virtualisation network drivers such as the s390 already model this using netif_carrier_*. So by converting backend_state over to the net carrier flag we can tap into existing infrastructure rather than creating new ones. Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> --- linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 32 +++++-------------- 1 files changed, 9 insertions(+), 23 deletions(-) diff -r e0bbba2b9850 -r c9c40f6baba0 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu May 25 14:15:49 2006 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu May 25 14:29:21 2006 +0100 @@ -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("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\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); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |