From patchwork Fri Sep 22 03:01:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9965587 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 B230C600C5 for ; Fri, 22 Sep 2017 09:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC76128501 for ; Fri, 22 Sep 2017 09:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A110728757; Fri, 22 Sep 2017 09:12:16 +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 3C72328501 for ; Fri, 22 Sep 2017 09:12:16 +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 1dvJyk-0004WE-Tr; Fri, 22 Sep 2017 09:10:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvJyj-0004Uk-TL for xen-devel@lists.xen.org; Fri, 22 Sep 2017 09:10:34 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 4F/76-09852-983D4C95; Fri, 22 Sep 2017 09:10:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42Jpa+uQ0O24fCT SYPkZI4slHxezODB6HN39mymAMYo1My8pvyKBNWP6/o+sBZuUK470sDYw7pHuYuTiEBKYxijx 6XoDWxcjJ4eEAK/EkWUzWCHsAIlP09tZIIo6GCV+Xt3DDJJgE1CXOLF4IiOILSIgLXHt82VGk CJmgRVMEisfLwFLCAuESrxaNosJxGYRUJW49PIeO4jNK+AqcePjb0aIDQoSUx6+BxvKCRT/1b cdrF5IwEWidel+pgmMvAsYGVYxahSnFpWlFukaGuolFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQ mFesl5+duYgQGBAMQ7GBc2e58iFGSg0lJlPf9+SORQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4 T1wCygkWpaanVqRl5gBDEyYtwcGjJMKbCJLmLS5IzC3OTIdInWI05jgw4cofJo6Om3f/MAmx5 OXnpUqJ8y4GKRUAKc0ozYMbBIuZS4yyUsK8jECnCfEUpBblZpagyr9iFOdgVBLmNQCZwpOZVw K37xXQKUxAp5SvBjulJBEhJdXAWJm9ftGf7r+vhb+tDVdu/vp+p6aygYjlijr/e9oieqpf65g nqyh4vhbbebqt/d6zQ5dvtk25Jeja3iG+/hY/k9bhHRWSNT8Wq+nLP//68fMF5Vcpslcu+Nzu U9i2ctmK+m0nWB5GfrW2WLXnvJDe9t0SzivCzAqMK+2vnDluwZT8575aE3eKmxJLcUaioRZzU XEiABqUIL+UAgAA X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1506071431!76473934!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39389 invoked from network); 22 Sep 2017 09:10:32 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 22 Sep 2017 09:10:32 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Sep 2017 02:10:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,427,1500966000"; d="scan'208"; a="1017290982" Received: from sky-ws.sh.intel.com (HELO localhost) ([10.239.48.141]) by orsmga003.jf.intel.com with ESMTP; 22 Sep 2017 02:10:27 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 23:01:59 -0400 Message-Id: <1506049330-11196-19-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506049330-11196-1-git-send-email-tianyu.lan@intel.com> References: <1506049330-11196-1-git-send-email-tianyu.lan@intel.com> Cc: Lan Tianyu , kevin.tian@intel.com, sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com, roger.pau@citrix.com, chao.gao@intel.com Subject: [Xen-devel] [PATCH V3 18/29] 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 | 72 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/viommu.h | 11 +++++++ 3 files changed, 98 insertions(+) create mode 100644 xen/include/asm-x86/viommu.h diff --git a/xen/common/viommu.c b/xen/common/viommu.c index 55feb5d..b517158 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -163,6 +163,21 @@ int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, return rc; } +int viommu_handle_irq_request(struct domain *d, + struct arch_irq_remapping_request *request) +{ + struct viommu *viommu = d->viommu; + + if ( !viommu ) + return -EINVAL; + + ASSERT(viommu->ops); + if ( !viommu->ops->handle_irq_request ) + return -EINVAL; + + return viommu->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..366fbb6 --- /dev/null +++ b/xen/include/asm-x86/viommu.h @@ -0,0 +1,72 @@ +/* + * 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__ + +/* IRQ request type */ +#define VIOMMU_REQUEST_IRQ_MSI 0 +#define VIOMMU_REQUEST_IRQ_APIC 1 + +struct arch_irq_remapping_request +{ + union { + /* MSI */ + struct { + uint64_t addr; + uint32_t data; + } msi; + /* Redirection Entry in IOAPIC */ + uint64_t rte; + } msg; + uint16_t source_id; + uint8_t type; +}; + +static inline void irq_request_ioapic_fill(struct arch_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 arch_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 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/viommu.h b/xen/include/xen/viommu.h index baa8ab7..230f6b1 100644 --- a/xen/include/xen/viommu.h +++ b/xen/include/xen/viommu.h @@ -21,10 +21,13 @@ #define __XEN_VIOMMU_H__ struct viommu; +struct arch_irq_remapping_request; struct viommu_ops { int (*create)(struct domain *d, struct viommu *viommu); int (*destroy)(struct viommu *viommu); + int (*handle_irq_request)(struct domain *d, + struct arch_irq_remapping_request *request); }; struct viommu { @@ -45,11 +48,19 @@ int viommu_register_type(uint64_t type, struct viommu_ops *ops); int viommu_destroy_domain(struct domain *d); int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, bool_t *need_copy); +int viommu_handle_irq_request(struct domain *d, + struct arch_irq_remapping_request *request); #else static inline int viommu_register_type(uint64_t type, struct viommu_ops *ops) { return -EINVAL; } +static inline int +viommu_handle_irq_request(struct domain *d, + struct arch_irq_remapping_request *request) +{ + return -EINVAL; +} #endif #endif /* __XEN_VIOMMU_H__ */