summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2014-07-11 08:48:39 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2014-07-11 08:48:39 +0000
commitae50fd127ec60f5383b64be51c3bd7e200e71fe4 (patch)
tree3ea225e94d4e460d274fcdf9435a3a8662dca370 /sys
parent3a313eb9792d5c5565a66f2d942d791a56b817ba (diff)
add sensors to export what the actual size of the balloon is and what it
should be, in bytes. currently uses SENSOR_INTEGER as sensor type, this may change in the future in favor of a new sensor type. ok sf@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/viomb.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/dev/pci/viomb.c b/sys/dev/pci/viomb.c
index e0b477ae6f4..ac24f4ee2ef 100644
--- a/sys/dev/pci/viomb.c
+++ b/sys/dev/pci/viomb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viomb.c,v 1.9 2014/07/09 22:45:26 jasper Exp $ */
+/* $OpenBSD: viomb.c,v 1.10 2014/07/11 08:48:38 jasper Exp $ */
/* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
/*
@@ -33,6 +33,7 @@
#include <sys/device.h>
#include <sys/task.h>
#include <sys/pool.h>
+#include <sys/sensors.h>
#include <uvm/uvm_extern.h>
@@ -99,6 +100,8 @@ struct viomb_softc {
struct taskq *sc_taskq;
struct task sc_task;
struct pglist sc_balloon_pages;
+ struct ksensor sc_sens[2];
+ struct ksensordev sc_sensdev;
};
int viomb_match(struct device *, void *, void *);
@@ -204,6 +207,22 @@ viomb_attach(struct device *parent, struct device *self, void *aux)
goto err_dmamap;
task_set(&sc->sc_task, viomb_worker, sc, NULL);
+ strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensdev.xname));
+ strlcpy(sc->sc_sens[0].desc, "desired",
+ sizeof(sc->sc_sens[0].desc));
+ sc->sc_sens[0].type = SENSOR_INTEGER;
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[0]);
+ sc->sc_sens[0].value = sc->sc_npages << PAGE_SHIFT;
+
+ strlcpy(sc->sc_sens[1].desc, "current",
+ sizeof(sc->sc_sens[1].desc));
+ sc->sc_sens[1].type = SENSOR_INTEGER;
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[1]);
+ sc->sc_sens[1].value = sc->sc_actual << PAGE_SHIFT;
+
+ sensordev_install(&sc->sc_sensdev);
+
printf("\n");
return;
err_dmamap:
@@ -249,6 +268,10 @@ viomb_worker(void *arg1, void *arg2)
sc->sc_actual, sc->sc_npages);
viomb_deflate(sc);
}
+
+ sc->sc_sens[0].value = sc->sc_npages << PAGE_SHIFT;
+ sc->sc_sens[1].value = sc->sc_actual << PAGE_SHIFT;
+
splx(s);
}