From owner-svn-src-all@FreeBSD.ORG Mon Aug 4 08:52:11 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 10775528 for ; Mon, 4 Aug 2014 08:52:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D9D8427CC for ; Mon, 4 Aug 2014 08:52:10 +0000 (UTC) Received: from royger (uid 1332) (envelope-from royger@FreeBSD.org) id 5c07 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 04 Aug 2014 08:52:10 +0000 From: Roger Pau Monné Date: Mon, 4 Aug 2014 08:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269509 - head/sys/x86/xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53df49ba.5c07.4c7afef2@svn.freebsd.org> X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Aug 2014 08:52:11 -0000 Author: royger Date: Mon Aug 4 08:52:10 2014 New Revision: 269509 URL: http://svnweb.freebsd.org/changeset/base/269509 Log: xen: add a DDB command to print event channel information Add a new DDB command to dump all registered event channels. Sponsored by: Citrix Systems R&D x86/xen/xen_intr.c: - Add a new xen_evtchn command to DDB in order to dump all information related to event channels. Modified: head/sys/x86/xen/xen_intr.c Modified: head/sys/x86/xen/xen_intr.c ============================================================================== --- head/sys/x86/xen/xen_intr.c Mon Aug 4 08:43:27 2014 (r269508) +++ head/sys/x86/xen/xen_intr.c Mon Aug 4 08:52:10 2014 (r269509) @@ -32,6 +32,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ddb.h" + #include #include #include @@ -62,6 +64,10 @@ __FBSDID("$FreeBSD$"); #include +#ifdef DDB +#include +#endif + static MALLOC_DEFINE(M_XENINTR, "xen_intr", "Xen Interrupt Services"); /** @@ -1427,3 +1433,74 @@ xen_intr_port(xen_intr_handle_t handle) return (isrc->xi_port); } + +#ifdef DDB +static const char * +xen_intr_print_type(enum evtchn_type type) +{ + static const char *evtchn_type_to_string[EVTCHN_TYPE_COUNT] = { + [EVTCHN_TYPE_UNBOUND] = "UNBOUND", + [EVTCHN_TYPE_PIRQ] = "PIRQ", + [EVTCHN_TYPE_VIRQ] = "VIRQ", + [EVTCHN_TYPE_IPI] = "IPI", + [EVTCHN_TYPE_PORT] = "PORT", + }; + + if (type >= EVTCHN_TYPE_COUNT) + return ("UNKNOWN"); + + return (evtchn_type_to_string[type]); +} + +static void +xen_intr_dump_port(struct xenisrc *isrc) +{ + struct xen_intr_pcpu_data *pcpu; + shared_info_t *s = HYPERVISOR_shared_info; + int i; + + db_printf("Port %d Type: %s\n", + isrc->xi_port, xen_intr_print_type(isrc->xi_type)); + if (isrc->xi_type == EVTCHN_TYPE_PIRQ) { + db_printf("\tPirq: %d ActiveHi: %d EdgeTrigger: %d " + "NeedsEOI: %d Shared: %d\n", + isrc->xi_pirq, isrc->xi_activehi, isrc->xi_edgetrigger, + !!test_bit(isrc->xi_pirq, xen_intr_pirq_eoi_map), + isrc->xi_shared); + } + if (isrc->xi_type == EVTCHN_TYPE_VIRQ) + db_printf("\tVirq: %d\n", isrc->xi_virq); + + db_printf("\tMasked: %d Pending: %d\n", + !!test_bit(isrc->xi_port, &s->evtchn_mask[0]), + !!test_bit(isrc->xi_port, &s->evtchn_pending[0])); + + db_printf("\tPer-CPU Masks: "); + CPU_FOREACH(i) { + pcpu = DPCPU_ID_PTR(i, xen_intr_pcpu); + db_printf("cpu#%d: %d ", i, + !!test_bit(isrc->xi_port, pcpu->evtchn_enabled)); + } + db_printf("\n"); +} + +DB_SHOW_COMMAND(xen_evtchn, db_show_xen_evtchn) +{ + int i; + + if (!xen_domain()) { + db_printf("Only available on Xen guests\n"); + return; + } + + for (i = 0; i < NR_EVENT_CHANNELS; i++) { + struct xenisrc *isrc; + + isrc = xen_intr_port_to_isrc[i]; + if (isrc == NULL) + continue; + + xen_intr_dump_port(isrc); + } +} +#endif /* DDB */