svn commit: r308723 - head/sys/dev/hyperv/vmbus

Dexuan Cui dexuan at FreeBSD.org
Wed Nov 16 09:02:18 UTC 2016


Author: dexuan
Date: Wed Nov 16 09:02:17 2016
New Revision: 308723
URL: https://svnweb.freebsd.org/changeset/base/308723

Log:
  hyperv/vmbus: add a new method to get vcpu_id
  
  vcpu_id is host's representation of guest CPU.
  We get the mapping between vcpu_id and FreeBSD kernel's cpu id when VMBus
  driver is loaded. Later, when a driver, like the coming pcib driver, talks
  to the host and needs to refer to a guest CPU, the driver must use the
  vcpu_id.
  
  Reviewed by:	jhb, sephe
  Approved by:	sephe (mentor)
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D8410

Modified:
  head/sys/dev/hyperv/vmbus/vmbus.c
  head/sys/dev/hyperv/vmbus/vmbus_if.m

Modified: head/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus.c	Wed Nov 16 07:05:42 2016	(r308722)
+++ head/sys/dev/hyperv/vmbus/vmbus.c	Wed Nov 16 09:02:17 2016	(r308723)
@@ -77,6 +77,8 @@ static int			vmbus_child_pnpinfo_str(dev
 static uint32_t			vmbus_get_version_method(device_t, device_t);
 static int			vmbus_probe_guid_method(device_t, device_t,
 				    const struct hyperv_guid *);
+static uint32_t			vmbus_get_vcpu_id_method(device_t bus,
+				    device_t dev, int cpu);
 
 static int			vmbus_init(struct vmbus_softc *);
 static int			vmbus_connect(struct vmbus_softc *, uint32_t);
@@ -135,6 +137,7 @@ static device_method_t vmbus_methods[] =
 	/* Vmbus interface */
 	DEVMETHOD(vmbus_get_version,		vmbus_get_version_method),
 	DEVMETHOD(vmbus_probe_guid,		vmbus_probe_guid_method),
+	DEVMETHOD(vmbus_get_vcpu_id,		vmbus_get_vcpu_id_method),
 
 	DEVMETHOD_END
 };
@@ -991,6 +994,14 @@ vmbus_probe_guid_method(device_t bus, de
 	return ENXIO;
 }
 
+static uint32_t
+vmbus_get_vcpu_id_method(device_t bus, device_t dev, int cpu)
+{
+	const struct vmbus_softc *sc = device_get_softc(bus);
+
+	return (VMBUS_PCPU_GET(sc, vcpuid, cpu));
+}
+
 static int
 vmbus_probe(device_t dev)
 {

Modified: head/sys/dev/hyperv/vmbus/vmbus_if.m
==============================================================================
--- head/sys/dev/hyperv/vmbus/vmbus_if.m	Wed Nov 16 07:05:42 2016	(r308722)
+++ head/sys/dev/hyperv/vmbus/vmbus_if.m	Wed Nov 16 09:02:17 2016	(r308723)
@@ -45,3 +45,9 @@ METHOD int probe_guid {
 	device_t dev;
 	const struct hyperv_guid *guid;
 };
+
+METHOD uint32_t get_vcpu_id {
+	device_t bus;
+	device_t dev;
+	int cpu;
+};


More information about the svn-src-head mailing list