uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu));
sPAPRDRConnector *drc;
- sPAPRDRConnectorClass *drck;
int drc_index;
uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ];
int i;
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, index);
if (drc) {
- drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- drc_index = drck->get_index(drc);
+ drc_index = spapr_drc_index(drc);
_FDT((fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)));
}
if (i >= hotplug_lmb_start) {
sPAPRDRConnector *drc;
- sPAPRDRConnectorClass *drck;
drc = spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_LMB, i);
g_assert(drc);
- drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
dynamic_memory[0] = cpu_to_be32(addr >> 32);
dynamic_memory[1] = cpu_to_be32(addr & 0xffffffff);
- dynamic_memory[2] = cpu_to_be32(drck->get_index(drc));
+ dynamic_memory[2] = cpu_to_be32(spapr_drc_index(drc));
dynamic_memory[3] = cpu_to_be32(0); /* reserved */
dynamic_memory[4] = cpu_to_be32(numa_get_node(addr, NULL));
if (memory_region_present(get_system_memory(), addr)) {
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_add_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs,
- drck->get_index(drc));
+ spapr_drc_index(drc));
} else {
spapr_hotplug_req_add_by_count(SPAPR_DR_CONNECTOR_TYPE_LMB,
nr_lmbs);
addr_start / SPAPR_MEMORY_BLOCK_SIZE);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
spapr_hotplug_req_remove_by_count_indexed(SPAPR_DR_CONNECTOR_TYPE_LMB,
- nr_lmbs,
- drck->get_index(drc));
+ nr_lmbs, spapr_drc_index(drc));
out:
error_propagate(errp, local_err);
}
return shift;
}
-static uint32_t get_index(sPAPRDRConnector *drc)
+uint32_t spapr_drc_index(sPAPRDRConnector *drc)
{
/* no set format for a drc index: it only needs to be globally
* unique. this is how we encode the DRC type on bare-metal
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- trace_spapr_drc_set_isolation_state(get_index(drc), state);
+ trace_spapr_drc_set_isolation_state(spapr_drc_index(drc), state);
if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) {
/* cannot unisolate a non-existent resource, and, or resources
* PAPR+ 2.7, 13.4
*/
if (drc->awaiting_release) {
+ uint32_t drc_index = spapr_drc_index(drc);
if (drc->configured) {
- trace_spapr_drc_set_isolation_state_finalizing(get_index(drc));
+ trace_spapr_drc_set_isolation_state_finalizing(drc_index);
drck->detach(drc, DEVICE(drc->dev), NULL);
} else {
- trace_spapr_drc_set_isolation_state_deferring(get_index(drc));
+ trace_spapr_drc_set_isolation_state_deferring(drc_index);
}
}
drc->configured = false;
static uint32_t set_indicator_state(sPAPRDRConnector *drc,
sPAPRDRIndicatorState state)
{
- trace_spapr_drc_set_indicator_state(get_index(drc), state);
+ trace_spapr_drc_set_indicator_state(spapr_drc_index(drc), state);
drc->indicator_state = state;
return RTAS_OUT_SUCCESS;
}
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- trace_spapr_drc_set_allocation_state(get_index(drc), state);
+ trace_spapr_drc_set_allocation_state(spapr_drc_index(drc), state);
if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
/* if there's no resource/device associated with the DRC, there's
drc->allocation_state = state;
if (drc->awaiting_release &&
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
- trace_spapr_drc_set_allocation_state_finalizing(get_index(drc));
+ uint32_t drc_index = spapr_drc_index(drc);
+ trace_spapr_drc_set_allocation_state_finalizing(drc_index);
drck->detach(drc, DEVICE(drc->dev), NULL);
} else if (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) {
drc->awaiting_allocation = false;
return RTAS_OUT_SUCCESS;
}
-static uint32_t get_type(sPAPRDRConnector *drc)
+sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc)
{
return drc->type;
}
}
}
- trace_spapr_drc_entity_sense(get_index(drc), *state);
+ trace_spapr_drc_entity_sense(spapr_drc_index(drc), *state);
return RTAS_OUT_SUCCESS;
}
void *opaque, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
- sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- uint32_t value = (uint32_t)drck->get_index(drc);
+ uint32_t value = spapr_drc_index(drc);
visit_type_uint32(v, name, &value, errp);
}
void *opaque, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
- sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
- uint32_t value = (uint32_t)drck->get_type(drc);
+ uint32_t value = (uint32_t)spapr_drc_type(drc);
visit_type_uint32(v, name, &value, errp);
}
static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
int fdt_start_offset, bool coldplug, Error **errp)
{
- trace_spapr_drc_attach(get_index(drc));
+ trace_spapr_drc_attach(spapr_drc_index(drc));
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
error_setg(errp, "an attached device is still awaiting release");
static void detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp)
{
- trace_spapr_drc_detach(get_index(drc));
+ trace_spapr_drc_detach(spapr_drc_index(drc));
/* if we've signalled device presence to the guest, or if the guest
* has gone ahead and configured the device (via manually-executed
}
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
- trace_spapr_drc_awaiting_isolated(get_index(drc));
+ trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
- trace_spapr_drc_awaiting_unusable(get_index(drc));
+ trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc));
drc->awaiting_release = true;
return;
}
if (drc->awaiting_allocation) {
if (!drc->awaiting_allocation_skippable) {
drc->awaiting_release = true;
- trace_spapr_drc_awaiting_allocation(get_index(drc));
+ trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc));
return;
}
}
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
sPAPRDREntitySense state;
- trace_spapr_drc_reset(drck->get_index(drc));
+ trace_spapr_drc_reset(spapr_drc_index(drc));
/* immediately upon reset we can safely assume DRCs whose devices
* are pending removal can be safely removed, and that they will
* subsequently be left in an ISOLATED state. move the DRC to this
static void realize(DeviceState *d, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
- sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
Object *root_container;
char link_name[256];
gchar *child_name;
Error *err = NULL;
- trace_spapr_drc_realize(drck->get_index(drc));
+ trace_spapr_drc_realize(spapr_drc_index(drc));
/* NOTE: we do this as part of realize/unrealize due to the fact
* that the guest will communicate with the DRC via RTAS calls
* referencing the global DRC index. By unlinking the DRC
* existing in the composition tree
*/
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
- snprintf(link_name, sizeof(link_name), "%x", drck->get_index(drc));
+ snprintf(link_name, sizeof(link_name), "%x", spapr_drc_index(drc));
child_name = object_get_canonical_path_component(OBJECT(drc));
- trace_spapr_drc_realize_child(drck->get_index(drc), child_name);
+ trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
object_property_add_alias(root_container, link_name,
drc->owner, child_name, &err);
if (err) {
object_unref(OBJECT(drc));
}
g_free(child_name);
- vmstate_register(DEVICE(drc), drck->get_index(drc), &vmstate_spapr_drc,
+ vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
drc);
- trace_spapr_drc_realize_complete(drck->get_index(drc));
+ trace_spapr_drc_realize_complete(spapr_drc_index(drc));
}
static void unrealize(DeviceState *d, Error **errp)
{
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
- sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
Object *root_container;
char name[256];
Error *err = NULL;
- trace_spapr_drc_unrealize(drck->get_index(drc));
+ trace_spapr_drc_unrealize(spapr_drc_index(drc));
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
- snprintf(name, sizeof(name), "%x", drck->get_index(drc));
+ snprintf(name, sizeof(name), "%x", spapr_drc_index(drc));
object_property_del(root_container, name, &err);
if (err) {
error_report_err(err);
drc->type = type;
drc->id = id;
drc->owner = owner;
- prop_name = g_strdup_printf("dr-connector[%"PRIu32"]", get_index(drc));
+ prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
+ spapr_drc_index(drc));
object_property_add_child(owner, prop_name, OBJECT(drc), NULL);
object_property_set_bool(OBJECT(drc), true, "realized", NULL);
g_free(prop_name);
drck->set_isolation_state = set_isolation_state;
drck->set_indicator_state = set_indicator_state;
drck->set_allocation_state = set_allocation_state;
- drck->get_index = get_index;
- drck->get_type = get_type;
drck->get_name = get_name;
drck->entity_sense = entity_sense;
drck->attach = attach;
drc_count++;
/* ibm,drc-indexes */
- drc_index = cpu_to_be32(drck->get_index(drc));
+ drc_index = cpu_to_be32(spapr_drc_index(drc));
g_array_append_val(drc_indexes, drc_index);
/* ibm,drc-power-domains */
ccs->fdt_depth--;
if (ccs->fdt_depth == 0) {
sPAPRDRIsolationState state = drc->isolation_state;
+ uint32_t drc_index = spapr_drc_index(drc);
/* done sending the device tree, don't need to track
* the state anymore
*/
- trace_spapr_drc_set_configured(get_index(drc));
+ trace_spapr_drc_set_configured(drc_index);
if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) {
drc->configured = true;
} else {
/* guest should be not configuring an isolated device */
- trace_spapr_drc_set_configured_skipping(get_index(drc));
+ trace_spapr_drc_set_configured_skipping(drc_index);
}
spapr_ccs_remove(spapr, ccs);
ccs = NULL;