2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Plugin library for PCI Express and PCI (SHPC) hotplug controller 2N/A "Error: hotplug service is probably not running, " \
2N/A "please use 'svcadm enable hotplug' to enable the service. " \
2N/A "See cfgadm_shp(1M) for more details." 2N/A * Set the version number 2N/A * External routines: 1 - 2 2N/A * Internal routines: 3 - 4 2N/A /* n */ "get-status ",
2N/A /* n */ "disconnect ",
2N/A /* n */ "configure ",
2N/A /* n */ "unconfigure ",
2N/A /* y */ "out of memory ",
2N/A /* y */ "invalid attachment point ",
2N/A /* y */ "invalid transition ",
2N/A /* y */ "no device is present ",
2N/A"\nPCI hotplug specific commands:",
2N/A"\t-c [connect|disconnect|configure|unconfigure|insert|remove] " 2N/A"\t-x led[=[fault|power|active|attn],mode=[on|off|blink]] ap_id [ap_id...]",
2N/A"\tunknown command or option: ",
2N/A /* n */ "???",
/* PCIEHPC_BOARD_UNKNOWN */ 2N/A /* n */ "hp",
/* PCIEHPC_BOARD_PCI_HOTPLUG */ 2N/A /* n */ "enable_slot",
2N/A /* n */ "disable_slot",
2N/A /* n */ "enable_autoconfig",
2N/A /* n */ "disable_autoconfig",
2N/A /* n */ "fault",
/* PCIEHPC_FAULT_LED */ 2N/A /* n */ "power",
/* PCIEHPC_POWER_LED */ 2N/A /* n */ "attn",
/* PCIEHPC_ATTN_LED */ 2N/A /* n */ "active",
/* PCIEHPC_ACTIVE_LED */ 2N/A /* n */ "off",
/* OFF */ 2N/A /* n */ "on",
/* ON */ 2N/A /* n */ "blink",
/* BLINK */ 2N/A * Return the corresponding hp node for a given ap_id, it is the caller's 2N/A * responsibility to call hp_fini() to free the snapshot. 2N/A /* Remove devices prefix (if any) */ 2N/A /* Remove dynamic component if any */ 2N/A /* Remove minor name (if any) */ 2N/A /* No reponse to operations on the door file. */ 2N/A * Callback function for hp_traverse(), to sum up the 2N/A * maximum length for error message display. 2N/A /* Only process USAGE nodes */ 2N/A /* size up resource name */ 2N/A /* size up usage description */ 2N/A * Callback function for hp_traverse(), to add the error 2N/A * message to he table. 2N/A /* Only process USAGE nodes */ 2N/A * Takes an opaque rcm_info_t pointer and a character pointer, and appends 2N/A * the rcm_info_t data in the form of a table to the given character pointer. 2N/A /* Protect against invalid arguments */ 2N/A /* Set localized table header strings */ 2N/A /* A first pass, to size up the RCM information */ 2N/A /* If nothing was sized up above, stop early */ 2N/A /* Adjust column widths for column headings */ 2N/A * Compute the total line width of each line, 2N/A * accounting for intercolumn spacing. 2N/A /* Allocate space for the table */ 2N/A /* zero fill for the strcat() call below */ 2N/A /* Place a table header into the string */ 2N/A /* The resource header */ 2N/A /* The information header */ 2N/A /* Underline the headers */ 2N/A /* Construct the format string */ 2N/A /* Add the tuples to the table string */ 2N/A * Figure out the target kernel state for a given cfgadm 2N/A * change-state operation. 2N/A * Translate kernel state to cfgadm receptacle state and occupant state. 2N/A /* Receptacle state */ 2N/A * Connector state can only be one of 2N/A * Empty, Present, Powered, Enabled. 2N/A * Mark occupant state as "configured" if at least one of the 2N/A * associated ports is at state "offline" or above. Driver 2N/A * attach ("online" state) is not necessary here. 2N/A * Transitional Diagram: 2N/A * (remove) ^| (physically insert card) 2N/A * disconnect configure 2N/A * "-c DISCONNECT" ^| "-c CONNECT" 2N/A * connect unconfigure -> connect configure 2N/A * Check for the FORCE flag. It is only used 2N/A * for DISCONNECT or UNCONFIGURE state changes. 2N/A * Which state should we drive to ? 2N/A /* Connect the slot */ 2N/A /* Disconnect the slot */ 2N/A * for multi-func device we allow multiple 2N/A * configure on the same slot because one 2N/A * func can be configured and other one won't 2N/A /* do nothing, just produce error msg as is */ 2N/A /* do nothing, just produce error msg as is */ 2N/A DBG(
1, (
"prt_led_mod function\n"));
2N/A for (i = 0; i < n; i++) {
2N/A * hp_get_private() will return back things like 2N/A * "led_fault=off", transform it to cfgadm desired 2N/A /* no action needed */ 2N/A /* ACTIVE=3,ATTN=2,POWER=1,FAULT=0 */ 2N/A /* ON = 1, OFF = 0 */ 2N/A /* will need to implement pci CTRL command */ 2N/A * The slot-names property describes the external labeling of add-in slots. 2N/A * This property is an encoded array, an integer followed by a list of 2N/A * strings. The return value from di_prop_lookup_ints for slot-names is -1. 2N/A * The expected return value should be the number of elements. 2N/A * Di_prop_decode_common does not decode encoded data from software, 2N/A * such as the solaris device tree, unlike from the prom. 2N/A * Di_prop_decode_common takes the size of the encoded data and mods 2N/A * it with the size of int. The size of the encoded data for slot-names is 9 2N/A * and the size of int is 4, yielding a non zero result. A value of -1 is used 2N/A * to indicate that the number of elements can not be determined. 2N/A * Di_prop_decode_common can be modified to decode encoded data from the solaris 2N/A /* wind tmptr to next \0 */ 2N/A /* point at unknown string */ 2N/A DBG(
2, (
"hot plug slots found so far:(%i)\n", 0));
2N/A * Check the Solaris device tree first 2N/A * in the case of a DR operation 2N/A * Check the prom device tree which is populated at boot. 2N/A * If this fails, give up and set the slot name to null. 2N/A DBG(
1, (
"find_physical_slot_names\n"));
2N/A DBG(
1, (
"di_init() failed\n"));
2N/A DBG(
1, (
"di_prom_init() failed\n"));
2N/A/* for type string assembly in get_type() */ 2N/A * call-back function for di_devlink_walk 2N/A * if the link lives in /dev/cfg copy its name 2N/A * Walk throught the cached /dev link tree looking for links to the ap 2N/A * if none are found return an error 2N/A /* ap_id is a valid minor_path with /devices prepended */ 2N/A DBG(
1, (
"check_devlinks: invalid ap_id: %s\n",
ap_id));
2N/A * most of this is needed to compensate for 2N/A * differences between various platforms 2N/A DBG(
1, (
"fix_ap_name: failed to snapshot node\n"));
2N/A * returns an allocated string containing the full path to the devlink for 2N/A * <ap_phys_id> in the devlink database; we expect only one devlink per 2N/A * <ap_phys_id> so we return the first encountered 2N/A * returns CFGA_OK if it can succesfully retrieve the devlink info associated 2N/A * with devlink for <ap_phys_id> which will be returned through <ap_info> 2N/A /* "condition" bus specific commands */ 2N/A DBG(
1, (
"physpath2node failed\n"));
2N/A DBG(
1, (
"cfga_get_state failed\n"));
2N/A DBG(
2, (
"ap_rstate = CFGA_STAT_EMPTY\n"));
2N/A DBG(
2, (
"ap_rstate = CFGA_STAT_DISCONNECTED\n"));
2N/A DBG(
2, (
"ap_rstate = CFGA_STAT_CONNECTED\n"));
2N/A DBG(
2, (
"ap_ostate = CFGA_STAT_CONFIGURED\n"));
2N/A DBG(
2, (
"ap_ostate = CFGA_STAT_UNCONFIGURED\n"));
2N/A DBG(
2, (
"ap_cond = CFGA_COND_OK\n"));
2N/A DBG(
2, (
"ap_cond = CFGA_COND_FAILING\n"));
2N/A DBG(
2, (
"ap_cond = CFGA_COND_FAILED\n"));
2N/A DBG(
2, (
"ap_cond = CFGA_COND_UNUSABLE\n"));
2N/A DBG(
2, (
"ap_cond = CFGA_COND_UNKNOW\n"));
2N/A * We're not busy since the entrance into the kernel has been 2N/A * sync'ed via libhotplug. 2N/A /* physical ap_id */ 2N/A /* slot_names of bus node */ 2N/A DBG(
1, (
"cfga_list_ext return success\n"));
2N/A * This routine prints a single line of help message 2N/A * cfga_err() accepts a command or error code, and converts it to a string. 2N/A * cfga_err() calls gettext() to internationalize proper messages. 2N/A /* If errstring is null, do nothing. */ 2N/A * Convert the indicated error code to a string. 2N/A * Command failures become "<command> failed", without translating 2N/A * the command name. Other errors use a full translation of one of 2N/A * the defined error strings. 2N/A /* Compute the length of the error message */ 2N/A /* Allocate memory for the error message */ 2N/A /* Concatenate the strings into the error message */ 2N/A * cfga_ap_id_cmp -- use default_ap_id_cmp() in libcfgadm