xref: /titanic_52/usr/src/uts/sun4v/sys/mpo.h (revision 183ef8a1713ca188e24d970f22c6f9cc333007fd)
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 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_MPO_H
28 #define	_SYS_MPO_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/lgrp.h>
35 
36 /*
37  * mpo.h -  Sun4v MPO common header file
38  *
39  */
40 
41 #define	PROP_LG_CPU_ID	"id"
42 #define	PROP_LG_MASK	"address-mask"
43 #define	PROP_LG_LATENCY "latency"
44 #define	PROP_LG_MATCH	"address-match"
45 #define	PROP_LG_MEM_LG	"memory-latency-group"
46 #define	PROP_LG_CPU	"cpu"
47 #define	PROP_LG_MBLOCK	"mblock"
48 #define	PROP_LG_BASE	"base"
49 #define	PROP_LG_SIZE	"size"
50 #define	PROP_LG_RA_PA_OFFSET	"address-congruence-offset"
51 
52 /* Macro to set the correspending bit if an mem-lg homeid is a member */
53 #define	HOMESET_ADD(homeset, home)\
54 	homeset |= ((int)1 << (home))
55 
56 /* Macro to check if an mem_lg homeid is a member of the homeset */
57 #define	MEM_LG_ISMEMBER(homeset, home)\
58 	((homeset) & ((uint64_t)1 << (home)))
59 
60 /* Structure to store CPU information from the MD */
61 
62 struct cpu_md {
63 	uint_t 	home;
64 	int	lgrp_index;
65 };
66 
67 /* Structure to store mem-lg information from the MD */
68 
69 struct lgrp_md {
70 	uint64_t	id;
71 	uint64_t	addr_mask;
72 	uint64_t	addr_match;
73 	uint64_t	latency;
74 	mde_cookie_t	node;
75 	int		ncpu;
76 };
77 
78 /* Structure to store mblock information retrieved from the MD */
79 
80 typedef struct mblock_md {
81 	uint64_t	base;
82 	uint64_t	size;
83 	uint64_t	ra_to_pa;
84 	pfn_t		base_pfn;
85 	pfn_t		end_pfn;
86 } mblock_md_t;
87 
88 /* Structure for memnode information for use by plat_pfn_to_mem_node */
89 
90 struct mnode_info {
91 	pfn_t		base_pfn;
92 	pfn_t		end_pfn;
93 };
94 
95 /* A stripe defines the portion of a mem_node that falls in one mblock */
96 typedef struct {
97 	pfn_t physbase;	/* first page in mnode in the corresponding mblock */
98 	pfn_t physmax;	/* last valid page in mnode in mblock */
99 	pfn_t offset;   /* stripe starts at physbase - offset */
100 	int exists;	/* set to 1 if mblock has memory in this mnode stripe */
101 } mem_stripe_t;
102 
103 /* Configuration including allocation state of mblocks and stripes */
104 
105 typedef struct {
106 	mblock_md_t	*mc_mblocks;	/* mblock array */
107 	int 		mc_nmblocks;	/* number in array */
108 	mem_stripe_t 	*mc_stripes;	/* stripe array */
109 	int 		mc_nstripes;	/* number in array */
110 	int 		mc_alloc_sz;	/* size in bytes of mc_mblocks if */
111 					/* it was kmem_alloc'd, else 0 */
112 } mpo_config_t;
113 
114 /* These are used when MPO requires preallocated kvseg32 space */
115 extern	caddr_t	mpo_heap32_buf;
116 extern	size_t	mpo_heap32_bufsz;
117 extern void mpo_cpu_add(md_t *md, int cpuid);
118 extern void mpo_cpu_remove(int cpuid);
119 
120 #ifdef	__cplusplus
121 }
122 #endif
123 
124 #endif /* _SYS_MPO_H */
125