269473047d747f7815af570197e4ef7322d3632cEvan Yan * CDDL HEADER START
269473047d747f7815af570197e4ef7322d3632cEvan Yan * The contents of this file are subject to the terms of the
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Common Development and Distribution License (the "License").
269473047d747f7815af570197e4ef7322d3632cEvan Yan * You may not use this file except in compliance with the License.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
269473047d747f7815af570197e4ef7322d3632cEvan Yan * See the License for the specific language governing permissions
269473047d747f7815af570197e4ef7322d3632cEvan Yan * and limitations under the License.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * When distributing Covered Code, include this CDDL HEADER in each
269473047d747f7815af570197e4ef7322d3632cEvan Yan * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * If applicable, add the following below this CDDL HEADER, with the
269473047d747f7815af570197e4ef7322d3632cEvan Yan * fields enclosed by brackets "[]" replaced with your own identifying
269473047d747f7815af570197e4ef7322d3632cEvan Yan * information: Portions Copyright [yyyy] [name of copyright owner]
269473047d747f7815af570197e4ef7322d3632cEvan Yan * CDDL HEADER END
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Use is subject to license terms.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Sun DDI hotplug implementation specific functions
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Local function prototypes
269473047d747f7815af570197e4ef7322d3632cEvan Yan/* Connector operations */
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_cn_pre_change_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_cn_post_change_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_cn_handle_state_change(ddi_hp_cn_handle_t *hdlp);
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_cn_change_children_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yan/* Port operations */
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_port_change_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_port_upgrade_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic int ddihp_port_downgrade_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yan/* Misc routines */
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic void ddihp_update_last_change(ddi_hp_cn_handle_t *hdlp);
269473047d747f7815af570197e4ef7322d3632cEvan Yanstatic boolean_t ddihp_check_status_prop(dev_info_t *dip);
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Global functions (called within hotplug framework)
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Implement modctl() commands for hotplug.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Called by modctl_hp() in modctl.c
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_modctl(int hp_op, char *path, char *cn_name, uintptr_t arg,
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Get the dip of nexus node */
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_modctl: dip %p op %x path %s "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "cn_name %s arg %p rval %p\n", (void *)dip, hp_op, path, cn_name,
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Lock before access */
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* this port already exists. */
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = (*(DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))(
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Invalid Connection name */
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t target_state = (ddi_hp_cn_state_t)arg;
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_modctl: target_state="
269473047d747f7815af570197e4ef7322d3632cEvan Yan "%x, result_state=%x, rv=%x \n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDIHP_CN_OPS(hdlp, op, (void *)arg, (void *)rval, rv);
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Return the state of Hotplug Connection (CN)
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_getstate: pdip %p hdlp %p\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_getstate: hdlp %p "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "current Connection state %x new Connection state %x\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Implementation function for unregistering the Hotplug Connection (CN)
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_NEXDBG((CE_CONT, "ddihp_cn_unregister: hdlp %p\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (hdlp->cn_info.cn_state > DDI_HP_CN_STATE_OFFLINE) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_NEXDBG((CE_CONT, "ddihp_cn_unregister: dip %p, hdlp %p "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "state %x. Device busy, failed to unregister connection!\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan (void *)dip, (void *)hdlp, hdlp->cn_info.cn_state));
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* unlink the handle */
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDIHP_LIST_REMOVE(ddi_hp_cn_handle_t, (DEVI(dip)->devi_hp_hdlp), hdlp);
269473047d747f7815af570197e4ef7322d3632cEvan Yan kmem_free(hdlp->cn_info.cn_name, strlen(hdlp->cn_info.cn_name) + 1);
269473047d747f7815af570197e4ef7322d3632cEvan Yan * For a given Connection name and the dip node where the Connection is
269473047d747f7815af570197e4ef7322d3632cEvan Yan * supposed to be, find the corresponding hotplug handle.
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_cn_name_to_handle(dev_info_t *dip, char *cn_name)
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_name_to_handle: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "dip %p cn_name to find: %s", (void *)dip, cn_name));
269473047d747f7815af570197e4ef7322d3632cEvan Yan for (hdlp = DEVI(dip)->devi_hp_hdlp; hdlp; hdlp = hdlp->next) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_name_to_handle: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* found */
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_name_to_handle: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "failed to find cn_name"));
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Process the hotplug operations for Connector and also create Port
269473047d747f7815af570197e4ef7322d3632cEvan Yan * upon user command.
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_connector_ops(ddi_hp_cn_handle_t *hdlp, ddi_hp_op_t op,
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_connector_ops: pdip=%p op=%x "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "hdlp=%p arg=%p\n", (void *)dip, op, (void *)hdlp, arg));
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t target_state = *(ddi_hp_cn_state_t *)arg;
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = ddihp_cn_pre_change_state(hdlp, target_state);
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* the state is not changed */
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = (*(DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))(
269473047d747f7815af570197e4ef7322d3632cEvan Yan "bus_hp_op failed: pdip=%p cn_name:%s op=%x "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "hdlp=%p arg=%p\n", (void *)dip, hdlp->cn_info.cn_name,
269473047d747f7815af570197e4ef7322d3632cEvan Yan "old_state=%x, new_state=%x, rv=%x\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan hdlp->cn_info.cn_state, *(ddi_hp_cn_state_t *)result, rv));
269473047d747f7815af570197e4ef7322d3632cEvan Yan * After state change op is successfully done or
269473047d747f7815af570197e4ef7322d3632cEvan Yan * failed at some stages, continue to do some jobs.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Process the hotplug op for Port
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_port_ops(ddi_hp_cn_handle_t *hdlp, ddi_hp_op_t op,
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_port_ops: pdip=%p op=%x hdlp=%p "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "arg=%p\n", (void *)hdlp->cn_dip, op, (void *)hdlp, arg));
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* No child. Either present or empty. */
269473047d747f7815af570197e4ef7322d3632cEvan Yan } else { /* There is a child of this Port */
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Check DEVI(dip)->devi_node_state */
269473047d747f7815af570197e4ef7322d3632cEvan Yan switch (i_ddi_node_state(hdlp->cn_info.cn_child)) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* should never reach here */
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Check DEVI(dip)->devi_state in case the node is
269473047d747f7815af570197e4ef7322d3632cEvan Yan * downgraded or quiesced.
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t target_state = *(ddi_hp_cn_state_t *)arg;
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state = hdlp->cn_info.cn_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan *((ddi_hp_cn_state_t *)result) = hdlp->cn_info.cn_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (hdlp->cn_info.cn_state != DDI_HP_CN_STATE_PORT_EMPTY) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Only empty PORT can be removed by commands */
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Generate the system event with a possible hint
269473047d747f7815af570197e4ef7322d3632cEvan Yan/* ARGSUSED */
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_sysevent_t event_sub_class, int hint, int kmflag)
269473047d747f7815af570197e4ef7322d3632cEvan Yan "%s%d: Failed to allocate memory for hotplug"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " connection: %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Minor device name will be bus path
269473047d747f7815af570197e4ef7322d3632cEvan Yan * concatenated with connection name.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * One of consumers of the sysevent will pass it
269473047d747f7815af570197e4ef7322d3632cEvan Yan * to cfgadm as AP ID.
269473047d747f7815af570197e4ef7322d3632cEvan Yan (void) ddi_pathname(dip, cn_path + strlen("/devices"));
269473047d747f7815af570197e4ef7322d3632cEvan Yan "%s%d: Failed to allocate memory for AP ID: %s:%s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan err = nvlist_alloc(&ev_attr_list, NV_UNIQUE_NAME_TYPE, kmflag);
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (err != 0) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan "%s%d: Failed to allocate memory for event subclass %d\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (err != 0) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan cmn_err(CE_WARN, "%s%d: Unknown hint on sysevent\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* event sub class: DDI_HP_CN_REQ */
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (err != 0) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan "%s%d: Failed to add attr [%s] for %s \n"
269473047d747f7815af570197e4ef7322d3632cEvan Yan cmn_err(CE_WARN, "%s%d: Unknown hint on sysevent\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Add Hotplug Connection (CN) as attribute (common attribute)
269473047d747f7815af570197e4ef7322d3632cEvan Yan err = nvlist_add_string(ev_attr_list, DR_AP_ID, ap_id);
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (err != 0) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan cmn_err(CE_WARN, "%s%d: Failed to add attr [%s] for %s event\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Log this event with sysevent framework.
269473047d747f7815af570197e4ef7322d3632cEvan Yan err = ddi_log_sysevent(dip, DDI_VENDOR_SUNW, EC_DR,
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (err != 0) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_driver_name(dip), ddi_get_instance(dip), EC_DR);
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Local functions (called within this file)
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Connector operations
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Prepare to change state for a Connector: offline, unprobe, etc.
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state = hdlp->cn_info.cn_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan * If the Connection goes to a lower state from ENABLED,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * then offline all children under it.
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = ddihp_cn_change_children_state(hdlp, B_FALSE);
269473047d747f7815af570197e4ef7322d3632cEvan Yan "failed to unconfigure the device in the"
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Remove all the children and their ports
269473047d747f7815af570197e4ef7322d3632cEvan Yan * after they are offlined.
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = (*(DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))(
269473047d747f7815af570197e4ef7322d3632cEvan Yan "(%s%d): failed"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " to unprobe the device in the Connector"
269473047d747f7815af570197e4ef7322d3632cEvan Yan "ddihp_connector_ops (%s%d): device"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " is unconfigured and unprobed in Connector %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Jobs after change state of a Connector: update last change time,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * probe, online, sysevent, etc.
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_cn_post_change_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state = hdlp->cn_info.cn_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Update the state in handle */
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Probe and online devices if state is
269473047d747f7815af570197e4ef7322d3632cEvan Yan * upgraded to ENABLED.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * For Connector, generate a sysevent on
269473047d747f7815af570197e4ef7322d3632cEvan Yan * state change.
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddihp_cn_gen_sysevent(hdlp, DDI_HP_CN_STATE_CHANGE,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Handle Connector state change.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * This function is called after connector is upgraded to ENABLED sate.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * It probes the device plugged in the connector to setup devinfo nodes
269473047d747f7815af570197e4ef7322d3632cEvan Yan * and then online the nodes.
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_cn_handle_state_change(ddi_hp_cn_handle_t *hdlp)
269473047d747f7815af570197e4ef7322d3632cEvan Yan * If the Connection went to state ENABLED from a lower state,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * probe it.
269473047d747f7815af570197e4ef7322d3632cEvan Yan rv = (*(DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))(
269473047d747f7815af570197e4ef7322d3632cEvan Yan dip, hdlp->cn_info.cn_name, DDI_HPOP_CN_PROBE, NULL, NULL);
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t target_state = DDI_HP_CN_STATE_POWERED;
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Probe failed. Disable the connector so that it can
269473047d747f7815af570197e4ef7322d3632cEvan Yan * be enabled again by a later try from userland.
269473047d747f7815af570197e4ef7322d3632cEvan Yan (void) (*(DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))(
269473047d747f7815af570197e4ef7322d3632cEvan Yan dip, hdlp->cn_info.cn_name, DDI_HPOP_CN_CHANGE_STATE,
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (result_state && result_state != hdlp->cn_info.cn_state) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan "(%s%d): failed to probe the Connection %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Try to online all the children of CN.
269473047d747f7815af570197e4ef7322d3632cEvan Yan (void) ddihp_cn_change_children_state(hdlp, B_TRUE);
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_NEXDBG((CE_CONT, "ddihp_cn_event_handler (%s%d): "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "device is configured in the Connection %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Online/Offline all the children under the Hotplug Connection (CN)
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Do online operation when the online parameter is true; otherwise do offline.
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_cn_change_children_state(ddi_hp_cn_handle_t *hdlp, boolean_t online)
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_change_children_state:"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " dip %p hdlp %p, online %x\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Return invalid if Connection state is < DDI_HP_CN_STATE_ENABLED
269473047d747f7815af570197e4ef7322d3632cEvan Yan * when try to online children.
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (online && hdlp->cn_info.cn_state < DDI_HP_CN_STATE_ENABLED) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_cn_change_children_state: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "Connector %p is not in probed state\n", (void *)hdlp));
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Now, online/offline all the devices depending on the Connector */
269473047d747f7815af570197e4ef7322d3632cEvan Yan * For offline operation we need to firstly clean up devfs
269473047d747f7815af570197e4ef7322d3632cEvan Yan * so as not to prevent driver detach.
269473047d747f7815af570197e4ef7322d3632cEvan Yan for (h = DEVI(dip)->devi_hp_hdlp; h; h = h->next) {
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (h->cn_info.cn_type != DDI_HP_CN_TYPE_VIRTUAL_PORT)
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* online children */
269473047d747f7815af570197e4ef7322d3632cEvan Yan " failed to attach driver for a device"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " (%s%d) under the Connection %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * One of the devices failed to online, but we
269473047d747f7815af570197e4ef7322d3632cEvan Yan * want to continue to online the rest siblings
269473047d747f7815af570197e4ef7322d3632cEvan Yan * after mark the failure here.
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* offline children */
269473047d747f7815af570197e4ef7322d3632cEvan Yan " failed to dettach driver for the device"
269473047d747f7815af570197e4ef7322d3632cEvan Yan " (%s%d) in the Connection %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Port operations
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Change Port state to target_state.
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state = hdlp->cn_info.cn_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan return (ddihp_port_upgrade_state(hdlp, target_state));
269473047d747f7815af570197e4ef7322d3632cEvan Yan return (ddihp_port_downgrade_state(hdlp, target_state));
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Upgrade port state to target_state.
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state, new_state, result_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Check the existence of the corresponding hardware */
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Read-only probe the corresponding hardware. */
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* fall through */
269473047d747f7815af570197e4ef7322d3632cEvan Yan "ddihp_port_upgrade_state: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "failed to online device %p at port: %s\n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* should never reach here */
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_port_upgrade_state: "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "failed curr_state=%x, target_state=%x \n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Downgrade state to target_state
269473047d747f7815af570197e4ef7322d3632cEvan Yanddihp_port_downgrade_state(ddi_hp_cn_handle_t *hdlp,
269473047d747f7815af570197e4ef7322d3632cEvan Yan ddi_hp_cn_state_t curr_state, new_state, result_state;
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* Check the existence of the corresponding hardware */
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Read-only unprobe the corresponding hardware:
269473047d747f7815af570197e4ef7322d3632cEvan Yan * 1. release the assigned resource;
269473047d747f7815af570197e4ef7322d3632cEvan Yan * 2. remove the node pointed by the port's cn_child
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* fall through. */
269473047d747f7815af570197e4ef7322d3632cEvan Yan "ddihp_port_downgrade_state: failed "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "to offline node, rv=%x, cdip=%p \n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* should never reach here */
269473047d747f7815af570197e4ef7322d3632cEvan Yan "ddihp_port_downgrade_state: failed "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "curr_state=%x, target_state=%x \n",
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Misc routines
269473047d747f7815af570197e4ef7322d3632cEvan Yan/* Update the last state change time */
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (drv_getparm(TIME, (void *)&time) != DDI_SUCCESS)
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Check the device for a 'status' property. A conforming device
269473047d747f7815af570197e4ef7322d3632cEvan Yan * should have a status of "okay", "disabled", "fail", or "fail-xxx".
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Return FALSE for a conforming device that is disabled or faulted.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Return TRUE in every other case.
269473047d747f7815af570197e4ef7322d3632cEvan Yan * 'status' property is NOT a bus specific property. It is defined in page 184,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * IEEE 1275 spec. The full name of the spec is "IEEE Standard for
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Boot (Initialization Configuration) Firmware: Core Requirements and
269473047d747f7815af570197e4ef7322d3632cEvan Yan * Practices".
269473047d747f7815af570197e4ef7322d3632cEvan Yan /* try to get the 'status' property */
269473047d747f7815af570197e4ef7322d3632cEvan Yan if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
269473047d747f7815af570197e4ef7322d3632cEvan Yan * test if the status is "disabled", "fail", or
269473047d747f7815af570197e4ef7322d3632cEvan Yan * "fail-xxx".
269473047d747f7815af570197e4ef7322d3632cEvan Yan DDI_HP_IMPLDBG((CE_CONT, "ddihp_check_status_prop "
269473047d747f7815af570197e4ef7322d3632cEvan Yan "(%s%d): device is in disabled state",
269473047d747f7815af570197e4ef7322d3632cEvan Yan "hotplug (%s%d): device is in fault state (%s)\n",