1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (c) 2015 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef INTEL_L3_CONFIG_H 25bf215546Sopenharmony_ci#define INTEL_L3_CONFIG_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdio.h> 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "dev/intel_device_info.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci/** 32bf215546Sopenharmony_ci * Chunk of L3 cache reserved for some specific purpose. 33bf215546Sopenharmony_ci */ 34bf215546Sopenharmony_cienum intel_l3_partition { 35bf215546Sopenharmony_ci /** Shared local memory. */ 36bf215546Sopenharmony_ci INTEL_L3P_SLM = 0, 37bf215546Sopenharmony_ci /** Unified return buffer. */ 38bf215546Sopenharmony_ci INTEL_L3P_URB, 39bf215546Sopenharmony_ci /** Union of DC and RO. */ 40bf215546Sopenharmony_ci INTEL_L3P_ALL, 41bf215546Sopenharmony_ci /** Data cluster RW partition. */ 42bf215546Sopenharmony_ci INTEL_L3P_DC, 43bf215546Sopenharmony_ci /** Union of IS, C and T. */ 44bf215546Sopenharmony_ci INTEL_L3P_RO, 45bf215546Sopenharmony_ci /** Instruction and state cache. */ 46bf215546Sopenharmony_ci INTEL_L3P_IS, 47bf215546Sopenharmony_ci /** Constant cache. */ 48bf215546Sopenharmony_ci INTEL_L3P_C, 49bf215546Sopenharmony_ci /** Texture cache. */ 50bf215546Sopenharmony_ci INTEL_L3P_T, 51bf215546Sopenharmony_ci /** Number of supported L3 partitions. */ 52bf215546Sopenharmony_ci INTEL_NUM_L3P 53bf215546Sopenharmony_ci}; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci/** 56bf215546Sopenharmony_ci * L3 configuration represented as the number of ways allocated for each 57bf215546Sopenharmony_ci * partition. \sa get_l3_way_size(). 58bf215546Sopenharmony_ci */ 59bf215546Sopenharmony_cistruct intel_l3_config { 60bf215546Sopenharmony_ci unsigned n[INTEL_NUM_L3P]; 61bf215546Sopenharmony_ci}; 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci/** 64bf215546Sopenharmony_ci * L3 configuration represented as a vector of weights giving the desired 65bf215546Sopenharmony_ci * relative size of each partition. The scale is arbitrary, only the ratios 66bf215546Sopenharmony_ci * between weights will have an influence on the selection of the closest L3 67bf215546Sopenharmony_ci * configuration. 68bf215546Sopenharmony_ci */ 69bf215546Sopenharmony_cistruct intel_l3_weights { 70bf215546Sopenharmony_ci float w[INTEL_NUM_L3P]; 71bf215546Sopenharmony_ci}; 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_cifloat intel_diff_l3_weights(struct intel_l3_weights w0, struct intel_l3_weights w1); 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_cistruct intel_l3_weights 76bf215546Sopenharmony_ciintel_get_default_l3_weights(const struct intel_device_info *devinfo, 77bf215546Sopenharmony_ci bool needs_dc, bool needs_slm); 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cistruct intel_l3_weights 80bf215546Sopenharmony_ciintel_get_l3_config_weights(const struct intel_l3_config *cfg); 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ciconst struct intel_l3_config * 83bf215546Sopenharmony_ciintel_get_default_l3_config(const struct intel_device_info *devinfo); 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ciconst struct intel_l3_config * 86bf215546Sopenharmony_ciintel_get_l3_config(const struct intel_device_info *devinfo, 87bf215546Sopenharmony_ci struct intel_l3_weights w0); 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ciunsigned 90bf215546Sopenharmony_ciintel_get_l3_config_urb_size(const struct intel_device_info *devinfo, 91bf215546Sopenharmony_ci const struct intel_l3_config *cfg); 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_civoid intel_dump_l3_config(const struct intel_l3_config *cfg, FILE *fp); 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_cienum intel_urb_deref_block_size { 96bf215546Sopenharmony_ci INTEL_URB_DEREF_BLOCK_SIZE_32 = 0, 97bf215546Sopenharmony_ci INTEL_URB_DEREF_BLOCK_SIZE_PER_POLY = 1, 98bf215546Sopenharmony_ci INTEL_URB_DEREF_BLOCK_SIZE_8 = 2, 99bf215546Sopenharmony_ci INTEL_URB_DEREF_BLOCK_SIZE_MESH = 3, 100bf215546Sopenharmony_ci}; 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_civoid intel_get_urb_config(const struct intel_device_info *devinfo, 103bf215546Sopenharmony_ci const struct intel_l3_config *l3_cfg, 104bf215546Sopenharmony_ci bool tess_present, bool gs_present, 105bf215546Sopenharmony_ci const unsigned entry_size[4], 106bf215546Sopenharmony_ci unsigned entries[4], unsigned start[4], 107bf215546Sopenharmony_ci enum intel_urb_deref_block_size *deref_block_size, 108bf215546Sopenharmony_ci bool *constrained); 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_cistruct intel_mesh_urb_allocation { 111bf215546Sopenharmony_ci unsigned task_entries; 112bf215546Sopenharmony_ci unsigned task_entry_size_64b; 113bf215546Sopenharmony_ci unsigned task_starting_address_8kb; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci unsigned mesh_entries; 116bf215546Sopenharmony_ci unsigned mesh_entry_size_64b; 117bf215546Sopenharmony_ci unsigned mesh_starting_address_8kb; 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci enum intel_urb_deref_block_size deref_block_size; 120bf215546Sopenharmony_ci}; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_cistruct intel_mesh_urb_allocation 123bf215546Sopenharmony_ciintel_get_mesh_urb_config(const struct intel_device_info *devinfo, 124bf215546Sopenharmony_ci const struct intel_l3_config *l3_cfg, 125bf215546Sopenharmony_ci unsigned tue_size_dw, unsigned mue_size_dw); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci#endif /* INTEL_L3_CONFIG_H */ 128