From patchwork Wed Aug 9 20:34:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9892641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9894F60236 for ; Thu, 10 Aug 2017 02:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F58B289E6 for ; Thu, 10 Aug 2017 02:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F5D28A08; Thu, 10 Aug 2017 02:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AE25D289E6 for ; Thu, 10 Aug 2017 02:43:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfdPQ-00010G-R6; Thu, 10 Aug 2017 02:41:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfdPP-000108-Pz for xen-devel@lists.xen.org; Thu, 10 Aug 2017 02:41:15 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id EF/CF-02177-BC7CB895; Thu, 10 Aug 2017 02:41:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42Jpa+tI0T1xvDv SoOuEsMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFw/hyWgguqFe3v57M3MC6X7WLk5BASqJR4 +GEnG4gtIcArcWTZDFYIO0Bi4a0eIJsLqKaDUaL76DEmkASbgLrEicUTGUFsEQFpiWufLzOCF DELnGKU+HF/C9gkYYEQiZ8nu8FsFgFViR+NV8BsXgEXifurZzJDbFCQmPLwPZjNKeAqMXXLVi aIi1wk1i2fxjiBkXcBI8MqRo3i1KKy1CJdI1O9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK 95PzcTYzAgKhnYGDcwbir3e8QoyQHk5Iob0dDd6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5/ R4FygkWp6akVaZk5wNCESUtw8CiJ8JYdA0rzFhck5hZnpkOkTjEacyzo2fCFiePVhP/fmIRY8 vLzUqXEeXVBSgVASjNK8+AGwWLmEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3i0gU3gy80 rg9r0COoUJ6JQI306QU0oSEVJSDYybGn9d03tzaMc59ZQLDlL3gjdbqXhWnnWd2jNt0hVLidz s+o7gQB/HU6tXiN2zimhfmzhhzUElzpDUHz+ef3q1c8PUbtdo6/n2xSePFm/QfOK0Iznwd7HW hdmcvmXPVxYdfCt/J03E3PLEd9uXcc+5Pp/6GHyloiC+L1tHS9m+t1gws3n2Vg8lluKMREMt5 qLiRAA1nNOulAIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1502332870!103723739!1 X-Originating-IP: [134.134.136.100] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28527 invoked from network); 10 Aug 2017 02:41:12 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-7.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Aug 2017 02:41:12 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 09 Aug 2017 19:41:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.41,349,1498546800"; d="scan'208"; a="1180964702" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.141]) by fmsmga001.fm.intel.com with ESMTP; 09 Aug 2017 19:41:07 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Wed, 9 Aug 2017 16:34:03 -0400 Message-Id: <1502310866-10450-3-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502310866-10450-1-git-send-email-tianyu.lan@intel.com> References: <1502310866-10450-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, jbeulich@suse.com, chao.gao@intel.com Subject: [Xen-devel] [PATCH V2 2/25] VIOMMU: Add irq request callback to deal with irq remapping X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch is to add irq request callback for platform implementation to deal with irq remapping request. Signed-off-by: Lan Tianyu --- xen/common/viommu.c | 15 +++++++++ xen/include/asm-x86/viommu.h | 73 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/viommu.h | 9 ++++++ 3 files changed, 97 insertions(+) create mode 100644 xen/include/asm-x86/viommu.h diff --git a/xen/common/viommu.c b/xen/common/viommu.c index a4d004d..f4d34e6 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -198,6 +198,21 @@ int __init viommu_setup(void) return 0; } +int viommu_handle_irq_request(struct domain *d, u32 viommu_id, + struct irq_remapping_request *request) +{ + struct viommu_info *info = &d->viommu; + + if ( viommu_id >= info->nr_viommu + || !info->viommu[viommu_id] ) + return -EINVAL; + + if ( !info->viommu[viommu_id]->ops->handle_irq_request ) + return -EINVAL; + + return info->viommu[viommu_id]->ops->handle_irq_request(d, request); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/viommu.h b/xen/include/asm-x86/viommu.h new file mode 100644 index 0000000..51bda72 --- /dev/null +++ b/xen/include/asm-x86/viommu.h @@ -0,0 +1,73 @@ +/* + * include/asm-x86/viommu.h + * + * Copyright (c) 2017 Intel Corporation. + * Author: Lan Tianyu + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + * + */ +#ifndef __ARCH_X86_VIOMMU_H__ +#define __ARCH_X86_VIOMMU_H__ + +#include +#include + +/* IRQ request type */ +#define VIOMMU_REQUEST_IRQ_MSI 0 +#define VIOMMU_REQUEST_IRQ_APIC 1 + +struct irq_remapping_request +{ + union { + /* MSI */ + struct { + u64 addr; + u32 data; + } msi; + /* Redirection Entry in IOAPIC */ + u64 rte; + } msg; + u16 source_id; + u8 type; +}; + +static inline void irq_request_ioapic_fill(struct irq_remapping_request *req, + uint32_t ioapic_id, uint64_t rte) +{ + ASSERT(req); + req->type = VIOMMU_REQUEST_IRQ_APIC; + req->source_id = ioapic_id; + req->msg.rte = rte; +} + +static inline void irq_request_msi_fill(struct irq_remapping_request *req, + uint32_t source_id, uint64_t addr, uint32_t data) +{ + ASSERT(req); + req->type = VIOMMU_REQUEST_IRQ_MSI; + req->source_id = source_id; + req->msg.msi.addr = addr; + req->msg.msi.data = data; +} + +#endif /* __ARCH_X86_VIOMMU_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/xen/include/xen/viommu.h b/xen/include/xen/viommu.h index 527afb1..0be1b3a 100644 --- a/xen/include/xen/viommu.h +++ b/xen/include/xen/viommu.h @@ -20,6 +20,8 @@ #ifndef __XEN_VIOMMU_H__ #define __XEN_VIOMMU_H__ +#include + #define NR_VIOMMU_PER_DOMAIN 1 struct viommu; @@ -28,6 +30,8 @@ struct viommu_ops { u64 (*query_caps)(struct domain *d); int (*create)(struct domain *d, struct viommu *viommu); int (*destroy)(struct viommu *viommu); + int (*handle_irq_request)(struct domain *d, + struct irq_remapping_request *request); }; struct viommu { @@ -52,6 +56,8 @@ int viommu_register_type(u64 type, struct viommu_ops * ops); int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, bool_t *need_copy); int viommu_setup(void); +int viommu_handle_irq_request(struct domain *d, u32 viommu_id, + struct irq_remapping_request *request); #else static inline int viommu_init_domain(struct domain *d) { return 0; } static inline int viommu_register_type(u64 type, struct viommu_ops * ops) @@ -62,6 +68,9 @@ static inline int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, bool *need_copy) { return -ENODEV }; +static inline int viommu_handle_irq_request(struct domain *d, u32 viommu_id, + struct irq_remapping_request *request) +{ return 0 }; #endif #endif /* __XEN_VIOMMU_H__ */