From patchwork Thu Jun 29 05:50:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9816539 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 B07A76020A for ; Thu, 29 Jun 2017 12:00:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914BC286F4 for ; Thu, 29 Jun 2017 12:00:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82EF228717; Thu, 29 Jun 2017 12:00:09 +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.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM 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 14DCD286F4 for ; Thu, 29 Jun 2017 12:00:09 +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 1dQY55-0005zP-U6; Thu, 29 Jun 2017 11:57:55 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQY54-0005yG-Ne for xen-devel@lists.xen.org; Thu, 29 Jun 2017 11:57:54 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 4F/5F-02175-14BE4595; Thu, 29 Jun 2017 11:57:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXS1taRouv4OiT SoP+WjMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrH07iGmgkuqFct+X2RtYFwp28XIwSEkUClx oYWli5GTQ0KAV+LIshmsIGEJAX+J+ceSuxi5gCraGSVebV7OBlLDJqAucWLxREYQW0RAWuLa5 8uMIEXMApsZJWZ9W8EOkhAWCJRom/UZbCiLgKrE7J0nweK8Ai4S8142skMsU5CY8vA9M4jNKe Aq0XBzC9gCIaCaTz07mScw8i5gZFjFqF6cWlSWWqRrppdUlJmeUZKbmJmja2hgqpebWlycmJ6 ak5hUrJecn7uJERgKDECwg3Fqg/MhRkkOJiVRXsPnIZFCfEn5KZUZicUZ8UWlOanFhxhlODiU JHi9XgLlBItS01Mr0jJzgEEJk5bg4FES4e0DaeUtLkjMLc5Mh0idYtTlWNCz4QuTEEtefl6ql Dgv1yugIgGQoozSPLgRsAi5xCgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHe5SCX8GTmlcBteg V0BBPQEcIzwI4oSURISTUwOjp2J95bvnyTEUNplIyRilbcyqks9j3HvyzoeSfHF33Y5NV1jzV l0tPnfzB+kr1XVHzhiamSAbYmP9fqnjmzpIGR57PQtUWfHi8K0+2atPxUb3Toz7glcWq8FjKS G1ITHKUU/7Btn9f5aGXv6YMfmOfcMXx7zzcj0OdlWD/jO6av//6mrPDrUWIpzkg01GIuKk4EA IuU/fqLAgAA X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1498737471!80840213!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62571 invoked from network); 29 Jun 2017 11:57:53 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-11.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Jun 2017 11:57:53 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 29 Jun 2017 04:57:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,280,1496127600"; d="scan'208";a="120737637" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.74]) by fmsmga006.fm.intel.com with ESMTP; 29 Jun 2017 04:57:48 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 29 Jun 2017 01:50:35 -0400 Message-Id: <1498715457-16565-4-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498715457-16565-1-git-send-email-tianyu.lan@intel.com> References: <1498715457-16565-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, jbeulich@suse.com, chao.gao@intel.com Subject: [Xen-devel] [PATCH 3/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 ffb2118..93a0176 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -196,6 +196,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 bce6825..83eb69b 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_t *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__ */