xref: /titanic_51/usr/src/uts/common/sys/pghw.h (revision 499fd60129a966ad9d9e752e65f591c3a6a1c697)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_PGHW_H
27 #define	_PGHW_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #if (defined(_KERNEL) || defined(_KMEMUSER))
37 #include <sys/cpuvar.h>
38 #include <sys/group.h>
39 #include <sys/processor.h>
40 #include <sys/bitmap.h>
41 #include <sys/atomic.h>
42 #include <sys/types.h>
43 #include <sys/kstat.h>
44 #include <sys/pg.h>
45 
46 /*
47  * Hardware that may be shared by a group of processors
48  */
49 typedef enum pghw_type {
50 	PGHW_START,
51 	PGHW_IPIPE,
52 	PGHW_CACHE,
53 	PGHW_FPU,
54 	PGHW_MPIPE,
55 	PGHW_CHIP,
56 	PGHW_MEMORY,
57 	PGHW_NUM_COMPONENTS
58 } pghw_type_t;
59 
60 /*
61  * Anonymous instance id
62  */
63 #define	PGHW_INSTANCE_ANON ((id_t)0xdecafbad)
64 
65 /*
66  * Processor Group (physical sharing relationship)
67  */
68 typedef struct pghw {
69 	pg_t		pghw_pg;	/* processor group */
70 	pghw_type_t	pghw_hw;	/* HW sharing relationship */
71 	id_t		pghw_instance;	/* sharing instance identifier */
72 	kstat_t		*pghw_kstat;	/* physical kstats exported */
73 } pghw_t;
74 
75 /*
76  * IDs associating a CPU with various physical hardware
77  */
78 typedef struct cpu_physid {
79 	id_t		cpu_chipid;	/* CPU's physical processor */
80 	id_t		cpu_coreid;	/* CPU's physical core */
81 	id_t		cpu_cacheid;	/* CPU's cache id */
82 } cpu_physid_t;
83 
84 /*
85  * Physical PG initialization / CPU service hooks
86  */
87 void		pghw_init(pghw_t *, cpu_t *, pghw_type_t);
88 void		pghw_fini(pghw_t *);
89 void		pghw_cpu_add(pghw_t *, cpu_t *);
90 pghw_t		*pghw_place_cpu(cpu_t *, pghw_type_t);
91 
92 /*
93  * Physical ID cache creation / destruction
94  */
95 void		pghw_physid_create(cpu_t *);
96 void		pghw_physid_destroy(cpu_t *);
97 
98 /*
99  * CPU / PG hardware related seach operations
100  */
101 pghw_t		*pghw_find_pg(cpu_t *, pghw_type_t);
102 pghw_t		*pghw_find_by_instance(id_t, pghw_type_t);
103 group_t		*pghw_set_lookup(pghw_type_t);
104 
105 int		pghw_level(pghw_type_t);
106 
107 void		pghw_kstat_create(pghw_t *);
108 int		pghw_kstat_update(kstat_t *, int);
109 
110 /* Hardware sharing relationship platform interfaces */
111 int		pg_plat_hw_shared(cpu_t *, pghw_type_t);
112 int		pg_plat_cpus_share(cpu_t *, cpu_t *, pghw_type_t);
113 int		pg_plat_hw_level(pghw_type_t);
114 id_t		pg_plat_hw_instance_id(cpu_t *, pghw_type_t);
115 
116 /*
117  * What comprises a "core" may vary across processor implementations,
118  * and so the term itself is somewhat unstable. For this reason, there
119  * is no PGHW_CORE type, but we provide an interface here to allow platforms
120  * to express cpu <=> core mappings.
121  */
122 id_t		pg_plat_get_core_id(cpu_t *);
123 
124 #endif	/* !_KERNEL && !_KMEMUSER */
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif /* _PGHW_H */
131