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