1 /* SPDX-License-Identifier: GPL-2.0-or-later */
5 * Copyright IBM Corp. 2022, 2023
6 * Author(s): Pierre Morel <pmorel@linux.ibm.com>
9 #ifndef HW_S390X_CPU_TOPOLOGY_H
10 #define HW_S390X_CPU_TOPOLOGY_H
12 #ifndef CONFIG_USER_ONLY
14 #include "qemu/queue.h"
15 #include "hw/boards.h"
16 #include "qapi/qapi-types-machine-target.h"
18 #define S390_TOPOLOGY_CPU_IFL 0x03
20 typedef struct S390TopologyId
{
27 uint8_t entitlement
:2;
32 typedef struct S390TopologyEntry
{
33 QTAILQ_ENTRY(S390TopologyEntry
) next
;
38 typedef struct S390Topology
{
39 uint8_t *cores_per_socket
;
40 S390CpuPolarization polarization
;
43 typedef QTAILQ_HEAD(, S390TopologyEntry
) S390TopologyList
;
46 bool s390_has_topology(void);
47 void s390_topology_setup_cpu(MachineState
*ms
, S390CPU
*cpu
, Error
**errp
);
48 void s390_topology_reset(void);
50 static inline bool s390_has_topology(void)
54 static inline void s390_topology_setup_cpu(MachineState
*ms
,
57 static inline void s390_topology_reset(void)
59 /* Unreachable, CPU topology not implemented for TCG */
60 g_assert_not_reached();
64 extern S390Topology s390_topology
;
66 static inline int s390_std_socket(int n
, CpuTopology
*smp
)
68 return (n
/ smp
->cores
) % smp
->sockets
;
71 static inline int s390_std_book(int n
, CpuTopology
*smp
)
73 return (n
/ (smp
->cores
* smp
->sockets
)) % smp
->books
;
76 static inline int s390_std_drawer(int n
, CpuTopology
*smp
)
78 return (n
/ (smp
->cores
* smp
->sockets
* smp
->books
)) % smp
->drawers
;
81 #endif /* CONFIG_USER_ONLY */