19a3c425cSJustin Ernst /* SPDX-License-Identifier: GPL-2.0-or-later 29a3c425cSJustin Ernst * 39a3c425cSJustin Ernst * This file is subject to the terms and conditions of the GNU General Public 49a3c425cSJustin Ernst * License. See the file "COPYING" in the main directory of this archive 59a3c425cSJustin Ernst * for more details. 69a3c425cSJustin Ernst * 79a3c425cSJustin Ernst * Copyright (C) 2020 Hewlett Packard Enterprise Development LP. All rights reserved. 89a3c425cSJustin Ernst */ 99a3c425cSJustin Ernst 109a3c425cSJustin Ernst #ifndef _ASM_UV_GEO_H 119a3c425cSJustin Ernst #define _ASM_UV_GEO_H 129a3c425cSJustin Ernst 13*d9f6e12fSIngo Molnar /* Type declarations */ 149a3c425cSJustin Ernst 159a3c425cSJustin Ernst /* Size of a geoid_s structure (must be before decl. of geoid_u) */ 169a3c425cSJustin Ernst #define GEOID_SIZE 8 179a3c425cSJustin Ernst 189a3c425cSJustin Ernst /* Fields common to all substructures */ 199a3c425cSJustin Ernst struct geo_common_s { 209a3c425cSJustin Ernst unsigned char type; /* What type of h/w is named by this geoid_s */ 219a3c425cSJustin Ernst unsigned char blade; 229a3c425cSJustin Ernst unsigned char slot; /* slot is IRU */ 239a3c425cSJustin Ernst unsigned char upos; 249a3c425cSJustin Ernst unsigned char rack; 259a3c425cSJustin Ernst }; 269a3c425cSJustin Ernst 279a3c425cSJustin Ernst /* Additional fields for particular types of hardware */ 289a3c425cSJustin Ernst struct geo_node_s { 299a3c425cSJustin Ernst struct geo_common_s common; /* No additional fields needed */ 309a3c425cSJustin Ernst }; 319a3c425cSJustin Ernst 329a3c425cSJustin Ernst struct geo_rtr_s { 339a3c425cSJustin Ernst struct geo_common_s common; /* No additional fields needed */ 349a3c425cSJustin Ernst }; 359a3c425cSJustin Ernst 369a3c425cSJustin Ernst struct geo_iocntl_s { 379a3c425cSJustin Ernst struct geo_common_s common; /* No additional fields needed */ 389a3c425cSJustin Ernst }; 399a3c425cSJustin Ernst 409a3c425cSJustin Ernst struct geo_pcicard_s { 419a3c425cSJustin Ernst struct geo_iocntl_s common; 429a3c425cSJustin Ernst char bus; /* Bus/widget number */ 439a3c425cSJustin Ernst char slot; /* PCI slot number */ 449a3c425cSJustin Ernst }; 459a3c425cSJustin Ernst 469a3c425cSJustin Ernst /* Subcomponents of a node */ 479a3c425cSJustin Ernst struct geo_cpu_s { 489a3c425cSJustin Ernst struct geo_node_s node; 499a3c425cSJustin Ernst unsigned char socket:4, /* Which CPU on the node */ 509a3c425cSJustin Ernst thread:4; 519a3c425cSJustin Ernst unsigned char core; 529a3c425cSJustin Ernst }; 539a3c425cSJustin Ernst 549a3c425cSJustin Ernst struct geo_mem_s { 559a3c425cSJustin Ernst struct geo_node_s node; 569a3c425cSJustin Ernst char membus; /* The memory bus on the node */ 579a3c425cSJustin Ernst char memslot; /* The memory slot on the bus */ 589a3c425cSJustin Ernst }; 599a3c425cSJustin Ernst 609a3c425cSJustin Ernst union geoid_u { 619a3c425cSJustin Ernst struct geo_common_s common; 629a3c425cSJustin Ernst struct geo_node_s node; 639a3c425cSJustin Ernst struct geo_iocntl_s iocntl; 649a3c425cSJustin Ernst struct geo_pcicard_s pcicard; 659a3c425cSJustin Ernst struct geo_rtr_s rtr; 669a3c425cSJustin Ernst struct geo_cpu_s cpu; 679a3c425cSJustin Ernst struct geo_mem_s mem; 689a3c425cSJustin Ernst char padsize[GEOID_SIZE]; 699a3c425cSJustin Ernst }; 709a3c425cSJustin Ernst 719a3c425cSJustin Ernst /* Defined constants */ 729a3c425cSJustin Ernst 739a3c425cSJustin Ernst #define GEO_MAX_LEN 48 749a3c425cSJustin Ernst 759a3c425cSJustin Ernst #define GEO_TYPE_INVALID 0 769a3c425cSJustin Ernst #define GEO_TYPE_MODULE 1 779a3c425cSJustin Ernst #define GEO_TYPE_NODE 2 789a3c425cSJustin Ernst #define GEO_TYPE_RTR 3 799a3c425cSJustin Ernst #define GEO_TYPE_IOCNTL 4 809a3c425cSJustin Ernst #define GEO_TYPE_IOCARD 5 819a3c425cSJustin Ernst #define GEO_TYPE_CPU 6 829a3c425cSJustin Ernst #define GEO_TYPE_MEM 7 839a3c425cSJustin Ernst #define GEO_TYPE_MAX (GEO_TYPE_MEM+1) 849a3c425cSJustin Ernst geo_rack(union geoid_u g)859a3c425cSJustin Ernststatic inline int geo_rack(union geoid_u g) 869a3c425cSJustin Ernst { 879a3c425cSJustin Ernst return (g.common.type == GEO_TYPE_INVALID) ? 889a3c425cSJustin Ernst -1 : g.common.rack; 899a3c425cSJustin Ernst } 909a3c425cSJustin Ernst geo_slot(union geoid_u g)919a3c425cSJustin Ernststatic inline int geo_slot(union geoid_u g) 929a3c425cSJustin Ernst { 939a3c425cSJustin Ernst return (g.common.type == GEO_TYPE_INVALID) ? 949a3c425cSJustin Ernst -1 : g.common.upos; 959a3c425cSJustin Ernst } 969a3c425cSJustin Ernst geo_blade(union geoid_u g)979a3c425cSJustin Ernststatic inline int geo_blade(union geoid_u g) 989a3c425cSJustin Ernst { 999a3c425cSJustin Ernst return (g.common.type == GEO_TYPE_INVALID) ? 1009a3c425cSJustin Ernst -1 : g.common.blade * 2 + g.common.slot; 1019a3c425cSJustin Ernst } 1029a3c425cSJustin Ernst 1039a3c425cSJustin Ernst #endif /* _ASM_UV_GEO_H */ 104