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 * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 9000 - 9499
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is part of the photon library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PLNDEF "SUNW,pln" /* check if box name starts with 'c' */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define IBFIRMWARE_FILE "/usr/lib/locale/C/LC_MESSAGES/ibfirmware"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Forward declarations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int pwr_up_down(char *, L_state *, int, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int load_flds_if_enc_disk(char *, struct path_struct **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int copy_config_page(struct l_state_struct *, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void copy_page_7(struct l_state_struct *, uchar_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int l_get_node_status(char *, struct l_disk_state_struct *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *, WWN_list *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int check_dpm_file(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int ib_download_code_cmd(int, int, int, uchar_t *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int dak_download_code_cmd(int, uchar_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void free_mp_dev_map(struct gfc_map_mp **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int get_mp_dev_map(char *, struct gfc_map_mp **, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_get_mode_pg() - Read all mode pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path pointer to device path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pg_buf ptr to mode pages
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_mode_pg(char *path, uchar_t **pg_buf, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_mode_pg: Reading Mode Sense pages.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do not do mode sense if this is a tape device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mode sense will rewind the tape */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open controller */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path, O_NDELAY | O_RDWR)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read the first part of the page to get the page size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*pg_buf = (uchar_t *)g_zalloc(size)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read page */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_mode_sense_cmd(fd, *pg_buf, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now get the size for all pages */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode_header_ptr = (struct mode_header_10_struct *)(void *)*pg_buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = mode_header_ptr->length + sizeof (mode_header_ptr->length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*pg_buf = (uchar_t *)g_zalloc(size)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read all pages */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_mode_sense_cmd(fd, *pg_buf, size,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format QLA21xx status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS: message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: Message of this format in message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "status type: 0xstatus count"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_format_ifp_status_msg(char *status_msg_buf, int count, int status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9003, "Unspecified transport error 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not enough packets for given request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format Fibre Channel status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUTS: message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: Message of this format in message buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "status type: 0xstatus count"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_format_fc_status_msg(char *status_msg_buf, int count, int status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not happen. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Should not happen. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Not enough packets for given request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9030, "Invalid # of segments for req 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9031, "Resource allocation failure 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9032, "Bad Source Identifier(S_ID) 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9038, "Diagnostics illegal request 0x%-2x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the indexes to the disk device elements in page 2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on the locations found in page 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_element_index(struct l_state_struct *l_state, int *front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint index = 0, front_flag = 0, local_front = 0, local_rear = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state == NULL) || (front_index == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the indexes to the disk device elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Index to front disk elements 0x%x\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_disk_element_index:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Index to rear disk elements 0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!front_flag && !rear_flag) { /* neither is found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_led() manage the device led's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_led(struct path_struct *path_struct, int led_action,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint err, write, fd, front_index, rear_index, offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need to get a valid location, front/rear & slot.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path_struct will return a valid slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the IB path or a disk path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(ses_path, path_struct->p_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_status(ses_path, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We are passing the disks path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_slot(path_struct, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
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 /* Get index to the disk we are interested in */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(ses_path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find enclosure type */
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 /* Double check slot. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (path_struct->slot >= l_state->total_num_drv/2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (8 + (front_index + path_struct->slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte offset = (8 + (rear_index + path_struct->slot)*4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem = (struct device_element *)(page_buf + offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now do requested action.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element)); /* save status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9043, " Blinking LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->f_flag ? path_struct->slot :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9043, " Blinking LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Turning off LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " %s\n"), path_struct->f_flag ? path_struct->slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Turning off LED for slot %d in enclosure"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen_page(fd, page_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem = (struct device_element *)(page_buf + offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)status, sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * frees the previously alloced l_state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)(*l_state)->total_num_drv/2; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*l_state)->drv_front[i].g_disk_state.multipath_list != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*l_state)->drv_front[i].g_disk_state.multipath_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*l_state)->drv_rear[i].g_disk_state.multipath_list != NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*l_state)->drv_rear[i].g_disk_state.multipath_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the state of an individual disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the Photon enclosure the powered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * up/down mode. The path must point to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a disk or the ib_path_flag must be set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_dev_pwr_up_down(char *path_phys, struct path_struct *path_struct,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_dev_map(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ses_path(path_struct->p_physical_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we have a photon, and if not, don't allow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this operation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OK, so we have a photon... we can continue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(ses_path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* We are passing the disks path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_slot(path_struct, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(dev_path, path_struct->p_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Either front or rear drive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for drive presence always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check disk state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * before the power off.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check whether disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is reserved by another
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((drive->g_disk_state.d_state_flags[PORT_A] & L_RESERVED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dl = (struct dlist *)g_zalloc(sizeof (struct dlist))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: It is not necessary to get the multipath list here as ------
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we alread have it after getting the status earlier.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - REWRITE -
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dl1 = dl->multipath; dl1 != NULL; dl1 = dl1->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((devhdl = devctl_device_acquire(dl1->dev_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = pwr_up_down(ses_path, l_state, path_struct->f_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_pho_pwr_up_down() Set the state of the Photon enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the powered up/down mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_pho_pwr_up_down(char *dev_name, char *path_phys, int power_off_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_status(path_phys, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if any disk in this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is reserved by another host before
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the power off.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state->drv_front[i].g_disk_state.d_state_flags[PORT_A] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_front[i].g_disk_state.d_state_flags[PORT_B] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_rear[i].g_disk_state.d_state_flags[PORT_A] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (l_state->drv_rear[i].g_disk_state.d_state_flags[PORT_B] &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if any disk in this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
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 /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "acquire the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release handle acquired above */
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 /* attempt to acquire the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "acquire the device: %s\n\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to offline the device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release handle acquired above */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = pwr_up_down(path_phys, l_state, 0, -1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the state of the Photon enclosure or disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * powered up/down mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * slot == -1 implies entire enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepwr_up_down(char *path_phys, L_state *l_state, int front, int slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint front_index, rear_index, front_offset, rear_offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To power up/down a Photon we use the Driver Off
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit in the global device control element.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((page_buf = (uchar_t *)malloc(MAX_REC_DIAG_LENGTH)) == NULL) {
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 /* Double check slot as convert_name only does gross check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte front_elem = (struct device_element *)(page_buf + front_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rear_elem = (struct device_element *)(page_buf + rear_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now do requested action.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(front_elem, sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set/reset power off bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now do rear */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(rear_elem, sizeof (struct device_element));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set/reset power off bit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Front Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Rear Device Status Element ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct device_element),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the password of the FPM by sending the password
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The size of the password string must be <= 8 bytes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The string can also be NULL. This is the way the user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * chooses to not have a password.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I then tell the photon by giving him 4 NULL bytes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)max((strlen(password) + 4), 8);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the name of the enclosure by sending the name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)((sizeof (struct page4_name) - 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)page4.name, name, sizeof (page4.name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page4))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the name really changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)inq.inq_box_name, name, sizeof (page4.name)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy((char *)name_buf, (char *)inq.inq_box_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue a Loop Port enable Primitive sequence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the device specified by the pathname.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue a Loop Port Bypass Primitive sequence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the device specified by the pathname. This requests the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device to set its L_Port into the bypass mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create a linked list of all the Photon enclosures that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are attached to this host.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURN VALUES: 0 O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_list pointer:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL: No enclosures found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * !NULL: Enclosures found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_list points to a linked list of boxes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_box_list(struct box_list_struct **box_list_ptr, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_name = (char *)g_zalloc(sizeof ("/dev/es"))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Searching directory %s for links to enclosures\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No Photons found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_DPRINTF(" l_get_box_list: No Photons found\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(namebuf, "%s/%s", dev_name, entp->d_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ER_DPRINTF("Warning: %s is not a symbolic link\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((result = g_get_physical_name_from_link(namebuf)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a SES card. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte B_DPRINTF(" l_get_box_list: Link to SES Card found: %s/%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(result, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Ignore errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the box name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue; /* Ignore errors */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the port WWN from the IB, page 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = l_get_envsen_page(fd, (uchar_t *)&page1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build list of names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Fill in structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure null terminated */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the port WWN for the port
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we are connected to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *box_list_ptr = box_list; /* pass back ptr to list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_free_box_list(struct box_list_struct **box_list)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds out if there are any other boxes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with the same name as "name".
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 There are no other boxes with the same name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * >0 if duplicate names found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_duplicate_names(Box_list *b_list, char wwn[], char *name, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp(name, (const char *)box_list_ptr->b_name) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strcmp(box_list_ptr->b_node_wwn_s, wwn) != 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checks for a name conflict with an SSA cN type name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_conflict(char *name, char **result, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*result = g_get_physical_name(s)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((const char *)*result, PLNDEF)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SSA path using %s\n", s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find path to IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_box_list(&box_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Valid cN type name found.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp((char *)s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "enclosure\nwith this name, %s, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "and a SSA name of the same form.\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Please use one of the following physical "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "pathnames:\n%s\n%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function sets the "slot", "slot_valid" and "f_flag" fields of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct that is passed in IFF the device path passed in ("phys_path")
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is a disk in an A5K or a Daktari. This is achieved by calling l_get_slot().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * phys_path - physical path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_sturct - Pointer to pointer to a path_struct data structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if phys_path is that of an A5K/Daktari disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot is set to the slot position in enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot_valid is set to 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->f_flag is set to 1 if in the front of an A5k
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or if among the first 6 disks on a Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * they are left as they were
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on SUCCESS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteload_flds_if_enc_disk(char *phys_path, struct path_struct **path_struct)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (*path_struct == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr(phys_path, SLSH_DRV_NAME_SSD) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't proceed when not a disk device or if it is not a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * valid FC device on which g_get_dev_map() can be done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (for example, g_get_dev_map() will fail on SSAs).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Just return success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this flag is set, l_get_slot() should not be called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * So, no point in proceeding. Just return success.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_dev_map(phys_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(phys_path, ses_path, &map, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is not an error since this could be a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * which does not have SES nodes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There is a SES path on the same FCA as the given disk. But if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SES node is not of a photon/Daktari, we dont proceed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_inquiry(ses_path, &inq)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only want to continue if this is a photon or a Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if product ID is not SENA or VID is not "SUN" (checks for photon)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and if enclosure type is not a Daktari, then I return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now, set some fields that l_get_slot() uses and then call it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)g_zalloc(sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ib_status(ses_path, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_slot(*path_struct, l_state, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert box name or WWN or logical path to physical path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - This structure is used to return more detailed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information about the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - *p_physical_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Normally this is the requested physical path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the requested path is not found then iff the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ib_path_flag is set this is the IB path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the argument variable input. e.g. Bob,f1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - slot_valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the slot number that was entered when using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the box,[fr]slot format. It is only valid if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * slot_valid flag is set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Front flag - If set, the requested device is located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * front of the enclosure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - ib_path_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this flag is set it means a devices path was requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but could not be found but an IB's path was found and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the p_physical_path points to that path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - **phys_path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * physical path to the device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - 0 if O.K.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - error otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint slot = 0, slot_flag = 0, found_box = 0, found_comma = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*path_struct = path_ptr = (struct path_struct *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_zalloc(sizeof (struct path_struct))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the path contains a "/" then assume
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it is a logical or physical path as the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box name or wwn can not contain "/"s.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((result = g_get_physical_name(name)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make sure it's a disk or tape path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(name, DEV_RDIR) || strstr(name, SLSH_DRV_NAME_SSD) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is not a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = load_flds_if_enc_disk(result, path_struct)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((int)strlen(tmp_name) > 1) && ((int)strlen(tmp_name) < 5)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_conflict(tmp_name, &result, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is a supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A5K/v880/v890 storage subsystem disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we have a box or WWN name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it contains a , then the format must be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * box_name,f1 where f is front and 1 is the slot number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or it is a format like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ssd@w2200002037049adf,0:h,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SUNW,pln@a0000000,77791d:ctlr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((char_ptr = strstr(tmp_name, ",")) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(char_ptr + 1) == 'f') || (*(char_ptr + 1) == 'r') ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: Need to double check the slot when we get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the number of the devices actually in the box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((save_frd != 's' && slot >= (MAX_DRIVES_PER_BOX/2))))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Say slot valid. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (save_frd == 's' && slot >= (MAX_DRIVES_DAK/2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_ptr->slot = slot = slot % (MAX_DRIVES_DAK/2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((char_ptr = strstr(tmp_name, ",")) != NULL) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(char_ptr + 1) == 'f') || (*(char_ptr + 1) == 'r') ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find path to IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_box_list(&box_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for box name. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strcmp((char *)tmp_name, (char *)box_list->b_name)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found subsystem: name %s WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for another box with this name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if we must get individual disks path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((l_state = (L_state *)g_zalloc(sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now double check the slot number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only allow the single slot version for Daktari */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((enc_type == DAK_ENC_TYPE) && (save_frd != 's')) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((enc_type != DAK_ENC_TYPE) && (save_frd == 's'))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_front[slot].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(l_state->drv_front[slot].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Result is the IB path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*l_state->drv_rear[slot].g_disk_state.physical_path) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte g_alloc_string(l_state->drv_rear[slot].g_disk_state.physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Result is the IB path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No luck with the box name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for the SES's WWN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found subsystem using the WWN"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ": name %s WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Look for a device's WWN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = g_get_wwn_list(&wwn_list, verbose)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found the device's WWN in the global WWN list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It MAY be in a photon/Daktari. If it is, we'll set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * additional fields in path_struct.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte result = g_alloc_string(wwn_list_ptr->physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Found device: WWN %s Path %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now check if it is a disk in an A5K and set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct fields
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check to see if it is a supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A5K/v880/v890 storage subsystem disk
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try again in case we were in the /dev
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or /devices directory.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte L_DPRINTF(" l_convert_name: path_struct:\n\tphysical_path:\n\t %s\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\targv:\t\t%s"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tslot_valid\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tslot\t\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tf_flag\t\t%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\tib_path_flag\t%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Time = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets envsen information of an enclosure from IB
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_envsen_page(int fd, uchar_t *buf, int buf_size, uchar_t page_code,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9046, " Reading SES page %x\n"), page_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&hdr, 0, sizeof (struct rec_diag_hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, (uchar_t *)&hdr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hdr.page_code != page_code) || (hdr.page_len == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Because of a hardware restriction in the soc+ chip
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the transfers must be word aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen_page: Adjusting size of the "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "g_scsi_rec_diag_cmd buffer.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen_page: Reading page %x of size 0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, pg, size, page_code)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)pg, (void *)buf, (size_t)new_size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get consolidated copy of all environmental information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * into buf structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_envsen(char *path_phys, uchar_t *buf, int size, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *page_list_ptr, page_code, *local_buf_ptr = buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRec_diag_hdr *hdr = (struct rec_diag_hdr *)(void *)buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open IB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_envsen: Getting list of supported"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " pages from IB\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9047, " Getting list of supported pages from IB\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get page 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page_list_ptr = buf + HEADER_LEN + 1; /* +1 to skip page 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check whether the number of pages received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from IB are valid. SENA enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * supports only 8 pages of sense information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * According to SES specification dpANS X3.xxx-1997
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * X3T10/Project 1212-D/Rev 8a, the enclosure supported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pages can go upto L_MAX_POSSIBLE_PAGES (0xFF).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return an error if no. of pages exceeds L_MAX_POSSIBLE_PAGES.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See if (num_pages >= L_MAX_POSSIBLE_PAGES) since 1 page (page 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * was already subtracted from the total number of pages before.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (num_pages < 1 || num_pages >= L_MAX_POSSIBLE_PAGES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Buffer size of MAX_REC_DIAG_LENGTH can be small if the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * number of pages exceed more than L_MAX_SENAIB_PAGES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * but less than L_MAX_POSSIBLE_PAGES.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Align buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Getting all pages and appending to buf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The fifth byte of page 0 is the start
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of the list of pages not including page 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr = (struct rec_diag_hdr *)(void *)local_buf_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the individual disk status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Path must be physical and point to a disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function updates the d_state_flags, port WWN's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and num_blocks for all accessiable ports
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in l_disk_state->g_disk_state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_status(char *path, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar path_a[MAXPATHLEN], path_b[MAXPATHLEN], ses_path[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint path_a_found = 0, path_b_found = 0, local_port_a_flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check device name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(path, &sbuf) || (sbuf.st_rdev == NODEV)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_status: invalid device %s\n", path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get paths. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "multipath to the disk.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is an MPXIO Path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathcnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip inactive paths.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A path that is not in either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDI_PATHINFO_STATE_ONLINE or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDI_PATHINFO_STATE_STANDBY state is not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an active path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When a disk port is bypassed and mpxio is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enabled, the path_state for that path goes to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * offline state
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(pwwn, pathlist.path_info[i].path_addr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do port b */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do port a */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ml && (!(path_a_found && path_b_found))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_dev_map(ml->dev_path, &map, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = l_get_ses_path(ml->dev_path, ses_path,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free((void *)map.dev_addr); /* Not used anymore */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the port, A or B, of the disk,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by passing the IB path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(ses_path, &local_port_a_flag, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l_disk_state->g_disk_state.port_a_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(l_disk_state->g_disk_state.port_b_wwn_s,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for Persistent Reservations.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_persistent_check(int fd, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(&read_key_buf, 0, sizeof (struct read_keys_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_persistent_reserve_in_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&read_key_buf, sizeof (struct read_keys_struct),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This means persistent reservations are supported by the disk. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_reserv_flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_registered = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct read_reserv_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((status = g_scsi_persistent_reserve_in_cmd(fd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct read_reserv_struct),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.persistent_active = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Reservations:"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_disk_state->g_disk_state.persistent_reserv_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_disk_state->g_disk_state.persistent_active != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(9049, "Registered"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Not being used"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets the disk status and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * updates the l_disk_state_struct structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Checks for open fail, Reservation Conflicts,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Not Ready and so on.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_disk_port_status(char *path, struct l_disk_state_struct *l_disk_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteRead_capacity_data capacity; /* local read capacity buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Try to open drive.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path, O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* See if drive ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is where I should figure out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the device is Not Ready or whatever.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There may not be a label on the drive - check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Sanity-check the vtoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Checking vtoc - No Label found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " invalid geometry\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need an extra check for tape devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read capacity should not be run on tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It will always return Not Readable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((local_state == 0) || (local_state == L_NO_LABEL)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_read_capacity_cmd(fd, (uchar_t *)&capacity,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Read Capacity failed.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* mark bad */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Need a more complete state definition here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.d_state_flags[port_a_flag] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save capacity */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_disk_state->g_disk_state.d_state_flags[port_a_flag] = local_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_disk_port_status: Individual Disk"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Status: 0x%x for"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " port %s for path:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy and format page 1 from big buffer to state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_config_page(struct l_state_struct *l_state, uchar_t *from_ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte encl_ptr = (struct ib_page_config *)(void *)from_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sanity check. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((encl_ptr->enc_len > MAX_VEND_SPECIFIC_ENC) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((encl_ptr->enc_num_elem > MAX_IB_ELEMENTS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = HEADER_LEN + 4 + HEADER_LEN + encl_ptr->enc_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy Type Descriptors seperately to get aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = (sizeof (struct type_desc_hdr))*encl_ptr->enc_num_elem;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.config.type_hdr, (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy Text Descriptors seperately to get aligned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must use the text size from the Type Descriptors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = l_state->ib_tbl.config.type_hdr[i].text_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.config.text[i], (size_t)size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy page 7 (Element Descriptor page) to state structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copy header then copy each element descriptor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * seperately.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecopy_page_7(struct l_state_struct *l_state, uchar_t *from_ptr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " copy_page_7: Elements being stored "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in state table\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* I am assuming page 1 has been read. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, p7_index = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j < (int)l_state->ib_tbl.config.enc_num_elem; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((*(my_from_ptr + 2) << 8) | *(my_from_ptr + 3));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p7_s.element_desc[p7_index++],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (k = 0; k < (int)l_state->ib_tbl.config.type_hdr[j].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Copy individual elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)&l_state->ib_tbl.p7_s.element_desc[p7_index++],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets IB diagnostic pages on a given pathname from l_get_envsen().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It also fills up the individual device element of l_state_struct using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * diagnostics pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Gets IB diagnostic pages on a given pathname from l_get_envsen().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It also fills up the individual device element of l_state_struct using
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * diagnostics pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must be of the ses driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@WWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_ib_status(char *path, struct l_state_struct *l_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get big buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get IB information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Even if there are 2 IB's in this box on this loop don't bother
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * talking to the other one as both IB's in a box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are supposed to report the same information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_envsen(path, ib_buf, MAX_REC_DIAG_LENGTH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set up state structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)ib_buf, (void *)&l_state->ib_tbl.p0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr = ib_buf + HEADER_LEN + l_state->ib_tbl.p0.page_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.p0.sup_page_codes[i] == L_PAGE_1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->ib_tbl.p0.sup_page_codes[i] ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->ib_tbl.p0.sup_page_codes[i] ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte from_ptr += ((*(from_ptr + 2) << 8) | *(from_ptr + 3));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_ib_status: Read %d Receive Diagnostic pages "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the total number of drives per box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes front & rear are the same.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->total_num_drv = 0; /* default to use as a flag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_DD) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * transfer the individual drive Device Element information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from IB state to drive state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_disk_element_index(l_state, &front_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip global element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)&l_state->ib_tbl.p2_s.element[front_index + i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)&l_state->ib_tbl.p2_s.element[rear_index + i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&l_state->ib_tbl.p2_s.element[front_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((sizeof (struct device_element)) * (l_state->total_num_drv)),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given an IB path get the port, A or B.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port_a: sets to 1 for port A
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and 0 for port B.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * err: 0 O.k.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_port(char *ses_path, int *port_a, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ib_state = (L_state *)calloc(1, sizeof (L_state))) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ib_status(ses_path, ib_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < (int)ib_state->ib_tbl.config.enc_num_elem; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ib_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_IB) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte elem_index += ib_state->ib_tbl.config.type_hdr[i].num;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_port: Found ses is the %s card.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function expects a pointer to a device path ending in the form
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * .../ses@w<NODEWWN>,<something> or .../ssd@w<NODEWWN>,<something>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No validity checking of the path is done by the function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It gets the wwn (node wwn) out of the passed string, searches the passed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map for a match, gets the corresponding phys addr (port id) for that entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and stores in the pointer the caller has passed as an argument (pid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is to be called only for public/fabric topologies
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this interface is going to get exported, one point to be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * considered is if a call to g_get_path_type() has to be made.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - pointer to the enclosure/disk device path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map - pointer to the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pid - the physical address associated for the node WWN that was found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero - otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_pid_from_path(const char *path, const gfc_map_t *map, int *pid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if mpxio device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First a quick check on the path */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ll_wwn = strtoull(wwn_str, &temp_ptr, L_WWN_LENGTH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno || (temp_ptr != (wwn_str + (WWN_SIZE * 2)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search for the ses's node wwn in map to get the area and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * domain ids from the corresponding port id (phys address).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (dev_addr_ptr = map->dev_addr, i = 0; i < map->count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pub_port.dev_nwwn.raw_wwn, byte_ptr, WWN_SIZE) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pid = dev_addr_ptr->gfc_port_dev.pub_port.dev_did.port_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Finds the disk's node wwn string, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * port A and B's WWNs and their port status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - pointer to a ses path
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wwn_list - pointer to the wwn_list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * state - node_wwn and wwn of ports A & B of disk, etc are inited
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - by l_get_disk_status()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found_flag - incremented after each examined element in the map
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_node_status(char *path, struct l_disk_state_struct *state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *found_flag, WWN_list *wwn_list, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a new map.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = get_mp_dev_map(path, &map_mp, verbose))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (map_ptr = map_mp; map_ptr != NULL; map_ptr = map_ptr->map_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a generic path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes the path looks something like this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/...
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ...ses@x,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then creates a path that looks like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(temp_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create complete path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build entry ssd@xx,0:c,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where xx is the WWN.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_node_status: Searching loop map "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to find disk: ID:0x%x"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we find a device on this loop in this box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update its status.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found a device on this loop in this box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Update state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "g%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check to make sure this is a valid path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paths may not always be created on the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host. So, we make a quick check.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bad if WWN is all zeros. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Invalid WWN.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get device status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found device in map. Don't need to look
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * any further
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a generic path to a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This assumes the path looks something like this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@wWWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then creates a path that looks like
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ssd@
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(temp_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_pid_from_path(path, &map_ptr->map, &path_pid)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now append the ssd string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create complete path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build entry ssd@WWN,0:c,raw
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First, search the map for a device with the area code and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * domain as in 'path_pid'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (map_ptr->map.dev_addr[j].gfc_port_dev.pub_port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Found the device. Update state.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paths for fabric cases may not always
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be created on the host. So, we make a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * quick check.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_ll_to_str(map_ptr->map.dev_addr[j].gfc_port_dev.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "w%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x,0:c,raw",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bad if WWN is all zeros. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_node_status: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Invalid WWN.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get device status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* if select_id match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* if !DTYPE_ESI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the individual drives status for the device specified by the index.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * device at the path where the path is of the IB and updates the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * g_disk_state_struct structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the disk's port is bypassed, it gets the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * drive status such as node WWN from the second port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct l_disk_state_struct *state, Ib_state *ib_state,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int front_flag, struct box_list_struct *box_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((state->ib_status.code != S_NOT_INSTALLED) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disk could have been bypassed on this loop.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the port state before l_state_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is set to L_INVALID_MAP.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check if port A & B of backplane are bypassed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If so, do not bother.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if disk is in rear slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((const void *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &seslist, 0)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_port(path, &port_a_flag, verbose))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk state was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Not in map.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Disk was found in the map.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_individual_state: Disk state was %s.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " l_get_individual_state:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\tTime = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the global state of the photon.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path and verbose flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "path" must be of the ses driver.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@e,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /devices/sbus@1f,0/SUNW,socal@1,0/SUNW,sf@0,0/ses@WWN,0:0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The struct l_state (which was passed in) has the status info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_status(char *path, struct l_state_struct *l_state, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint al_pa, found_front, found_rear, front_flag, enc_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Get Status for enclosure at: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialization */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset(l_state, 0, sizeof (struct l_state_struct));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy((char *)l_state->ib_tbl.enclosure_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)inq.inq_box_name, sizeof (inq.inq_box_name));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get all of the IB Receive Diagnostic pages.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = l_get_ib_status(path, l_state, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the individual devices information from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device itself.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * May need to use multiple paths to get to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * front and rear drives in the box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the loop is split some drives may not even be available
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from this host.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The way this works is in the select ID the front disks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are accessed via the IB with the bit 4 = 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the rear disks by the IB with bit 4 = 1.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * First get device map from fc nexus driver for this loop.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the boxes node WWN & al_pa for this path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(path, port_wwn, node_wwn, &al_pa, verbose)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < WWN_SIZE; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(&node_wwn_s[i << 1], "%02x", node_wwn[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The al_pa (or pa) can be 24 bits in size for fabric loops.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * But we will take only the low order byte to get the select_id.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Private loops have al_pa which is only a byte in size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte l_state->ib_tbl.box_id = (select_id & BOX_ID_MASK) >> 5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte G_DPRINTF(" l_get_status: Using this select_id 0x%x "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "and node WWN %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* there is no way to obtain all the al_pa with */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current implementation. assume both front */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* and rear. need changes later on. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(b_list->b_node_wwn_s, node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Take the low order byte of al_pa */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(b_list->b_node_wwn_s, node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("l_get_status: Loop to front disks not found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("l_get_status: Loop to rear disks not found.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get path to all the FC disk and tape devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I get this now and pass down for performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If for some reason the list can become invalid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i.e. device being offlined, then the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * must be re-gotten.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0, count = 0; i < l_state->total_num_drv/2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for front disk in slot %d\n", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_front[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set to loop not accessable. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For Daktari's, disk 0-5 information are located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_state->drv_front array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For Daktari's, disk 6-11 information are located in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * l_state->drv_rear array
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For this reason, on daktari's, I ignore the found_front and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * found_rear flags and check both the drv_front and drv_rear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++, count++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_rear[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (enc_type != DAK_ENC_TYPE && found_rear) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < l_state->total_num_drv/2; i++, count++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " State for rear disk in slot %d\n", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (struct l_disk_state_struct *)&l_state->drv_rear[i],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set to loop not accessable. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Time = %lld millisec\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the SENA file for validity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the size is that of 3 proms worth of text.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify PROM_MAGIC.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify (and print) the date.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the checksum.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - verify the WWN == 0.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since this requires reading the entire file, do it now and pass a pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the allocated buffer back to the calling routine (which is responsible
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for freeing it). If the buffer is not allocated it will be NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecheck_file(int fd, int verbose, uchar_t **buf_ptr, int dl_info_offset)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* read exec header */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((temp = read(fd, (char *)&the_exec, sizeof (the_exec))) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check the IB firmware MAGIC */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl_info = (struct dl_info *)(unsigned long)(buf + dl_info_offset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the date
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verify checksum
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0, p = start, i = 0; i < (size/ 4); i++, j ^= *p++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* file verified */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the DPM file for validity:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First record */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset((void*)&theRec, 0, sizeof (struct s3hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error reading first record/length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&theRec.rtype[0], "S0", 2) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in first record type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reclen = strtol(&theRec.rlen[0], (char **)NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in length == 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec.data[0], ((reclen*2) +1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in trying to read data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(&theRec.data[4], dakstring, 14) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in compiled file name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Second record */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset((void*)&theRec, 0, sizeof (struct s3hdr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error reading second record/length */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&theRec.rtype[0], "S3", 2) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in second record type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reclen = strtol(&theRec.rlen[0], (char **)NULL, 16);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in length == 0 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nread = read(fd, (void *)&theRec.data[0], ((reclen*2) +1));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in trying to read data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error in SSC100 offset pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_fd = g_object_open(file, O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte err = check_file(file_fd, verbose, &buf, FW_DL_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write buffer command set up to download
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * firmware to the Photon IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteib_download_code_cmd(int fd, int promid, int off, uchar_t *buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_scsi_writebuffer_cmd(fd, off, buf_ptr, sz,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Downloads the code to the DAKTARI/DPM with the hdr set correctly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fd - int for the file descriptor
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf_ptr - uchar_t pointer to the firmware itself
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf_len - int for the length of the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * status: 0 indicates success, != 0 failure, returned from writebuffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedak_download_code_cmd(int fd, uchar_t *buf_ptr, int buf_len)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (buf_len > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = g_scsi_writebuffer_cmd(fd, offs, buf_ptr, sz, 0x07, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Downloads the new prom image to IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path - physical path of Photon SES card
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file - input file for new code (may be NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ps - whether the "save" bit should be set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verbose - to be verbose or not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_download(char *path_phys, char *file, int ps, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(file_path, file, sizeof (file_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((controller_fd = g_object_open(path_phys, O_NDELAY | O_RDWR)) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(printbuf, MSGSTR(9052, " Doing download to:"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\t%s.\n From file: %s."), path_phys, file_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n\t%s\n From file: %s\n", path_phys, file_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_fd = g_object_open(file_path, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return a different error code here to differentiate between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this failure in g_object_open() and the one above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_scsi_inquiry_cmd(controller_fd, (uchar_t *)&inq, sizeof (inq))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We don't have a default daktari file location, so
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the user must specify the firmware file on the command line
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Validate the file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now go ahead and load up the data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9101, " Stat'ing the F/W file:"), strerror(err));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9102, " Cannot alloc mem to read F/W file:"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read(file_fd, buf_ptr, statbuf.st_size) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9103, " Reading F/W file:"), strerror(err));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = check_file(file_fd, verbose, &buf_ptr, FW_DL_INFO)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(127, "Checkfile O.K."));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Verifying the IB is available.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " available.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = dak_download_code_cmd(controller_fd, buf_ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, IBEEPROM, TEXT_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)(buf_ptr + TEXT_OFFSET), TEXT_SZ, ps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, IBEEPROM, IDATA_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)(buf_ptr + IDATA_OFFSET), IDATA_SZ, ps);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Re-verifying the IB is available.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " available.\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ib_download_code_cmd(controller_fd, MBEEPROM, FPM_OFFSET,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset the IB
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the World Wide Name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in page 4 of the Send Diagnostic command.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Is it allowed to change the wwn ???
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The path must point to an IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(path_phys, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Verify it is a Photon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uchar_t *)&inq, sizeof (struct l_inquiry_struct))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte page4.page_len = (ushort_t)((sizeof (struct page4_name) - 4));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (g_string_to_wwn((uchar_t *)wwn, (uchar_t *)&page4.name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy((void *)wwnp, (void *)page4.name, (size_t)WWN_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_send_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (page4))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check the wwn really changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status = g_scsi_rec_diag_cmd(fd, (uchar_t *)&page4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use a physical path to a disk in a Photon box
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as the base to genererate a path to a SES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * card in this box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_phys: Physical path to a Photon disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ses_path: This must be a pointer to an already allocated path string.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_ses_path(char *path_phys, char *ses_path, gfc_map_t *map,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t t_wwn[20], *ses_wwn, *ses_wwn1, *ses_nwwn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_phys == NULL) || (ses_path == NULL) || (map == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(ses_path, '/')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Figure out and create the boxes pathname.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: This uses the fact that the disks's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * AL_PA and the boxes AL_PA must match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the assigned hard address in the current
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * implementations. This may not be true in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((char_ptr = strrchr(path_phys, '@')) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte box_id = g_sf_alpa_to_switch[al_pa & 0xFF] & BOX_ID_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found ses wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found second ses " "wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dev_addr_ptr->gfc_port_dev.pub_port.dev_dtype ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We found an enclosure, lets match the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * area and domain codes for this enclosure with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that of the ses path since there may be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * multiple enclosures with same box id on a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The area and domain matched. Now, we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * match the box id of the disk with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this enclosure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found ses wwn = %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " l_get_ses_path: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Found second ses "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch on port_topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(9058, " Creating enclosure path:\n %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see if these paths exist.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = g_object_open(ses_path, O_NDELAY | O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Using second path, ses wwn1 = %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a valid location, front/rear & slot.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->p_physical_path must be of a disk.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * OUTPUT: path_struct->slot_valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->slot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * path_struct->f_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_slot(struct path_struct *path_struct, L_state *l_state, int verbose)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path_struct == NULL) || (l_state == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Double check to see if we need to calculate. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Programming error if this occures */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(path_struct->p_physical_path, "ssd") == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = g_get_wwn(path_struct->p_physical_path, port_wwn, node_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find the slot by searching for the matching hard address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take only the low order byte ignoring area and domain code in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fabric devices' 24 bit al_pa
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_slot: Searching Receive Diagnostic page 2, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to find the slot number with this ID:0x%x\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (slot = 0; slot < l_state->total_num_drv/2; slot++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (l_state->drv_rear[slot].ib_status.sel_id ==
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 path_struct->f_flag ? slot : slot + (MAX_DRIVES_DAK/2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte P_DPRINTF(" l_get_slot: Found slot %d %s.\n", slot,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(9059, "Noncritical failure"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(es, MSGSTR(122, "Critical failure"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get all ses paths paths to a given box.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The arg should be the physical path to one of the box's IB.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOTE: The caller must free the allocated lists.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a pointer to a list of ses paths if found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL on error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortel_get_allses(char *path, struct box_list_struct *box_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((path == NULL) || (box_list == NULL) || (ses_list == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize lists/arrays */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: Looking for all ses paths for"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (box_list_ptr = box_list; box_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(path, box_list_ptr->b_physical_path) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(node_wwn_s, box_list_ptr->b_node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte H_DPRINTF(" l_get_allses: node_wwn=%s\n", node_wwn_s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (box_list_ptr = box_list; box_list_ptr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(node_wwn_s, box_list_ptr->b_node_wwn_s) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->dev_path = strdup(box_list_ptr->b_physical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dl->logical_path = strdup(box_list_ptr->logical_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Routine to return the enclosure type pointed to by the path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inputs: The inquiry data for the device in question
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return: >= 0 is the type:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Types are defined in storage/libg_fc/common/hdrs/g_state.h:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 -> default (SENA)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 -> Daktari
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2 -> Other Enclosures
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], ENCLOSURE_PROD_ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], DAK_OFF_NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp((char *)&inq.inq_pid[0], DAK_PROD_STR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ADD OTHERS here if ever needed/wanted, and add to def's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * as noted above
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; *map_mp_ptr != NULL; *map_mp_ptr = next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) g_destroy_data((*map_mp_ptr)->map.dev_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function will return a linked list of device maps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * An example of when this will be used is when we want to return the device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map of a vhci path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_mp_dev_map(char *path, gfc_map_mp_t **map_mp_ptr, int verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < pathcnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * only pay attention to paths that are either
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ONLINE or STANDBY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add newly created map onto list */