From 3c1b8d5bfe77e840dfeb1ea909549d29a403ae6e Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 16 Apr 2009 13:19:55 +0100 Subject: [PATCH] Make the frontend work again. --- drivers/net/xen-netchannel2/Makefile | 2 -- drivers/net/xen-netchannel2/chan.c | 30 +------------------ .../net/xen-netchannel2/netchannel2_core.h | 2 +- .../xen-netchannel2/netchannel2_endpoint.h | 12 -------- drivers/net/xen-netchannel2/netfront2.c | 16 ++-------- drivers/xen/events.c | 17 +++++++++++ drivers/xen/xenbus/xenbus_client.c | 18 +++++------ include/xen/events.h | 2 ++ 8 files changed, 31 insertions(+), 68 deletions(-) diff --git a/drivers/net/xen-netchannel2/Makefile b/drivers/net/xen-netchannel2/Makefile index 69d510282d8..4ae3d3e2ffe 100644 --- a/drivers/net/xen-netchannel2/Makefile +++ b/drivers/net/xen-netchannel2/Makefile @@ -30,9 +30,7 @@ ifeq ($(CONFIG_XEN_NETDEV2_BACKEND),y) netchannel2-objs += netback2.o endif -ifeq ($(CONFIG_XEN_NETDEV2_FRONTEND),y) netchannel2-objs += netfront2.o -endif ifeq ($(CONFIG_XEN_NETDEV2_VMQ),y) netchannel2-objs += vmq.o diff --git a/drivers/net/xen-netchannel2/chan.c b/drivers/net/xen-netchannel2/chan.c index 90fca1e9042..c2a88db5071 100644 --- a/drivers/net/xen-netchannel2/chan.c +++ b/drivers/net/xen-netchannel2/chan.c @@ -8,12 +8,8 @@ #include #include #include -#ifdef CONFIG_PARAVIRT #include #include -#else -#include -#endif #include #include "netchannel2_endpoint.h" @@ -60,7 +56,7 @@ static void nc2_enable_irq(struct netchannel2_ring_pair *ncrp) #endif } -irqreturn_t nc2_int(int irq, void *dev_id, struct pt_regs *ptregs) +irqreturn_t nc2_int(int irq, void *dev_id) { struct netchannel2_ring_pair *ncr = dev_id; @@ -959,10 +955,8 @@ int nc2_connect_evtchn(struct netchannel2 *nc, domid_t domid, } #endif -#if defined(CONFIG_XEN_NETDEV2_FRONTEND) /* Listen for incoming event channel connections from domain domid. Similar semantics to nc2_connect_evtchn(). */ -#ifdef CONFIG_PARAVIRT int nc2_listen_evtchn(struct netchannel2 *nc, domid_t domid) { int err; @@ -981,28 +975,6 @@ int nc2_listen_evtchn(struct netchannel2 *nc, domid_t domid) nc->rings.irq = err; return 0; } -#else -int nc2_listen_evtchn(struct netchannel2 *nc, domid_t domid) -{ - int err; - - BUG_ON(nc->rings.irq >= 0); - - err = bind_listening_port_to_irqhandler(domid, - nc2_int, - IRQF_SAMPLE_RANDOM, - "netchannel2", - &nc->rings); - if (err >= 0) { - nc->rings.irq = err; - nc->rings.evtchn = irq_to_evtchn_port(err); - return 0; - } else { - return err; - } -} -#endif -#endif /* Find the local event channel port which was allocated by * nc2_listen_evtchn() or nc2_connect_evtchn(). It is an error to diff --git a/drivers/net/xen-netchannel2/netchannel2_core.h b/drivers/net/xen-netchannel2/netchannel2_core.h index 7c5f46a665c..315877973a4 100644 --- a/drivers/net/xen-netchannel2/netchannel2_core.h +++ b/drivers/net/xen-netchannel2/netchannel2_core.h @@ -1041,7 +1041,7 @@ void queue_packet_to_interface(struct sk_buff *skb, unsigned get_transmitted_packet_msg_size(struct sk_buff *skb); void init_ring_pair(struct netchannel2_ring_pair *ncrp); -irqreturn_t nc2_int(int irq, void *dev_id, struct pt_regs *ptregs); +irqreturn_t nc2_int(int irq, void *dev_id); void cleanup_ring_pair(struct netchannel2_ring_pair *ncrp); void nc2_rscb_on_gntcopy_fail(void *ctxt, gnttab_copy_t *gop); diff --git a/drivers/net/xen-netchannel2/netchannel2_endpoint.h b/drivers/net/xen-netchannel2/netchannel2_endpoint.h index ca3a7078e5a..ff38dd42e33 100644 --- a/drivers/net/xen-netchannel2/netchannel2_endpoint.h +++ b/drivers/net/xen-netchannel2/netchannel2_endpoint.h @@ -24,9 +24,7 @@ int nc2_attach_rings(struct netchannel2 *nc, size_t prod_size, domid_t otherend_id); void nc2_detach_rings(struct netchannel2 *nc); -#if defined(CONFIG_XEN_NETDEV2_FRONTEND) int nc2_listen_evtchn(struct netchannel2 *nc, domid_t dom); -#endif #if defined(CONFIG_XEN_NETDEV2_BACKEND) int nc2_connect_evtchn(struct netchannel2 *nc, domid_t domid, int evtchn); @@ -37,18 +35,8 @@ void nc2_suspend(struct netchannel2 *nc); void nc2_set_nr_tx_buffers(struct netchannel2 *nc, unsigned nr_buffers); /* Interface which the endpoints provide to the core. */ -#ifdef CONFIG_XEN_NETDEV2_FRONTEND int __init netfront2_init(void); void __exit netfront2_exit(void); -#else -static inline int netfront2_init(void) -{ - return 0; -} -static inline void netfront2_exit(void) -{ -} -#endif #ifdef CONFIG_XEN_NETDEV2_BACKEND int __init netback2_init(void); #else diff --git a/drivers/net/xen-netchannel2/netfront2.c b/drivers/net/xen-netchannel2/netfront2.c index 0894740bda4..57997b7eb07 100644 --- a/drivers/net/xen-netchannel2/netfront2.c +++ b/drivers/net/xen-netchannel2/netfront2.c @@ -453,6 +453,7 @@ static int __devinit netfront_probe(struct xenbus_device *xd, { struct netfront2 *nf; + printk("<0>Found an nc2 interface.\n"); nf = kzalloc(sizeof(*nf), GFP_KERNEL); if (nf == NULL) goto err; @@ -474,17 +475,6 @@ err: return -ENOMEM; } -static int netfront_suspend(struct xenbus_device *xd) -{ - /* We're about to suspend. Do the minimum amount of work to - make that safe. */ - struct netfront2 *nf = xenbus_device_to_nf2(xd); - - nc2_suspend(nf->chan); - - return 0; -} - static int netfront_resume(struct xenbus_device *xd) { /* We've been suspended and come back. The rings are @@ -523,8 +513,7 @@ static struct xenbus_driver netfront2 = { .probe = netfront_probe, .remove = __devexit_p(netfront_remove), .otherend_changed = backend_changed, - .resume = netfront_resume, - .suspend = netfront_suspend, + .resume = netfront_resume }; int __init netfront2_init(void) @@ -533,6 +522,7 @@ int __init netfront2_init(void) if (!is_running_on_xen()) return -ENODEV; #endif + printk("<0>Hello world.\n"); return xenbus_register_frontend(&netfront2); } diff --git a/drivers/xen/events.c b/drivers/xen/events.c index a7beb235409..d30c75cfd09 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -775,6 +775,23 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu) return irq; } +int xen_alloc_evtchn(domid_t otherend_id) +{ + struct evtchn_alloc_unbound alloc_unbound; + int err; + + alloc_unbound.dom = DOMID_SELF; + alloc_unbound.remote_dom = otherend_id; + + err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, + &alloc_unbound); + if (err) + return err; + else + return alloc_unbound.port; +} +EXPORT_SYMBOL_GPL(xen_alloc_evtchn); + static void unbind_from_irq(unsigned int irq) { struct evtchn_close close; diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 92a1ef80a28..b39e0d85b99 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -309,20 +309,16 @@ EXPORT_SYMBOL_GPL(xenbus_grant_ring); */ int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port) { - struct evtchn_alloc_unbound alloc_unbound; int err; - alloc_unbound.dom = DOMID_SELF; - alloc_unbound.remote_dom = dev->otherend_id; - - err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, - &alloc_unbound); - if (err) + err = xen_alloc_evtchn(dev->otherend_id); + if (err < 0) { xenbus_dev_fatal(dev, err, "allocating event channel"); - else - *port = alloc_unbound.port; - - return err; + return err; + } else { + *port = err; + return 0; + } } EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn); diff --git a/include/xen/events.h b/include/xen/events.h index a5d4a5d54c9..571046df40d 100644 --- a/include/xen/events.h +++ b/include/xen/events.h @@ -78,6 +78,8 @@ int xen_vector_from_irq(unsigned pirq); /* Return gsi allocated to pirq */ int xen_gsi_from_irq(unsigned pirq); +int xen_alloc_evtchn(domid_t otherend_id); + #ifdef CONFIG_XEN_DOM0_PCI void xen_setup_pirqs(void); #else -- 2.39.5