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