direct-io.hg
changeset 2286:bcbc2b546582
bitkeeper revision 1.1159.37.4 (412467b8n9cEOShz4lDXGSB702f0ag)
Fix problem with multiple network interfaces.
Fix problem with multiple network interfaces.
author | mjw@wray-m-3.hpl.hp.com |
---|---|
date | Thu Aug 19 08:41:28 2004 +0000 (2004-08-19) |
parents | 4851d48567fe |
children | 6160f02c8c62 |
files | linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c |
line diff
1.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c Wed Aug 18 13:49:34 2004 +0000 1.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c Thu Aug 19 08:41:28 2004 +0000 1.3 @@ -26,6 +26,12 @@ 1.4 #include <asm-xen/hypervisor-ifs/io/netif.h> 1.5 #include <asm/page.h> 1.6 1.7 +#if 0 1.8 +#define dprintf(fmt, args...) printk(KERN_INFO "[XEN] %s" fmt, __FUNCTION__, ##args) 1.9 +#else 1.10 +#define dprintf(fmt, args...) do {} while(0) 1.11 +#endif 1.12 + 1.13 #define RX_BUF_SIZE ((PAGE_SIZE/2)+1) /* Fool the slab allocator :-) */ 1.14 1.15 static void network_tx_buf_gc(struct net_device *dev); 1.16 @@ -157,6 +163,8 @@ static int netctrl_connected_count(void) 1.17 } 1.18 1.19 netctrl.connected_n = connected; 1.20 + dprintf("> connected_n=%d interface_n=%d\n", 1.21 + netctrl.connected_n, netctrl.interface_n); 1.22 return connected; 1.23 } 1.24 1.25 @@ -628,6 +636,13 @@ static void netif_status_change(netif_fe 1.26 struct net_device *dev; 1.27 struct net_private *np; 1.28 1.29 + dprintf(">\n"); 1.30 + dprintf("> status=%d handle=%d mac=%02x:%02x:%02x:%02x:%02x:%02x\n", 1.31 + status->status, 1.32 + status->handle, 1.33 + status->mac[0], status->mac[1], status->mac[2], 1.34 + status->mac[3], status->mac[4], status->mac[5]); 1.35 + 1.36 if ( netctrl.interface_n <= 0 ) 1.37 { 1.38 printk(KERN_WARNING "Status change: no interfaces\n"); 1.39 @@ -797,6 +812,8 @@ static void netif_driver_status_change( 1.40 int err = 0; 1.41 int i; 1.42 1.43 + dprintf("> nr_interfaces=%d\n", status->nr_interfaces); 1.44 + 1.45 netctrl.interface_n = status->nr_interfaces; 1.46 netctrl.connected_n = 0; 1.47 1.48 @@ -828,8 +845,6 @@ static void netif_ctrlif_rx(ctrl_msg_t * 1.49 goto error; 1.50 netif_driver_status_change((netif_fe_driver_status_changed_t *) 1.51 &msg->msg[0]); 1.52 - /* Message is a response */ 1.53 - respond = 0; 1.54 break; 1.55 1.56 error: 1.57 @@ -843,17 +858,40 @@ static void netif_ctrlif_rx(ctrl_msg_t * 1.58 } 1.59 1.60 1.61 +/* Wait for all interfaces to be connected. */ 1.62 +static int wait_for_interfaces(void) 1.63 +{ 1.64 + int err = 0, conn = 0; 1.65 + int wait_i, wait_n = 100; 1.66 + 1.67 + dprintf(">\n"); 1.68 + for ( wait_i = 0; wait_i < wait_n; wait_i++) 1.69 + { 1.70 + dprintf("> wait_i=%d\n", wait_i); 1.71 + conn = netctrl_connected(); 1.72 + if(conn) break; 1.73 + set_current_state(TASK_INTERRUPTIBLE); 1.74 + schedule_timeout(10); 1.75 + } 1.76 + if(conn <= 0){ 1.77 + err = netctrl_err(-ENETDOWN); 1.78 + printk(KERN_WARNING "[XEN] Failed to connect all virtual interfaces: err=%d\n", err); 1.79 + } 1.80 + dprintf("< err=%d\n", err); 1.81 + return err; 1.82 +} 1.83 + 1.84 static int __init netif_init(void) 1.85 { 1.86 ctrl_msg_t cmsg; 1.87 netif_fe_driver_status_changed_t st; 1.88 - int err = 0, wait_i, wait_n = 20; 1.89 + int err = 0; 1.90 1.91 if ( (start_info.flags & SIF_INITDOMAIN) || 1.92 (start_info.flags & SIF_NET_BE_DOMAIN) ) 1.93 return 0; 1.94 1.95 - printk("Initialising Xen virtual ethernet frontend driver"); 1.96 + printk(KERN_INFO "Initialising Xen virtual ethernet frontend driver.\n"); 1.97 1.98 INIT_LIST_HEAD(&dev_list); 1.99 1.100 @@ -871,18 +909,7 @@ static int __init netif_init(void) 1.101 memcpy(cmsg.msg, &st, sizeof(st)); 1.102 ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE); 1.103 1.104 - /* Wait for all interfaces to be connected. */ 1.105 - for ( wait_i = 0; ; wait_i++) 1.106 - { 1.107 - if ( (err = (wait_i < wait_n) ? netctrl_connected() : -ENETDOWN) != 0 ) 1.108 - { 1.109 - err = (err > 0) ? 0 : err; 1.110 - break; 1.111 - } 1.112 - set_current_state(TASK_INTERRUPTIBLE); 1.113 - schedule_timeout(1); 1.114 - } 1.115 - 1.116 + err = wait_for_interfaces(); 1.117 if ( err ) 1.118 ctrl_if_unregister_receiver(CMSG_NETIF_FE, netif_ctrlif_rx); 1.119