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