From 47a3ee5c60bf70f7aa247faa922a31343045fdb4 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Mon, 11 Jul 2016 06:55:02 +0000 Subject: [PATCH] hyperv/vmbus: Add sysctl to expose vmbus version. Requested by: Hongxiong Xian MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D6860 --- sys/dev/hyperv/vmbus/vmbus.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index d7187876bba..1829af69993 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -100,6 +100,8 @@ static int vmbus_init_contact(struct vmbus_softc *, 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 *); @@ -947,6 +949,17 @@ hv_vmbus_child_device_unregister(struct hv_device *child_dev) return(ret); } +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) { @@ -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: