fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*LINTLIBRARY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is part of the photon library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 8500 - 8999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* #define _POSIX_SOURCE 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function checks if the passed char pointer has WWN_SIZE nulls (zeroes).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is only a convenience function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wwn_ptr - pointer to a character string of length WWN_SIZE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is expected to be holding the WWN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ex: A WWN like 508002000000ddc1 is expected to be stored as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the following 8 bytes -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0x50, 0x80, 0x00, 0x20, ... etc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - if there is atleast one of WWN_SIZE bytes is != '\0'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero - if all WWN_SIZE bytes are '\0'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < WWN_SIZE; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This functions constructs a device path of the device/enclosure with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * given tid and, for public/fabric cases, on the same area and domain as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the given ses_path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ses_path - pointer to the ses_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tid - tid of the device/enclosure whose path is to be constructed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map - pointer to the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dtype - dtype of the device whose path is to be constructed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dev_path - pointer to the device path of type dtype and with tid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - Caller has to free this after use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero - otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_make_node(char *ses_path, int tid, char *dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ses_path == NULL) || (dev_path == NULL) || (map == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure that the port WWN is valid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TBD: Must find path, not just use :c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First lets get the PA from the ses path passed in */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_pid_from_path(ses_path, map, &ses_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now we go through every entry in the map and match the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * area and domain ids with the PA of the passed ses path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we find a match, we then match the low order byte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0, dev_addr_ptr = map->dev_addr; i < map->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure that the port WWN is valid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (is_null_wwn(dev_addr_ptr->gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TBD: Must find path, not just use :c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * checks for null wwn to a disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and returns -1 if found, 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * char *ses_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_chk_null_wwn(Path_struct *path_struct, char *ses_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (ses_path == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verify and continue only if the argv
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * has a format like box,{f/r}<slot #>.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Otherwise, return to the caller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The only way to address null wwn disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is using the box,{f/r}<slot#> format.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* add support for new {f/r/s}<slot#> support for DPM */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the list of enclosures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * connected to the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The following method is safer to get an ses path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the enclosure than calling l_get_ses_path(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with physical path to null WWN disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Because, l_get_ses_path uses the disk's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * al_pa to get the box id and then ses path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the box. When a disk has null wwn, it may
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not have a valid al_pa, and hard address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There is a possibility that l_get_ses_path()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not returning ses path to the correct enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp(boxname, (char *)boxlist->b_name) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path, boxlist->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free the box list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ses_path != NULL) && (strstr(ses_path, "ses") != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->drv_front[path_struct->slot].g_disk_state.node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->drv_rear[path_struct->slot].g_disk_state.node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for null WWN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0); /* Non-null wwn */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If OVERALL_STATUS is sent as the "func",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the code pointer must be valid (non NULL).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Otherwise NULL is a valid input for the code pointer.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_encl_status_page_funcs(int func, char *code, int todo, char *ses_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((page_buf = (uchar_t *)g_zalloc(MAX_REC_DIAG_LENGTH)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(ses_path, O_NDELAY | O_RDWR)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_envsen_page(fd, page_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_len = (page_buf[2] << 8 | page_buf[3]) + HEADER_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_OFF_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp((char *)l_state->ib_tbl.config.prod_id, DAK_PROD_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem = (struct device_element *)(page_buf + offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = g_scsi_send_diag_cmd(fd, (uchar_t *)page_buf, page_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds whether device id (tid) exists in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Arbitrated loop map or not.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ses_path - pointer to a ses path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tid - the target id of the device we want to check on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - only the low order 8 bits has the tid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map - pointer to a map of the system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verbose_flag - self explanatory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dev_path - the device path of the device with "tid".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Caller is responsible for freeing it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 if device present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_device_present(char *ses_path, int tid, gfc_map_t *map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0, dev_addr_ptr = map->dev_addr; i < map->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make sure that the port WWN is valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, k = 0; j < WWN_SIZE; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = dev_addr_ptr->gfc_port_dev.priv_port.sf_port_wwn[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the phys address (port id) of this ses device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_pid_from_path(ses_path, map, &ses_pid))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0, dev_addr_ptr = map->dev_addr; i < map->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dev_addr_ptr->gfc_port_dev.pub_port.dev_dtype !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We have a device. First match the area and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * domain ids and if they match, then see if
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the 8bit tid matches the last 8 bits of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 'this_pid'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make sure that the port WWN is valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, k = 0; j < WWN_SIZE; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memcmp(wwnlp->port_wwn_s, wwn, WWN_S_LEN) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*dev_path = g_zalloc(MAXPATHLEN)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(ses_path) - strlen(strrchr(ses_path, '/'));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_device_present: wwn=%s, sf_path=%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*dev_path = g_zalloc(MAXPATHLEN)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(*dev_path, "%s/%s", sf_path, ssd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_device_present: dev_path=%s\n", *dev_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * onlines the given list of devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and free up the allocated memory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_online_drive(dl->multipath, force_flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * offlines all the disks in a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SENA enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_offline_photon(struct hotplug_disk_list *hotplug_sena,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get global status for this Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_get_status(ses_path, l_state, verbose_flag) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_front[i].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)&l_state->drv_front[i].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_rear[i].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)&l_state->drv_rear[i].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prepares a char string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * containing the name of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device which will be hotplugged.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_drive_name(char *drive_name, int slot, int f_flag, char *box_name)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((drive_name == NULL) || (box_name == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!l_convert_name(box_name, &physpath, &p_pathstruct, 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If either of the above fail, we use the default value of 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Drive in \"%s\" front slot %d"), box_name, slot);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Drive in \"%s\" rear slot %d"), box_name, slot);