ia64/xen-unstable

changeset 2582:86f3590030af

bitkeeper revision 1.1159.1.196 (415d2c407zgMBjgq11fXyF4ysEuEkA)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into freefall.cl.cam.ac.uk:/auto/groups/xeno/users/cl349/BK/xeno.bk-nbsd
author cl349@freefall.cl.cam.ac.uk
date Fri Oct 01 10:06:56 2004 +0000 (2004-10-01)
parents fa14084f05cc e7ec6d1ba0b4
children f64b48547d69
files linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/vbd.c netbsd-2.0-xen-sparse/sys/arch/xen/xen/if_xennet.c
line diff
     1.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Oct 01 00:34:35 2004 +0000
     1.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/vbd.c	Fri Oct 01 10:06:56 2004 +0000
     1.3 @@ -101,6 +101,8 @@ static int xlvbd_get_vbd_info(vdisk_t *d
     1.4           nr = MAX_VBDS;
     1.5      memcpy(disk_info, buf, nr * sizeof(vdisk_t));
     1.6  
     1.7 +    free_page((unsigned long)buf);
     1.8 +
     1.9      return nr;
    1.10  }
    1.11  
     2.1 --- a/netbsd-2.0-xen-sparse/sys/arch/xen/xen/if_xennet.c	Fri Oct 01 00:34:35 2004 +0000
     2.2 +++ b/netbsd-2.0-xen-sparse/sys/arch/xen/xen/if_xennet.c	Fri Oct 01 10:06:56 2004 +0000
     2.3 @@ -121,8 +121,9 @@ static void xennet_hex_dump(unsigned cha
     2.4  int xennet_match (struct device *, struct cfdata *, void *);
     2.5  void xennet_attach (struct device *, struct device *, void *);
     2.6  static void xennet_ctrlif_rx(ctrl_msg_t *, unsigned long);
     2.7 +static int xennet_driver_count_connected(void);
     2.8  static void xennet_driver_status_change(netif_fe_driver_status_t *);
     2.9 -static void xennet_status_change(netif_fe_interface_status_t *);
    2.10 +static void xennet_interface_status_change(netif_fe_interface_status_t *);
    2.11  static void xennet_tx_mbuf_free(struct mbuf *, caddr_t, size_t, void *);
    2.12  static void xennet_rx_mbuf_free(struct mbuf *, caddr_t, size_t, void *);
    2.13  static int xen_network_handler(void *);
    2.14 @@ -156,6 +157,8 @@ struct xennet_ctrl {
    2.15  	int xc_connected;
    2.16  	/** Error code. */
    2.17  	int xc_err;
    2.18 +	/** Driver status. */
    2.19 +	int xc_up;
    2.20  
    2.21  	cfprint_t xc_cfprint;
    2.22  	struct device *xc_parent;
    2.23 @@ -279,7 +282,7 @@ xennet_ctrlif_rx(ctrl_msg_t *msg, unsign
    2.24  	case CMSG_NETIF_FE_INTERFACE_STATUS:
    2.25  		if (msg->length != sizeof(netif_fe_interface_status_t))
    2.26  			goto error;
    2.27 -		xennet_status_change(
    2.28 +		xennet_interface_status_change(
    2.29  			(netif_fe_interface_status_t *)&msg->msg[0]);
    2.30  		break;
    2.31  
    2.32 @@ -303,49 +306,60 @@ xennet_ctrlif_rx(ctrl_msg_t *msg, unsign
    2.33  static void
    2.34  xennet_driver_status_change(netif_fe_driver_status_t *status)
    2.35  {
    2.36 -	struct xennet_attach_args xneta;
    2.37 -	int i;
    2.38 +
    2.39 +	DPRINTFN(XEDB_EVENT, ("> status=%d\n", status->status));
    2.40  
    2.41 -	DPRINTFN(XEDB_EVENT, ("> max_handle=%d\n", status->max_handle));
    2.42 +	netctrl.xc_up = status->status;
    2.43 +	xennet_driver_count_connected();
    2.44 +}
    2.45 +
    2.46 +static int
    2.47 +xennet_driver_count_connected(void)
    2.48 +{
    2.49 +	struct device *dv;
    2.50 +	struct xennet_softc *xs = NULL;
    2.51  
    2.52 -	/* XXX FIXME: Abuse of 'max_handle' as interface count. */
    2.53 -	netctrl.xc_interfaces = status->max_handle;
    2.54 -	netctrl.xc_connected = 0;
    2.55 +	netctrl.xc_interfaces = netctrl.xc_connected = 0;
    2.56 +	for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) {
    2.57 +		if (dv->dv_cfattach == NULL ||
    2.58 +		    dv->dv_cfattach->ca_attach != xennet_attach)
    2.59 +			continue;
    2.60 +		xs = (struct xennet_softc *)dv;
    2.61 +		netctrl.xc_interfaces++;
    2.62 +		if (xs->sc_backend_state == BEST_CONNECTED)
    2.63 +			netctrl.xc_connected++;
    2.64 +	}
    2.65  
    2.66 -	xneta.xa_device = "xennet";
    2.67 -
    2.68 -	for (i = 0; i < netctrl.xc_interfaces; i++) {
    2.69 -		xneta.xa_handle = i;
    2.70 -		config_found(netctrl.xc_parent, &xneta, netctrl.xc_cfprint);
    2.71 -	}
    2.72 +	return netctrl.xc_connected;
    2.73  }
    2.74  
    2.75  static void
    2.76 -xennet_status_change(netif_fe_interface_status_t *status)
    2.77 +xennet_interface_status_change(netif_fe_interface_status_t *status)
    2.78  {
    2.79  	ctrl_msg_t cmsg;
    2.80  	netif_fe_interface_connect_t up;
    2.81  	struct xennet_softc *sc;
    2.82  	struct ifnet *ifp;
    2.83  	struct vm_page *pg_tx, *pg_rx;
    2.84 +	struct xennet_attach_args xneta;
    2.85  
    2.86 -	DPRINTFN(XEDB_EVENT, (">\n"));
    2.87  	DPRINTFN(XEDB_EVENT, ("> status=%d handle=%d mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
    2.88  	    status->status,
    2.89  	    status->handle,
    2.90  	    status->mac[0], status->mac[1], status->mac[2],
    2.91  	    status->mac[3], status->mac[4], status->mac[5]));
    2.92  
    2.93 -	if (netctrl.xc_interfaces <= 0) {
    2.94 -		printf("Status change: no interfaces\n");
    2.95 -		return;
    2.96 -	}
    2.97 -
    2.98  	sc = find_device(status->handle);
    2.99  	if (sc == NULL) {
   2.100 -		printf("Status change: invalid netif handle %u\n",
   2.101 -		    status->handle);
   2.102 -		return;
   2.103 +		xneta.xa_device = "xennet";
   2.104 +		xneta.xa_handle = status->handle;
   2.105 +		config_found(netctrl.xc_parent, &xneta, netctrl.xc_cfprint);
   2.106 +		sc = find_device(status->handle);
   2.107 +		if (sc == NULL) {
   2.108 +			printf("Status change: invalid netif handle %u\n",
   2.109 +			    status->handle);
   2.110 +			return;
   2.111 +		}
   2.112  	}
   2.113  	ifp = &sc->sc_ethercom.ec_if;
   2.114  
   2.115 @@ -484,7 +498,7 @@ xennet_status_change(netif_fe_interface_
   2.116  		sc->sc_irq = bind_evtchn_to_irq(sc->sc_evtchn);
   2.117  		event_set_handler(sc->sc_irq, &xen_network_handler, sc, IPL_NET);
   2.118  		hypervisor_enable_irq(sc->sc_irq);
   2.119 -		netctrl.xc_connected++;
   2.120 +		xennet_driver_count_connected();
   2.121  
   2.122  		aprint_normal("%s: MAC address %s\n", sc->sc_dev.dv_xname,
   2.123  		    ether_sprintf(sc->sc_enaddr));