summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pv/if_xnf.c68
-rw-r--r--sys/dev/pv/xen.c17
-rw-r--r--sys/dev/pv/xenstore.c23
-rw-r--r--sys/dev/pv/xenvar.h32
4 files changed, 78 insertions, 62 deletions
diff --git a/sys/dev/pv/if_xnf.c b/sys/dev/pv/if_xnf.c
index adec5ec6afa..7a5b0ed7bd7 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.41 2016/10/06 17:02:22 mikeb Exp $ */
+/* $OpenBSD: if_xnf.c,v 1.42 2016/11/29 14:55:04 mikeb Exp $ */
/*
* Copyright (c) 2015, 2016 Mike Belopuhov
@@ -149,8 +149,9 @@ struct xnf_mgmt {
struct xnf_softc {
struct device sc_dev;
- struct xen_attach_args sc_xa;
- struct xen_softc *sc_xen;
+ struct device *sc_parent;
+ char sc_node[XEN_MAX_NODE_LEN];
+ char sc_backend[XEN_MAX_BACKEND_LEN];
bus_dma_tag_t sc_dmat;
int sc_domid;
@@ -239,11 +240,13 @@ xnf_attach(struct device *parent, struct device *self, void *aux)
struct xnf_softc *sc = (struct xnf_softc *)self;
struct ifnet *ifp = &sc->sc_ac.ac_if;
- sc->sc_xa = *xa;
- sc->sc_xen = xa->xa_parent;
+ sc->sc_parent = parent;
sc->sc_dmat = xa->xa_dmat;
sc->sc_domid = xa->xa_domid;
+ memcpy(sc->sc_node, xa->xa_node, XEN_MAX_NODE_LEN);
+ memcpy(sc->sc_backend, xa->xa_backend, XEN_MAX_BACKEND_LEN);
+
strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
if (xnf_lladdr(sc)) {
@@ -309,7 +312,7 @@ xnf_attach(struct device *parent, struct device *self, void *aux)
ether_ifattach(ifp);
/* Kick out emulated em's and re's */
- sc->sc_xen->sc_flags |= XSF_UNPLUG_NIC;
+ xen_unplug_emulated(parent, XEN_UNPLUG_NIC);
}
static int
@@ -331,8 +334,7 @@ xnf_lladdr(struct xnf_softc *sc)
char mac[32];
int i, j, lo, hi;
- if (xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend, "mac",
- mac, sizeof(mac)))
+ if (xs_getprop(sc->sc_parent, sc->sc_backend, "mac", mac, sizeof(mac)))
return (-1);
for (i = 0, j = 0; j < ETHER_ADDR_LEN; i += 3) {
@@ -1046,8 +1048,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query scatter-gather capability */
prop = "feature-sg";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0) {
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0) {
if (val[0] == '1')
sc->sc_caps |= XNF_CAP_SG;
} else if (error != ENOENT)
@@ -1056,8 +1058,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query IPv4 checksum offloading capability, enabled by default */
sc->sc_caps |= XNF_CAP_CSUM4;
prop = "feature-no-csum-offload";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0) {
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0) {
if (val[0] == '1')
sc->sc_caps &= ~XNF_CAP_CSUM4;
} else if (error != ENOENT)
@@ -1065,8 +1067,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query IPv6 checksum offloading capability */
prop = "feature-ipv6-csum-offload";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0) {
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0) {
if (val[0] == '1')
sc->sc_caps |= XNF_CAP_CSUM6;
} else if (error != ENOENT)
@@ -1074,8 +1076,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query multicast traffic contol capability */
prop = "feature-multicast-control";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0) {
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0) {
if (val[0] == '1')
sc->sc_caps |= XNF_CAP_MCAST;
} else if (error != ENOENT)
@@ -1083,8 +1085,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query split Rx/Tx event channel capability */
prop = "feature-split-event-channels";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0) {
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0) {
if (val[0] == '1')
sc->sc_caps |= XNF_CAP_SPLIT;
} else if (error != ENOENT)
@@ -1092,8 +1094,8 @@ xnf_capabilities(struct xnf_softc *sc)
/* Query multiqueue capability */
prop = "multi-queue-max-queues";
- if ((error = xs_getprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_backend,
- prop, val, sizeof(val))) == 0)
+ if ((error = xs_getprop(sc->sc_parent, sc->sc_backend, prop, val,
+ sizeof(val))) == 0)
sc->sc_caps |= XNF_CAP_MULTIQ;
else if (error != ENOENT)
goto errout;
@@ -1117,34 +1119,30 @@ xnf_init_backend(struct xnf_softc *sc)
/* Plumb the Rx ring */
prop = "rx-ring-ref";
snprintf(val, sizeof(val), "%u", sc->sc_rx_ref);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
/* Enable "copy" mode */
prop = "request-rx-copy";
snprintf(val, sizeof(val), "%u", 1);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
/* Enable notify mode */
prop = "feature-rx-notify";
snprintf(val, sizeof(val), "%u", 1);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
/* Plumb the Tx ring */
prop = "tx-ring-ref";
snprintf(val, sizeof(val), "%u", sc->sc_tx_ref);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
/* Enable scatter-gather mode */
if (sc->sc_tx_frags > 1) {
prop = "feature-sg";
snprintf(val, sizeof(val), "%u", 1);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop,
- val, strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val,
+ strlen(val)))
goto errout;
}
@@ -1152,23 +1150,21 @@ xnf_init_backend(struct xnf_softc *sc)
if (sc->sc_caps & XNF_CAP_CSUM6) {
prop = "feature-ipv6-csum-offload";
snprintf(val, sizeof(val), "%u", 1);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop,
- val, strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val,
+ strlen(val)))
goto errout;
}
/* Plumb the event channel port */
prop = "event-channel";
snprintf(val, sizeof(val), "%u", sc->sc_xih);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
/* Connect the device */
prop = "state";
snprintf(val, sizeof(val), "%u", 4);
- if (xs_setprop(sc->sc_xa.xa_parent, sc->sc_xa.xa_node, prop, val,
- strlen(val)))
+ if (xs_setprop(sc->sc_parent, sc->sc_node, prop, val, strlen(val)))
goto errout;
return (0);
diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c
index d5a60e0edec..b5f73f025e7 100644
--- a/sys/dev/pv/xen.c
+++ b/sys/dev/pv/xen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xen.c,v 1.65 2016/11/29 13:55:33 mikeb Exp $ */
+/* $OpenBSD: xen.c,v 1.66 2016/11/29 14:55:04 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -1297,7 +1297,6 @@ xen_probe_devices(struct xen_softc *sc)
return (error);
}
for (j = 0; j < iov2_cnt; j++) {
- xa.xa_parent = sc;
xa.xa_dmat = &xen_bus_dma_tag;
strlcpy(xa.xa_name, (char *)iovp1[i].iov_base,
sizeof(xa.xa_name));
@@ -1344,13 +1343,21 @@ xen_disable_emulated_devices(struct xen_softc *sc)
sc->sc_dev.dv_xname);
return;
}
- if (sc->sc_flags & XSF_UNPLUG_IDE)
+ if (sc->sc_unplug & XEN_UNPLUG_IDE)
unplug |= XMI_UNPLUG_IDE;
- if (sc->sc_flags & XSF_UNPLUG_IDESEC)
+ if (sc->sc_unplug & XEN_UNPLUG_IDESEC)
unplug |= XMI_UNPLUG_IDESEC;
- if (sc->sc_flags & XSF_UNPLUG_NIC)
+ if (sc->sc_unplug & XEN_UNPLUG_NIC)
unplug |= XMI_UNPLUG_NIC;
if (unplug)
outw(XMI_PORT, unplug);
#endif /* __i386__ || __amd64__ */
}
+
+void
+xen_unplug_emulated(void *xsc, int what)
+{
+ struct xen_softc *sc = xsc;
+
+ sc->sc_unplug |= what;
+}
diff --git a/sys/dev/pv/xenstore.c b/sys/dev/pv/xenstore.c
index 2ea8e63156e..42692426f4a 100644
--- a/sys/dev/pv/xenstore.c
+++ b/sys/dev/pv/xenstore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xenstore.c,v 1.31 2016/11/29 13:55:33 mikeb Exp $ */
+/* $OpenBSD: xenstore.c,v 1.32 2016/11/29 14:55:04 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -799,9 +799,10 @@ xs_cmd(struct xs_transaction *xst, int cmd, const char *path,
}
int
-xs_watch(struct xen_softc *sc, const char *path, const char *property,
- struct task *task, void (*cb)(void *), void *arg)
+xs_watch(void *xsc, const char *path, const char *property, struct task *task,
+ void (*cb)(void *), void *arg)
{
+ struct xen_softc *sc = xsc;
struct xs_softc *xs = sc->sc_xs;
struct xs_transaction xst;
struct xs_watch *xsw;
@@ -856,9 +857,10 @@ xs_watch(struct xen_softc *sc, const char *path, const char *property,
}
int
-xs_getprop(struct xen_softc *sc, const char *path, const char *property,
- char *value, int size)
+xs_getprop(void *xsc, const char *path, const char *property, char *value,
+ int size)
{
+ struct xen_softc *sc = xsc;
struct xs_transaction xst;
struct iovec *iovp = NULL;
char key[256];
@@ -892,9 +894,10 @@ xs_getprop(struct xen_softc *sc, const char *path, const char *property,
}
int
-xs_setprop(struct xen_softc *sc, const char *path, const char *property,
- char *value, int size)
+xs_setprop(void *xsc, const char *path, const char *property, char *value,
+ int size)
{
+ struct xen_softc *sc = xsc;
struct xs_transaction xst;
struct iovec iov, *iovp = &iov;
char key[256];
@@ -926,9 +929,9 @@ xs_setprop(struct xen_softc *sc, const char *path, const char *property,
}
int
-xs_kvop(void *arg, int op, char *key, char *value, size_t valuelen)
+xs_kvop(void *xsc, int op, char *key, char *value, size_t valuelen)
{
- struct xen_softc *sc = arg;
+ struct xen_softc *sc = xsc;
struct xs_transaction xst;
struct iovec iov, *iovp = &iov;
int error = 0, iov_cnt = 0, cmd, i;
@@ -971,7 +974,7 @@ xs_kvop(void *arg, int op, char *key, char *value, size_t valuelen)
* returns an empty string (single nul byte),
* so try to get the directory list in this case.
*/
- return (xs_kvop(arg, PVBUS_KVLS, key, value, valuelen));
+ return (xs_kvop(xsc, PVBUS_KVLS, key, value, valuelen));
}
/* FALLTHROUGH */
case XS_LIST:
diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h
index c10d67caf58..8378d1db0a2 100644
--- a/sys/dev/pv/xenvar.h
+++ b/sys/dev/pv/xenvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: xenvar.h,v 1.40 2016/11/29 13:55:33 mikeb Exp $ */
+/* $OpenBSD: xenvar.h,v 1.41 2016/11/29 14:55:04 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -61,10 +61,9 @@ struct xen_softc {
struct shared_info *sc_ipg; /* HYPERVISOR_shared_info */
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 */
+#define XSF_CBVEC 0x0001
+
+ uint32_t sc_unplug;
uint64_t sc_irq; /* IDT vector number */
SLIST_HEAD(, xen_intsrc) sc_intrs;
@@ -84,11 +83,13 @@ struct xen_softc {
extern struct xen_softc *xen_sc;
+#define XEN_MAX_NODE_LEN 64
+#define XEN_MAX_BACKEND_LEN 128
+
struct xen_attach_args {
- void *xa_parent;
char xa_name[16];
- char xa_node[64];
- char xa_backend[128];
+ char xa_node[XEN_MAX_NODE_LEN];
+ char xa_backend[XEN_MAX_BACKEND_LEN];
int xa_domid;
bus_dma_tag_t xa_dmat;
};
@@ -123,6 +124,15 @@ void xen_intr_mask(xen_intr_handle_t);
int xen_intr_unmask(xen_intr_handle_t);
/*
+ * Miscellaneous
+ */
+#define XEN_UNPLUG_NIC 0x0001 /* disable emul. NICs */
+#define XEN_UNPLUG_IDE 0x0002 /* disable emul. primary IDE */
+#define XEN_UNPLUG_IDESEC 0x0004 /* disable emul. secondary IDE */
+
+void xen_unplug_emulated(void *, int);
+
+/*
* XenStore
*/
#define XS_LIST 0x01
@@ -164,10 +174,10 @@ test_bit(u_int b, volatile void *p)
int xs_cmd(struct xs_transaction *, int, const char *, struct iovec **,
int *);
void xs_resfree(struct xs_transaction *, struct iovec *, int);
-int xs_watch(struct xen_softc *, const char *, const char *, struct task *,
+int xs_watch(void *, const char *, const char *, struct task *,
void (*)(void *), void *);
-int xs_getprop(struct xen_softc *, const char *, const char *, char *, int);
-int xs_setprop(struct xen_softc *, const char *, const char *, char *, int);
+int xs_getprop(void *, const char *, const char *, char *, int);
+int xs_setprop(void *, const char *, const char *, char *, int);
int xs_kvop(void *, int, char *, char *, size_t);
#endif /* _DEV_PV_XENVAR_H_ */