intel: Pull the guts of gen7_l3_state.c into a shared helper
[mesa.git] / src / intel / common / gen_l3_config.h
1 /*
2 * Copyright (c) 2015 Intel Corporation
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include <stdio.h>
25
26 #include "gen_device_info.h"
27
28 /**
29 * Chunk of L3 cache reserved for some specific purpose.
30 */
31 enum gen_l3_partition {
32 /** Shared local memory. */
33 GEN_L3P_SLM = 0,
34 /** Unified return buffer. */
35 GEN_L3P_URB,
36 /** Union of DC and RO. */
37 GEN_L3P_ALL,
38 /** Data cluster RW partition. */
39 GEN_L3P_DC,
40 /** Union of IS, C and T. */
41 GEN_L3P_RO,
42 /** Instruction and state cache. */
43 GEN_L3P_IS,
44 /** Constant cache. */
45 GEN_L3P_C,
46 /** Texture cache. */
47 GEN_L3P_T,
48 /** Number of supported L3 partitions. */
49 GEN_NUM_L3P
50 };
51
52 /**
53 * L3 configuration represented as the number of ways allocated for each
54 * partition. \sa get_l3_way_size().
55 */
56 struct gen_l3_config {
57 unsigned n[GEN_NUM_L3P];
58 };
59
60 /**
61 * L3 configuration represented as a vector of weights giving the desired
62 * relative size of each partition. The scale is arbitrary, only the ratios
63 * between weights will have an influence on the selection of the closest L3
64 * configuration.
65 */
66 struct gen_l3_weights {
67 float w[GEN_NUM_L3P];
68 };
69
70 float gen_diff_l3_weights(struct gen_l3_weights w0, struct gen_l3_weights w1);
71
72 struct gen_l3_weights
73 gen_get_default_l3_weights(const struct gen_device_info *devinfo,
74 bool needs_dc, bool needs_slm);
75
76 struct gen_l3_weights
77 gen_get_l3_config_weights(const struct gen_l3_config *cfg);
78
79 const struct gen_l3_config *
80 gen_get_default_l3_config(const struct gen_device_info *devinfo);
81
82 const struct gen_l3_config *
83 gen_get_l3_config(const struct gen_device_info *devinfo,
84 struct gen_l3_weights w0);
85
86 unsigned
87 gen_get_l3_config_urb_size(const struct gen_device_info *devinfo,
88 const struct gen_l3_config *cfg);
89
90 void gen_dump_l3_config(const struct gen_l3_config *cfg, FILE *fp);