xref: /qemu/hw/ppc/spapr_drc.c (revision db725815)
1 /*
2  * QEMU SPAPR Dynamic Reconfiguration Connector Implementation
3  *
4  * Copyright IBM Corp. 2014
5  *
6  * Authors:
7  *  Michael Roth      <mdroth@linux.vnet.ibm.com>
8  *
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.
11  */
12 
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "qapi/qmp/qnull.h"
16 #include "cpu.h"
17 #include "qemu/cutils.h"
18 #include "hw/ppc/spapr_drc.h"
19 #include "qom/object.h"
20 #include "hw/qdev.h"
21 #include "migration/vmstate.h"
22 #include "qapi/visitor.h"
23 #include "qemu/error-report.h"
24 #include "hw/ppc/spapr.h" /* for RTAS return codes */
25 #include "hw/pci-host/spapr.h" /* spapr_phb_remove_pci_device_cb callback */
26 #include "sysemu/device_tree.h"
27 #include "sysemu/reset.h"
28 #include "trace.h"
29 
30 #define DRC_CONTAINER_PATH "/dr-connector"
31 #define DRC_INDEX_TYPE_SHIFT 28
32 #define DRC_INDEX_ID_MASK ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1)
33 
34 SpaprDrcType spapr_drc_type(SpaprDrc *drc)
35 {
36     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
37 
38     return 1 << drck->typeshift;
39 }
40 
41 uint32_t spapr_drc_index(SpaprDrc *drc)
42 {
43     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
44 
45     /* no set format for a drc index: it only needs to be globally
46      * unique. this is how we encode the DRC type on bare-metal
47      * however, so might as well do that here
48      */
49     return (drck->typeshift << DRC_INDEX_TYPE_SHIFT)
50         | (drc->id & DRC_INDEX_ID_MASK);
51 }
52 
53 static uint32_t drc_isolate_physical(SpaprDrc *drc)
54 {
55     switch (drc->state) {
56     case SPAPR_DRC_STATE_PHYSICAL_POWERON:
57         return RTAS_OUT_SUCCESS; /* Nothing to do */
58     case SPAPR_DRC_STATE_PHYSICAL_CONFIGURED:
59         break; /* see below */
60     case SPAPR_DRC_STATE_PHYSICAL_UNISOLATE:
61         return RTAS_OUT_PARAM_ERROR; /* not allowed */
62     default:
63         g_assert_not_reached();
64     }
65 
66     drc->state = SPAPR_DRC_STATE_PHYSICAL_POWERON;
67 
68     if (drc->unplug_requested) {
69         uint32_t drc_index = spapr_drc_index(drc);
70         trace_spapr_drc_set_isolation_state_finalizing(drc_index);
71         spapr_drc_detach(drc);
72     }
73 
74     return RTAS_OUT_SUCCESS;
75 }
76 
77 static uint32_t drc_unisolate_physical(SpaprDrc *drc)
78 {
79     switch (drc->state) {
80     case SPAPR_DRC_STATE_PHYSICAL_UNISOLATE:
81     case SPAPR_DRC_STATE_PHYSICAL_CONFIGURED:
82         return RTAS_OUT_SUCCESS; /* Nothing to do */
83     case SPAPR_DRC_STATE_PHYSICAL_POWERON:
84         break; /* see below */
85     default:
86         g_assert_not_reached();
87     }
88 
89     /* cannot unisolate a non-existent resource, and, or resources
90      * which are in an 'UNUSABLE' allocation state. (PAPR 2.7,
91      * 13.5.3.5)
92      */
93     if (!drc->dev) {
94         return RTAS_OUT_NO_SUCH_INDICATOR;
95     }
96 
97     drc->state = SPAPR_DRC_STATE_PHYSICAL_UNISOLATE;
98     drc->ccs_offset = drc->fdt_start_offset;
99     drc->ccs_depth = 0;
100 
101     return RTAS_OUT_SUCCESS;
102 }
103 
104 static uint32_t drc_isolate_logical(SpaprDrc *drc)
105 {
106     switch (drc->state) {
107     case SPAPR_DRC_STATE_LOGICAL_AVAILABLE:
108     case SPAPR_DRC_STATE_LOGICAL_UNUSABLE:
109         return RTAS_OUT_SUCCESS; /* Nothing to do */
110     case SPAPR_DRC_STATE_LOGICAL_CONFIGURED:
111         break; /* see below */
112     case SPAPR_DRC_STATE_LOGICAL_UNISOLATE:
113         return RTAS_OUT_PARAM_ERROR; /* not allowed */
114     default:
115         g_assert_not_reached();
116     }
117 
118     /*
119      * Fail any requests to ISOLATE the LMB DRC if this LMB doesn't
120      * belong to a DIMM device that is marked for removal.
121      *
122      * Currently the guest userspace tool drmgr that drives the memory
123      * hotplug/unplug will just try to remove a set of 'removable' LMBs
124      * in response to a hot unplug request that is based on drc-count.
125      * If the LMB being removed doesn't belong to a DIMM device that is
126      * actually being unplugged, fail the isolation request here.
127      */
128     if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB
129         && !drc->unplug_requested) {
130         return RTAS_OUT_HW_ERROR;
131     }
132 
133     drc->state = SPAPR_DRC_STATE_LOGICAL_AVAILABLE;
134 
135     /* if we're awaiting release, but still in an unconfigured state,
136      * it's likely the guest is still in the process of configuring
137      * the device and is transitioning the devices to an ISOLATED
138      * state as a part of that process. so we only complete the
139      * removal when this transition happens for a device in a
140      * configured state, as suggested by the state diagram from PAPR+
141      * 2.7, 13.4
142      */
143     if (drc->unplug_requested) {
144         uint32_t drc_index = spapr_drc_index(drc);
145         trace_spapr_drc_set_isolation_state_finalizing(drc_index);
146         spapr_drc_detach(drc);
147     }
148     return RTAS_OUT_SUCCESS;
149 }
150 
151 static uint32_t drc_unisolate_logical(SpaprDrc *drc)
152 {
153     switch (drc->state) {
154     case SPAPR_DRC_STATE_LOGICAL_UNISOLATE:
155     case SPAPR_DRC_STATE_LOGICAL_CONFIGURED:
156         return RTAS_OUT_SUCCESS; /* Nothing to do */
157     case SPAPR_DRC_STATE_LOGICAL_AVAILABLE:
158         break; /* see below */
159     case SPAPR_DRC_STATE_LOGICAL_UNUSABLE:
160         return RTAS_OUT_NO_SUCH_INDICATOR; /* not allowed */
161     default:
162         g_assert_not_reached();
163     }
164 
165     /* Move to AVAILABLE state should have ensured device was present */
166     g_assert(drc->dev);
167 
168     drc->state = SPAPR_DRC_STATE_LOGICAL_UNISOLATE;
169     drc->ccs_offset = drc->fdt_start_offset;
170     drc->ccs_depth = 0;
171 
172     return RTAS_OUT_SUCCESS;
173 }
174 
175 static uint32_t drc_set_usable(SpaprDrc *drc)
176 {
177     switch (drc->state) {
178     case SPAPR_DRC_STATE_LOGICAL_AVAILABLE:
179     case SPAPR_DRC_STATE_LOGICAL_UNISOLATE:
180     case SPAPR_DRC_STATE_LOGICAL_CONFIGURED:
181         return RTAS_OUT_SUCCESS; /* Nothing to do */
182     case SPAPR_DRC_STATE_LOGICAL_UNUSABLE:
183         break; /* see below */
184     default:
185         g_assert_not_reached();
186     }
187 
188     /* if there's no resource/device associated with the DRC, there's
189      * no way for us to put it in an allocation state consistent with
190      * being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
191      * result in an RTAS return code of -3 / "no such indicator"
192      */
193     if (!drc->dev) {
194         return RTAS_OUT_NO_SUCH_INDICATOR;
195     }
196     if (drc->unplug_requested) {
197         /* Don't allow the guest to move a device away from UNUSABLE
198          * state when we want to unplug it */
199         return RTAS_OUT_NO_SUCH_INDICATOR;
200     }
201 
202     drc->state = SPAPR_DRC_STATE_LOGICAL_AVAILABLE;
203 
204     return RTAS_OUT_SUCCESS;
205 }
206 
207 static uint32_t drc_set_unusable(SpaprDrc *drc)
208 {
209     switch (drc->state) {
210     case SPAPR_DRC_STATE_LOGICAL_UNUSABLE:
211         return RTAS_OUT_SUCCESS; /* Nothing to do */
212     case SPAPR_DRC_STATE_LOGICAL_AVAILABLE:
213         break; /* see below */
214     case SPAPR_DRC_STATE_LOGICAL_UNISOLATE:
215     case SPAPR_DRC_STATE_LOGICAL_CONFIGURED:
216         return RTAS_OUT_NO_SUCH_INDICATOR; /* not allowed */
217     default:
218         g_assert_not_reached();
219     }
220 
221     drc->state = SPAPR_DRC_STATE_LOGICAL_UNUSABLE;
222     if (drc->unplug_requested) {
223         uint32_t drc_index = spapr_drc_index(drc);
224         trace_spapr_drc_set_allocation_state_finalizing(drc_index);
225         spapr_drc_detach(drc);
226     }
227 
228     return RTAS_OUT_SUCCESS;
229 }
230 
231 static const char *spapr_drc_name(SpaprDrc *drc)
232 {
233     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
234 
235     /* human-readable name for a DRC to encode into the DT
236      * description. this is mainly only used within a guest in place
237      * of the unique DRC index.
238      *
239      * in the case of VIO/PCI devices, it corresponds to a "location
240      * code" that maps a logical device/function (DRC index) to a
241      * physical (or virtual in the case of VIO) location in the system
242      * by chaining together the "location label" for each
243      * encapsulating component.
244      *
245      * since this is more to do with diagnosing physical hardware
246      * issues than guest compatibility, we choose location codes/DRC
247      * names that adhere to the documented format, but avoid encoding
248      * the entire topology information into the label/code, instead
249      * just using the location codes based on the labels for the
250      * endpoints (VIO/PCI adaptor connectors), which is basically just
251      * "C" followed by an integer ID.
252      *
253      * DRC names as documented by PAPR+ v2.7, 13.5.2.4
254      * location codes as documented by PAPR+ v2.7, 12.3.1.5
255      */
256     return g_strdup_printf("%s%d", drck->drc_name_prefix, drc->id);
257 }
258 
259 /*
260  * dr-entity-sense sensor value
261  * returned via get-sensor-state RTAS calls
262  * as expected by state diagram in PAPR+ 2.7, 13.4
263  * based on the current allocation/indicator/power states
264  * for the DR connector.
265  */
266 static SpaprDREntitySense physical_entity_sense(SpaprDrc *drc)
267 {
268     /* this assumes all PCI devices are assigned to a 'live insertion'
269      * power domain, where QEMU manages power state automatically as
270      * opposed to the guest. present, non-PCI resources are unaffected
271      * by power state.
272      */
273     return drc->dev ? SPAPR_DR_ENTITY_SENSE_PRESENT
274         : SPAPR_DR_ENTITY_SENSE_EMPTY;
275 }
276 
277 static SpaprDREntitySense logical_entity_sense(SpaprDrc *drc)
278 {
279     switch (drc->state) {
280     case SPAPR_DRC_STATE_LOGICAL_UNUSABLE:
281         return SPAPR_DR_ENTITY_SENSE_UNUSABLE;
282     case SPAPR_DRC_STATE_LOGICAL_AVAILABLE:
283     case SPAPR_DRC_STATE_LOGICAL_UNISOLATE:
284     case SPAPR_DRC_STATE_LOGICAL_CONFIGURED:
285         g_assert(drc->dev);
286         return SPAPR_DR_ENTITY_SENSE_PRESENT;
287     default:
288         g_assert_not_reached();
289     }
290 }
291 
292 static void prop_get_index(Object *obj, Visitor *v, const char *name,
293                            void *opaque, Error **errp)
294 {
295     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
296     uint32_t value = spapr_drc_index(drc);
297     visit_type_uint32(v, name, &value, errp);
298 }
299 
300 static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
301                          void *opaque, Error **errp)
302 {
303     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
304     QNull *null = NULL;
305     Error *err = NULL;
306     int fdt_offset_next, fdt_offset, fdt_depth;
307     void *fdt;
308 
309     if (!drc->fdt) {
310         visit_type_null(v, NULL, &null, errp);
311         qobject_unref(null);
312         return;
313     }
314 
315     fdt = drc->fdt;
316     fdt_offset = drc->fdt_start_offset;
317     fdt_depth = 0;
318 
319     do {
320         const char *name = NULL;
321         const struct fdt_property *prop = NULL;
322         int prop_len = 0, name_len = 0;
323         uint32_t tag;
324 
325         tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
326         switch (tag) {
327         case FDT_BEGIN_NODE:
328             fdt_depth++;
329             name = fdt_get_name(fdt, fdt_offset, &name_len);
330             visit_start_struct(v, name, NULL, 0, &err);
331             if (err) {
332                 error_propagate(errp, err);
333                 return;
334             }
335             break;
336         case FDT_END_NODE:
337             /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
338             g_assert(fdt_depth > 0);
339             visit_check_struct(v, &err);
340             visit_end_struct(v, NULL);
341             if (err) {
342                 error_propagate(errp, err);
343                 return;
344             }
345             fdt_depth--;
346             break;
347         case FDT_PROP: {
348             int i;
349             prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
350             name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
351             visit_start_list(v, name, NULL, 0, &err);
352             if (err) {
353                 error_propagate(errp, err);
354                 return;
355             }
356             for (i = 0; i < prop_len; i++) {
357                 visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
358                 if (err) {
359                     error_propagate(errp, err);
360                     return;
361                 }
362             }
363             visit_check_list(v, &err);
364             visit_end_list(v, NULL);
365             if (err) {
366                 error_propagate(errp, err);
367                 return;
368             }
369             break;
370         }
371         default:
372             error_report("device FDT in unexpected state: %d", tag);
373             abort();
374         }
375         fdt_offset = fdt_offset_next;
376     } while (fdt_depth != 0);
377 }
378 
379 void spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp)
380 {
381     trace_spapr_drc_attach(spapr_drc_index(drc));
382 
383     if (drc->dev) {
384         error_setg(errp, "an attached device is still awaiting release");
385         return;
386     }
387     g_assert((drc->state == SPAPR_DRC_STATE_LOGICAL_UNUSABLE)
388              || (drc->state == SPAPR_DRC_STATE_PHYSICAL_POWERON));
389 
390     drc->dev = d;
391 
392     object_property_add_link(OBJECT(drc), "device",
393                              object_get_typename(OBJECT(drc->dev)),
394                              (Object **)(&drc->dev),
395                              NULL, 0, NULL);
396 }
397 
398 static void spapr_drc_release(SpaprDrc *drc)
399 {
400     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
401 
402     drck->release(drc->dev);
403 
404     drc->unplug_requested = false;
405     g_free(drc->fdt);
406     drc->fdt = NULL;
407     drc->fdt_start_offset = 0;
408     object_property_del(OBJECT(drc), "device", &error_abort);
409     drc->dev = NULL;
410 }
411 
412 void spapr_drc_detach(SpaprDrc *drc)
413 {
414     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
415 
416     trace_spapr_drc_detach(spapr_drc_index(drc));
417 
418     g_assert(drc->dev);
419 
420     drc->unplug_requested = true;
421 
422     if (drc->state != drck->empty_state) {
423         trace_spapr_drc_awaiting_quiesce(spapr_drc_index(drc));
424         return;
425     }
426 
427     spapr_drc_release(drc);
428 }
429 
430 void spapr_drc_reset(SpaprDrc *drc)
431 {
432     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
433 
434     trace_spapr_drc_reset(spapr_drc_index(drc));
435 
436     /* immediately upon reset we can safely assume DRCs whose devices
437      * are pending removal can be safely removed.
438      */
439     if (drc->unplug_requested) {
440         spapr_drc_release(drc);
441     }
442 
443     if (drc->dev) {
444         /* A device present at reset is ready to go, same as coldplugged */
445         drc->state = drck->ready_state;
446         /*
447          * Ensure that we are able to send the FDT fragment again
448          * via configure-connector call if the guest requests.
449          */
450         drc->ccs_offset = drc->fdt_start_offset;
451         drc->ccs_depth = 0;
452     } else {
453         drc->state = drck->empty_state;
454         drc->ccs_offset = -1;
455         drc->ccs_depth = -1;
456     }
457 }
458 
459 bool spapr_drc_needed(void *opaque)
460 {
461     SpaprDrc *drc = (SpaprDrc *)opaque;
462     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
463 
464     /* If no dev is plugged in there is no need to migrate the DRC state */
465     if (!drc->dev) {
466         return false;
467     }
468 
469     /*
470      * We need to migrate the state if it's not equal to the expected
471      * long-term state, which is the same as the coldplugged initial
472      * state */
473     return (drc->state != drck->ready_state);
474 }
475 
476 static const VMStateDescription vmstate_spapr_drc = {
477     .name = "spapr_drc",
478     .version_id = 1,
479     .minimum_version_id = 1,
480     .needed = spapr_drc_needed,
481     .fields  = (VMStateField []) {
482         VMSTATE_UINT32(state, SpaprDrc),
483         VMSTATE_END_OF_LIST()
484     }
485 };
486 
487 static void realize(DeviceState *d, Error **errp)
488 {
489     SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
490     Object *root_container;
491     gchar *link_name;
492     gchar *child_name;
493     Error *err = NULL;
494 
495     trace_spapr_drc_realize(spapr_drc_index(drc));
496     /* NOTE: we do this as part of realize/unrealize due to the fact
497      * that the guest will communicate with the DRC via RTAS calls
498      * referencing the global DRC index. By unlinking the DRC
499      * from DRC_CONTAINER_PATH/<drc_index> we effectively make it
500      * inaccessible by the guest, since lookups rely on this path
501      * existing in the composition tree
502      */
503     root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
504     link_name = g_strdup_printf("%x", spapr_drc_index(drc));
505     child_name = object_get_canonical_path_component(OBJECT(drc));
506     trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
507     object_property_add_alias(root_container, link_name,
508                               drc->owner, child_name, &err);
509     g_free(child_name);
510     g_free(link_name);
511     if (err) {
512         error_propagate(errp, err);
513         return;
514     }
515     vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
516                      drc);
517     trace_spapr_drc_realize_complete(spapr_drc_index(drc));
518 }
519 
520 static void unrealize(DeviceState *d, Error **errp)
521 {
522     SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
523     Object *root_container;
524     gchar *name;
525 
526     trace_spapr_drc_unrealize(spapr_drc_index(drc));
527     vmstate_unregister(DEVICE(drc), &vmstate_spapr_drc, drc);
528     root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
529     name = g_strdup_printf("%x", spapr_drc_index(drc));
530     object_property_del(root_container, name, errp);
531     g_free(name);
532 }
533 
534 SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type,
535                                          uint32_t id)
536 {
537     SpaprDrc *drc = SPAPR_DR_CONNECTOR(object_new(type));
538     char *prop_name;
539 
540     drc->id = id;
541     drc->owner = owner;
542     prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
543                                 spapr_drc_index(drc));
544     object_property_add_child(owner, prop_name, OBJECT(drc), &error_abort);
545     object_unref(OBJECT(drc));
546     object_property_set_bool(OBJECT(drc), true, "realized", NULL);
547     g_free(prop_name);
548 
549     return drc;
550 }
551 
552 static void spapr_dr_connector_instance_init(Object *obj)
553 {
554     SpaprDrc *drc = SPAPR_DR_CONNECTOR(obj);
555     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
556 
557     object_property_add_uint32_ptr(obj, "id", &drc->id, NULL);
558     object_property_add(obj, "index", "uint32", prop_get_index,
559                         NULL, NULL, NULL, NULL);
560     object_property_add(obj, "fdt", "struct", prop_get_fdt,
561                         NULL, NULL, NULL, NULL);
562     drc->state = drck->empty_state;
563 }
564 
565 static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
566 {
567     DeviceClass *dk = DEVICE_CLASS(k);
568 
569     dk->realize = realize;
570     dk->unrealize = unrealize;
571     /*
572      * Reason: it crashes FIXME find and document the real reason
573      */
574     dk->user_creatable = false;
575 }
576 
577 static bool drc_physical_needed(void *opaque)
578 {
579     SpaprDrcPhysical *drcp = (SpaprDrcPhysical *)opaque;
580     SpaprDrc *drc = SPAPR_DR_CONNECTOR(drcp);
581 
582     if ((drc->dev && (drcp->dr_indicator == SPAPR_DR_INDICATOR_ACTIVE))
583         || (!drc->dev && (drcp->dr_indicator == SPAPR_DR_INDICATOR_INACTIVE))) {
584         return false;
585     }
586     return true;
587 }
588 
589 static const VMStateDescription vmstate_spapr_drc_physical = {
590     .name = "spapr_drc/physical",
591     .version_id = 1,
592     .minimum_version_id = 1,
593     .needed = drc_physical_needed,
594     .fields  = (VMStateField []) {
595         VMSTATE_UINT32(dr_indicator, SpaprDrcPhysical),
596         VMSTATE_END_OF_LIST()
597     }
598 };
599 
600 static void drc_physical_reset(void *opaque)
601 {
602     SpaprDrc *drc = SPAPR_DR_CONNECTOR(opaque);
603     SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(drc);
604 
605     if (drc->dev) {
606         drcp->dr_indicator = SPAPR_DR_INDICATOR_ACTIVE;
607     } else {
608         drcp->dr_indicator = SPAPR_DR_INDICATOR_INACTIVE;
609     }
610 }
611 
612 static void realize_physical(DeviceState *d, Error **errp)
613 {
614     SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
615     Error *local_err = NULL;
616 
617     realize(d, &local_err);
618     if (local_err) {
619         error_propagate(errp, local_err);
620         return;
621     }
622 
623     vmstate_register(DEVICE(drcp), spapr_drc_index(SPAPR_DR_CONNECTOR(drcp)),
624                      &vmstate_spapr_drc_physical, drcp);
625     qemu_register_reset(drc_physical_reset, drcp);
626 }
627 
628 static void unrealize_physical(DeviceState *d, Error **errp)
629 {
630     SpaprDrcPhysical *drcp = SPAPR_DRC_PHYSICAL(d);
631     Error *local_err = NULL;
632 
633     unrealize(d, &local_err);
634     if (local_err) {
635         error_propagate(errp, local_err);
636         return;
637     }
638 
639     vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp);
640     qemu_unregister_reset(drc_physical_reset, drcp);
641 }
642 
643 static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
644 {
645     DeviceClass *dk = DEVICE_CLASS(k);
646     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
647 
648     dk->realize = realize_physical;
649     dk->unrealize = unrealize_physical;
650     drck->dr_entity_sense = physical_entity_sense;
651     drck->isolate = drc_isolate_physical;
652     drck->unisolate = drc_unisolate_physical;
653     drck->ready_state = SPAPR_DRC_STATE_PHYSICAL_CONFIGURED;
654     drck->empty_state = SPAPR_DRC_STATE_PHYSICAL_POWERON;
655 }
656 
657 static void spapr_drc_logical_class_init(ObjectClass *k, void *data)
658 {
659     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
660 
661     drck->dr_entity_sense = logical_entity_sense;
662     drck->isolate = drc_isolate_logical;
663     drck->unisolate = drc_unisolate_logical;
664     drck->ready_state = SPAPR_DRC_STATE_LOGICAL_CONFIGURED;
665     drck->empty_state = SPAPR_DRC_STATE_LOGICAL_UNUSABLE;
666 }
667 
668 static void spapr_drc_cpu_class_init(ObjectClass *k, void *data)
669 {
670     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
671 
672     drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU;
673     drck->typename = "CPU";
674     drck->drc_name_prefix = "CPU ";
675     drck->release = spapr_core_release;
676     drck->dt_populate = spapr_core_dt_populate;
677 }
678 
679 static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
680 {
681     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
682 
683     drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI;
684     drck->typename = "28";
685     drck->drc_name_prefix = "C";
686     drck->release = spapr_phb_remove_pci_device_cb;
687     drck->dt_populate = spapr_pci_dt_populate;
688 }
689 
690 static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
691 {
692     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
693 
694     drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB;
695     drck->typename = "MEM";
696     drck->drc_name_prefix = "LMB ";
697     drck->release = spapr_lmb_release;
698     drck->dt_populate = spapr_lmb_dt_populate;
699 }
700 
701 static void spapr_drc_phb_class_init(ObjectClass *k, void *data)
702 {
703     SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
704 
705     drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PHB;
706     drck->typename = "PHB";
707     drck->drc_name_prefix = "PHB ";
708     drck->release = spapr_phb_release;
709     drck->dt_populate = spapr_phb_dt_populate;
710 }
711 
712 static const TypeInfo spapr_dr_connector_info = {
713     .name          = TYPE_SPAPR_DR_CONNECTOR,
714     .parent        = TYPE_DEVICE,
715     .instance_size = sizeof(SpaprDrc),
716     .instance_init = spapr_dr_connector_instance_init,
717     .class_size    = sizeof(SpaprDrcClass),
718     .class_init    = spapr_dr_connector_class_init,
719     .abstract      = true,
720 };
721 
722 static const TypeInfo spapr_drc_physical_info = {
723     .name          = TYPE_SPAPR_DRC_PHYSICAL,
724     .parent        = TYPE_SPAPR_DR_CONNECTOR,
725     .instance_size = sizeof(SpaprDrcPhysical),
726     .class_init    = spapr_drc_physical_class_init,
727     .abstract      = true,
728 };
729 
730 static const TypeInfo spapr_drc_logical_info = {
731     .name          = TYPE_SPAPR_DRC_LOGICAL,
732     .parent        = TYPE_SPAPR_DR_CONNECTOR,
733     .class_init    = spapr_drc_logical_class_init,
734     .abstract      = true,
735 };
736 
737 static const TypeInfo spapr_drc_cpu_info = {
738     .name          = TYPE_SPAPR_DRC_CPU,
739     .parent        = TYPE_SPAPR_DRC_LOGICAL,
740     .class_init    = spapr_drc_cpu_class_init,
741 };
742 
743 static const TypeInfo spapr_drc_pci_info = {
744     .name          = TYPE_SPAPR_DRC_PCI,
745     .parent        = TYPE_SPAPR_DRC_PHYSICAL,
746     .class_init    = spapr_drc_pci_class_init,
747 };
748 
749 static const TypeInfo spapr_drc_lmb_info = {
750     .name          = TYPE_SPAPR_DRC_LMB,
751     .parent        = TYPE_SPAPR_DRC_LOGICAL,
752     .class_init    = spapr_drc_lmb_class_init,
753 };
754 
755 static const TypeInfo spapr_drc_phb_info = {
756     .name          = TYPE_SPAPR_DRC_PHB,
757     .parent        = TYPE_SPAPR_DRC_LOGICAL,
758     .instance_size = sizeof(SpaprDrc),
759     .class_init    = spapr_drc_phb_class_init,
760 };
761 
762 /* helper functions for external users */
763 
764 SpaprDrc *spapr_drc_by_index(uint32_t index)
765 {
766     Object *obj;
767     gchar *name;
768 
769     name = g_strdup_printf("%s/%x", DRC_CONTAINER_PATH, index);
770     obj = object_resolve_path(name, NULL);
771     g_free(name);
772 
773     return !obj ? NULL : SPAPR_DR_CONNECTOR(obj);
774 }
775 
776 SpaprDrc *spapr_drc_by_id(const char *type, uint32_t id)
777 {
778     SpaprDrcClass *drck
779         = SPAPR_DR_CONNECTOR_CLASS(object_class_by_name(type));
780 
781     return spapr_drc_by_index(drck->typeshift << DRC_INDEX_TYPE_SHIFT
782                               | (id & DRC_INDEX_ID_MASK));
783 }
784 
785 /**
786  * spapr_dt_drc
787  *
788  * @fdt: libfdt device tree
789  * @path: path in the DT to generate properties
790  * @owner: parent Object/DeviceState for which to generate DRC
791  *         descriptions for
792  * @drc_type_mask: mask of SpaprDrcType values corresponding
793  *   to the types of DRCs to generate entries for
794  *
795  * generate OF properties to describe DRC topology/indices to guests
796  *
797  * as documented in PAPR+ v2.1, 13.5.2
798  */
799 int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask)
800 {
801     Object *root_container;
802     ObjectProperty *prop;
803     ObjectPropertyIterator iter;
804     uint32_t drc_count = 0;
805     GArray *drc_indexes, *drc_power_domains;
806     GString *drc_names, *drc_types;
807     int ret;
808 
809     /* the first entry of each properties is a 32-bit integer encoding
810      * the number of elements in the array. we won't know this until
811      * we complete the iteration through all the matching DRCs, but
812      * reserve the space now and set the offsets accordingly so we
813      * can fill them in later.
814      */
815     drc_indexes = g_array_new(false, true, sizeof(uint32_t));
816     drc_indexes = g_array_set_size(drc_indexes, 1);
817     drc_power_domains = g_array_new(false, true, sizeof(uint32_t));
818     drc_power_domains = g_array_set_size(drc_power_domains, 1);
819     drc_names = g_string_set_size(g_string_new(NULL), sizeof(uint32_t));
820     drc_types = g_string_set_size(g_string_new(NULL), sizeof(uint32_t));
821 
822     /* aliases for all DRConnector objects will be rooted in QOM
823      * composition tree at DRC_CONTAINER_PATH
824      */
825     root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
826 
827     object_property_iter_init(&iter, root_container);
828     while ((prop = object_property_iter_next(&iter))) {
829         Object *obj;
830         SpaprDrc *drc;
831         SpaprDrcClass *drck;
832         uint32_t drc_index, drc_power_domain;
833 
834         if (!strstart(prop->type, "link<", NULL)) {
835             continue;
836         }
837 
838         obj = object_property_get_link(root_container, prop->name, NULL);
839         drc = SPAPR_DR_CONNECTOR(obj);
840         drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
841 
842         if (owner && (drc->owner != owner)) {
843             continue;
844         }
845 
846         if ((spapr_drc_type(drc) & drc_type_mask) == 0) {
847             continue;
848         }
849 
850         drc_count++;
851 
852         /* ibm,drc-indexes */
853         drc_index = cpu_to_be32(spapr_drc_index(drc));
854         g_array_append_val(drc_indexes, drc_index);
855 
856         /* ibm,drc-power-domains */
857         drc_power_domain = cpu_to_be32(-1);
858         g_array_append_val(drc_power_domains, drc_power_domain);
859 
860         /* ibm,drc-names */
861         drc_names = g_string_append(drc_names, spapr_drc_name(drc));
862         drc_names = g_string_insert_len(drc_names, -1, "\0", 1);
863 
864         /* ibm,drc-types */
865         drc_types = g_string_append(drc_types, drck->typename);
866         drc_types = g_string_insert_len(drc_types, -1, "\0", 1);
867     }
868 
869     /* now write the drc count into the space we reserved at the
870      * beginning of the arrays previously
871      */
872     *(uint32_t *)drc_indexes->data = cpu_to_be32(drc_count);
873     *(uint32_t *)drc_power_domains->data = cpu_to_be32(drc_count);
874     *(uint32_t *)drc_names->str = cpu_to_be32(drc_count);
875     *(uint32_t *)drc_types->str = cpu_to_be32(drc_count);
876 
877     ret = fdt_setprop(fdt, offset, "ibm,drc-indexes",
878                       drc_indexes->data,
879                       drc_indexes->len * sizeof(uint32_t));
880     if (ret) {
881         error_report("Couldn't create ibm,drc-indexes property");
882         goto out;
883     }
884 
885     ret = fdt_setprop(fdt, offset, "ibm,drc-power-domains",
886                       drc_power_domains->data,
887                       drc_power_domains->len * sizeof(uint32_t));
888     if (ret) {
889         error_report("Couldn't finalize ibm,drc-power-domains property");
890         goto out;
891     }
892 
893     ret = fdt_setprop(fdt, offset, "ibm,drc-names",
894                       drc_names->str, drc_names->len);
895     if (ret) {
896         error_report("Couldn't finalize ibm,drc-names property");
897         goto out;
898     }
899 
900     ret = fdt_setprop(fdt, offset, "ibm,drc-types",
901                       drc_types->str, drc_types->len);
902     if (ret) {
903         error_report("Couldn't finalize ibm,drc-types property");
904         goto out;
905     }
906 
907 out:
908     g_array_free(drc_indexes, true);
909     g_array_free(drc_power_domains, true);
910     g_string_free(drc_names, true);
911     g_string_free(drc_types, true);
912 
913     return ret;
914 }
915 
916 /*
917  * RTAS calls
918  */
919 
920 static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state)
921 {
922     SpaprDrc *drc = spapr_drc_by_index(idx);
923     SpaprDrcClass *drck;
924 
925     if (!drc) {
926         return RTAS_OUT_NO_SUCH_INDICATOR;
927     }
928 
929     trace_spapr_drc_set_isolation_state(spapr_drc_index(drc), state);
930 
931     drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
932 
933     switch (state) {
934     case SPAPR_DR_ISOLATION_STATE_ISOLATED:
935         return drck->isolate(drc);
936 
937     case SPAPR_DR_ISOLATION_STATE_UNISOLATED:
938         return drck->unisolate(drc);
939 
940     default:
941         return RTAS_OUT_PARAM_ERROR;
942     }
943 }
944 
945 static uint32_t rtas_set_allocation_state(uint32_t idx, uint32_t state)
946 {
947     SpaprDrc *drc = spapr_drc_by_index(idx);
948 
949     if (!drc || !object_dynamic_cast(OBJECT(drc), TYPE_SPAPR_DRC_LOGICAL)) {
950         return RTAS_OUT_NO_SUCH_INDICATOR;
951     }
952 
953     trace_spapr_drc_set_allocation_state(spapr_drc_index(drc), state);
954 
955     switch (state) {
956     case SPAPR_DR_ALLOCATION_STATE_USABLE:
957         return drc_set_usable(drc);
958 
959     case SPAPR_DR_ALLOCATION_STATE_UNUSABLE:
960         return drc_set_unusable(drc);
961 
962     default:
963         return RTAS_OUT_PARAM_ERROR;
964     }
965 }
966 
967 static uint32_t rtas_set_dr_indicator(uint32_t idx, uint32_t state)
968 {
969     SpaprDrc *drc = spapr_drc_by_index(idx);
970 
971     if (!drc || !object_dynamic_cast(OBJECT(drc), TYPE_SPAPR_DRC_PHYSICAL)) {
972         return RTAS_OUT_NO_SUCH_INDICATOR;
973     }
974     if ((state != SPAPR_DR_INDICATOR_INACTIVE)
975         && (state != SPAPR_DR_INDICATOR_ACTIVE)
976         && (state != SPAPR_DR_INDICATOR_IDENTIFY)
977         && (state != SPAPR_DR_INDICATOR_ACTION)) {
978         return RTAS_OUT_PARAM_ERROR; /* bad state parameter */
979     }
980 
981     trace_spapr_drc_set_dr_indicator(idx, state);
982     SPAPR_DRC_PHYSICAL(drc)->dr_indicator = state;
983     return RTAS_OUT_SUCCESS;
984 }
985 
986 static void rtas_set_indicator(PowerPCCPU *cpu, SpaprMachineState *spapr,
987                                uint32_t token,
988                                uint32_t nargs, target_ulong args,
989                                uint32_t nret, target_ulong rets)
990 {
991     uint32_t type, idx, state;
992     uint32_t ret = RTAS_OUT_SUCCESS;
993 
994     if (nargs != 3 || nret != 1) {
995         ret = RTAS_OUT_PARAM_ERROR;
996         goto out;
997     }
998 
999     type = rtas_ld(args, 0);
1000     idx = rtas_ld(args, 1);
1001     state = rtas_ld(args, 2);
1002 
1003     switch (type) {
1004     case RTAS_SENSOR_TYPE_ISOLATION_STATE:
1005         ret = rtas_set_isolation_state(idx, state);
1006         break;
1007     case RTAS_SENSOR_TYPE_DR:
1008         ret = rtas_set_dr_indicator(idx, state);
1009         break;
1010     case RTAS_SENSOR_TYPE_ALLOCATION_STATE:
1011         ret = rtas_set_allocation_state(idx, state);
1012         break;
1013     default:
1014         ret = RTAS_OUT_NOT_SUPPORTED;
1015     }
1016 
1017 out:
1018     rtas_st(rets, 0, ret);
1019 }
1020 
1021 static void rtas_get_sensor_state(PowerPCCPU *cpu, SpaprMachineState *spapr,
1022                                   uint32_t token, uint32_t nargs,
1023                                   target_ulong args, uint32_t nret,
1024                                   target_ulong rets)
1025 {
1026     uint32_t sensor_type;
1027     uint32_t sensor_index;
1028     uint32_t sensor_state = 0;
1029     SpaprDrc *drc;
1030     SpaprDrcClass *drck;
1031     uint32_t ret = RTAS_OUT_SUCCESS;
1032 
1033     if (nargs != 2 || nret != 2) {
1034         ret = RTAS_OUT_PARAM_ERROR;
1035         goto out;
1036     }
1037 
1038     sensor_type = rtas_ld(args, 0);
1039     sensor_index = rtas_ld(args, 1);
1040 
1041     if (sensor_type != RTAS_SENSOR_TYPE_ENTITY_SENSE) {
1042         /* currently only DR-related sensors are implemented */
1043         trace_spapr_rtas_get_sensor_state_not_supported(sensor_index,
1044                                                         sensor_type);
1045         ret = RTAS_OUT_NOT_SUPPORTED;
1046         goto out;
1047     }
1048 
1049     drc = spapr_drc_by_index(sensor_index);
1050     if (!drc) {
1051         trace_spapr_rtas_get_sensor_state_invalid(sensor_index);
1052         ret = RTAS_OUT_PARAM_ERROR;
1053         goto out;
1054     }
1055     drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
1056     sensor_state = drck->dr_entity_sense(drc);
1057 
1058 out:
1059     rtas_st(rets, 0, ret);
1060     rtas_st(rets, 1, sensor_state);
1061 }
1062 
1063 /* configure-connector work area offsets, int32_t units for field
1064  * indexes, bytes for field offset/len values.
1065  *
1066  * as documented by PAPR+ v2.7, 13.5.3.5
1067  */
1068 #define CC_IDX_NODE_NAME_OFFSET 2
1069 #define CC_IDX_PROP_NAME_OFFSET 2
1070 #define CC_IDX_PROP_LEN 3
1071 #define CC_IDX_PROP_DATA_OFFSET 4
1072 #define CC_VAL_DATA_OFFSET ((CC_IDX_PROP_DATA_OFFSET + 1) * 4)
1073 #define CC_WA_LEN 4096
1074 
1075 static void configure_connector_st(target_ulong addr, target_ulong offset,
1076                                    const void *buf, size_t len)
1077 {
1078     cpu_physical_memory_write(ppc64_phys_to_real(addr + offset),
1079                               buf, MIN(len, CC_WA_LEN - offset));
1080 }
1081 
1082 static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
1083                                          SpaprMachineState *spapr,
1084                                          uint32_t token, uint32_t nargs,
1085                                          target_ulong args, uint32_t nret,
1086                                          target_ulong rets)
1087 {
1088     uint64_t wa_addr;
1089     uint64_t wa_offset;
1090     uint32_t drc_index;
1091     SpaprDrc *drc;
1092     SpaprDrcClass *drck;
1093     SpaprDRCCResponse resp = SPAPR_DR_CC_RESPONSE_CONTINUE;
1094     int rc;
1095 
1096     if (nargs != 2 || nret != 1) {
1097         rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
1098         return;
1099     }
1100 
1101     wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0);
1102 
1103     drc_index = rtas_ld(wa_addr, 0);
1104     drc = spapr_drc_by_index(drc_index);
1105     if (!drc) {
1106         trace_spapr_rtas_ibm_configure_connector_invalid(drc_index);
1107         rc = RTAS_OUT_PARAM_ERROR;
1108         goto out;
1109     }
1110 
1111     if ((drc->state != SPAPR_DRC_STATE_LOGICAL_UNISOLATE)
1112         && (drc->state != SPAPR_DRC_STATE_PHYSICAL_UNISOLATE)
1113         && (drc->state != SPAPR_DRC_STATE_LOGICAL_CONFIGURED)
1114         && (drc->state != SPAPR_DRC_STATE_PHYSICAL_CONFIGURED)) {
1115         /*
1116          * Need to unisolate the device before configuring
1117          * or it should already be in configured state to
1118          * allow configure-connector be called repeatedly.
1119          */
1120         rc = SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE;
1121         goto out;
1122     }
1123 
1124     drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
1125 
1126     if (!drc->fdt) {
1127         Error *local_err = NULL;
1128         void *fdt;
1129         int fdt_size;
1130 
1131         fdt = create_device_tree(&fdt_size);
1132 
1133         if (drck->dt_populate(drc, spapr, fdt, &drc->fdt_start_offset,
1134                               &local_err)) {
1135             g_free(fdt);
1136             error_free(local_err);
1137             rc = SPAPR_DR_CC_RESPONSE_ERROR;
1138             goto out;
1139         }
1140 
1141         drc->fdt = fdt;
1142         drc->ccs_offset = drc->fdt_start_offset;
1143         drc->ccs_depth = 0;
1144     }
1145 
1146     do {
1147         uint32_t tag;
1148         const char *name;
1149         const struct fdt_property *prop;
1150         int fdt_offset_next, prop_len;
1151 
1152         tag = fdt_next_tag(drc->fdt, drc->ccs_offset, &fdt_offset_next);
1153 
1154         switch (tag) {
1155         case FDT_BEGIN_NODE:
1156             drc->ccs_depth++;
1157             name = fdt_get_name(drc->fdt, drc->ccs_offset, NULL);
1158 
1159             /* provide the name of the next OF node */
1160             wa_offset = CC_VAL_DATA_OFFSET;
1161             rtas_st(wa_addr, CC_IDX_NODE_NAME_OFFSET, wa_offset);
1162             configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
1163             resp = SPAPR_DR_CC_RESPONSE_NEXT_CHILD;
1164             break;
1165         case FDT_END_NODE:
1166             drc->ccs_depth--;
1167             if (drc->ccs_depth == 0) {
1168                 uint32_t drc_index = spapr_drc_index(drc);
1169 
1170                 /* done sending the device tree, move to configured state */
1171                 trace_spapr_drc_set_configured(drc_index);
1172                 drc->state = drck->ready_state;
1173                 /*
1174                  * Ensure that we are able to send the FDT fragment
1175                  * again via configure-connector call if the guest requests.
1176                  */
1177                 drc->ccs_offset = drc->fdt_start_offset;
1178                 drc->ccs_depth = 0;
1179                 fdt_offset_next = drc->fdt_start_offset;
1180                 resp = SPAPR_DR_CC_RESPONSE_SUCCESS;
1181             } else {
1182                 resp = SPAPR_DR_CC_RESPONSE_PREV_PARENT;
1183             }
1184             break;
1185         case FDT_PROP:
1186             prop = fdt_get_property_by_offset(drc->fdt, drc->ccs_offset,
1187                                               &prop_len);
1188             name = fdt_string(drc->fdt, fdt32_to_cpu(prop->nameoff));
1189 
1190             /* provide the name of the next OF property */
1191             wa_offset = CC_VAL_DATA_OFFSET;
1192             rtas_st(wa_addr, CC_IDX_PROP_NAME_OFFSET, wa_offset);
1193             configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
1194 
1195             /* provide the length and value of the OF property. data gets
1196              * placed immediately after NULL terminator of the OF property's
1197              * name string
1198              */
1199             wa_offset += strlen(name) + 1,
1200             rtas_st(wa_addr, CC_IDX_PROP_LEN, prop_len);
1201             rtas_st(wa_addr, CC_IDX_PROP_DATA_OFFSET, wa_offset);
1202             configure_connector_st(wa_addr, wa_offset, prop->data, prop_len);
1203             resp = SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY;
1204             break;
1205         case FDT_END:
1206             resp = SPAPR_DR_CC_RESPONSE_ERROR;
1207         default:
1208             /* keep seeking for an actionable tag */
1209             break;
1210         }
1211         if (drc->ccs_offset >= 0) {
1212             drc->ccs_offset = fdt_offset_next;
1213         }
1214     } while (resp == SPAPR_DR_CC_RESPONSE_CONTINUE);
1215 
1216     rc = resp;
1217 out:
1218     rtas_st(rets, 0, rc);
1219 }
1220 
1221 static void spapr_drc_register_types(void)
1222 {
1223     type_register_static(&spapr_dr_connector_info);
1224     type_register_static(&spapr_drc_physical_info);
1225     type_register_static(&spapr_drc_logical_info);
1226     type_register_static(&spapr_drc_cpu_info);
1227     type_register_static(&spapr_drc_pci_info);
1228     type_register_static(&spapr_drc_lmb_info);
1229     type_register_static(&spapr_drc_phb_info);
1230 
1231     spapr_rtas_register(RTAS_SET_INDICATOR, "set-indicator",
1232                         rtas_set_indicator);
1233     spapr_rtas_register(RTAS_GET_SENSOR_STATE, "get-sensor-state",
1234                         rtas_get_sensor_state);
1235     spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR, "ibm,configure-connector",
1236                         rtas_ibm_configure_connector);
1237 }
1238 type_init(spapr_drc_register_types)
1239