Allow to pass a more descriptive name to event_set_handler() (e.g. IRQ number

for physical IRQ, or device name for xen device drivers). This makes
systat and vmstat output more usable, especially as the channel numbers
change each time a guest reboots.
This commit is contained in:
bouyer 2005-04-17 14:50:11 +00:00
parent 2db3ae3497
commit c7520961bf
9 changed files with 44 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: evtchn.h,v 1.5 2005/04/16 22:49:37 bouyer Exp $ */
/* $NetBSD: evtchn.h,v 1.6 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -41,7 +41,7 @@ extern struct evtsource *evtsource[];
void events_default_setup(void);
void init_events(void);
unsigned int do_event(int, struct intrframe *);
int event_set_handler(int, int (*func)(void *), void *, int);
int event_set_handler(int, int (*func)(void *), void *, int, const char *);
int event_remove_handler(int, int (*func)(void *), void *);
int bind_virq_to_evtch(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: clock.c,v 1.10 2005/04/16 22:49:38 bouyer Exp $ */
/* $NetBSD: clock.c,v 1.11 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -34,7 +34,7 @@
#include "opt_xen.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.10 2005/04/16 22:49:38 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.11 2005/04/17 14:50:11 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -235,7 +235,7 @@ xen_initclocks()
processed_system_time = shadow_system_time;
event_set_handler(evtch, (int (*)(void *))xen_timer_handler,
NULL, IPL_CLOCK);
NULL, IPL_CLOCK, "clock");
hypervisor_enable_event(evtch);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctrl_if.c,v 1.5 2005/04/16 22:49:38 bouyer Exp $ */
/* $NetBSD: ctrl_if.c,v 1.6 2005/04/17 14:50:11 bouyer Exp $ */
/******************************************************************************
* ctrl_if.c
@ -9,7 +9,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.5 2005/04/16 22:49:38 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: ctrl_if.c,v 1.6 2005/04/17 14:50:11 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -497,7 +497,8 @@ void ctrl_if_resume(void)
aprint_verbose("Domain controller: using event channel %d\n",
ctrl_if_evtchn);
event_set_handler(ctrl_if_evtchn, &ctrl_if_interrupt, NULL, IPL_CTRL);
event_set_handler(ctrl_if_evtchn, &ctrl_if_interrupt, NULL, IPL_CTRL,
"ctrlev");
hypervisor_enable_event(ctrl_if_evtchn);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: evtchn.c,v 1.6 2005/04/16 23:33:18 bouyer Exp $ */
/* $NetBSD: evtchn.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.6 2005/04/16 23:33:18 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -125,13 +125,15 @@ init_events()
evtch = bind_virq_to_evtch(VIRQ_DEBUG);
aprint_verbose("debug vitual interrupt using event channel %d\n",
evtch);
event_set_handler(evtch, &xen_debug_handler, NULL, IPL_DEBUG);
event_set_handler(evtch, &xen_debug_handler, NULL, IPL_DEBUG,
"debugev");
hypervisor_enable_event(evtch);
evtch = bind_virq_to_evtch(VIRQ_MISDIRECT);
aprint_verbose("misdirect vitual interrupt using event channel %d\n",
evtch);
event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_DIE);
event_set_handler(evtch, &xen_misdirect_handler, NULL, IPL_DIE,
"misdirev");
hypervisor_enable_event(evtch);
/* This needs to be done early, but after the IRQ subsystem is
@ -352,13 +354,15 @@ pirq_establish(int pirq, int evtch, int (*func)(void *), void *arg, int level)
{
struct pintrhand *ih;
physdev_op_t physdev_op;
char evname[8];
ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
if (ih == NULL) {
printf("pirq_establish: can't malloc handler info\n");
return NULL;
}
if (event_set_handler(evtch, pirq_interrupt, ih, level) != 0) {
snprintf(evname, sizeof(evname), "irq%d", pirq);
if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) {
free(ih, M_DEVBUF);
return NULL;
}
@ -400,7 +404,8 @@ pirq_interrupt(void *arg)
#endif /* DOM0OPS */
int
event_set_handler(int evtch, int (*func)(void *), void *arg, int level)
event_set_handler(int evtch, int (*func)(void *), void *arg, int level,
const char *evname)
{
struct iplsource *ipls;
struct evtsource *evts;
@ -458,8 +463,12 @@ event_set_handler(int evtch, int (*func)(void *), void *arg, int level)
panic("can't allocate fixed interrupt source");
evts->ev_handlers = ih;
evtsource[evtch] = evts;
snprintf(evts->ev_evname, sizeof(evts->ev_evname), "evt%d",
evtch);
if (evname)
strncpy(evts->ev_evname, evname,
sizeof(evts->ev_evname));
else
snprintf(evts->ev_evname, sizeof(evts->ev_evname),
"evt%d", evtch);
evcnt_attach_dynamic(&evts->ev_evcnt, EVCNT_TYPE_INTR, NULL,
ci->ci_dev->dv_xname, evts->ev_evname);
} else {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_xennet.c,v 1.20 2005/04/16 22:49:38 bouyer Exp $ */
/* $NetBSD: if_xennet.c,v 1.21 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.20 2005/04/16 22:49:38 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.21 2005/04/17 14:50:11 bouyer Exp $");
#include "opt_inet.h"
#include "rnd.h"
@ -532,7 +532,7 @@ xennet_interface_status_change(netif_fe_interface_status_t *status)
aprint_verbose("%s: using event channel %d\n",
sc->sc_dev.dv_xname, sc->sc_evtchn);
event_set_handler(sc->sc_evtchn,
&xen_network_handler, sc, IPL_NET);
&xen_network_handler, sc, IPL_NET, sc->sc_dev.dv_xname);
hypervisor_enable_event(sc->sc_evtchn);
xennet_driver_count_connected();

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbd.c,v 1.17 2005/04/16 22:49:38 bouyer Exp $ */
/* $NetBSD: xbd.c,v 1.18 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.17 2005/04/16 22:49:38 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: xbd.c,v 1.18 2005/04/17 14:50:11 bouyer Exp $");
#include "xbd.h"
#include "rnd.h"
@ -568,7 +568,8 @@ connect_interface(blkif_fe_interface_status_t *status)
aprint_verbose("xbd: using event channel %d\n", blkif_evtchn);
event_set_handler(blkif_evtchn, &xbd_response_handler, NULL, IPL_BIO);
event_set_handler(blkif_evtchn, &xbd_response_handler, NULL, IPL_BIO,
"xbd");
hypervisor_enable_event(blkif_evtchn);
/* Transition to connected in case we need to do
@ -775,7 +776,8 @@ enable_update_events(struct device *self)
{
kthread_create(xbd_update_create_kthread, self);
event_set_handler(_EVENT_VBD_UPD, &xbd_update_handler, self, IPL_BIO);
event_set_handler(_EVENT_VBD_UPD, &xbd_update_handler, self, IPL_BIO,
"xbdup");
hypervisor_enable_event(_EVENT_VBD_UPD);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbdback.c,v 1.9 2005/04/16 23:33:18 bouyer Exp $ */
/* $NetBSD: xbdback.c,v 1.10 2005/04/17 14:50:11 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -228,6 +228,7 @@ xbdback_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
{
blkif_be_connect_t *req = (blkif_be_connect_t *)&msg->msg[0];
vaddr_t ring_addr;
char evname[16];
if (msg->length != sizeof(blkif_be_connect_t))
goto error;
@ -262,8 +263,9 @@ xbdback_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
}
xbdi->blk_ring = (void *)ring_addr;
xbdi->evtchn = req->evtchn;
snprintf(evname, sizeof(evname), "xbdback%d", xbdi->domid);
event_set_handler(xbdi->evtchn,
xbdback_evthandler, xbdi, IPL_BIO);
xbdback_evthandler, xbdi, IPL_BIO, evname);
printf("xbd backend %d for domain %d using event channel %d\n",
xbdi->handle, xbdi->domid, xbdi->evtchn);
hypervisor_enable_event(xbdi->evtchn);

View File

@ -1,4 +1,4 @@
/* $NetBSD: xencons.c,v 1.6 2005/04/16 22:49:38 bouyer Exp $ */
/* $NetBSD: xencons.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $ */
/*
*
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.6 2005/04/16 22:49:38 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: xencons.c,v 1.7 2005/04/17 14:50:11 bouyer Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@ -159,7 +159,7 @@ xencons_attach(struct device *parent, struct device *self, void *aux)
aprint_verbose("%s: using event channel %d\n",
sc->sc_dev.dv_xname, evtch);
if (event_set_handler(evtch, xencons_intr, sc,
IPL_TTY) != 0)
IPL_TTY, "xencons") != 0)
printf("console: "
"can't register xencons_intr\n");
hypervisor_enable_event(evtch);

View File

@ -1,4 +1,4 @@
/* $NetBSD: xennetback.c,v 1.8 2005/04/16 23:33:18 bouyer Exp $ */
/* $NetBSD: xennetback.c,v 1.9 2005/04/17 14:50:11 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -349,7 +349,7 @@ fail_1:
xneti->xni_txring = (void *)ring_txaddr;
xneti->xni_evtchn = req->evtchn;
event_set_handler(xneti->xni_evtchn, xennetback_evthandler,
xneti, IPL_NET);
xneti, IPL_NET, xneti->xni_if.if_xname);
printf("%s using event channel %d\n",
xneti->xni_if.if_xname, xneti->xni_evtchn);
hypervisor_enable_event(xneti->xni_evtchn);