2 * QEMU SPAPR Dynamic Reconfiguration Connector Implementation
4 * Copyright IBM Corp. 2014
7 * Michael Roth <mdroth@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef HW_SPAPR_DRC_H
14 #define HW_SPAPR_DRC_H
17 #include "qom/object.h"
20 #define TYPE_SPAPR_DR_CONNECTOR "spapr-dr-connector"
21 #define SPAPR_DR_CONNECTOR_GET_CLASS(obj) \
22 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DR_CONNECTOR)
23 #define SPAPR_DR_CONNECTOR_CLASS(klass) \
24 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \
25 TYPE_SPAPR_DR_CONNECTOR)
26 #define SPAPR_DR_CONNECTOR(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
27 TYPE_SPAPR_DR_CONNECTOR)
29 #define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical"
30 #define SPAPR_DRC_PHYSICAL_GET_CLASS(obj) \
31 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PHYSICAL)
32 #define SPAPR_DRC_PHYSICAL_CLASS(klass) \
33 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \
34 TYPE_SPAPR_DRC_PHYSICAL)
35 #define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
36 TYPE_SPAPR_DRC_PHYSICAL)
38 #define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical"
39 #define SPAPR_DRC_LOGICAL_GET_CLASS(obj) \
40 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LOGICAL)
41 #define SPAPR_DRC_LOGICAL_CLASS(klass) \
42 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \
43 TYPE_SPAPR_DRC_LOGICAL)
44 #define SPAPR_DRC_LOGICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
45 TYPE_SPAPR_DRC_LOGICAL)
47 #define TYPE_SPAPR_DRC_CPU "spapr-drc-cpu"
48 #define SPAPR_DRC_CPU_GET_CLASS(obj) \
49 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_CPU)
50 #define SPAPR_DRC_CPU_CLASS(klass) \
51 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_CPU)
52 #define SPAPR_DRC_CPU(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
55 #define TYPE_SPAPR_DRC_PCI "spapr-drc-pci"
56 #define SPAPR_DRC_PCI_GET_CLASS(obj) \
57 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PCI)
58 #define SPAPR_DRC_PCI_CLASS(klass) \
59 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_PCI)
60 #define SPAPR_DRC_PCI(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
63 #define TYPE_SPAPR_DRC_LMB "spapr-drc-lmb"
64 #define SPAPR_DRC_LMB_GET_CLASS(obj) \
65 OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LMB)
66 #define SPAPR_DRC_LMB_CLASS(klass) \
67 OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_LMB)
68 #define SPAPR_DRC_LMB(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \
72 * Various hotplug types managed by sPAPRDRConnector
74 * these are somewhat arbitrary, but to make things easier
75 * when generating DRC indexes later we've aligned the bit
76 * positions with the values used to assign DRC indexes on
77 * pSeries. we use those values as bit shifts to allow for
78 * the OR'ing of these values in various QEMU routines, but
79 * for values exposed to the guest (via DRC indexes for
80 * instance) we will use the shift amounts.
83 SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU
= 1,
84 SPAPR_DR_CONNECTOR_TYPE_SHIFT_PHB
= 2,
85 SPAPR_DR_CONNECTOR_TYPE_SHIFT_VIO
= 3,
86 SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI
= 4,
87 SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB
= 8,
88 } sPAPRDRConnectorTypeShift
;
91 SPAPR_DR_CONNECTOR_TYPE_ANY
= ~0,
92 SPAPR_DR_CONNECTOR_TYPE_CPU
= 1 << SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU
,
93 SPAPR_DR_CONNECTOR_TYPE_PHB
= 1 << SPAPR_DR_CONNECTOR_TYPE_SHIFT_PHB
,
94 SPAPR_DR_CONNECTOR_TYPE_VIO
= 1 << SPAPR_DR_CONNECTOR_TYPE_SHIFT_VIO
,
95 SPAPR_DR_CONNECTOR_TYPE_PCI
= 1 << SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI
,
96 SPAPR_DR_CONNECTOR_TYPE_LMB
= 1 << SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB
,
97 } sPAPRDRConnectorType
;
100 * set via set-indicator RTAS calls
101 * as documented by PAPR+ 2.7 13.5.3.4, Table 177
103 * isolated: put device under firmware control
104 * unisolated: claim OS control of device (may or may not be in use)
107 SPAPR_DR_ISOLATION_STATE_ISOLATED
= 0,
108 SPAPR_DR_ISOLATION_STATE_UNISOLATED
= 1
109 } sPAPRDRIsolationState
;
112 * set via set-indicator RTAS calls
113 * as documented by PAPR+ 2.7 13.5.3.4, Table 177
115 * unusable: mark device as unavailable to OS
116 * usable: mark device as available to OS
117 * exchange: (currently unused)
118 * recover: (currently unused)
121 SPAPR_DR_ALLOCATION_STATE_UNUSABLE
= 0,
122 SPAPR_DR_ALLOCATION_STATE_USABLE
= 1,
123 SPAPR_DR_ALLOCATION_STATE_EXCHANGE
= 2,
124 SPAPR_DR_ALLOCATION_STATE_RECOVER
= 3
125 } sPAPRDRAllocationState
;
128 * DR-indicator (LED/visual indicator)
130 * set via set-indicator RTAS calls
131 * as documented by PAPR+ 2.7 13.5.3.4, Table 177,
132 * and PAPR+ 2.7 13.5.4.1, Table 180
134 * inactive: hotpluggable entity inactive and safely removable
135 * active: hotpluggable entity in use and not safely removable
136 * identify: (currently unused)
137 * action: (currently unused)
140 SPAPR_DR_INDICATOR_INACTIVE
= 0,
141 SPAPR_DR_INDICATOR_ACTIVE
= 1,
142 SPAPR_DR_INDICATOR_IDENTIFY
= 2,
143 SPAPR_DR_INDICATOR_ACTION
= 3,
144 } sPAPRDRIndicatorState
;
147 * returned via get-sensor-state RTAS calls
148 * as documented by PAPR+ 2.7 13.5.3.3, Table 175:
150 * empty: connector slot empty (e.g. empty hotpluggable PCI slot)
151 * present: connector slot populated and device available to OS
152 * unusable: device not currently available to OS
153 * exchange: (currently unused)
154 * recover: (currently unused)
157 SPAPR_DR_ENTITY_SENSE_EMPTY
= 0,
158 SPAPR_DR_ENTITY_SENSE_PRESENT
= 1,
159 SPAPR_DR_ENTITY_SENSE_UNUSABLE
= 2,
160 SPAPR_DR_ENTITY_SENSE_EXCHANGE
= 3,
161 SPAPR_DR_ENTITY_SENSE_RECOVER
= 4,
162 } sPAPRDREntitySense
;
165 SPAPR_DR_CC_RESPONSE_NEXT_SIB
= 1, /* currently unused */
166 SPAPR_DR_CC_RESPONSE_NEXT_CHILD
= 2,
167 SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY
= 3,
168 SPAPR_DR_CC_RESPONSE_PREV_PARENT
= 4,
169 SPAPR_DR_CC_RESPONSE_SUCCESS
= 0,
170 SPAPR_DR_CC_RESPONSE_ERROR
= -1,
171 SPAPR_DR_CC_RESPONSE_CONTINUE
= -2,
172 SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE
= -9003,
175 /* rtas-configure-connector state */
176 typedef struct sPAPRConfigureConnectorState
{
179 } sPAPRConfigureConnectorState
;
181 typedef struct sPAPRDRConnector
{
189 uint32_t dr_indicator
;
191 /* sensor/indicator states */
192 uint32_t isolation_state
;
193 uint32_t allocation_state
;
195 /* configure-connector state */
197 int fdt_start_offset
;
199 sPAPRConfigureConnectorState
*ccs
;
201 bool awaiting_release
;
202 bool awaiting_allocation
;
204 /* device pointer, via link property */
208 typedef struct sPAPRDRConnectorClass
{
213 sPAPRDRConnectorTypeShift typeshift
;
214 const char *typename
; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */
215 const char *drc_name_prefix
; /* used other places in device tree */
217 sPAPRDREntitySense (*dr_entity_sense
)(sPAPRDRConnector
*drc
);
218 uint32_t (*isolate
)(sPAPRDRConnector
*drc
);
219 uint32_t (*unisolate
)(sPAPRDRConnector
*drc
);
220 void (*release
)(DeviceState
*dev
);
222 /* QEMU interfaces for managing hotplug operations */
223 bool (*release_pending
)(sPAPRDRConnector
*drc
);
224 } sPAPRDRConnectorClass
;
226 uint32_t spapr_drc_index(sPAPRDRConnector
*drc
);
227 sPAPRDRConnectorType
spapr_drc_type(sPAPRDRConnector
*drc
);
229 sPAPRDRConnector
*spapr_dr_connector_new(Object
*owner
, const char *type
,
231 sPAPRDRConnector
*spapr_drc_by_index(uint32_t index
);
232 sPAPRDRConnector
*spapr_drc_by_id(const char *type
, uint32_t id
);
233 int spapr_drc_populate_dt(void *fdt
, int fdt_offset
, Object
*owner
,
234 uint32_t drc_type_mask
);
236 void spapr_drc_attach(sPAPRDRConnector
*drc
, DeviceState
*d
, void *fdt
,
237 int fdt_start_offset
, Error
**errp
);
238 void spapr_drc_detach(sPAPRDRConnector
*drc
, DeviceState
*d
, Error
**errp
);
240 #endif /* HW_SPAPR_DRC_H */