Date: Mon, 11 Jul 2016 06:55:02 +0000 (UTC) From: Sepherosa Ziehau <sephe@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302549 - head/sys/dev/hyperv/vmbus Message-ID: <201607110655.u6B6t239055378@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sephe Date: Mon Jul 11 06:55:02 2016 New Revision: 302549 URL: https://svnweb.freebsd.org/changeset/base/302549 Log: hyperv/vmbus: Add sysctl to expose vmbus version. Requested by: Hongxiong Xian <v-hoxian microsoft com> MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6860 Modified: head/sys/dev/hyperv/vmbus/vmbus.c Modified: head/sys/dev/hyperv/vmbus/vmbus.c ============================================================================== --- head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 06:49:56 2016 (r302548) +++ head/sys/dev/hyperv/vmbus/vmbus.c Mon Jul 11 06:55:02 2016 (r302549) @@ -100,6 +100,8 @@ static int vmbus_init_contact(struct v uint32_t); static int vmbus_req_channels(struct vmbus_softc *sc); +static int vmbus_sysctl_version(SYSCTL_HANDLER_ARGS); + static struct vmbus_msghc_ctx *vmbus_msghc_ctx_create(bus_dma_tag_t); static void vmbus_msghc_ctx_destroy( struct vmbus_msghc_ctx *); @@ -948,6 +950,17 @@ hv_vmbus_child_device_unregister(struct } static int +vmbus_sysctl_version(SYSCTL_HANDLER_ARGS) +{ + char verstr[16]; + + snprintf(verstr, sizeof(verstr), "%u.%u", + hv_vmbus_protocal_version >> 16, + hv_vmbus_protocal_version & 0xffff); + return sysctl_handle_string(oidp, verstr, sizeof(verstr), req); +} + +static int vmbus_probe(device_t dev) { char *id[] = { "VMBUS", NULL }; @@ -977,6 +990,8 @@ vmbus_probe(device_t dev) static int vmbus_doattach(struct vmbus_softc *sc) { + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx; int ret; if (sc->vmbus_flags & VMBUS_FLAG_ATTACHED) @@ -1040,6 +1055,12 @@ vmbus_doattach(struct vmbus_softc *sc) bus_generic_attach(sc->vmbus_dev); device_printf(sc->vmbus_dev, "device scan, probe and attach done\n"); + ctx = device_get_sysctl_ctx(sc->vmbus_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->vmbus_dev)); + SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + vmbus_sysctl_version, "A", "vmbus version"); + return (ret); cleanup:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607110655.u6B6t239055378>