From owner-svn-src-head@freebsd.org Wed Nov 16 09:02:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8802BC419EA; Wed, 16 Nov 2016 09:02:18 +0000 (UTC) (envelope-from dexuan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40B4E17E; Wed, 16 Nov 2016 09:02:18 +0000 (UTC) (envelope-from dexuan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAG92Hon051972; Wed, 16 Nov 2016 09:02:17 GMT (envelope-from dexuan@FreeBSD.org) Received: (from dexuan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAG92HIu051971; Wed, 16 Nov 2016 09:02:17 GMT (envelope-from dexuan@FreeBSD.org) Message-Id: <201611160902.uAG92HIu051971@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dexuan set sender to dexuan@FreeBSD.org using -f From: Dexuan Cui Date: Wed, 16 Nov 2016 09:02:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308723 - head/sys/dev/hyperv/vmbus X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2016 09:02:18 -0000 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; +};