xref: /openbmc/linux/arch/x86/include/asm/uv/uv_geo.h (revision 981b22b8)
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (C) 2020 Hewlett Packard Enterprise Development LP. All rights reserved.
8  */
9 
10 #ifndef _ASM_UV_GEO_H
11 #define _ASM_UV_GEO_H
12 
13 /* Type declaractions */
14 
15 /* Size of a geoid_s structure (must be before decl. of geoid_u) */
16 #define GEOID_SIZE	8
17 
18 /* Fields common to all substructures */
19 struct geo_common_s {
20 	unsigned char type;		/* What type of h/w is named by this geoid_s */
21 	unsigned char blade;
22 	unsigned char slot;		/* slot is IRU */
23 	unsigned char upos;
24 	unsigned char rack;
25 };
26 
27 /* Additional fields for particular types of hardware */
28 struct geo_node_s {
29 	struct geo_common_s common;		/* No additional fields needed */
30 };
31 
32 struct geo_rtr_s {
33 	struct geo_common_s common;		/* No additional fields needed */
34 };
35 
36 struct geo_iocntl_s {
37 	struct geo_common_s common;		/* No additional fields needed */
38 };
39 
40 struct geo_pcicard_s {
41 	struct geo_iocntl_s common;
42 	char bus;				/* Bus/widget number */
43 	char slot;				/* PCI slot number */
44 };
45 
46 /* Subcomponents of a node */
47 struct geo_cpu_s {
48 	struct geo_node_s node;
49 	unsigned char	socket:4,	/* Which CPU on the node */
50 			thread:4;
51 	unsigned char	core;
52 };
53 
54 struct geo_mem_s {
55 	struct geo_node_s node;
56 	char membus;			/* The memory bus on the node */
57 	char memslot;			/* The memory slot on the bus */
58 };
59 
60 union geoid_u {
61 	struct geo_common_s common;
62 	struct geo_node_s node;
63 	struct geo_iocntl_s iocntl;
64 	struct geo_pcicard_s pcicard;
65 	struct geo_rtr_s rtr;
66 	struct geo_cpu_s cpu;
67 	struct geo_mem_s mem;
68 	char padsize[GEOID_SIZE];
69 };
70 
71 /* Defined constants */
72 
73 #define GEO_MAX_LEN	48
74 
75 #define GEO_TYPE_INVALID	0
76 #define GEO_TYPE_MODULE		1
77 #define GEO_TYPE_NODE		2
78 #define GEO_TYPE_RTR		3
79 #define GEO_TYPE_IOCNTL		4
80 #define GEO_TYPE_IOCARD		5
81 #define GEO_TYPE_CPU		6
82 #define GEO_TYPE_MEM		7
83 #define GEO_TYPE_MAX		(GEO_TYPE_MEM+1)
84 
85 static inline int geo_rack(union geoid_u g)
86 {
87 	return (g.common.type == GEO_TYPE_INVALID) ?
88 		-1 : g.common.rack;
89 }
90 
91 static inline int geo_slot(union geoid_u g)
92 {
93 	return (g.common.type == GEO_TYPE_INVALID) ?
94 		-1 : g.common.upos;
95 }
96 
97 static inline int geo_blade(union geoid_u g)
98 {
99 	return (g.common.type == GEO_TYPE_INVALID) ?
100 		-1 : g.common.blade * 2 + g.common.slot;
101 }
102 
103 #endif /* _ASM_UV_GEO_H */
104