18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next
128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
138c2ecf20Sopenharmony_ci * Software.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
208c2ecf20Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
218c2ecf20Sopenharmony_ci * SOFTWARE.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * Authors:
248c2ecf20Sopenharmony_ci *    Eddie Dong <eddie.dong@intel.com>
258c2ecf20Sopenharmony_ci *    Dexuan Cui
268c2ecf20Sopenharmony_ci *    Jike Song <jike.song@intel.com>
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * Contributors:
298c2ecf20Sopenharmony_ci *    Zhi Wang <zhi.a.wang@intel.com>
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef _GVT_HYPERCALL_H_
348c2ecf20Sopenharmony_ci#define _GVT_HYPERCALL_H_
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include <linux/types.h>
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct device;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cienum hypervisor_type {
418c2ecf20Sopenharmony_ci	INTEL_GVT_HYPERVISOR_XEN = 0,
428c2ecf20Sopenharmony_ci	INTEL_GVT_HYPERVISOR_KVM,
438c2ecf20Sopenharmony_ci};
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Specific GVT-g MPT modules function collections. Currently GVT-g supports
478c2ecf20Sopenharmony_ci * both Xen and KVM by providing dedicated hypervisor-related MPT modules.
488c2ecf20Sopenharmony_ci */
498c2ecf20Sopenharmony_cistruct intel_gvt_mpt {
508c2ecf20Sopenharmony_ci	enum hypervisor_type type;
518c2ecf20Sopenharmony_ci	int (*host_init)(struct device *dev, void *gvt, const void *ops);
528c2ecf20Sopenharmony_ci	void (*host_exit)(struct device *dev);
538c2ecf20Sopenharmony_ci	int (*attach_vgpu)(void *vgpu, unsigned long *handle);
548c2ecf20Sopenharmony_ci	void (*detach_vgpu)(void *vgpu);
558c2ecf20Sopenharmony_ci	int (*inject_msi)(unsigned long handle, u32 addr, u16 data);
568c2ecf20Sopenharmony_ci	unsigned long (*from_virt_to_mfn)(void *p);
578c2ecf20Sopenharmony_ci	int (*enable_page_track)(unsigned long handle, u64 gfn);
588c2ecf20Sopenharmony_ci	int (*disable_page_track)(unsigned long handle, u64 gfn);
598c2ecf20Sopenharmony_ci	int (*read_gpa)(unsigned long handle, unsigned long gpa, void *buf,
608c2ecf20Sopenharmony_ci			unsigned long len);
618c2ecf20Sopenharmony_ci	int (*write_gpa)(unsigned long handle, unsigned long gpa, void *buf,
628c2ecf20Sopenharmony_ci			 unsigned long len);
638c2ecf20Sopenharmony_ci	unsigned long (*gfn_to_mfn)(unsigned long handle, unsigned long gfn);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	int (*dma_map_guest_page)(unsigned long handle, unsigned long gfn,
668c2ecf20Sopenharmony_ci				  unsigned long size, dma_addr_t *dma_addr);
678c2ecf20Sopenharmony_ci	void (*dma_unmap_guest_page)(unsigned long handle, dma_addr_t dma_addr);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	int (*dma_pin_guest_page)(unsigned long handle, dma_addr_t dma_addr);
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	int (*map_gfn_to_mfn)(unsigned long handle, unsigned long gfn,
728c2ecf20Sopenharmony_ci			      unsigned long mfn, unsigned int nr, bool map);
738c2ecf20Sopenharmony_ci	int (*set_trap_area)(unsigned long handle, u64 start, u64 end,
748c2ecf20Sopenharmony_ci			     bool map);
758c2ecf20Sopenharmony_ci	int (*set_opregion)(void *vgpu);
768c2ecf20Sopenharmony_ci	int (*set_edid)(void *vgpu, int port_num);
778c2ecf20Sopenharmony_ci	int (*get_vfio_device)(void *vgpu);
788c2ecf20Sopenharmony_ci	void (*put_vfio_device)(void *vgpu);
798c2ecf20Sopenharmony_ci	bool (*is_valid_gfn)(unsigned long handle, unsigned long gfn);
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#endif /* _GVT_HYPERCALL_H_ */
83