From patchwork Thu May 18 05:34:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9733859 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 02F55601BC for ; Thu, 18 May 2017 11:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6ABF20952 for ; Thu, 18 May 2017 11:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB21A24560; Thu, 18 May 2017 11:42:36 +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 8C04C2621D for ; Thu, 18 May 2017 11:42:35 +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 1dBJmz-0004Bp-P4; Thu, 18 May 2017 11:40:17 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBJmy-0004As-6G for xen-devel@lists.xen.org; Thu, 18 May 2017 11:40:16 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 72/72-03371-F188D195; Thu, 18 May 2017 11:40:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXS1tbhqCvXIRt p8HiWtcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnH89UO2gqOqFeeW/WdpYNwg28XIxSEkMI1R 4vnjeaxdjJwcEgK8EkeWzYCy/SV+9D9nhSjqYJS4t/YxG0iCTUBd4sTiiYwgtoiAtMS1z5cZQ YqYBTYzSsz6toIdJCEsECHx6M5HZhCbRUBVYs7KjWDNvAIuEjsbNjJBbFCQmPLwPVgNp4CrxL att1hAbCGgmsaFvawTGHkXMDKsYtQoTi0qSy3SNTLTSyrKTM8oyU3MzNE1NDDTy00tLk5MT81 JTCrWS87P3cQIDAkGINjBeGZB4CFGSQ4mJVHewwWykUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQk ePnagXKCRanpqRVpmTnA4IRJS3DwKInwFrQBpXmLCxJzizPTIVKnGHU5rrR+fM8kxJKXn5cqJ c67EaRIAKQoozQPbgQsUi4xykoJ8zICHSXEU5BalJtZgir/ilGcg1FJmPcYyBSezLwSuE2vgI 5gAjqi+YE0yBEliQgpqQZGJwPjXC+9b3PiGmMe7oleJxL+Z26x5wHnkleZZyuc6tbefu7Zf+i hcNbe3Mtr/BzUxNU/uIiIqZrcnx5RKHpKuKy/fue/nMIUtnNPfFTPzT1a9dWR+3j3hu2VfAwL Fu222XzUpZrHdarrnNqizpQv5wSZ+pc/bkj1y9i5em3mlqv/tQP8+NOVWIozEg21mIuKEwHel YHnjwIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1495107612!102707860!1 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56484 invoked from network); 18 May 2017 11:40:14 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-16.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 May 2017 11:40:14 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 May 2017 04:40:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,358,1491289200"; d="scan'208";a="970138626" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.124]) by orsmga003.jf.intel.com with ESMTP; 18 May 2017 04:40:08 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 18 May 2017 01:34:33 -0400 Message-Id: <1495085696-10819-4-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1495085696-10819-1-git-send-email-tianyu.lan@intel.com> References: <1495085696-10819-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] [RFC PATCH V2 3/26] 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 74afbf5..4e3ecd7 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -194,6 +194,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 ( !info || 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 5909800..5b99211 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 { @@ -55,6 +59,8 @@ u64 viommu_query_caps(struct domain *d, u64 viommu_type); 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_create(struct domain *d, u64 type, u64 base_address, @@ -70,6 +76,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__ */