diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-15 14:27:09 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-15 14:27:09 +0000 |
commit | abd48148ace0480aeaa124b3e057cb90f230040c (patch) | |
tree | b94b0ecc8efe9413ef93ccf06fd970150a57ab5a /sys/dev | |
parent | abf356c15e493beb6e7f406c70e248bf3735ddc3 (diff) |
Detach emulated network devices if Netfront driver is enabled
Xen doesn't provide a way for a guest to decide which model of
the interface is selected in the VM configuration and therefore
there's no simple way for Netfront and emulated devices to co-
exist on the same system. Emulated em(4) or re(4) drivers will
take over if xnf(4) driver is disabled or not compiled in.
Idea and OK reyk
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/xspd.c | 6 | ||||
-rw-r--r-- | sys/dev/pv/if_xnf.c | 12 | ||||
-rw-r--r-- | sys/dev/pv/xen.c | 24 | ||||
-rw-r--r-- | sys/dev/pv/xenvar.h | 9 |
4 files changed, 26 insertions, 25 deletions
diff --git a/sys/dev/pci/xspd.c b/sys/dev/pci/xspd.c index 47a703bfb59..69ee0e178e9 100644 --- a/sys/dev/pci/xspd.c +++ b/sys/dev/pci/xspd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xspd.c,v 1.3 2015/12/21 18:17:36 mikeb Exp $ */ +/* $OpenBSD: xspd.c,v 1.4 2016/01/15 14:27:08 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -70,7 +70,7 @@ xspd_attach(struct device *parent, struct device *self, void *aux) struct xen_hvm_param xhp; extern struct xen_softc *xen_sc; - if (xen_sc == NULL || xen_sc->sc_cbvec != 0) { + if (xen_sc == NULL || (xen_sc->sc_flags & XSF_CBVEC)) { printf("\n"); return; } @@ -108,7 +108,7 @@ xspd_attach(struct device *parent, struct device *self, void *aux) return; } - xen_sc->sc_cbvec = 1; + xen_sc->sc_flags |= XSF_CBVEC; } int diff --git a/sys/dev/pv/if_xnf.c b/sys/dev/pv/if_xnf.c index 1852b7693c7..02761d8ff29 100644 --- a/sys/dev/pv/if_xnf.c +++ b/sys/dev/pv/if_xnf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xnf.c,v 1.5 2016/01/13 20:27:18 mikeb Exp $ */ +/* $OpenBSD: if_xnf.c,v 1.6 2016/01/15 14:27:08 mikeb Exp $ */ /* * Copyright (c) 2015, 2016 Mike Belopuhov @@ -216,16 +216,11 @@ int xnf_match(struct device *parent, void *match, void *aux) { struct xen_attach_args *xa = aux; - char type[64]; if (strcmp("vif", xa->xa_name)) return (0); - if (xs_getprop(xa, "type", type, sizeof(type)) == 0 && - ((strcmp("vif", type) == 0) || (strcmp("front", type) == 0))) - return (1); - - return (0); + return (1); } void @@ -291,6 +286,9 @@ xnf_attach(struct device *parent, struct device *self, void *aux) ether_ifattach(ifp); timeout_set(&sc->sc_rx_fill, xnf_rx_ring_fill, sc); + + /* Kick out emulated em's and re's */ + sc->sc_xen->sc_flags |= XSF_UNPLUG_NIC; } static int diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index 4ed8e2eba36..51b47eed52f 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xen.c,v 1.26 2016/01/14 12:37:17 mikeb Exp $ */ +/* $OpenBSD: xen.c,v 1.27 2016/01/15 14:27:08 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -146,10 +146,11 @@ xen_attach(struct device *parent, struct device *self, void *aux) if (xs_attach(sc)) return; - xen_disable_emulated_devices(sc); xen_probe_devices(sc); + xen_disable_emulated_devices(sc); + config_mountroot(self, xen_deferred); } @@ -158,7 +159,7 @@ xen_deferred(struct device *self) { struct xen_softc *sc = (struct xen_softc *)self; - if (!sc->sc_cbvec) { + if (!(sc->sc_flags & XSF_CBVEC)) { DPRINTF("%s: callback vector hasn't been established\n", sc->sc_dev.dv_xname); return; @@ -496,7 +497,7 @@ xen_init_cbvec(struct xen_softc *sc) DPRINTF("%s: registered callback IDT vector %d\n", sc->sc_dev.dv_xname, LAPIC_XEN_VECTOR); - sc->sc_cbvec = 1; + sc->sc_flags |= XSF_CBVEC; return (0); } @@ -1170,8 +1171,6 @@ xen_probe_devices(struct xen_softc *sc) #define XMI_UNPLUG_NIC 0x02 #define XMI_UNPLUG_IDESEC 0x04 -int xen_disable_pv_ide, xen_disable_pv_idesec, xen_disable_pv_nic; - void xen_disable_emulated_devices(struct xen_softc *sc) { @@ -1179,18 +1178,17 @@ xen_disable_emulated_devices(struct xen_softc *sc) ushort unplug = 0; if (inw(XMI_PORT) != XMI_MAGIC) { - printf("%s: no magic!\n", sc->sc_dev.dv_xname); + printf("%s: failed to disable emulated devices\n", + sc->sc_dev.dv_xname); return; } - if (xen_disable_pv_ide) + if (sc->sc_flags & XSF_UNPLUG_IDE) unplug |= XMI_UNPLUG_IDE; - if (xen_disable_pv_idesec) + if (sc->sc_flags & XSF_UNPLUG_IDESEC) unplug |= XMI_UNPLUG_IDESEC; - if (xen_disable_pv_nic) + if (sc->sc_flags & XSF_UNPLUG_NIC) unplug |= XMI_UNPLUG_NIC; - if (unplug) { + if (unplug) outw(XMI_PORT, unplug); - DPRINTF("%s: disabled emulated devices\n", sc->sc_dev.dv_xname); - } #endif /* __i386__ || __amd64__ */ } diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h index 3f03673d93d..ef599b6e159 100644 --- a/sys/dev/pv/xenvar.h +++ b/sys/dev/pv/xenvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xenvar.h,v 1.19 2016/01/05 13:47:28 mikeb Exp $ */ +/* $OpenBSD: xenvar.h,v 1.20 2016/01/15 14:27:08 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -61,7 +61,12 @@ struct xen_softc { struct shared_info *sc_ipg; /* HYPERVISOR_shared_info */ - int sc_cbvec; /* callback was installed */ + uint32_t sc_flags; +#define XSF_CBVEC 0x0001 +#define XSF_UNPLUG_NIC 0x0002 /* disable emul. NICs */ +#define XSF_UNPLUG_IDE 0x0004 /* disable emul. primary IDE */ +#define XSF_UNPLUG_IDESEC 0x0008 /* disable emul. sec. IDE */ + uint64_t sc_irq; /* IDT vector number */ struct evcount sc_evcnt; /* upcall counter */ SLIST_HEAD(, xen_intsrc) sc_intrs; |