Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright(c) 2011-2016 Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | * SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Ke Yu |
| 25 | * Kevin Tian <kevin.tian@intel.com> |
| 26 | * Dexuan Cui |
| 27 | * |
| 28 | * Contributors: |
| 29 | * Tina Zhang <tina.zhang@intel.com> |
| 30 | * Min He <min.he@intel.com> |
| 31 | * Niu Bing <bing.niu@intel.com> |
| 32 | * Zhi Wang <zhi.a.wang@intel.com> |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | #ifndef _GVT_MMIO_H_ |
| 37 | #define _GVT_MMIO_H_ |
| 38 | |
| 39 | struct intel_gvt; |
| 40 | struct intel_vgpu; |
| 41 | |
fred gao | a1dcba9 | 2017-05-25 15:32:27 +0800 | [diff] [blame] | 42 | #define D_BDW (1 << 0) |
| 43 | #define D_SKL (1 << 1) |
| 44 | #define D_KBL (1 << 2) |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 45 | |
Xu Han | 18af19d | 2017-03-29 10:13:56 +0800 | [diff] [blame] | 46 | #define D_GEN9PLUS (D_SKL | D_KBL) |
| 47 | #define D_GEN8PLUS (D_BDW | D_SKL | D_KBL) |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 48 | |
Xu Han | 18af19d | 2017-03-29 10:13:56 +0800 | [diff] [blame] | 49 | #define D_SKL_PLUS (D_SKL | D_KBL) |
| 50 | #define D_BDW_PLUS (D_BDW | D_SKL | D_KBL) |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 51 | |
fred gao | a1dcba9 | 2017-05-25 15:32:27 +0800 | [diff] [blame] | 52 | #define D_PRE_SKL (D_BDW) |
| 53 | #define D_ALL (D_BDW | D_SKL | D_KBL) |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 54 | |
Changbin Du | 65f9f6f | 2017-06-06 15:56:09 +0800 | [diff] [blame] | 55 | typedef int (*gvt_mmio_func)(struct intel_vgpu *, unsigned int, void *, |
| 56 | unsigned int); |
| 57 | |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 58 | struct intel_gvt_mmio_info { |
| 59 | u32 offset; |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 60 | u64 ro_mask; |
| 61 | u32 device; |
Changbin Du | 65f9f6f | 2017-06-06 15:56:09 +0800 | [diff] [blame] | 62 | gvt_mmio_func read; |
| 63 | gvt_mmio_func write; |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 64 | u32 addr_range; |
| 65 | struct hlist_node node; |
| 66 | }; |
| 67 | |
| 68 | unsigned long intel_gvt_get_device_type(struct intel_gvt *gvt); |
| 69 | bool intel_gvt_match_device(struct intel_gvt *gvt, unsigned long device); |
| 70 | |
| 71 | int intel_gvt_setup_mmio_info(struct intel_gvt *gvt); |
| 72 | void intel_gvt_clean_mmio_info(struct intel_gvt *gvt); |
| 73 | |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 74 | #define INTEL_GVT_MMIO_OFFSET(reg) ({ \ |
| 75 | typeof(reg) __reg = reg; \ |
| 76 | u32 *offset = (u32 *)&__reg; \ |
| 77 | *offset; \ |
| 78 | }) |
| 79 | |
Changbin Du | cdcc434 | 2017-01-13 11:16:00 +0800 | [diff] [blame] | 80 | int intel_vgpu_init_mmio(struct intel_vgpu *vgpu); |
fred gao | 615c16a | 2017-05-25 15:33:52 +0800 | [diff] [blame] | 81 | void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr); |
Changbin Du | cdcc434 | 2017-01-13 11:16:00 +0800 | [diff] [blame] | 82 | void intel_vgpu_clean_mmio(struct intel_vgpu *vgpu); |
| 83 | |
Zhi Wang | e39c5ad | 2016-09-02 13:33:29 +0800 | [diff] [blame] | 84 | int intel_vgpu_gpa_to_mmio_offset(struct intel_vgpu *vgpu, u64 gpa); |
Jike Song | 9ec1e66 | 2016-11-03 18:38:35 +0800 | [diff] [blame] | 85 | |
| 86 | int intel_vgpu_emulate_mmio_read(struct intel_vgpu *vgpu, u64 pa, |
| 87 | void *p_data, unsigned int bytes); |
| 88 | int intel_vgpu_emulate_mmio_write(struct intel_vgpu *vgpu, u64 pa, |
| 89 | void *p_data, unsigned int bytes); |
Changbin Du | 5c6d4c6 | 2017-06-06 15:56:12 +0800 | [diff] [blame] | 90 | |
Zhi Wang | e39c5ad | 2016-09-02 13:33:29 +0800 | [diff] [blame] | 91 | int intel_vgpu_default_mmio_read(struct intel_vgpu *vgpu, unsigned int offset, |
| 92 | void *p_data, unsigned int bytes); |
| 93 | int intel_vgpu_default_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, |
| 94 | void *p_data, unsigned int bytes); |
Zhao Yan | 4938ca9 | 2017-03-09 10:09:44 +0800 | [diff] [blame] | 95 | |
| 96 | bool intel_gvt_in_force_nonpriv_whitelist(struct intel_gvt *gvt, |
| 97 | unsigned int offset); |
Changbin Du | 65f9f6f | 2017-06-06 15:56:09 +0800 | [diff] [blame] | 98 | |
| 99 | int intel_vgpu_mmio_reg_rw(struct intel_vgpu *vgpu, unsigned int offset, |
| 100 | void *pdata, unsigned int bytes, bool is_read); |
| 101 | |
Zhi Wang | 12d14cc | 2016-08-30 11:06:17 +0800 | [diff] [blame] | 102 | #endif |