1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte * CDDL HEADER START
3fcf3ce44SJohn Forte *
4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte *
8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte * and limitations under the License.
12fcf3ce44SJohn Forte *
13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte *
19fcf3ce44SJohn Forte * CDDL HEADER END
20fcf3ce44SJohn Forte */
21fcf3ce44SJohn Forte /*
22fcf3ce44SJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23fcf3ce44SJohn Forte * Use is subject to license terms.
24fcf3ce44SJohn Forte */
25fcf3ce44SJohn Forte
26fcf3ce44SJohn Forte
27fcf3ce44SJohn Forte
28fcf3ce44SJohn Forte #define LUX_SF_INST_SHIFT4MINOR 6
29fcf3ce44SJohn Forte #define LUX_SF_MINOR2INST(x) (x >> LUX_SF_INST_SHIFT4MINOR)
30fcf3ce44SJohn Forte
31fcf3ce44SJohn Forte #include <stdlib.h>
32fcf3ce44SJohn Forte #include <stdio.h>
33fcf3ce44SJohn Forte #include <sys/file.h>
34fcf3ce44SJohn Forte #include <sys/errno.h>
35fcf3ce44SJohn Forte #include <sys/types.h>
36fcf3ce44SJohn Forte #include <sys/stat.h>
37fcf3ce44SJohn Forte #include <sys/param.h>
38fcf3ce44SJohn Forte #include <kstat.h>
39fcf3ce44SJohn Forte #include <sys/mkdev.h>
40fcf3ce44SJohn Forte #include <locale.h>
41fcf3ce44SJohn Forte #include <nl_types.h>
42fcf3ce44SJohn Forte #include <fcntl.h>
43fcf3ce44SJohn Forte #include <unistd.h>
44fcf3ce44SJohn Forte #include <strings.h>
45fcf3ce44SJohn Forte #include <ctype.h>
46fcf3ce44SJohn Forte #include <dirent.h>
47fcf3ce44SJohn Forte #include <limits.h>
48fcf3ce44SJohn Forte #include <stdarg.h>
49fcf3ce44SJohn Forte #include <termio.h> /* For password */
50fcf3ce44SJohn Forte #include <signal.h>
51fcf3ce44SJohn Forte #include <sys/scsi/scsi.h>
52fcf3ce44SJohn Forte #include <sys/scsi/generic/commands.h>
53fcf3ce44SJohn Forte #include <l_common.h>
54fcf3ce44SJohn Forte #include <l_error.h>
55fcf3ce44SJohn Forte #include <stgcom.h>
56fcf3ce44SJohn Forte #include <a_state.h>
57fcf3ce44SJohn Forte #include <devid.h>
58fcf3ce44SJohn Forte #include <g_state.h>
59fcf3ce44SJohn Forte #include "common.h"
60fcf3ce44SJohn Forte
61fcf3ce44SJohn Forte extern char *dtype[];
62fcf3ce44SJohn Forte extern char *whoami;
63fcf3ce44SJohn Forte extern int Options;
64fcf3ce44SJohn Forte extern const int OPTION_A;
65fcf3ce44SJohn Forte extern const int OPTION_B;
66fcf3ce44SJohn Forte extern const int OPTION_C;
67fcf3ce44SJohn Forte extern const int OPTION_D;
68fcf3ce44SJohn Forte extern const int OPTION_E;
69fcf3ce44SJohn Forte extern const int OPTION_F;
70fcf3ce44SJohn Forte extern const int OPTION_L;
71fcf3ce44SJohn Forte extern const int OPTION_P;
72fcf3ce44SJohn Forte extern const int OPTION_R;
73fcf3ce44SJohn Forte extern const int OPTION_T;
74fcf3ce44SJohn Forte extern const int OPTION_V;
75fcf3ce44SJohn Forte extern const int OPTION_Z;
76fcf3ce44SJohn Forte extern const int OPTION_Y;
77fcf3ce44SJohn Forte extern const int OPTION_CAPF;
78fcf3ce44SJohn Forte extern const int PVERBOSE;
79fcf3ce44SJohn Forte extern const int SAVE;
80fcf3ce44SJohn Forte extern const int EXPERT;
81fcf3ce44SJohn Forte
82fcf3ce44SJohn Forte static struct termios termios;
83fcf3ce44SJohn Forte static int termio_fd;
84fcf3ce44SJohn Forte static void pho_display_config(char *);
85fcf3ce44SJohn Forte static void dpm_display_config(char *);
86fcf3ce44SJohn Forte static void n_rem_list_entry(uchar_t, struct gfc_map *,
87fcf3ce44SJohn Forte WWN_list **);
88fcf3ce44SJohn Forte static void n_rem_list_entry_fabric(int, struct gfc_map *,
89fcf3ce44SJohn Forte WWN_list **);
90fcf3ce44SJohn Forte static void n_rem_wwn_entry(uchar_t *, WWN_list **);
91fcf3ce44SJohn Forte static void display_disk_info(L_inquiry, L_disk_state,
92fcf3ce44SJohn Forte Path_struct *, struct mode_page *, int, char *, int);
93fcf3ce44SJohn Forte static void display_lun_info(L_disk_state, Path_struct *,
94fcf3ce44SJohn Forte struct mode_page *, int, WWN_list *, char *);
95fcf3ce44SJohn Forte static void display_fc_disk(struct path_struct *, char *, gfc_map_t *,
96fcf3ce44SJohn Forte L_inquiry, int);
97fcf3ce44SJohn Forte static void adm_display_err(char *, int);
98fcf3ce44SJohn Forte static void temperature_messages(struct l_state_struct *, int);
99fcf3ce44SJohn Forte static void ctlr_messages(struct l_state_struct *, int, int);
100fcf3ce44SJohn Forte static void fan_messages(struct l_state_struct *, int, int);
101fcf3ce44SJohn Forte static void ps_messages(struct l_state_struct *, int, int);
102fcf3ce44SJohn Forte static void abnormal_condition_display(struct l_state_struct *);
103fcf3ce44SJohn Forte static void loop_messages(struct l_state_struct *, int, int);
104fcf3ce44SJohn Forte static void revision_msg(struct l_state_struct *, int);
105fcf3ce44SJohn Forte static void mb_messages(struct l_state_struct *, int, int);
106fcf3ce44SJohn Forte static void back_plane_messages(struct l_state_struct *, int, int);
107fcf3ce44SJohn Forte static void dpm_SSC100_messages(struct l_state_struct *, int, int);
108fcf3ce44SJohn Forte static void mb_messages(struct l_state_struct *, int, int);
109fcf3ce44SJohn Forte static void back_plane_messages(struct l_state_struct *, int, int);
110fcf3ce44SJohn Forte static void dpm_SSC100_messages(struct l_state_struct *, int, int);
111fcf3ce44SJohn Forte static void trans_decode(Trans_elem_st *trans);
112fcf3ce44SJohn Forte static void trans_messages(struct l_state_struct *, int);
113fcf3ce44SJohn Forte static void adm_print_pathlist(char *);
114fcf3ce44SJohn Forte static void display_path_info(char *, char *, WWN_list *);
115fcf3ce44SJohn Forte static void copy_wwn_data_to_str(char *, const uchar_t *);
116fcf3ce44SJohn Forte static void adm_mplist_free(struct mplist_struct *);
117fcf3ce44SJohn Forte static int lun_display(Path_struct *path_struct, L_inquiry inq_struct,
118fcf3ce44SJohn Forte int verbose);
119fcf3ce44SJohn Forte static int non_encl_fc_disk_display(Path_struct *path_struct,
120fcf3ce44SJohn Forte L_inquiry inq_struct, int verbose);
121fcf3ce44SJohn Forte static int get_enclStatus(char *phys_path, char *encl_name, int off_flag);
122fcf3ce44SJohn Forte static int get_host_controller_pwwn(char *hba_path, uchar_t *pwwn);
123fcf3ce44SJohn Forte static int get_lun_capacity(char *devpath,
124fcf3ce44SJohn Forte struct scsi_capacity_16 *cap_data);
125fcf3ce44SJohn Forte static int get_path_status(char *devpath, int *status);
126fcf3ce44SJohn Forte static int get_FC4_host_controller_pwwn(char *hba_path, uchar_t *pwwn);
127fcf3ce44SJohn Forte
128fcf3ce44SJohn Forte /*
129fcf3ce44SJohn Forte * Gets the device's state from the SENA IB and
130fcf3ce44SJohn Forte * checks whether device is offlined, bypassed
131fcf3ce44SJohn Forte * or if the slot is empty and prints it to the
132fcf3ce44SJohn Forte * stdout.
133fcf3ce44SJohn Forte *
134fcf3ce44SJohn Forte * RETURNS:
135fcf3ce44SJohn Forte * 0 O.K.
136fcf3ce44SJohn Forte * non-zero otherwise
137fcf3ce44SJohn Forte */
138fcf3ce44SJohn Forte int
print_devState(char * devname,char * ppath,int fr_flag,int slot,int verbose_flag)139fcf3ce44SJohn Forte print_devState(char *devname, char *ppath, int fr_flag, int slot,
140fcf3ce44SJohn Forte int verbose_flag)
141fcf3ce44SJohn Forte {
142fcf3ce44SJohn Forte L_state l_state;
143fcf3ce44SJohn Forte int err;
144fcf3ce44SJohn Forte int i, elem_index = 0;
145fcf3ce44SJohn Forte uchar_t device_off, ib_status_code, bypass_a_en, bypass_b_en;
146fcf3ce44SJohn Forte Bp_elem_st bpf, bpr;
147fcf3ce44SJohn Forte
148fcf3ce44SJohn Forte
149fcf3ce44SJohn Forte if ((err = l_get_status(ppath, &l_state, verbose_flag)) != 0) {
150fcf3ce44SJohn Forte (void) print_errString(err, ppath);
151fcf3ce44SJohn Forte return (err);
152fcf3ce44SJohn Forte }
153fcf3ce44SJohn Forte
154fcf3ce44SJohn Forte for (i = 0; i < (int)l_state.ib_tbl.config.enc_num_elem; i++) {
155fcf3ce44SJohn Forte elem_index++;
156fcf3ce44SJohn Forte if (l_state.ib_tbl.config.type_hdr[i].type == ELM_TYP_BP) {
157fcf3ce44SJohn Forte break;
158fcf3ce44SJohn Forte }
159fcf3ce44SJohn Forte elem_index += l_state.ib_tbl.config.type_hdr[i].num;
160fcf3ce44SJohn Forte }
161fcf3ce44SJohn Forte (void) bcopy((const void *)
162fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index]),
163fcf3ce44SJohn Forte (void *)&bpf, sizeof (bpf));
164fcf3ce44SJohn Forte (void) bcopy((const void *)
165fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index + 1]),
166fcf3ce44SJohn Forte (void *)&bpr, sizeof (bpr));
167fcf3ce44SJohn Forte
168fcf3ce44SJohn Forte if (fr_flag) {
169fcf3ce44SJohn Forte device_off = l_state.drv_front[slot].ib_status.dev_off;
170fcf3ce44SJohn Forte bypass_a_en = l_state.drv_front[slot].ib_status.bypass_a_en;
171fcf3ce44SJohn Forte bypass_b_en = l_state.drv_front[slot].ib_status.bypass_b_en;
172fcf3ce44SJohn Forte ib_status_code = l_state.drv_front[slot].ib_status.code;
173fcf3ce44SJohn Forte } else {
174fcf3ce44SJohn Forte device_off = l_state.drv_rear[slot].ib_status.dev_off;
175fcf3ce44SJohn Forte bypass_a_en = l_state.drv_rear[slot].ib_status.bypass_a_en;
176fcf3ce44SJohn Forte bypass_b_en = l_state.drv_rear[slot].ib_status.bypass_b_en;
177fcf3ce44SJohn Forte ib_status_code = l_state.drv_rear[slot].ib_status.code;
178fcf3ce44SJohn Forte }
179fcf3ce44SJohn Forte if (device_off) {
180fcf3ce44SJohn Forte (void) fprintf(stdout,
181fcf3ce44SJohn Forte MSGSTR(2000,
182fcf3ce44SJohn Forte "%s is offlined and bypassed.\n"
183fcf3ce44SJohn Forte " Could not get device specific"
184fcf3ce44SJohn Forte " information.\n\n"),
185fcf3ce44SJohn Forte devname);
186fcf3ce44SJohn Forte } else if (bypass_a_en && bypass_b_en) {
187fcf3ce44SJohn Forte (void) fprintf(stdout,
188fcf3ce44SJohn Forte MSGSTR(2001,
189fcf3ce44SJohn Forte "%s is bypassed (Port:AB).\n"
190fcf3ce44SJohn Forte " Could not get device specific"
191fcf3ce44SJohn Forte " information.\n\n"),
192fcf3ce44SJohn Forte devname);
193fcf3ce44SJohn Forte } else if (ib_status_code == S_NOT_INSTALLED) {
194fcf3ce44SJohn Forte (void) fprintf(stdout,
195fcf3ce44SJohn Forte MSGSTR(2002,
196fcf3ce44SJohn Forte "Slot %s is empty.\n\n"),
197fcf3ce44SJohn Forte devname);
198fcf3ce44SJohn Forte } else if (((bpf.code != S_NOT_INSTALLED) &&
199fcf3ce44SJohn Forte ((bpf.byp_a_enabled || bpf.en_bypass_a) &&
200fcf3ce44SJohn Forte (bpf.byp_b_enabled || bpf.en_bypass_b))) ||
201fcf3ce44SJohn Forte ((bpr.code != S_NOT_INSTALLED) &&
202fcf3ce44SJohn Forte ((bpr.byp_a_enabled || bpr.en_bypass_a) &&
203fcf3ce44SJohn Forte (bpr.byp_b_enabled || bpr.en_bypass_b)))) {
204fcf3ce44SJohn Forte (void) fprintf(stdout,
205fcf3ce44SJohn Forte MSGSTR(2003,
206fcf3ce44SJohn Forte "Backplane(Port:AB) is bypassed.\n"
207fcf3ce44SJohn Forte " Could not get device specific"
208fcf3ce44SJohn Forte " information for"
209fcf3ce44SJohn Forte " %s.\n\n"), devname);
210fcf3ce44SJohn Forte } else {
211fcf3ce44SJohn Forte (void) fprintf(stderr,
212fcf3ce44SJohn Forte MSGSTR(33,
213fcf3ce44SJohn Forte " Error: converting"
214fcf3ce44SJohn Forte " %s to physical path.\n"
215fcf3ce44SJohn Forte " Invalid pathname.\n"),
216fcf3ce44SJohn Forte devname);
217fcf3ce44SJohn Forte }
218fcf3ce44SJohn Forte return (-1);
219fcf3ce44SJohn Forte }
220fcf3ce44SJohn Forte
221fcf3ce44SJohn Forte /*
222fcf3ce44SJohn Forte * Given an error number, this functions
223fcf3ce44SJohn Forte * calls the get_errString() to print a
224fcf3ce44SJohn Forte * corresponding error message to the stderr.
225fcf3ce44SJohn Forte * get_errString() always returns an error
226fcf3ce44SJohn Forte * message, even in case of undefined error number.
227fcf3ce44SJohn Forte * So, there is no need to check for a NULL pointer
228fcf3ce44SJohn Forte * while printing the error message to the stdout.
229fcf3ce44SJohn Forte *
230fcf3ce44SJohn Forte * RETURNS: N/A
231fcf3ce44SJohn Forte *
232fcf3ce44SJohn Forte */
233fcf3ce44SJohn Forte void
print_errString(int errnum,char * devpath)234fcf3ce44SJohn Forte print_errString(int errnum, char *devpath)
235fcf3ce44SJohn Forte {
236fcf3ce44SJohn Forte
237fcf3ce44SJohn Forte char *errStr;
238fcf3ce44SJohn Forte
239fcf3ce44SJohn Forte errStr = g_get_errString(errnum);
240fcf3ce44SJohn Forte
241fcf3ce44SJohn Forte if (devpath == NULL) {
242fcf3ce44SJohn Forte (void) fprintf(stderr,
243fcf3ce44SJohn Forte "%s \n\n", errStr);
244fcf3ce44SJohn Forte } else {
245fcf3ce44SJohn Forte (void) fprintf(stderr,
246fcf3ce44SJohn Forte "%s - %s.\n\n", errStr, devpath);
247fcf3ce44SJohn Forte }
248fcf3ce44SJohn Forte
249fcf3ce44SJohn Forte /* free the allocated memory for error string */
250fcf3ce44SJohn Forte if (errStr != NULL)
251fcf3ce44SJohn Forte (void) free(errStr);
252fcf3ce44SJohn Forte }
253fcf3ce44SJohn Forte
254fcf3ce44SJohn Forte /*
255fcf3ce44SJohn Forte * adm_inquiry() Display the inquiry information for
256fcf3ce44SJohn Forte * a SENA enclosure(s) or disk(s).
257fcf3ce44SJohn Forte *
258fcf3ce44SJohn Forte * RETURNS:
259fcf3ce44SJohn Forte * none.
260fcf3ce44SJohn Forte */
261fcf3ce44SJohn Forte int
adm_inquiry(char ** argv)262fcf3ce44SJohn Forte adm_inquiry(char **argv)
263fcf3ce44SJohn Forte {
264fcf3ce44SJohn Forte L_inquiry inq;
265fcf3ce44SJohn Forte L_inquiry80 inq80;
266fcf3ce44SJohn Forte size_t serial_len;
267fcf3ce44SJohn Forte int path_index = 0, retval = 0;
268fcf3ce44SJohn Forte int slot, f_r, err = 0, argpwwn, argnwwn;
269fcf3ce44SJohn Forte char inq_path[MAXNAMELEN];
270fcf3ce44SJohn Forte char *path_phys = NULL, *ptr;
271fcf3ce44SJohn Forte Path_struct *path_struct;
272fcf3ce44SJohn Forte WWN_list *wwn_list, *wwn_list_ptr, *list_start;
273fcf3ce44SJohn Forte char last_logical_path[MAXPATHLEN];
274fcf3ce44SJohn Forte
275fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
276fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
277fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
278fcf3ce44SJohn Forte (void) strcpy(inq_path, argv[path_index]);
279fcf3ce44SJohn Forte if (((ptr = strstr(inq_path, ",")) != NULL) &&
280fcf3ce44SJohn Forte ((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
281fcf3ce44SJohn Forte (*(ptr +1) == 's'))) {
282fcf3ce44SJohn Forte if (err != -1) {
283fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
284fcf3ce44SJohn Forte path_index++;
285fcf3ce44SJohn Forte retval++;
286fcf3ce44SJohn Forte continue;
287fcf3ce44SJohn Forte }
288fcf3ce44SJohn Forte *ptr = NULL;
289fcf3ce44SJohn Forte slot = path_struct->slot;
290fcf3ce44SJohn Forte f_r = path_struct->f_flag;
291fcf3ce44SJohn Forte path_phys = NULL;
292fcf3ce44SJohn Forte if ((err = l_convert_name(inq_path, &path_phys,
293fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
294fcf3ce44SJohn Forte (void) fprintf(stderr,
295fcf3ce44SJohn Forte MSGSTR(33,
296fcf3ce44SJohn Forte " Error: converting"
297fcf3ce44SJohn Forte " %s to physical path.\n"
298fcf3ce44SJohn Forte " Invalid pathname.\n"),
299fcf3ce44SJohn Forte argv[path_index]);
300fcf3ce44SJohn Forte if (err != -1) {
301fcf3ce44SJohn Forte (void) print_errString(err,
302fcf3ce44SJohn Forte argv[path_index]);
303fcf3ce44SJohn Forte }
304fcf3ce44SJohn Forte path_index++;
305fcf3ce44SJohn Forte retval++;
306fcf3ce44SJohn Forte continue;
307fcf3ce44SJohn Forte }
308fcf3ce44SJohn Forte if ((err = print_devState(argv[path_index],
309fcf3ce44SJohn Forte path_struct->p_physical_path,
310fcf3ce44SJohn Forte f_r, slot, Options & PVERBOSE)) != 0) {
311fcf3ce44SJohn Forte path_index++;
312fcf3ce44SJohn Forte retval++;
313fcf3ce44SJohn Forte continue;
314fcf3ce44SJohn Forte }
315fcf3ce44SJohn Forte } else {
316fcf3ce44SJohn Forte if (err != -1) {
317fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
318fcf3ce44SJohn Forte } else {
319fcf3ce44SJohn Forte (void) fprintf(stderr, "\n ");
320fcf3ce44SJohn Forte (void) fprintf(stderr,
321fcf3ce44SJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
322fcf3ce44SJohn Forte argv[path_index]);
323fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
324fcf3ce44SJohn Forte }
325fcf3ce44SJohn Forte }
326fcf3ce44SJohn Forte path_index++;
327fcf3ce44SJohn Forte retval++;
328fcf3ce44SJohn Forte continue;
329fcf3ce44SJohn Forte }
330fcf3ce44SJohn Forte
331fcf3ce44SJohn Forte if (strstr(argv[path_index], "/") != NULL) {
332fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
333fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
334fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
335fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
336fcf3ce44SJohn Forte path_index++;
337fcf3ce44SJohn Forte retval++;
338fcf3ce44SJohn Forte continue;
339fcf3ce44SJohn Forte }
340fcf3ce44SJohn Forte
341fcf3ce44SJohn Forte serial_len = sizeof (inq80.inq_serial);
342fcf3ce44SJohn Forte if (err = g_get_serial_number(path_phys, inq80.inq_serial,
343fcf3ce44SJohn Forte &serial_len)) {
344fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
345fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
346fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
347fcf3ce44SJohn Forte path_index++;
348fcf3ce44SJohn Forte retval++;
349fcf3ce44SJohn Forte continue;
350fcf3ce44SJohn Forte }
351fcf3ce44SJohn Forte print_inq_data(argv[path_index], path_phys, inq,
352fcf3ce44SJohn Forte inq80.inq_serial, serial_len);
353fcf3ce44SJohn Forte path_index++;
354fcf3ce44SJohn Forte continue;
355fcf3ce44SJohn Forte }
356fcf3ce44SJohn Forte if ((err = g_get_wwn_list(&wwn_list, 0)) != 0) {
357fcf3ce44SJohn Forte return (err);
358fcf3ce44SJohn Forte }
359fcf3ce44SJohn Forte g_sort_wwn_list(&wwn_list);
360fcf3ce44SJohn Forte list_start = wwn_list;
361fcf3ce44SJohn Forte argpwwn = argnwwn = 0;
362fcf3ce44SJohn Forte (void) strcpy(last_logical_path, path_phys);
363fcf3ce44SJohn Forte for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
364fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
365fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s, path_struct->argv) ==
366fcf3ce44SJohn Forte 0) {
367fcf3ce44SJohn Forte list_start = wwn_list_ptr;
368fcf3ce44SJohn Forte argpwwn = 1;
369fcf3ce44SJohn Forte break;
370fcf3ce44SJohn Forte } else if (strcasecmp(wwn_list_ptr->node_wwn_s,
371fcf3ce44SJohn Forte path_struct->argv) == 0) {
372fcf3ce44SJohn Forte list_start = wwn_list_ptr;
373fcf3ce44SJohn Forte argnwwn = 1;
374fcf3ce44SJohn Forte break;
375fcf3ce44SJohn Forte }
376fcf3ce44SJohn Forte }
377fcf3ce44SJohn Forte
378fcf3ce44SJohn Forte if (!(argpwwn || argnwwn)) {
379fcf3ce44SJohn Forte /*
380fcf3ce44SJohn Forte * if the wwn list is null or the arg device not found
381fcf3ce44SJohn Forte * from the wwn list, still go ahead to issue inquiry.
382fcf3ce44SJohn Forte */
383fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
384fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
385fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
386fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
387fcf3ce44SJohn Forte path_index++;
388fcf3ce44SJohn Forte retval++;
389fcf3ce44SJohn Forte continue;
390fcf3ce44SJohn Forte }
391fcf3ce44SJohn Forte
392fcf3ce44SJohn Forte serial_len = sizeof (inq80.inq_serial);
393fcf3ce44SJohn Forte if (err = g_get_serial_number(path_phys, inq80.inq_serial,
394fcf3ce44SJohn Forte &serial_len)) {
395fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
396fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
397fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
398fcf3ce44SJohn Forte path_index++;
399fcf3ce44SJohn Forte retval++;
400fcf3ce44SJohn Forte continue;
401fcf3ce44SJohn Forte }
402fcf3ce44SJohn Forte print_inq_data(argv[path_index], path_phys, inq,
403fcf3ce44SJohn Forte inq80.inq_serial, serial_len);
404fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
405fcf3ce44SJohn Forte path_index++;
406fcf3ce44SJohn Forte continue;
407fcf3ce44SJohn Forte }
408fcf3ce44SJohn Forte
409fcf3ce44SJohn Forte for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
410fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
411fcf3ce44SJohn Forte if (argpwwn) {
412fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s,
413fcf3ce44SJohn Forte path_struct->argv) != 0) {
414fcf3ce44SJohn Forte continue;
415fcf3ce44SJohn Forte }
416fcf3ce44SJohn Forte (void) strcpy(path_phys,
417fcf3ce44SJohn Forte wwn_list_ptr->physical_path);
418fcf3ce44SJohn Forte } else if (argnwwn) {
419fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->node_wwn_s,
420fcf3ce44SJohn Forte path_struct->argv) != 0) {
421fcf3ce44SJohn Forte continue;
422fcf3ce44SJohn Forte }
423fcf3ce44SJohn Forte if (strstr(wwn_list_ptr->logical_path,
424fcf3ce44SJohn Forte last_logical_path) != NULL) {
425fcf3ce44SJohn Forte continue;
426fcf3ce44SJohn Forte }
427fcf3ce44SJohn Forte (void) strcpy(path_phys,
428fcf3ce44SJohn Forte wwn_list_ptr->physical_path);
429fcf3ce44SJohn Forte (void) strcpy(last_logical_path,
430fcf3ce44SJohn Forte wwn_list_ptr->logical_path);
431fcf3ce44SJohn Forte }
432fcf3ce44SJohn Forte
433fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
434fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
435fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
436fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
437fcf3ce44SJohn Forte retval++;
438fcf3ce44SJohn Forte break;
439fcf3ce44SJohn Forte }
440fcf3ce44SJohn Forte
441fcf3ce44SJohn Forte serial_len = sizeof (inq80.inq_serial);
442fcf3ce44SJohn Forte if (err = g_get_serial_number(path_phys, inq80.inq_serial,
443fcf3ce44SJohn Forte &serial_len)) {
444fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
445fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
446fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
447fcf3ce44SJohn Forte retval++;
448fcf3ce44SJohn Forte break;
449fcf3ce44SJohn Forte }
450fcf3ce44SJohn Forte print_inq_data(argv[path_index], path_phys, inq,
451fcf3ce44SJohn Forte inq80.inq_serial, serial_len);
452fcf3ce44SJohn Forte
453fcf3ce44SJohn Forte }
454fcf3ce44SJohn Forte
455fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
456fcf3ce44SJohn Forte path_index++;
457fcf3ce44SJohn Forte }
458fcf3ce44SJohn Forte return (retval);
459fcf3ce44SJohn Forte }
460fcf3ce44SJohn Forte
461fcf3ce44SJohn Forte /*
462fcf3ce44SJohn Forte * FORCELIP expert function
463fcf3ce44SJohn Forte */
464fcf3ce44SJohn Forte int
adm_forcelip(char ** argv)465fcf3ce44SJohn Forte adm_forcelip(char **argv)
466fcf3ce44SJohn Forte {
467fcf3ce44SJohn Forte int slot, f_r, path_index = 0, err = 0, retval = 0;
468fcf3ce44SJohn Forte Path_struct *path_struct = NULL;
469fcf3ce44SJohn Forte char *path_phys = NULL, *ptr;
470fcf3ce44SJohn Forte char err_path[MAXNAMELEN];
471fcf3ce44SJohn Forte
472fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
473fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
474fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
475fcf3ce44SJohn Forte (void) strcpy(err_path, argv[path_index]);
476fcf3ce44SJohn Forte if (err != -1) {
477fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
478fcf3ce44SJohn Forte path_index++;
479fcf3ce44SJohn Forte retval++;
480fcf3ce44SJohn Forte continue;
481fcf3ce44SJohn Forte }
482fcf3ce44SJohn Forte if (((ptr = strstr(err_path, ", ")) != NULL) &&
483fcf3ce44SJohn Forte ((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
484fcf3ce44SJohn Forte (*(ptr +1) == 's'))) {
485fcf3ce44SJohn Forte *ptr = NULL;
486fcf3ce44SJohn Forte slot = path_struct->slot;
487fcf3ce44SJohn Forte f_r = path_struct->f_flag;
488fcf3ce44SJohn Forte path_phys = NULL;
489fcf3ce44SJohn Forte if ((err = l_convert_name(err_path,
490fcf3ce44SJohn Forte &path_phys, &path_struct,
491fcf3ce44SJohn Forte Options & PVERBOSE)) != 0) {
492fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(33,
493fcf3ce44SJohn Forte " Error: converting"
494fcf3ce44SJohn Forte " %s to physical path.\n"
495fcf3ce44SJohn Forte " Invalid pathname.\n"),
496fcf3ce44SJohn Forte argv[path_index]);
497fcf3ce44SJohn Forte if (err != -1) {
498fcf3ce44SJohn Forte (void) print_errString(err,
499fcf3ce44SJohn Forte argv[path_index]);
500fcf3ce44SJohn Forte }
501fcf3ce44SJohn Forte path_index++;
502fcf3ce44SJohn Forte retval++;
503fcf3ce44SJohn Forte continue;
504fcf3ce44SJohn Forte }
505fcf3ce44SJohn Forte if ((err = print_devState(argv[path_index],
506fcf3ce44SJohn Forte path_struct->p_physical_path,
507fcf3ce44SJohn Forte f_r, slot, Options & PVERBOSE)) != 0) {
508fcf3ce44SJohn Forte path_index++;
509fcf3ce44SJohn Forte retval++;
510fcf3ce44SJohn Forte continue;
511fcf3ce44SJohn Forte }
512fcf3ce44SJohn Forte } else {
513fcf3ce44SJohn Forte (void) fprintf(stderr, "\n ");
514fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(112,
515fcf3ce44SJohn Forte "Error: Invalid pathname (%s)"),
516fcf3ce44SJohn Forte argv[path_index]);
517fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
518fcf3ce44SJohn Forte }
519fcf3ce44SJohn Forte path_index++;
520fcf3ce44SJohn Forte retval++;
521fcf3ce44SJohn Forte continue;
522fcf3ce44SJohn Forte }
523fcf3ce44SJohn Forte if (err = g_force_lip(path_phys, Options & PVERBOSE)) {
524fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
525fcf3ce44SJohn Forte path_index++;
526fcf3ce44SJohn Forte retval++;
527fcf3ce44SJohn Forte continue;
528fcf3ce44SJohn Forte }
529fcf3ce44SJohn Forte path_index++;
530fcf3ce44SJohn Forte if (path_struct != NULL) {
531fcf3ce44SJohn Forte (void) free(path_struct);
532fcf3ce44SJohn Forte }
533fcf3ce44SJohn Forte }
534fcf3ce44SJohn Forte return (retval);
535fcf3ce44SJohn Forte }
536fcf3ce44SJohn Forte
537fcf3ce44SJohn Forte
538fcf3ce44SJohn Forte /*
539fcf3ce44SJohn Forte * DISPLAY function
540fcf3ce44SJohn Forte *
541fcf3ce44SJohn Forte * RETURNS:
542fcf3ce44SJohn Forte * 0 O.K.
543fcf3ce44SJohn Forte */
544fcf3ce44SJohn Forte int
adm_display_config(char ** argv)545fcf3ce44SJohn Forte adm_display_config(char **argv)
546fcf3ce44SJohn Forte {
547fcf3ce44SJohn Forte L_inquiry inq, ses_inq;
548fcf3ce44SJohn Forte int i, slot, f_r, path_index = 0, err = 0, opnerr = 0;
549fcf3ce44SJohn Forte int retval = 0;
550fcf3ce44SJohn Forte gfc_map_t map;
551fcf3ce44SJohn Forte Path_struct *path_struct;
552fcf3ce44SJohn Forte char *path_phys = NULL, *ptr;
553fcf3ce44SJohn Forte char ses_path[MAXPATHLEN], inq_path[MAXNAMELEN];
554fcf3ce44SJohn Forte
555fcf3ce44SJohn Forte
556fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
557fcf3ce44SJohn Forte VERBPRINT(MSGSTR(2108, " Displaying information for: %s\n"),
558fcf3ce44SJohn Forte argv[path_index]);
559fcf3ce44SJohn Forte map.dev_addr = (gfc_port_dev_info_t *)NULL;
560fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
561fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
562fcf3ce44SJohn Forte if (strstr(argv[path_index], SCSI_VHCI) == NULL) {
563fcf3ce44SJohn Forte
564fcf3ce44SJohn Forte (void) strcpy(inq_path, argv[path_index]);
565fcf3ce44SJohn Forte if (((ptr = strstr(inq_path, ",")) != NULL) &&
566fcf3ce44SJohn Forte ((*(ptr + 1) == 'f') || (*(ptr + 1) == 'r') ||
567fcf3ce44SJohn Forte (*(ptr +1) == 's'))) {
568fcf3ce44SJohn Forte
569fcf3ce44SJohn Forte if (err != -1) {
570fcf3ce44SJohn Forte (void) print_errString(err,
571fcf3ce44SJohn Forte argv[path_index]);
572fcf3ce44SJohn Forte path_index++;
573fcf3ce44SJohn Forte retval++;
574fcf3ce44SJohn Forte continue;
575fcf3ce44SJohn Forte }
576fcf3ce44SJohn Forte *ptr = NULL;
577fcf3ce44SJohn Forte slot = path_struct->slot;
578fcf3ce44SJohn Forte f_r = path_struct->f_flag;
579fcf3ce44SJohn Forte if ((err = l_convert_name(inq_path, &path_phys,
580fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE))
581fcf3ce44SJohn Forte != 0) {
582fcf3ce44SJohn Forte
583fcf3ce44SJohn Forte (void) fprintf(stderr,
584fcf3ce44SJohn Forte MSGSTR(33,
585fcf3ce44SJohn Forte " Error: converting"
586fcf3ce44SJohn Forte " %s to physical path.\n"
587fcf3ce44SJohn Forte " Invalid pathname.\n"),
588fcf3ce44SJohn Forte argv[path_index]);
589fcf3ce44SJohn Forte if (err != -1) {
590fcf3ce44SJohn Forte (void) print_errString(err,
591fcf3ce44SJohn Forte argv[path_index]);
592fcf3ce44SJohn Forte }
593fcf3ce44SJohn Forte path_index++;
594fcf3ce44SJohn Forte retval++;
595fcf3ce44SJohn Forte continue;
596fcf3ce44SJohn Forte }
597fcf3ce44SJohn Forte
598fcf3ce44SJohn Forte if ((err = print_devState(argv[path_index],
599fcf3ce44SJohn Forte path_struct->p_physical_path,
600fcf3ce44SJohn Forte f_r, slot, Options & PVERBOSE)) != 0) {
601fcf3ce44SJohn Forte path_index++;
602fcf3ce44SJohn Forte retval++;
603fcf3ce44SJohn Forte continue;
604fcf3ce44SJohn Forte }
605fcf3ce44SJohn Forte } else {
606fcf3ce44SJohn Forte if (err != -1) {
607fcf3ce44SJohn Forte (void) print_errString(err,
608fcf3ce44SJohn Forte argv[path_index]);
609fcf3ce44SJohn Forte } else {
610fcf3ce44SJohn Forte (void) fprintf(stderr, "\n ");
611fcf3ce44SJohn Forte (void) fprintf(stderr,
612fcf3ce44SJohn Forte MSGSTR(112,
613fcf3ce44SJohn Forte "Error: Invalid pathname (%s)"),
614fcf3ce44SJohn Forte argv[path_index]);
615fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
616fcf3ce44SJohn Forte }
617fcf3ce44SJohn Forte }
618fcf3ce44SJohn Forte
619fcf3ce44SJohn Forte } else {
620fcf3ce44SJohn Forte if (err != -1) {
621fcf3ce44SJohn Forte (void) print_errString(err,
622fcf3ce44SJohn Forte argv[path_index]);
623fcf3ce44SJohn Forte } else {
624fcf3ce44SJohn Forte (void) fprintf(stderr, "\n ");
625fcf3ce44SJohn Forte (void) fprintf(stderr,
626fcf3ce44SJohn Forte MSGSTR(112,
627fcf3ce44SJohn Forte "Error: Invalid pathname (%s)"),
628fcf3ce44SJohn Forte argv[path_index]);
629fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
630fcf3ce44SJohn Forte }
631fcf3ce44SJohn Forte }
632fcf3ce44SJohn Forte
633fcf3ce44SJohn Forte path_index++;
634fcf3ce44SJohn Forte retval++;
635fcf3ce44SJohn Forte continue;
636fcf3ce44SJohn Forte }
637fcf3ce44SJohn Forte
638fcf3ce44SJohn Forte /*
639fcf3ce44SJohn Forte * See what kind of device we are talking to.
640fcf3ce44SJohn Forte */
641fcf3ce44SJohn Forte if ((opnerr = g_get_inquiry(path_phys, &inq)) != 0) {
642fcf3ce44SJohn Forte if (opnerr == L_OPEN_PATH_FAIL) {
643fcf3ce44SJohn Forte /*
644fcf3ce44SJohn Forte * We check only for L_OPEN_PATH_FAIL because
645fcf3ce44SJohn Forte * that is the only error code returned by
646fcf3ce44SJohn Forte * g_get_inquiry() which is not got from the ioctl
647fcf3ce44SJohn Forte * call itself. So, we are dependent, in a way, on the
648fcf3ce44SJohn Forte * implementation of g_get_inquiry().
649fcf3ce44SJohn Forte *
650fcf3ce44SJohn Forte */
651fcf3ce44SJohn Forte (void) print_errString(errno, argv[path_index]);
652fcf3ce44SJohn Forte path_index++;
653fcf3ce44SJohn Forte retval++;
654fcf3ce44SJohn Forte continue;
655fcf3ce44SJohn Forte }
656fcf3ce44SJohn Forte } else if (!g_enclDiskChk((char *)inq.inq_vid,
657fcf3ce44SJohn Forte (char *)inq.inq_pid)) {
658fcf3ce44SJohn Forte if ((err = lun_display(path_struct,
659fcf3ce44SJohn Forte inq, Options & PVERBOSE)) != 0) {
660fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
661fcf3ce44SJohn Forte exit(1);
662fcf3ce44SJohn Forte }
663fcf3ce44SJohn Forte } else if (strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != NULL) {
664fcf3ce44SJohn Forte /*
665fcf3ce44SJohn Forte * Display SENA enclosure.
666fcf3ce44SJohn Forte */
667fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t\t\t\t ");
668fcf3ce44SJohn Forte print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
669fcf3ce44SJohn Forte
670fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
671fcf3ce44SJohn Forte if (Options & OPTION_R) {
672fcf3ce44SJohn Forte adm_display_err(path_phys,
673fcf3ce44SJohn Forte (inq.inq_dtype & DTYPE_MASK));
674fcf3ce44SJohn Forte } else {
675fcf3ce44SJohn Forte pho_display_config(path_phys);
676fcf3ce44SJohn Forte }
677fcf3ce44SJohn Forte } else if ((((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)) &&
678fcf3ce44SJohn Forte (l_get_enc_type(inq) == DAK_ENC_TYPE)) {
679fcf3ce44SJohn Forte /*
680fcf3ce44SJohn Forte * Display for the Daktari/DPM
681fcf3ce44SJohn Forte */
682fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t\t");
683fcf3ce44SJohn Forte for (i = 0; i < sizeof (inq.inq_pid); i++) {
684fcf3ce44SJohn Forte (void) fprintf(stdout, "%c", inq.inq_pid[i]);
685fcf3ce44SJohn Forte }
686fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
687fcf3ce44SJohn Forte if (Options & OPTION_R) {
688fcf3ce44SJohn Forte adm_display_err(path_phys,
689fcf3ce44SJohn Forte (inq.inq_dtype & DTYPE_MASK));
690fcf3ce44SJohn Forte } else {
691fcf3ce44SJohn Forte dpm_display_config(path_phys);
692fcf3ce44SJohn Forte }
693fcf3ce44SJohn Forte /*
694fcf3ce44SJohn Forte * if device is in SENA enclosure
695fcf3ce44SJohn Forte *
696fcf3ce44SJohn Forte * if the slot is valid, then I know this is a SENA enclosure
697fcf3ce44SJohn Forte * and can continue
698fcf3ce44SJohn Forte * otherwise:
699fcf3ce44SJohn Forte * I first get the ses_path, if this doesn't fail
700fcf3ce44SJohn Forte * I retrieve the inquiry data from the ses node
701fcf3ce44SJohn Forte * and check teh PID to make sure this is a SENA
702fcf3ce44SJohn Forte */
703fcf3ce44SJohn Forte } else if (((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) &&
704fcf3ce44SJohn Forte ((path_struct->slot_valid == 1) ||
705fcf3ce44SJohn Forte ((g_get_dev_map(path_phys, &map,
706fcf3ce44SJohn Forte (Options & PVERBOSE)) == 0) &&
707fcf3ce44SJohn Forte (l_get_ses_path(path_phys, ses_path,
708fcf3ce44SJohn Forte &map, Options & PVERBOSE) == 0) &&
709fcf3ce44SJohn Forte (g_get_inquiry(ses_path, &ses_inq) == 0) &&
710fcf3ce44SJohn Forte ((strstr((char *)ses_inq.inq_pid, ENCLOSURE_PROD_ID)
711fcf3ce44SJohn Forte != NULL))))) {
712fcf3ce44SJohn Forte if (Options & OPTION_R) {
713fcf3ce44SJohn Forte adm_display_err(path_phys,
714fcf3ce44SJohn Forte (inq.inq_dtype & DTYPE_MASK));
715fcf3ce44SJohn Forte } else {
716fcf3ce44SJohn Forte display_fc_disk(path_struct, ses_path, &map, inq,
717fcf3ce44SJohn Forte Options & PVERBOSE);
718fcf3ce44SJohn Forte }
719fcf3ce44SJohn Forte
720fcf3ce44SJohn Forte } else if (strstr((char *)inq.inq_pid, "SUN_SEN") != 0) {
721fcf3ce44SJohn Forte if (strcmp(argv[path_index], path_phys) != 0) {
722fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
723fcf3ce44SJohn Forte (void) fprintf(stdout,
724fcf3ce44SJohn Forte MSGSTR(5, "Physical Path:"));
725fcf3ce44SJohn Forte (void) fprintf(stdout, "\n %s\n", path_phys);
726fcf3ce44SJohn Forte }
727fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2109, "DEVICE is a "));
728fcf3ce44SJohn Forte print_chars(inq.inq_vid, sizeof (inq.inq_vid), 1);
729fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
730fcf3ce44SJohn Forte print_chars(inq.inq_pid, sizeof (inq.inq_pid), 1);
731fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2110, " card."));
732fcf3ce44SJohn Forte if (inq.inq_len > 31) {
733fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
734fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(26, "Revision:"));
735fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
736fcf3ce44SJohn Forte print_chars(inq.inq_revision,
737fcf3ce44SJohn Forte sizeof (inq.inq_revision), 0);
738fcf3ce44SJohn Forte }
739fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
740fcf3ce44SJohn Forte /* if device is not in SENA or SSA enclosures. */
741fcf3ce44SJohn Forte } else if ((inq.inq_dtype & DTYPE_MASK) < 0x10) {
742fcf3ce44SJohn Forte switch ((inq.inq_dtype & DTYPE_MASK)) {
743fcf3ce44SJohn Forte case DTYPE_DIRECT:
744fcf3ce44SJohn Forte case DTYPE_SEQUENTIAL: /* Tape */
745fcf3ce44SJohn Forte if (Options & OPTION_R) {
746fcf3ce44SJohn Forte adm_display_err(path_phys,
747fcf3ce44SJohn Forte (inq.inq_dtype & DTYPE_MASK));
748fcf3ce44SJohn Forte } else if (non_encl_fc_disk_display(path_struct,
749fcf3ce44SJohn Forte inq, Options & PVERBOSE) != 0) {
750fcf3ce44SJohn Forte (void) fprintf(stderr,
751fcf3ce44SJohn Forte MSGSTR(2111,
752fcf3ce44SJohn Forte "Error: getting the device"
753fcf3ce44SJohn Forte " information.\n"));
754fcf3ce44SJohn Forte retval++;
755fcf3ce44SJohn Forte }
756fcf3ce44SJohn Forte break;
757fcf3ce44SJohn Forte /* case 0x01: same as default */
758fcf3ce44SJohn Forte default:
759fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
760fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(35,
761fcf3ce44SJohn Forte "Device Type:"));
762fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
763fcf3ce44SJohn Forte dtype[inq.inq_dtype & DTYPE_MASK]);
764fcf3ce44SJohn Forte break;
765fcf3ce44SJohn Forte }
766fcf3ce44SJohn Forte } else if ((inq.inq_dtype & DTYPE_MASK) < 0x1f) {
767fcf3ce44SJohn Forte (void) fprintf(stdout,
768fcf3ce44SJohn Forte MSGSTR(2112, " Device type: Reserved"));
769fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
770fcf3ce44SJohn Forte } else {
771fcf3ce44SJohn Forte (void) fprintf(stdout,
772fcf3ce44SJohn Forte MSGSTR(2113, " Device type: Unknown device"));
773fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
774fcf3ce44SJohn Forte }
775fcf3ce44SJohn Forte path_index++;
776fcf3ce44SJohn Forte if (map.dev_addr != NULL) {
777fcf3ce44SJohn Forte free((void *)map.dev_addr);
778fcf3ce44SJohn Forte }
779fcf3ce44SJohn Forte (void) free(path_struct);
780fcf3ce44SJohn Forte }
781fcf3ce44SJohn Forte return (retval);
782fcf3ce44SJohn Forte }
783fcf3ce44SJohn Forte
784fcf3ce44SJohn Forte
785fcf3ce44SJohn Forte /*
786fcf3ce44SJohn Forte * Powers off a list of SENA enclosure(s)
787fcf3ce44SJohn Forte * and disk(s) which is provided by the user.
788fcf3ce44SJohn Forte *
789fcf3ce44SJohn Forte * RETURNS:
790fcf3ce44SJohn Forte * none.
791fcf3ce44SJohn Forte */
792fcf3ce44SJohn Forte int
adm_power_off(char ** argv,int off_flag)793fcf3ce44SJohn Forte adm_power_off(char **argv, int off_flag)
794fcf3ce44SJohn Forte {
795fcf3ce44SJohn Forte int path_index = 0, err = 0, retval = 0;
796fcf3ce44SJohn Forte L_inquiry inq;
797fcf3ce44SJohn Forte char *path_phys = NULL;
798fcf3ce44SJohn Forte Path_struct *path_struct;
799fcf3ce44SJohn Forte
800fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
801fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
802fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
803fcf3ce44SJohn Forte /*
804fcf3ce44SJohn Forte * In case we did not find the device
805fcf3ce44SJohn Forte * in the /devices directory.
806fcf3ce44SJohn Forte *
807fcf3ce44SJohn Forte * Only valid for pathnames like box,f1
808fcf3ce44SJohn Forte */
809fcf3ce44SJohn Forte if (path_struct->ib_path_flag) {
810fcf3ce44SJohn Forte path_phys = path_struct->p_physical_path;
811fcf3ce44SJohn Forte } else {
812fcf3ce44SJohn Forte (void) fprintf(stderr,
813fcf3ce44SJohn Forte MSGSTR(33,
814fcf3ce44SJohn Forte " Error: converting"
815fcf3ce44SJohn Forte " %s to physical path.\n"
816fcf3ce44SJohn Forte " Invalid pathname.\n"),
817fcf3ce44SJohn Forte argv[path_index]);
818fcf3ce44SJohn Forte if (err != -1) {
819fcf3ce44SJohn Forte (void) print_errString(err,
820fcf3ce44SJohn Forte argv[path_index]);
821fcf3ce44SJohn Forte }
822fcf3ce44SJohn Forte path_index++;
823fcf3ce44SJohn Forte retval++;
824fcf3ce44SJohn Forte continue;
825fcf3ce44SJohn Forte }
826fcf3ce44SJohn Forte }
827fcf3ce44SJohn Forte if (path_struct->ib_path_flag) {
828fcf3ce44SJohn Forte /*
829fcf3ce44SJohn Forte * We are addressing a disk using a path
830fcf3ce44SJohn Forte * format type box,f1.
831fcf3ce44SJohn Forte */
832fcf3ce44SJohn Forte if (err = l_dev_pwr_up_down(path_phys,
833fcf3ce44SJohn Forte path_struct, off_flag, Options & PVERBOSE,
834fcf3ce44SJohn Forte Options & OPTION_CAPF)) {
835fcf3ce44SJohn Forte /*
836fcf3ce44SJohn Forte * Is it Bypassed... try to give more
837fcf3ce44SJohn Forte * informtaion.
838fcf3ce44SJohn Forte */
839fcf3ce44SJohn Forte print_devState(argv[path_index],
840fcf3ce44SJohn Forte path_struct->p_physical_path,
841fcf3ce44SJohn Forte path_struct->f_flag, path_struct->slot,
842fcf3ce44SJohn Forte Options & PVERBOSE);
843fcf3ce44SJohn Forte retval++;
844fcf3ce44SJohn Forte }
845fcf3ce44SJohn Forte path_index++;
846fcf3ce44SJohn Forte continue;
847fcf3ce44SJohn Forte }
848fcf3ce44SJohn Forte
849fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
850fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
851fcf3ce44SJohn Forte path_index++;
852fcf3ce44SJohn Forte retval++;
853fcf3ce44SJohn Forte continue;
854fcf3ce44SJohn Forte }
855fcf3ce44SJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
856fcf3ce44SJohn Forte (strncmp((char *)inq.inq_vid, "SUN ",
857fcf3ce44SJohn Forte sizeof (inq.inq_vid)) &&
858fcf3ce44SJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
859fcf3ce44SJohn Forte
860fcf3ce44SJohn Forte if (get_enclStatus(path_phys, argv[path_index],
861fcf3ce44SJohn Forte off_flag) != 0) {
862fcf3ce44SJohn Forte path_index++;
863fcf3ce44SJohn Forte retval++;
864fcf3ce44SJohn Forte continue;
865fcf3ce44SJohn Forte }
866fcf3ce44SJohn Forte /* power off SENA enclosure. */
867fcf3ce44SJohn Forte if (err = l_pho_pwr_up_down(argv[path_index], path_phys,
868fcf3ce44SJohn Forte off_flag, Options & PVERBOSE,
869fcf3ce44SJohn Forte Options & OPTION_CAPF)) {
870fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
871fcf3ce44SJohn Forte retval++;
872fcf3ce44SJohn Forte }
873fcf3ce44SJohn Forte } else if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
874fcf3ce44SJohn Forte if (err = l_dev_pwr_up_down(path_phys,
875fcf3ce44SJohn Forte path_struct, off_flag, Options & PVERBOSE,
876fcf3ce44SJohn Forte Options & OPTION_CAPF)) {
877fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
878fcf3ce44SJohn Forte retval++;
879fcf3ce44SJohn Forte }
880fcf3ce44SJohn Forte } else {
881fcf3ce44SJohn Forte /*
882fcf3ce44SJohn Forte * SSA section:
883fcf3ce44SJohn Forte */
884fcf3ce44SJohn Forte (void) print_errString(L_INVALID_PATH,
885fcf3ce44SJohn Forte argv[path_index]);
886fcf3ce44SJohn Forte }
887fcf3ce44SJohn Forte path_index++;
888fcf3ce44SJohn Forte }
889fcf3ce44SJohn Forte return (retval);
890fcf3ce44SJohn Forte }
891fcf3ce44SJohn Forte
892fcf3ce44SJohn Forte
893fcf3ce44SJohn Forte
894fcf3ce44SJohn Forte void
adm_bypass_enable(char ** argv,int bypass_flag)895fcf3ce44SJohn Forte adm_bypass_enable(char **argv, int bypass_flag)
896fcf3ce44SJohn Forte {
897fcf3ce44SJohn Forte int path_index = 0, err = 0;
898fcf3ce44SJohn Forte L_inquiry inq;
899fcf3ce44SJohn Forte char *path_phys = NULL;
900fcf3ce44SJohn Forte Path_struct *path_struct;
901fcf3ce44SJohn Forte
902fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
903fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
904fcf3ce44SJohn Forte /*
905fcf3ce44SJohn Forte * In case we did not find the device
906fcf3ce44SJohn Forte * in the /devices directory.
907fcf3ce44SJohn Forte *
908fcf3ce44SJohn Forte * Only valid for pathnames like box,f1
909fcf3ce44SJohn Forte */
910fcf3ce44SJohn Forte if (path_struct->ib_path_flag) {
911fcf3ce44SJohn Forte path_phys = path_struct->p_physical_path;
912fcf3ce44SJohn Forte } else {
913fcf3ce44SJohn Forte (void) fprintf(stderr,
914fcf3ce44SJohn Forte MSGSTR(33,
915fcf3ce44SJohn Forte " Error: converting"
916fcf3ce44SJohn Forte " %s to physical path.\n"
917fcf3ce44SJohn Forte " Invalid pathname.\n"),
918fcf3ce44SJohn Forte argv[path_index]);
919fcf3ce44SJohn Forte if (err != -1) {
920fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
921fcf3ce44SJohn Forte }
922fcf3ce44SJohn Forte exit(-1);
923fcf3ce44SJohn Forte }
924fcf3ce44SJohn Forte }
925fcf3ce44SJohn Forte if (path_struct->ib_path_flag) {
926fcf3ce44SJohn Forte if (Options & OPTION_F) {
927fcf3ce44SJohn Forte E_USEAGE();
928fcf3ce44SJohn Forte exit(-1);
929fcf3ce44SJohn Forte }
930fcf3ce44SJohn Forte /*
931fcf3ce44SJohn Forte * We are addressing a disk using a path
932fcf3ce44SJohn Forte * format type box,f1 and no disk
933fcf3ce44SJohn Forte * path was found.
934fcf3ce44SJohn Forte * So set the Force flag so no reserved/busy
935fcf3ce44SJohn Forte * check is performed.
936fcf3ce44SJohn Forte */
937fcf3ce44SJohn Forte if (err = l_dev_bypass_enable(path_struct,
938fcf3ce44SJohn Forte bypass_flag, OPTION_CAPF,
939fcf3ce44SJohn Forte Options & OPTION_A,
940fcf3ce44SJohn Forte Options & PVERBOSE)) {
941fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
942fcf3ce44SJohn Forte exit(-1);
943fcf3ce44SJohn Forte }
944fcf3ce44SJohn Forte return;
945fcf3ce44SJohn Forte }
946fcf3ce44SJohn Forte
947fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
948fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
949fcf3ce44SJohn Forte exit(-1);
950fcf3ce44SJohn Forte }
951fcf3ce44SJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
952fcf3ce44SJohn Forte (strncmp((char *)inq.inq_vid, "SUN ",
953fcf3ce44SJohn Forte sizeof (inq.inq_vid)) &&
954fcf3ce44SJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
955fcf3ce44SJohn Forte if ((!((Options & OPTION_F) ||
956fcf3ce44SJohn Forte (Options & OPTION_R))) ||
957fcf3ce44SJohn Forte ((Options & OPTION_R) &&
958fcf3ce44SJohn Forte (Options & OPTION_F))) {
959fcf3ce44SJohn Forte E_USEAGE();
960fcf3ce44SJohn Forte exit(-1);
961fcf3ce44SJohn Forte }
962fcf3ce44SJohn Forte if (err = l_bp_bypass_enable(path_phys, bypass_flag,
963fcf3ce44SJohn Forte Options & OPTION_A,
964fcf3ce44SJohn Forte Options & OPTION_F,
965fcf3ce44SJohn Forte Options & OPTION_CAPF,
966fcf3ce44SJohn Forte Options & PVERBOSE)) {
967fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
968fcf3ce44SJohn Forte exit(-1);
969fcf3ce44SJohn Forte }
970fcf3ce44SJohn Forte } else if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
971fcf3ce44SJohn Forte if (Options & OPTION_F) {
972fcf3ce44SJohn Forte E_USEAGE();
973fcf3ce44SJohn Forte exit(-1);
974fcf3ce44SJohn Forte }
975fcf3ce44SJohn Forte if (err = l_dev_bypass_enable(path_struct,
976fcf3ce44SJohn Forte bypass_flag, Options & OPTION_CAPF,
977fcf3ce44SJohn Forte Options & OPTION_A,
978fcf3ce44SJohn Forte Options & PVERBOSE)) {
979fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
980fcf3ce44SJohn Forte exit(-1);
981fcf3ce44SJohn Forte }
982fcf3ce44SJohn Forte }
983fcf3ce44SJohn Forte }
984fcf3ce44SJohn Forte
985fcf3ce44SJohn Forte /*
986fcf3ce44SJohn Forte * adm_download() Download subsystem microcode.
987fcf3ce44SJohn Forte * Path must point to a LUX IB.
988fcf3ce44SJohn Forte *
989fcf3ce44SJohn Forte * RETURNS:
990fcf3ce44SJohn Forte * None.
991fcf3ce44SJohn Forte */
992fcf3ce44SJohn Forte void
adm_download(char ** argv,char * file_name)993fcf3ce44SJohn Forte adm_download(char **argv, char *file_name)
994fcf3ce44SJohn Forte {
995fcf3ce44SJohn Forte int path_index = 0, err = 0;
996fcf3ce44SJohn Forte char *path_phys = NULL;
997fcf3ce44SJohn Forte L_inquiry inq;
998fcf3ce44SJohn Forte Path_struct *path_struct;
999fcf3ce44SJohn Forte
1000fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
1001fcf3ce44SJohn Forte /*
1002fcf3ce44SJohn Forte * See what kind of device we are talking to.
1003fcf3ce44SJohn Forte */
1004fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
1005fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
1006fcf3ce44SJohn Forte (void) fprintf(stderr,
1007fcf3ce44SJohn Forte MSGSTR(33,
1008fcf3ce44SJohn Forte " Error: converting"
1009fcf3ce44SJohn Forte " %s to physical path.\n"
1010fcf3ce44SJohn Forte " Invalid pathname.\n"),
1011fcf3ce44SJohn Forte argv[path_index]);
1012fcf3ce44SJohn Forte if (err != -1) {
1013fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1014fcf3ce44SJohn Forte }
1015fcf3ce44SJohn Forte exit(-1);
1016fcf3ce44SJohn Forte }
1017fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
1018fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1019fcf3ce44SJohn Forte exit(-1);
1020fcf3ce44SJohn Forte }
1021fcf3ce44SJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) != 0) ||
1022fcf3ce44SJohn Forte (strncmp((char *)inq.inq_vid, "SUN ",
1023fcf3ce44SJohn Forte sizeof (inq.inq_vid)) &&
1024fcf3ce44SJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI))) {
1025fcf3ce44SJohn Forte if (err = l_download(path_phys,
1026fcf3ce44SJohn Forte file_name, (Options & SAVE),
1027fcf3ce44SJohn Forte (Options & PVERBOSE))) {
1028fcf3ce44SJohn Forte (void) print_errString(err,
1029fcf3ce44SJohn Forte (err == L_OPEN_PATH_FAIL) ?
1030fcf3ce44SJohn Forte argv[path_index]: file_name);
1031fcf3ce44SJohn Forte exit(-1);
1032fcf3ce44SJohn Forte }
1033fcf3ce44SJohn Forte } else {
1034fcf3ce44SJohn Forte (void) fprintf(stderr,
1035fcf3ce44SJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
1036fcf3ce44SJohn Forte argv[path_index]);
1037fcf3ce44SJohn Forte }
1038fcf3ce44SJohn Forte path_index++;
1039fcf3ce44SJohn Forte }
1040fcf3ce44SJohn Forte }
1041fcf3ce44SJohn Forte
1042fcf3ce44SJohn Forte /*
1043fcf3ce44SJohn Forte * display_link_status() Reads and displays the link status.
1044fcf3ce44SJohn Forte *
1045fcf3ce44SJohn Forte * RETURNS:
1046fcf3ce44SJohn Forte * none.
1047fcf3ce44SJohn Forte */
1048fcf3ce44SJohn Forte void
display_link_status(char ** argv)1049fcf3ce44SJohn Forte display_link_status(char **argv)
1050fcf3ce44SJohn Forte {
1051fcf3ce44SJohn Forte AL_rls *rls = NULL, *n;
1052fcf3ce44SJohn Forte int path_index = 0, err = 0;
1053fcf3ce44SJohn Forte char *path_phys = NULL;
1054fcf3ce44SJohn Forte Path_struct *path_struct;
1055fcf3ce44SJohn Forte
1056fcf3ce44SJohn Forte
1057fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
1058fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
1059fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
1060fcf3ce44SJohn Forte (void) fprintf(stderr,
1061fcf3ce44SJohn Forte MSGSTR(33,
1062fcf3ce44SJohn Forte " Error: converting"
1063fcf3ce44SJohn Forte " %s to physical path.\n"
1064fcf3ce44SJohn Forte " Invalid pathname.\n"),
1065fcf3ce44SJohn Forte argv[path_index]);
1066fcf3ce44SJohn Forte if (err != -1) {
1067fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1068fcf3ce44SJohn Forte }
1069fcf3ce44SJohn Forte exit(-1);
1070fcf3ce44SJohn Forte }
1071fcf3ce44SJohn Forte if (err = g_rdls(path_phys, &rls, Options & PVERBOSE)) {
1072fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1073fcf3ce44SJohn Forte exit(-1);
1074fcf3ce44SJohn Forte }
1075fcf3ce44SJohn Forte n = rls;
1076fcf3ce44SJohn Forte if (n != NULL) {
1077fcf3ce44SJohn Forte (void) fprintf(stdout,
1078fcf3ce44SJohn Forte MSGSTR(2007, "\nLink Error Status "
1079fcf3ce44SJohn Forte "information for loop:%s\n"),
1080fcf3ce44SJohn Forte n->driver_path);
1081fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2008, "al_pa lnk fail "
1082fcf3ce44SJohn Forte " sync loss signal loss sequence err"
1083fcf3ce44SJohn Forte " invalid word CRC\n"));
1084fcf3ce44SJohn Forte }
1085fcf3ce44SJohn Forte while (n) {
1086fcf3ce44SJohn Forte if ((n->payload.rls_linkfail == 0xffffffff) &&
1087fcf3ce44SJohn Forte (n->payload.rls_syncfail == 0xffffffff) &&
1088fcf3ce44SJohn Forte (n->payload.rls_sigfail == 0xffffffff) &&
1089fcf3ce44SJohn Forte (n->payload.rls_primitiverr == 0xffffffff) &&
1090fcf3ce44SJohn Forte (n->payload.rls_invalidword == 0xffffffff) &&
1091fcf3ce44SJohn Forte (n->payload.rls_invalidcrc == 0xffffffff)) {
1092fcf3ce44SJohn Forte (void) fprintf(stdout,
1093fcf3ce44SJohn Forte "%x\t%-12d%-12d%-14d%-15d%-15d%-12d\n",
1094fcf3ce44SJohn Forte n->al_ha,
1095fcf3ce44SJohn Forte n->payload.rls_linkfail,
1096fcf3ce44SJohn Forte n->payload.rls_syncfail,
1097fcf3ce44SJohn Forte n->payload.rls_sigfail,
1098fcf3ce44SJohn Forte n->payload.rls_primitiverr,
1099fcf3ce44SJohn Forte n->payload.rls_invalidword,
1100fcf3ce44SJohn Forte n->payload.rls_invalidcrc);
1101fcf3ce44SJohn Forte } else {
1102fcf3ce44SJohn Forte (void) fprintf(stdout,
1103fcf3ce44SJohn Forte "%x\t%-12u%-12u%-14u%-15u%-15u%-12u\n",
1104fcf3ce44SJohn Forte n->al_ha,
1105fcf3ce44SJohn Forte n->payload.rls_linkfail,
1106fcf3ce44SJohn Forte n->payload.rls_syncfail,
1107fcf3ce44SJohn Forte n->payload.rls_sigfail,
1108fcf3ce44SJohn Forte n->payload.rls_primitiverr,
1109fcf3ce44SJohn Forte n->payload.rls_invalidword,
1110fcf3ce44SJohn Forte n->payload.rls_invalidcrc);
1111fcf3ce44SJohn Forte }
1112fcf3ce44SJohn Forte n = n->next;
1113fcf3ce44SJohn Forte }
1114fcf3ce44SJohn Forte
1115fcf3ce44SJohn Forte path_index++;
1116fcf3ce44SJohn Forte }
1117fcf3ce44SJohn Forte (void) fprintf(stdout,
1118fcf3ce44SJohn Forte MSGSTR(2009, "NOTE: These LESB counts are not"
1119fcf3ce44SJohn Forte " cleared by a reset, only power cycles.\n"
1120fcf3ce44SJohn Forte "These counts must be compared"
1121fcf3ce44SJohn Forte " to previously read counts.\n"));
1122fcf3ce44SJohn Forte }
1123fcf3ce44SJohn Forte
1124fcf3ce44SJohn Forte
1125fcf3ce44SJohn Forte /*
1126fcf3ce44SJohn Forte * ib_present_chk() Check to see if IB 0 or 1 is present in the box.
1127fcf3ce44SJohn Forte *
1128fcf3ce44SJohn Forte * RETURN:
1129fcf3ce44SJohn Forte * 1 if ib present
1130fcf3ce44SJohn Forte * 0 otherwise
1131fcf3ce44SJohn Forte */
1132fcf3ce44SJohn Forte int
ib_present_chk(struct l_state_struct * l_state,int which_one)1133fcf3ce44SJohn Forte ib_present_chk(struct l_state_struct *l_state, int which_one)
1134fcf3ce44SJohn Forte {
1135fcf3ce44SJohn Forte Ctlr_elem_st ctlr;
1136fcf3ce44SJohn Forte int i;
1137fcf3ce44SJohn Forte int elem_index = 0;
1138fcf3ce44SJohn Forte int result = 1;
1139fcf3ce44SJohn Forte
1140fcf3ce44SJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
1141fcf3ce44SJohn Forte elem_index++; /* skip global */
1142fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_IB) {
1143fcf3ce44SJohn Forte (void) bcopy((const void *)
1144fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + which_one],
1145fcf3ce44SJohn Forte (void *)&ctlr, sizeof (ctlr));
1146fcf3ce44SJohn Forte if (ctlr.code == S_NOT_INSTALLED) {
1147fcf3ce44SJohn Forte result = 0;
1148fcf3ce44SJohn Forte }
1149fcf3ce44SJohn Forte break;
1150fcf3ce44SJohn Forte }
1151fcf3ce44SJohn Forte elem_index += l_state->ib_tbl.config.type_hdr[i].num;
1152fcf3ce44SJohn Forte }
1153fcf3ce44SJohn Forte return (result);
1154fcf3ce44SJohn Forte }
1155fcf3ce44SJohn Forte
1156fcf3ce44SJohn Forte /*
1157fcf3ce44SJohn Forte * print_individual_state() Print individual disk status.
1158fcf3ce44SJohn Forte *
1159fcf3ce44SJohn Forte * RETURNS:
1160fcf3ce44SJohn Forte * none.
1161fcf3ce44SJohn Forte */
1162fcf3ce44SJohn Forte void
print_individual_state(int status,int port)1163fcf3ce44SJohn Forte print_individual_state(int status, int port)
1164fcf3ce44SJohn Forte {
1165fcf3ce44SJohn Forte if (status & L_OPEN_FAIL) {
1166fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1167fcf3ce44SJohn Forte (void) fprintf(stdout,
1168fcf3ce44SJohn Forte MSGSTR(28, "Open Failed"));
1169fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1170fcf3ce44SJohn Forte } else if (status & L_NOT_READY) {
1171fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1172fcf3ce44SJohn Forte (void) fprintf(stdout,
1173fcf3ce44SJohn Forte MSGSTR(20, "Not Ready"));
1174fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1175fcf3ce44SJohn Forte } else if (status & L_NOT_READABLE) {
1176fcf3ce44SJohn Forte (void) fprintf(stdout, "(");
1177fcf3ce44SJohn Forte (void) fprintf(stdout,
1178fcf3ce44SJohn Forte MSGSTR(88, "Not Readable"));
1179fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1180fcf3ce44SJohn Forte } else if (status & L_SPUN_DWN_D) {
1181fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1182fcf3ce44SJohn Forte (void) fprintf(stdout,
1183fcf3ce44SJohn Forte MSGSTR(68, "Spun Down"));
1184fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1185fcf3ce44SJohn Forte } else if (status & L_SCSI_ERR) {
1186fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1187fcf3ce44SJohn Forte (void) fprintf(stdout,
1188fcf3ce44SJohn Forte MSGSTR(70, "SCSI Error"));
1189fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1190fcf3ce44SJohn Forte } else if (status & L_RESERVED) {
1191fcf3ce44SJohn Forte if (port == PORT_A) {
1192fcf3ce44SJohn Forte (void) fprintf(stdout,
1193fcf3ce44SJohn Forte MSGSTR(2010,
1194fcf3ce44SJohn Forte " (Rsrv cnflt:A) "));
1195fcf3ce44SJohn Forte } else if (port == PORT_B) {
1196fcf3ce44SJohn Forte (void) fprintf(stdout,
1197fcf3ce44SJohn Forte MSGSTR(2011,
1198fcf3ce44SJohn Forte " (Rsrv cnflt:B) "));
1199fcf3ce44SJohn Forte } else {
1200fcf3ce44SJohn Forte (void) fprintf(stdout,
1201fcf3ce44SJohn Forte MSGSTR(2012,
1202fcf3ce44SJohn Forte " (Reserve cnflt)"));
1203fcf3ce44SJohn Forte }
1204fcf3ce44SJohn Forte } else if (status & L_NO_LABEL) {
1205fcf3ce44SJohn Forte (void) fprintf(stdout, "(");
1206fcf3ce44SJohn Forte (void) fprintf(stdout,
1207fcf3ce44SJohn Forte MSGSTR(92, "No UNIX Label"));
1208fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1209fcf3ce44SJohn Forte }
1210fcf3ce44SJohn Forte }
1211fcf3ce44SJohn Forte
1212fcf3ce44SJohn Forte
1213fcf3ce44SJohn Forte /*
1214fcf3ce44SJohn Forte * display_disk_msg() Displays status for
1215fcf3ce44SJohn Forte * an individual SENA device.
1216fcf3ce44SJohn Forte *
1217fcf3ce44SJohn Forte * RETURNS:
1218fcf3ce44SJohn Forte * none.
1219fcf3ce44SJohn Forte */
1220fcf3ce44SJohn Forte void
display_disk_msg(struct l_disk_state_struct * dsk_ptr,struct l_state_struct * l_state,Bp_elem_st * bp,int front_flag)1221fcf3ce44SJohn Forte display_disk_msg(struct l_disk_state_struct *dsk_ptr,
1222fcf3ce44SJohn Forte struct l_state_struct *l_state, Bp_elem_st *bp, int front_flag)
1223fcf3ce44SJohn Forte {
1224fcf3ce44SJohn Forte int loop_flag = 0;
1225fcf3ce44SJohn Forte int a_and_b = 0;
1226fcf3ce44SJohn Forte int state_a = 0, state_b = 0;
1227fcf3ce44SJohn Forte
1228fcf3ce44SJohn Forte if (dsk_ptr->ib_status.code == S_NOT_INSTALLED) {
1229fcf3ce44SJohn Forte (void) fprintf(stdout,
1230fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
1231fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1232fcf3ce44SJohn Forte if (dsk_ptr->ib_status.fault ||
1233fcf3ce44SJohn Forte dsk_ptr->ib_status.fault_req) {
1234fcf3ce44SJohn Forte (void) fprintf(stdout, "(");
1235fcf3ce44SJohn Forte (void) fprintf(stdout,
1236fcf3ce44SJohn Forte MSGSTR(2013, "Faulted"));
1237fcf3ce44SJohn Forte (void) fprintf(stdout,
1238fcf3ce44SJohn Forte ") ");
1239fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.ident ||
1240fcf3ce44SJohn Forte dsk_ptr->ib_status.rdy_to_ins ||
1241fcf3ce44SJohn Forte dsk_ptr->ib_status.rmv) {
1242fcf3ce44SJohn Forte (void) fprintf(stdout,
1243fcf3ce44SJohn Forte MSGSTR(2014,
1244fcf3ce44SJohn Forte "(LED Blinking) "));
1245fcf3ce44SJohn Forte } else {
1246fcf3ce44SJohn Forte (void) fprintf(stdout,
1247fcf3ce44SJohn Forte " ");
1248fcf3ce44SJohn Forte }
1249fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.dev_off) {
1250fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2015, "Off"));
1251fcf3ce44SJohn Forte if (dsk_ptr->ib_status.fault || dsk_ptr->ib_status.fault_req) {
1252fcf3ce44SJohn Forte (void) fprintf(stdout, "(");
1253fcf3ce44SJohn Forte (void) fprintf(stdout,
1254fcf3ce44SJohn Forte MSGSTR(2016, "Faulted"));
1255fcf3ce44SJohn Forte (void) fprintf(stdout,
1256fcf3ce44SJohn Forte ") ");
1257fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.bypass_a_en &&
1258fcf3ce44SJohn Forte dsk_ptr->ib_status.bypass_b_en) {
1259fcf3ce44SJohn Forte (void) fprintf(stdout,
1260fcf3ce44SJohn Forte MSGSTR(2017,
1261fcf3ce44SJohn Forte "(Bypassed:AB)"));
1262fcf3ce44SJohn Forte (void) fprintf(stdout,
1263fcf3ce44SJohn Forte " ");
1264fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.bypass_a_en) {
1265fcf3ce44SJohn Forte (void) fprintf(stdout,
1266fcf3ce44SJohn Forte MSGSTR(2018,
1267fcf3ce44SJohn Forte "(Bypassed: A)"));
1268fcf3ce44SJohn Forte (void) fprintf(stdout,
1269fcf3ce44SJohn Forte " ");
1270fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.bypass_b_en) {
1271fcf3ce44SJohn Forte (void) fprintf(stdout,
1272fcf3ce44SJohn Forte MSGSTR(2019,
1273fcf3ce44SJohn Forte "(Bypassed: B)"));
1274fcf3ce44SJohn Forte (void) fprintf(stdout,
1275fcf3ce44SJohn Forte " ");
1276fcf3ce44SJohn Forte } else {
1277fcf3ce44SJohn Forte (void) fprintf(stdout,
1278fcf3ce44SJohn Forte " ");
1279fcf3ce44SJohn Forte }
1280fcf3ce44SJohn Forte } else {
1281fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2020, "On"));
1282fcf3ce44SJohn Forte
1283fcf3ce44SJohn Forte if (dsk_ptr->ib_status.fault || dsk_ptr->ib_status.fault_req) {
1284fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1285fcf3ce44SJohn Forte (void) fprintf(stdout,
1286fcf3ce44SJohn Forte MSGSTR(2021, "Faulted"));
1287fcf3ce44SJohn Forte (void) fprintf(stdout, ") ");
1288fcf3ce44SJohn Forte } else if (dsk_ptr->ib_status.bypass_a_en &&
1289fcf3ce44SJohn Forte dsk_ptr->ib_status.bypass_b_en) {
1290fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1291fcf3ce44SJohn Forte (void) fprintf(stdout,
1292fcf3ce44SJohn Forte MSGSTR(2022, "(Bypassed:AB)"));
1293fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1294fcf3ce44SJohn Forte } else if (ib_present_chk(l_state, 0) &&
1295fcf3ce44SJohn Forte dsk_ptr->ib_status.bypass_a_en) {
1296fcf3ce44SJohn Forte /*
1297fcf3ce44SJohn Forte * Before printing that the port is bypassed
1298fcf3ce44SJohn Forte * verify that there is an IB for this port.
1299fcf3ce44SJohn Forte * If not then don't print.
1300fcf3ce44SJohn Forte */
1301fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1302fcf3ce44SJohn Forte (void) fprintf(stdout,
1303fcf3ce44SJohn Forte MSGSTR(2023, "(Bypassed: A)"));
1304fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1305fcf3ce44SJohn Forte } else if (ib_present_chk(l_state, 1) &&
1306fcf3ce44SJohn Forte dsk_ptr->ib_status.bypass_b_en) {
1307fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1308fcf3ce44SJohn Forte (void) fprintf(stdout,
1309fcf3ce44SJohn Forte MSGSTR(2024, "(Bypassed: B)"));
1310fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1311fcf3ce44SJohn Forte } else if ((bp->code != S_NOT_INSTALLED) &&
1312fcf3ce44SJohn Forte ((bp->byp_a_enabled || bp->en_bypass_a) &&
1313fcf3ce44SJohn Forte !(bp->byp_b_enabled || bp->en_bypass_b))) {
1314fcf3ce44SJohn Forte (void) fprintf(stdout,
1315fcf3ce44SJohn Forte MSGSTR(2025,
1316fcf3ce44SJohn Forte " (Bypassed BP: A)"));
1317fcf3ce44SJohn Forte } else if ((bp->code != S_NOT_INSTALLED) &&
1318fcf3ce44SJohn Forte ((bp->byp_b_enabled || bp->en_bypass_b) &&
1319fcf3ce44SJohn Forte !(bp->byp_a_enabled || bp->en_bypass_a))) {
1320fcf3ce44SJohn Forte (void) fprintf(stdout,
1321fcf3ce44SJohn Forte MSGSTR(2026,
1322fcf3ce44SJohn Forte "(Bypassed BP: B)"));
1323fcf3ce44SJohn Forte } else if ((bp->code != S_NOT_INSTALLED) &&
1324fcf3ce44SJohn Forte ((bp->byp_a_enabled || bp->en_bypass_a) &&
1325fcf3ce44SJohn Forte (bp->byp_b_enabled || bp->en_bypass_b))) {
1326fcf3ce44SJohn Forte (void) fprintf(stdout,
1327fcf3ce44SJohn Forte MSGSTR(2027,
1328fcf3ce44SJohn Forte "(Bypassed BP:AB)"));
1329fcf3ce44SJohn Forte } else {
1330fcf3ce44SJohn Forte state_a = dsk_ptr->g_disk_state.d_state_flags[PORT_A];
1331fcf3ce44SJohn Forte state_b = dsk_ptr->g_disk_state.d_state_flags[PORT_B];
1332fcf3ce44SJohn Forte a_and_b = state_a & state_b;
1333fcf3ce44SJohn Forte
1334fcf3ce44SJohn Forte if (dsk_ptr->l_state_flag & L_NO_LOOP) {
1335fcf3ce44SJohn Forte (void) fprintf(stdout,
1336fcf3ce44SJohn Forte MSGSTR(2028,
1337fcf3ce44SJohn Forte " (Loop not accessible)"));
1338fcf3ce44SJohn Forte loop_flag = 1;
1339fcf3ce44SJohn Forte } else if (dsk_ptr->l_state_flag & L_INVALID_WWN) {
1340fcf3ce44SJohn Forte (void) fprintf(stdout,
1341fcf3ce44SJohn Forte MSGSTR(2029,
1342fcf3ce44SJohn Forte " (Invalid WWN) "));
1343fcf3ce44SJohn Forte } else if (dsk_ptr->l_state_flag & L_INVALID_MAP) {
1344fcf3ce44SJohn Forte (void) fprintf(stdout,
1345fcf3ce44SJohn Forte MSGSTR(2030,
1346fcf3ce44SJohn Forte " (Login failed) "));
1347fcf3ce44SJohn Forte } else if (dsk_ptr->l_state_flag & L_NO_PATH_FOUND) {
1348fcf3ce44SJohn Forte (void) fprintf(stdout,
1349fcf3ce44SJohn Forte MSGSTR(2031,
1350fcf3ce44SJohn Forte " (No path found)"));
1351fcf3ce44SJohn Forte } else if (a_and_b) {
1352fcf3ce44SJohn Forte print_individual_state(a_and_b, PORT_A_B);
1353fcf3ce44SJohn Forte } else if (state_a && (!state_b)) {
1354fcf3ce44SJohn Forte print_individual_state(state_a, PORT_A);
1355fcf3ce44SJohn Forte } else if ((!state_a) && state_b) {
1356fcf3ce44SJohn Forte print_individual_state(state_b, PORT_B);
1357fcf3ce44SJohn Forte } else if (state_a || state_b) {
1358fcf3ce44SJohn Forte /* NOTE: Double state - should do 2 lines. */
1359fcf3ce44SJohn Forte print_individual_state(state_a | state_b,
1360fcf3ce44SJohn Forte PORT_A_B);
1361fcf3ce44SJohn Forte } else {
1362fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
1363fcf3ce44SJohn Forte (void) fprintf(stdout,
1364fcf3ce44SJohn Forte MSGSTR(29, "O.K."));
1365fcf3ce44SJohn Forte (void) fprintf(stdout,
1366fcf3ce44SJohn Forte ") ");
1367fcf3ce44SJohn Forte }
1368fcf3ce44SJohn Forte }
1369fcf3ce44SJohn Forte if (loop_flag) {
1370fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1371fcf3ce44SJohn Forte } else if (strlen(dsk_ptr->g_disk_state.node_wwn_s)) {
1372fcf3ce44SJohn Forte (void) fprintf(stdout, "%s",
1373fcf3ce44SJohn Forte dsk_ptr->g_disk_state.node_wwn_s);
1374fcf3ce44SJohn Forte } else {
1375fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1376fcf3ce44SJohn Forte }
1377fcf3ce44SJohn Forte }
1378fcf3ce44SJohn Forte if (front_flag) {
1379fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1380fcf3ce44SJohn Forte }
1381fcf3ce44SJohn Forte }
1382fcf3ce44SJohn Forte
1383fcf3ce44SJohn Forte
1384fcf3ce44SJohn Forte
1385fcf3ce44SJohn Forte /*
1386fcf3ce44SJohn Forte * pho_display_config() Displays device status
1387fcf3ce44SJohn Forte * information for a SENA enclosure.
1388fcf3ce44SJohn Forte *
1389fcf3ce44SJohn Forte * RETURNS:
1390fcf3ce44SJohn Forte * none.
1391fcf3ce44SJohn Forte */
1392fcf3ce44SJohn Forte void
pho_display_config(char * path_phys)1393fcf3ce44SJohn Forte pho_display_config(char *path_phys)
1394fcf3ce44SJohn Forte {
1395fcf3ce44SJohn Forte L_state l_state;
1396fcf3ce44SJohn Forte Bp_elem_st bpf, bpr;
1397fcf3ce44SJohn Forte int i, j, elem_index = 0, err = 0;
1398fcf3ce44SJohn Forte
1399fcf3ce44SJohn Forte
1400fcf3ce44SJohn Forte /* Get global status */
1401fcf3ce44SJohn Forte if (err = l_get_status(path_phys, &l_state,
1402fcf3ce44SJohn Forte (Options & PVERBOSE))) {
1403fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
1404fcf3ce44SJohn Forte exit(-1);
1405fcf3ce44SJohn Forte }
1406fcf3ce44SJohn Forte
1407fcf3ce44SJohn Forte /*
1408fcf3ce44SJohn Forte * Look for abnormal status.
1409fcf3ce44SJohn Forte */
1410fcf3ce44SJohn Forte if (l_state.ib_tbl.p2_s.ui.ab_cond) {
1411fcf3ce44SJohn Forte abnormal_condition_display(&l_state);
1412fcf3ce44SJohn Forte }
1413fcf3ce44SJohn Forte
1414fcf3ce44SJohn Forte (void) fprintf(stdout,
1415fcf3ce44SJohn Forte MSGSTR(2032, " DISK STATUS \n"
1416fcf3ce44SJohn Forte "SLOT FRONT DISKS (Node WWN) "
1417fcf3ce44SJohn Forte " REAR DISKS (Node WWN)\n"));
1418fcf3ce44SJohn Forte /*
1419fcf3ce44SJohn Forte * Print the status for each disk
1420fcf3ce44SJohn Forte */
1421fcf3ce44SJohn Forte for (j = 0; j < (int)l_state.ib_tbl.config.enc_num_elem; j++) {
1422fcf3ce44SJohn Forte elem_index++;
1423fcf3ce44SJohn Forte if (l_state.ib_tbl.config.type_hdr[j].type == ELM_TYP_BP)
1424fcf3ce44SJohn Forte break;
1425fcf3ce44SJohn Forte elem_index += l_state.ib_tbl.config.type_hdr[j].num;
1426fcf3ce44SJohn Forte }
1427fcf3ce44SJohn Forte (void) bcopy((const void *)
1428fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index]),
1429fcf3ce44SJohn Forte (void *)&bpf, sizeof (bpf));
1430fcf3ce44SJohn Forte (void) bcopy((const void *)
1431fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index + 1]),
1432fcf3ce44SJohn Forte (void *)&bpr, sizeof (bpr));
1433fcf3ce44SJohn Forte
1434fcf3ce44SJohn Forte for (i = 0; i < (int)l_state.total_num_drv/2; i++) {
1435fcf3ce44SJohn Forte (void) fprintf(stdout, "%-2d ", i);
1436fcf3ce44SJohn Forte display_disk_msg(&l_state.drv_front[i], &l_state, &bpf, 1);
1437fcf3ce44SJohn Forte display_disk_msg(&l_state.drv_rear[i], &l_state, &bpr, 0);
1438fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1439fcf3ce44SJohn Forte }
1440fcf3ce44SJohn Forte
1441fcf3ce44SJohn Forte
1442fcf3ce44SJohn Forte
1443fcf3ce44SJohn Forte /*
1444fcf3ce44SJohn Forte * Display the subsystem status.
1445fcf3ce44SJohn Forte */
1446fcf3ce44SJohn Forte (void) fprintf(stdout,
1447fcf3ce44SJohn Forte MSGSTR(2242,
1448fcf3ce44SJohn Forte " SUBSYSTEM STATUS\nFW Revision:"));
1449fcf3ce44SJohn Forte print_chars(l_state.ib_tbl.config.prod_revision,
1450fcf3ce44SJohn Forte sizeof (l_state.ib_tbl.config.prod_revision), 1);
1451fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2034, " Box ID:%d"),
1452fcf3ce44SJohn Forte l_state.ib_tbl.box_id);
1453fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
1454fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
1455fcf3ce44SJohn Forte for (i = 0; i < 8; i++) {
1456fcf3ce44SJohn Forte (void) fprintf(stdout, "%1.2x",
1457fcf3ce44SJohn Forte l_state.ib_tbl.config.enc_node_wwn[i]);
1458fcf3ce44SJohn Forte }
1459fcf3ce44SJohn Forte /* Make sure NULL terminated although it is supposed to be */
1460fcf3ce44SJohn Forte if (strlen((const char *)l_state.ib_tbl.enclosure_name) <=
1461fcf3ce44SJohn Forte sizeof (l_state.ib_tbl.enclosure_name)) {
1462fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2035, " Enclosure Name:%s\n"),
1463fcf3ce44SJohn Forte l_state.ib_tbl.enclosure_name);
1464fcf3ce44SJohn Forte }
1465fcf3ce44SJohn Forte
1466fcf3ce44SJohn Forte /*
1467fcf3ce44SJohn Forte *
1468fcf3ce44SJohn Forte */
1469fcf3ce44SJohn Forte elem_index = 0;
1470fcf3ce44SJohn Forte /* Get and print CONTROLLER messages */
1471fcf3ce44SJohn Forte for (i = 0; i < (int)l_state.ib_tbl.config.enc_num_elem; i++) {
1472fcf3ce44SJohn Forte elem_index++; /* skip global */
1473fcf3ce44SJohn Forte switch (l_state.ib_tbl.config.type_hdr[i].type) {
1474fcf3ce44SJohn Forte case ELM_TYP_PS:
1475fcf3ce44SJohn Forte ps_messages(&l_state, i, elem_index);
1476fcf3ce44SJohn Forte break;
1477fcf3ce44SJohn Forte case ELM_TYP_FT:
1478fcf3ce44SJohn Forte fan_messages(&l_state, i, elem_index);
1479fcf3ce44SJohn Forte break;
1480fcf3ce44SJohn Forte case ELM_TYP_BP:
1481fcf3ce44SJohn Forte back_plane_messages(&l_state, i, elem_index);
1482fcf3ce44SJohn Forte break;
1483fcf3ce44SJohn Forte case ELM_TYP_IB:
1484fcf3ce44SJohn Forte ctlr_messages(&l_state, i, elem_index);
1485fcf3ce44SJohn Forte break;
1486fcf3ce44SJohn Forte case ELM_TYP_LN:
1487fcf3ce44SJohn Forte /*
1488fcf3ce44SJohn Forte * NOTE: I just use the Photon's message
1489fcf3ce44SJohn Forte * string here and don't look at the
1490fcf3ce44SJohn Forte * language code. The string includes
1491fcf3ce44SJohn Forte * the language name.
1492fcf3ce44SJohn Forte */
1493fcf3ce44SJohn Forte if (l_state.ib_tbl.config.type_hdr[i].text_len != 0) {
1494fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\t",
1495fcf3ce44SJohn Forte l_state.ib_tbl.config.text[i]);
1496fcf3ce44SJohn Forte }
1497fcf3ce44SJohn Forte break;
1498fcf3ce44SJohn Forte case ELM_TYP_LO: /* Loop configuration */
1499fcf3ce44SJohn Forte loop_messages(&l_state, i, elem_index);
1500fcf3ce44SJohn Forte break;
1501fcf3ce44SJohn Forte case ELM_TYP_MB: /* Loop configuration */
1502fcf3ce44SJohn Forte mb_messages(&l_state, i, elem_index);
1503fcf3ce44SJohn Forte break;
1504fcf3ce44SJohn Forte
1505fcf3ce44SJohn Forte }
1506fcf3ce44SJohn Forte /*
1507fcf3ce44SJohn Forte * Calculate the index to each element.
1508fcf3ce44SJohn Forte */
1509fcf3ce44SJohn Forte elem_index += l_state.ib_tbl.config.type_hdr[i].num;
1510fcf3ce44SJohn Forte }
1511fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1512fcf3ce44SJohn Forte }
1513fcf3ce44SJohn Forte
1514fcf3ce44SJohn Forte
1515fcf3ce44SJohn Forte
1516fcf3ce44SJohn Forte
1517fcf3ce44SJohn Forte /*
1518fcf3ce44SJohn Forte * dpm_display_config() Displays device status
1519fcf3ce44SJohn Forte * information for a DAKTARI enclosure.
1520fcf3ce44SJohn Forte *
1521fcf3ce44SJohn Forte * RETURNS:
1522fcf3ce44SJohn Forte * none.
1523fcf3ce44SJohn Forte */
1524fcf3ce44SJohn Forte void
dpm_display_config(char * path_phys)1525fcf3ce44SJohn Forte dpm_display_config(char *path_phys)
1526fcf3ce44SJohn Forte {
1527fcf3ce44SJohn Forte L_state l_state;
1528fcf3ce44SJohn Forte Bp_elem_st bpf, bpr;
1529fcf3ce44SJohn Forte int i, j, elem_index = 0, err = 0, count;
1530fcf3ce44SJohn Forte
1531fcf3ce44SJohn Forte
1532fcf3ce44SJohn Forte /* Get global status */
1533fcf3ce44SJohn Forte if (err = l_get_status(path_phys, &l_state,
1534fcf3ce44SJohn Forte (Options & PVERBOSE))) {
1535fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
1536fcf3ce44SJohn Forte exit(-1);
1537fcf3ce44SJohn Forte }
1538fcf3ce44SJohn Forte
1539fcf3ce44SJohn Forte /*
1540fcf3ce44SJohn Forte * Look for abnormal status.
1541fcf3ce44SJohn Forte */
1542fcf3ce44SJohn Forte if (l_state.ib_tbl.p2_s.ui.ab_cond) {
1543fcf3ce44SJohn Forte abnormal_condition_display(&l_state);
1544fcf3ce44SJohn Forte }
1545fcf3ce44SJohn Forte
1546fcf3ce44SJohn Forte (void) fprintf(stdout,
1547fcf3ce44SJohn Forte MSGSTR(2247, " DISK STATUS \n"
1548fcf3ce44SJohn Forte "SLOT DISKS (Node WWN) \n"));
1549fcf3ce44SJohn Forte /*
1550fcf3ce44SJohn Forte * Print the status for each disk
1551fcf3ce44SJohn Forte */
1552fcf3ce44SJohn Forte for (j = 0; j < (int)l_state.ib_tbl.config.enc_num_elem; j++) {
1553fcf3ce44SJohn Forte elem_index++;
1554fcf3ce44SJohn Forte if (l_state.ib_tbl.config.type_hdr[j].type == ELM_TYP_BP)
1555fcf3ce44SJohn Forte break;
1556fcf3ce44SJohn Forte elem_index += l_state.ib_tbl.config.type_hdr[j].num;
1557fcf3ce44SJohn Forte }
1558fcf3ce44SJohn Forte (void) bcopy((const void *)
1559fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index]),
1560fcf3ce44SJohn Forte (void *)&bpf, sizeof (bpf));
1561fcf3ce44SJohn Forte (void) bcopy((const void *)
1562fcf3ce44SJohn Forte &(l_state.ib_tbl.p2_s.element[elem_index + 1]),
1563fcf3ce44SJohn Forte (void *)&bpr, sizeof (bpr));
1564fcf3ce44SJohn Forte
1565fcf3ce44SJohn Forte for (i = 0, count = 0;
1566fcf3ce44SJohn Forte i < (int)l_state.total_num_drv/2;
1567fcf3ce44SJohn Forte i++, count++) {
1568fcf3ce44SJohn Forte (void) fprintf(stdout, "%-2d ", count);
1569fcf3ce44SJohn Forte display_disk_msg(&l_state.drv_front[i], &l_state, &bpf, 1);
1570fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1571fcf3ce44SJohn Forte }
1572fcf3ce44SJohn Forte for (i = 0; i < (int)l_state.total_num_drv/2; i++, count++) {
1573fcf3ce44SJohn Forte (void) fprintf(stdout, "%-2d ", count);
1574fcf3ce44SJohn Forte display_disk_msg(&l_state.drv_rear[i], &l_state, &bpf, 1);
1575fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1576fcf3ce44SJohn Forte }
1577fcf3ce44SJohn Forte
1578fcf3ce44SJohn Forte
1579fcf3ce44SJohn Forte /*
1580fcf3ce44SJohn Forte * Display the subsystem status.
1581fcf3ce44SJohn Forte */
1582fcf3ce44SJohn Forte (void) fprintf(stdout,
1583fcf3ce44SJohn Forte MSGSTR(2033,
1584fcf3ce44SJohn Forte "\t\tSUBSYSTEM STATUS\nFW Revision:"));
1585fcf3ce44SJohn Forte for (i = 0; i < sizeof (l_state.ib_tbl.config.prod_revision); i++) {
1586fcf3ce44SJohn Forte (void) fprintf(stdout, "%c",
1587fcf3ce44SJohn Forte l_state.ib_tbl.config.prod_revision[i]);
1588fcf3ce44SJohn Forte }
1589fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2034, " Box ID:%d"),
1590fcf3ce44SJohn Forte l_state.ib_tbl.box_id);
1591fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
1592fcf3ce44SJohn Forte
1593fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
1594fcf3ce44SJohn Forte
1595fcf3ce44SJohn Forte for (i = 0; i < 8; i++) {
1596fcf3ce44SJohn Forte (void) fprintf(stdout, "%1.2x",
1597fcf3ce44SJohn Forte l_state.ib_tbl.config.enc_node_wwn[i]);
1598fcf3ce44SJohn Forte }
1599fcf3ce44SJohn Forte /* Make sure NULL terminated although it is supposed to be */
1600fcf3ce44SJohn Forte if (strlen((const char *)l_state.ib_tbl.enclosure_name) <=
1601fcf3ce44SJohn Forte sizeof (l_state.ib_tbl.enclosure_name)) {
1602fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2035, " Enclosure Name:%s\n"),
1603fcf3ce44SJohn Forte l_state.ib_tbl.enclosure_name);
1604fcf3ce44SJohn Forte }
1605fcf3ce44SJohn Forte
1606fcf3ce44SJohn Forte /*
1607fcf3ce44SJohn Forte *
1608fcf3ce44SJohn Forte */
1609fcf3ce44SJohn Forte elem_index = 0;
1610fcf3ce44SJohn Forte /* Get and print CONTROLLER messages */
1611fcf3ce44SJohn Forte for (i = 0; i < (int)l_state.ib_tbl.config.enc_num_elem; i++) {
1612fcf3ce44SJohn Forte elem_index++; /* skip global */
1613fcf3ce44SJohn Forte switch (l_state.ib_tbl.config.type_hdr[i].type) {
1614fcf3ce44SJohn Forte case ELM_TYP_PS:
1615fcf3ce44SJohn Forte ps_messages(&l_state, i, elem_index);
1616fcf3ce44SJohn Forte break;
1617fcf3ce44SJohn Forte case ELM_TYP_FT:
1618fcf3ce44SJohn Forte fan_messages(&l_state, i, elem_index);
1619fcf3ce44SJohn Forte break;
1620fcf3ce44SJohn Forte case ELM_TYP_BP:
1621fcf3ce44SJohn Forte dpm_SSC100_messages(&l_state, i, elem_index);
1622fcf3ce44SJohn Forte break;
1623fcf3ce44SJohn Forte case ELM_TYP_IB:
1624fcf3ce44SJohn Forte ctlr_messages(&l_state, i, elem_index);
1625fcf3ce44SJohn Forte break;
1626fcf3ce44SJohn Forte case ELM_TYP_LN:
1627fcf3ce44SJohn Forte /*
1628fcf3ce44SJohn Forte * NOTE: I just use the Photon's message
1629fcf3ce44SJohn Forte * string here and don't look at the
1630fcf3ce44SJohn Forte * language code. The string includes
1631fcf3ce44SJohn Forte * the language name.
1632fcf3ce44SJohn Forte */
1633fcf3ce44SJohn Forte if (l_state.ib_tbl.config.type_hdr[i].text_len != 0) {
1634fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\t",
1635fcf3ce44SJohn Forte l_state.ib_tbl.config.text[i]);
1636fcf3ce44SJohn Forte }
1637fcf3ce44SJohn Forte break;
1638fcf3ce44SJohn Forte case ELM_TYP_LO: /* Loop configuration */
1639fcf3ce44SJohn Forte loop_messages(&l_state, i, elem_index);
1640fcf3ce44SJohn Forte break;
1641fcf3ce44SJohn Forte case ELM_TYP_MB: /* Loop configuration */
1642fcf3ce44SJohn Forte mb_messages(&l_state, i, elem_index);
1643fcf3ce44SJohn Forte break;
1644fcf3ce44SJohn Forte case ELM_TYP_FL:
1645fcf3ce44SJohn Forte trans_messages(&l_state, 1);
1646fcf3ce44SJohn Forte break;
1647fcf3ce44SJohn Forte
1648fcf3ce44SJohn Forte }
1649fcf3ce44SJohn Forte /*
1650fcf3ce44SJohn Forte * Calculate the index to each element.
1651fcf3ce44SJohn Forte */
1652fcf3ce44SJohn Forte elem_index += l_state.ib_tbl.config.type_hdr[i].num;
1653fcf3ce44SJohn Forte }
1654fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1655fcf3ce44SJohn Forte }
1656fcf3ce44SJohn Forte
1657fcf3ce44SJohn Forte
1658fcf3ce44SJohn Forte
1659fcf3ce44SJohn Forte
1660fcf3ce44SJohn Forte
1661fcf3ce44SJohn Forte
1662fcf3ce44SJohn Forte /*
1663fcf3ce44SJohn Forte * Change the FPM (Front Panel Module) password of the
1664fcf3ce44SJohn Forte * subsystem associated with the IB addressed by the
1665fcf3ce44SJohn Forte * enclosure or pathname to name.
1666fcf3ce44SJohn Forte *
1667fcf3ce44SJohn Forte */
1668fcf3ce44SJohn Forte void
intfix(void)1669fcf3ce44SJohn Forte intfix(void)
1670fcf3ce44SJohn Forte {
1671fcf3ce44SJohn Forte if (termio_fd) {
1672fcf3ce44SJohn Forte termios.c_lflag |= ECHO;
1673fcf3ce44SJohn Forte ioctl(termio_fd, TCSETS, &termios);
1674fcf3ce44SJohn Forte }
1675fcf3ce44SJohn Forte exit(SIGINT);
1676fcf3ce44SJohn Forte }
1677fcf3ce44SJohn Forte
1678fcf3ce44SJohn Forte
1679fcf3ce44SJohn Forte /*
1680fcf3ce44SJohn Forte * up_password() Changes the password for SENA enclosure.
1681fcf3ce44SJohn Forte *
1682fcf3ce44SJohn Forte * RETURNS:
1683fcf3ce44SJohn Forte * none.
1684fcf3ce44SJohn Forte */
1685fcf3ce44SJohn Forte void
up_password(char ** argv)1686fcf3ce44SJohn Forte up_password(char **argv)
1687fcf3ce44SJohn Forte {
1688fcf3ce44SJohn Forte int path_index = 0, err = 0;
1689fcf3ce44SJohn Forte char password[1024];
1690fcf3ce44SJohn Forte char input[1024];
1691fcf3ce44SJohn Forte int i, j, matched, equal;
1692fcf3ce44SJohn Forte L_inquiry inq;
1693fcf3ce44SJohn Forte void (*sig)();
1694fcf3ce44SJohn Forte char *path_phys = NULL;
1695fcf3ce44SJohn Forte Path_struct *path_struct;
1696fcf3ce44SJohn Forte
1697fcf3ce44SJohn Forte
1698fcf3ce44SJohn Forte if ((termio_fd = open("/dev/tty", O_RDONLY)) == -1) {
1699fcf3ce44SJohn Forte (void) fprintf(stderr,
1700fcf3ce44SJohn Forte MSGSTR(2036, "Error: tty open failed.\n"));
1701fcf3ce44SJohn Forte exit(-1);
1702fcf3ce44SJohn Forte }
1703fcf3ce44SJohn Forte ioctl(termio_fd, TCGETS, &termios);
1704fcf3ce44SJohn Forte sig = sigset(SIGINT, (void (*)())intfix);
1705fcf3ce44SJohn Forte /*
1706fcf3ce44SJohn Forte * Make sure path valid and is to a PHO
1707fcf3ce44SJohn Forte * before bothering operator.
1708fcf3ce44SJohn Forte */
1709fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
1710fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
1711fcf3ce44SJohn Forte (void) fprintf(stderr,
1712fcf3ce44SJohn Forte MSGSTR(33,
1713fcf3ce44SJohn Forte " Error: converting"
1714fcf3ce44SJohn Forte " %s to physical path.\n"
1715fcf3ce44SJohn Forte " Invalid pathname.\n"),
1716fcf3ce44SJohn Forte argv[path_index]);
1717fcf3ce44SJohn Forte if (err != -1) {
1718fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1719fcf3ce44SJohn Forte }
1720fcf3ce44SJohn Forte exit(-1);
1721fcf3ce44SJohn Forte }
1722fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
1723fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1724fcf3ce44SJohn Forte exit(-1);
1725fcf3ce44SJohn Forte }
1726fcf3ce44SJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
1727fcf3ce44SJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
1728fcf3ce44SJohn Forte sizeof (inq.inq_vid)) &&
1729fcf3ce44SJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
1730fcf3ce44SJohn Forte /*
1731fcf3ce44SJohn Forte * Again this is like the ssaadm code in that the name
1732fcf3ce44SJohn Forte * is still not defined before this code must be released.
1733fcf3ce44SJohn Forte */
1734fcf3ce44SJohn Forte (void) fprintf(stderr,
1735fcf3ce44SJohn Forte MSGSTR(2037, "Error: Enclosure is not a %s\n"),
1736fcf3ce44SJohn Forte ENCLOSURE_PROD_ID);
1737fcf3ce44SJohn Forte exit(-1);
1738fcf3ce44SJohn Forte }
1739fcf3ce44SJohn Forte (void) fprintf(stdout,
1740fcf3ce44SJohn Forte MSGSTR(2038,
1741fcf3ce44SJohn Forte "Changing FPM password for subsystem %s\n"),
1742fcf3ce44SJohn Forte argv[path_index]);
1743fcf3ce44SJohn Forte
1744fcf3ce44SJohn Forte equal = 0;
1745fcf3ce44SJohn Forte while (!equal) {
1746fcf3ce44SJohn Forte memset(input, 0, sizeof (input));
1747fcf3ce44SJohn Forte memset(password, 0, sizeof (password));
1748fcf3ce44SJohn Forte (void) fprintf(stdout,
1749fcf3ce44SJohn Forte MSGSTR(2039, "New password: "));
1750fcf3ce44SJohn Forte
1751fcf3ce44SJohn Forte termios.c_lflag &= ~ECHO;
1752fcf3ce44SJohn Forte ioctl(termio_fd, TCSETS, &termios);
1753fcf3ce44SJohn Forte
1754fcf3ce44SJohn Forte (void) gets(input);
1755fcf3ce44SJohn Forte (void) fprintf(stdout,
1756fcf3ce44SJohn Forte MSGSTR(2040, "\nRe-enter new password: "));
1757fcf3ce44SJohn Forte (void) gets(password);
1758fcf3ce44SJohn Forte termios.c_lflag |= ECHO;
1759fcf3ce44SJohn Forte ioctl(termio_fd, TCSETS, &termios);
1760fcf3ce44SJohn Forte for (i = 0; input[i]; i++) {
1761fcf3ce44SJohn Forte if (!isdigit(input[i])) {
1762fcf3ce44SJohn Forte (void) fprintf(stderr,
1763fcf3ce44SJohn Forte MSGSTR(2041, "\nError: Invalid password."
1764fcf3ce44SJohn Forte " The password"
1765fcf3ce44SJohn Forte " must be 4 decimal-digit characters.\n"));
1766fcf3ce44SJohn Forte exit(-1);
1767fcf3ce44SJohn Forte }
1768fcf3ce44SJohn Forte }
1769fcf3ce44SJohn Forte if (i && (i != 4)) {
1770fcf3ce44SJohn Forte (void) fprintf(stderr,
1771fcf3ce44SJohn Forte MSGSTR(2042, "\nError: Invalid password."
1772fcf3ce44SJohn Forte " The password"
1773fcf3ce44SJohn Forte " must be 4 decimal-digit characters.\n"));
1774fcf3ce44SJohn Forte exit(-1);
1775fcf3ce44SJohn Forte }
1776fcf3ce44SJohn Forte for (j = 0; password[j]; j++) {
1777fcf3ce44SJohn Forte if (!isdigit(password[j])) {
1778fcf3ce44SJohn Forte (void) fprintf(stderr,
1779fcf3ce44SJohn Forte MSGSTR(2043, "\nError: Invalid password."
1780fcf3ce44SJohn Forte " The password"
1781fcf3ce44SJohn Forte " must be 4 decimal-digit characters.\n"));
1782fcf3ce44SJohn Forte exit(-1);
1783fcf3ce44SJohn Forte }
1784fcf3ce44SJohn Forte }
1785fcf3ce44SJohn Forte if (i != j) {
1786fcf3ce44SJohn Forte matched = -1;
1787fcf3ce44SJohn Forte } else for (i = matched = 0; password[i]; i++) {
1788fcf3ce44SJohn Forte if (password[i] == input[i]) {
1789fcf3ce44SJohn Forte matched++;
1790fcf3ce44SJohn Forte }
1791fcf3ce44SJohn Forte }
1792fcf3ce44SJohn Forte if ((matched != -1) && (matched == i)) {
1793fcf3ce44SJohn Forte equal = 1;
1794fcf3ce44SJohn Forte } else {
1795fcf3ce44SJohn Forte (void) fprintf(stdout,
1796fcf3ce44SJohn Forte MSGSTR(2044, "\npassword: They don't match;"
1797fcf3ce44SJohn Forte " try again.\n"));
1798fcf3ce44SJohn Forte }
1799fcf3ce44SJohn Forte }
1800fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
1801fcf3ce44SJohn Forte sscanf(input, "%s", password);
1802fcf3ce44SJohn Forte (void) signal(SIGINT, sig); /* restore signal handler */
1803fcf3ce44SJohn Forte
1804fcf3ce44SJohn Forte /* Send new password to IB */
1805fcf3ce44SJohn Forte if (l_new_password(path_phys, input)) {
1806fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
1807fcf3ce44SJohn Forte exit(-1);
1808fcf3ce44SJohn Forte }
1809fcf3ce44SJohn Forte }
1810fcf3ce44SJohn Forte
1811fcf3ce44SJohn Forte /*
1812fcf3ce44SJohn Forte * Call g_failover to process failover command
1813fcf3ce44SJohn Forte */
1814fcf3ce44SJohn Forte void
adm_failover(char ** argv)1815fcf3ce44SJohn Forte adm_failover(char **argv)
1816fcf3ce44SJohn Forte {
1817fcf3ce44SJohn Forte int path_index = 0, err = 0;
1818fcf3ce44SJohn Forte char pathclass[20];
1819fcf3ce44SJohn Forte char *path_phys = NULL;
1820fcf3ce44SJohn Forte
1821fcf3ce44SJohn Forte (void) memset(pathclass, 0, sizeof (pathclass));
1822fcf3ce44SJohn Forte (void) strcpy(pathclass, argv[path_index++]);
1823fcf3ce44SJohn Forte if ((strcmp(pathclass, "primary") != 0) &&
1824fcf3ce44SJohn Forte (strcmp(pathclass, "secondary") != 0)) {
1825fcf3ce44SJohn Forte (void) fprintf(stderr,
1826fcf3ce44SJohn Forte MSGSTR(2300, "Incorrect pathclass\n"));
1827fcf3ce44SJohn Forte exit(-1);
1828fcf3ce44SJohn Forte }
1829fcf3ce44SJohn Forte
1830fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
1831fcf3ce44SJohn Forte path_phys = g_get_physical_name(argv[path_index++]);
1832fcf3ce44SJohn Forte if ((path_phys == NULL) ||
1833fcf3ce44SJohn Forte (strstr(path_phys, SCSI_VHCI) == NULL)) {
1834fcf3ce44SJohn Forte (void) fprintf(stderr,
1835fcf3ce44SJohn Forte MSGSTR(2301, "Incorrect pathname\n"));
1836fcf3ce44SJohn Forte exit(-1);
1837fcf3ce44SJohn Forte }
1838fcf3ce44SJohn Forte
1839fcf3ce44SJohn Forte if (err = g_failover(path_phys, pathclass)) {
1840fcf3ce44SJohn Forte (void) print_errString(err, NULL);
1841fcf3ce44SJohn Forte exit(-1);
1842fcf3ce44SJohn Forte }
1843fcf3ce44SJohn Forte }
1844fcf3ce44SJohn Forte }
1845fcf3ce44SJohn Forte
1846fcf3ce44SJohn Forte
1847fcf3ce44SJohn Forte
1848fcf3ce44SJohn Forte /*
1849fcf3ce44SJohn Forte * up_encl_name() Update the enclosures logical name.
1850fcf3ce44SJohn Forte *
1851fcf3ce44SJohn Forte * RETURNS:
1852fcf3ce44SJohn Forte * none.
1853fcf3ce44SJohn Forte */
1854fcf3ce44SJohn Forte void
up_encl_name(char ** argv,int argc)1855fcf3ce44SJohn Forte up_encl_name(char **argv, int argc)
1856fcf3ce44SJohn Forte {
1857fcf3ce44SJohn Forte int i, rval, al_pa, path_index = 0, err = 0;
1858fcf3ce44SJohn Forte L_inquiry inq;
1859fcf3ce44SJohn Forte Box_list *b_list = NULL;
1860fcf3ce44SJohn Forte uchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
1861fcf3ce44SJohn Forte char wwn1[(WWN_SIZE*2)+1], name[1024], *path_phys = NULL;
1862fcf3ce44SJohn Forte Path_struct *path_struct;
1863fcf3ce44SJohn Forte
1864fcf3ce44SJohn Forte (void) memset(name, 0, sizeof (name));
1865fcf3ce44SJohn Forte (void) memset(&inq, 0, sizeof (inq));
1866fcf3ce44SJohn Forte (void) sscanf(argv[path_index++], "%s", name);
1867fcf3ce44SJohn Forte for (i = 0; name[i]; i++) {
1868fcf3ce44SJohn Forte if ((!isalnum(name[i]) &&
1869fcf3ce44SJohn Forte ((name[i] != '#') &&
1870fcf3ce44SJohn Forte (name[i] != '-') &&
1871fcf3ce44SJohn Forte (name[i] != '_') &&
1872fcf3ce44SJohn Forte (name[i] != '.'))) || i >= 16) {
1873fcf3ce44SJohn Forte (void) fprintf(stderr,
1874fcf3ce44SJohn Forte MSGSTR(2045, "Error: Invalid enclosure name.\n"));
1875fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(2046,
1876fcf3ce44SJohn Forte "Usage: %s [-v] subcommand {a name consisting of"
1877fcf3ce44SJohn Forte " 1-16 alphanumeric characters}"
1878fcf3ce44SJohn Forte " {enclosure... | pathname...}\n"), whoami);
1879fcf3ce44SJohn Forte exit(-1);
1880fcf3ce44SJohn Forte }
1881fcf3ce44SJohn Forte }
1882fcf3ce44SJohn Forte
1883fcf3ce44SJohn Forte if (((Options & PVERBOSE) && (argc != 5)) ||
1884fcf3ce44SJohn Forte (!(Options & PVERBOSE) && (argc != 4))) {
1885fcf3ce44SJohn Forte (void) fprintf(stderr,
1886fcf3ce44SJohn Forte MSGSTR(114, "Error: Incorrect number of arguments.\n"));
1887fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(2047,
1888fcf3ce44SJohn Forte "Usage: %s [-v] subcommand {a name consisting of"
1889fcf3ce44SJohn Forte " 1-16 alphanumeric characters}"
1890fcf3ce44SJohn Forte " {enclosure... | pathname...}\n"), whoami);
1891fcf3ce44SJohn Forte exit(-1);
1892fcf3ce44SJohn Forte }
1893fcf3ce44SJohn Forte
1894fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
1895fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
1896fcf3ce44SJohn Forte (void) fprintf(stderr,
1897fcf3ce44SJohn Forte MSGSTR(33,
1898fcf3ce44SJohn Forte " Error: converting"
1899fcf3ce44SJohn Forte " %s to physical path.\n"
1900fcf3ce44SJohn Forte " Invalid pathname.\n"),
1901fcf3ce44SJohn Forte argv[path_index]);
1902fcf3ce44SJohn Forte if (err != -1) {
1903fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1904fcf3ce44SJohn Forte }
1905fcf3ce44SJohn Forte exit(-1);
1906fcf3ce44SJohn Forte }
1907fcf3ce44SJohn Forte /*
1908fcf3ce44SJohn Forte * Make sure we are talking to an IB.
1909fcf3ce44SJohn Forte */
1910fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
1911fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1912fcf3ce44SJohn Forte exit(-1);
1913fcf3ce44SJohn Forte }
1914fcf3ce44SJohn Forte if ((strstr((char *)inq.inq_pid, ENCLOSURE_PROD_ID) == 0) &&
1915fcf3ce44SJohn Forte (!(strncmp((char *)inq.inq_vid, "SUN ",
1916fcf3ce44SJohn Forte sizeof (inq.inq_vid)) &&
1917fcf3ce44SJohn Forte ((inq.inq_dtype & DTYPE_MASK) == DTYPE_ESI)))) {
1918fcf3ce44SJohn Forte /*
1919fcf3ce44SJohn Forte * Again this is like the ssaadm code in that the name
1920fcf3ce44SJohn Forte * is still not defined before this code must be released.
1921fcf3ce44SJohn Forte */
1922fcf3ce44SJohn Forte (void) fprintf(stderr,
1923fcf3ce44SJohn Forte MSGSTR(2048, "Error: Pathname does not point to a %s"
1924fcf3ce44SJohn Forte " enclosure\n"), ENCLOSURE_PROD_NAME);
1925fcf3ce44SJohn Forte exit(-1);
1926fcf3ce44SJohn Forte }
1927fcf3ce44SJohn Forte
1928fcf3ce44SJohn Forte if (err = g_get_wwn(path_phys, port_wwn, node_wwn, &al_pa,
1929fcf3ce44SJohn Forte Options & PVERBOSE)) {
1930fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1931fcf3ce44SJohn Forte exit(-1);
1932fcf3ce44SJohn Forte }
1933fcf3ce44SJohn Forte
1934fcf3ce44SJohn Forte for (i = 0; i < WWN_SIZE; i++) {
1935fcf3ce44SJohn Forte (void) sprintf(&wwn1[i << 1], "%02x", node_wwn[i]);
1936fcf3ce44SJohn Forte }
1937fcf3ce44SJohn Forte if ((err = l_get_box_list(&b_list, Options & PVERBOSE)) != 0) {
1938fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
1939fcf3ce44SJohn Forte exit(-1);
1940fcf3ce44SJohn Forte }
1941fcf3ce44SJohn Forte if (b_list == NULL) {
1942fcf3ce44SJohn Forte (void) fprintf(stdout,
1943fcf3ce44SJohn Forte MSGSTR(93, "No %s enclosures found "
1944fcf3ce44SJohn Forte "in /dev/es\n"), ENCLOSURE_PROD_NAME);
1945fcf3ce44SJohn Forte exit(-1);
1946fcf3ce44SJohn Forte } else if (l_duplicate_names(b_list, wwn1, name,
1947fcf3ce44SJohn Forte Options & PVERBOSE)) {
1948fcf3ce44SJohn Forte (void) fprintf(stderr,
1949fcf3ce44SJohn Forte MSGSTR(2049, "Warning: The name you selected, %s,"
1950fcf3ce44SJohn Forte " is already being used.\n"
1951fcf3ce44SJohn Forte "Please choose a unique name.\n"
1952fcf3ce44SJohn Forte "You can use the \"probe\" subcommand to"
1953fcf3ce44SJohn Forte " see all of the enclosure names.\n"),
1954fcf3ce44SJohn Forte name);
1955fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
1956fcf3ce44SJohn Forte exit(-1);
1957fcf3ce44SJohn Forte }
1958fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
1959fcf3ce44SJohn Forte
1960fcf3ce44SJohn Forte /* Send new name to IB */
1961fcf3ce44SJohn Forte if (rval = l_new_name(path_phys, name)) {
1962fcf3ce44SJohn Forte (void) print_errString(rval, path_phys);
1963fcf3ce44SJohn Forte exit(-1);
1964fcf3ce44SJohn Forte }
1965fcf3ce44SJohn Forte if (Options & PVERBOSE) {
1966fcf3ce44SJohn Forte (void) fprintf(stdout,
1967fcf3ce44SJohn Forte MSGSTR(2050, "The enclosure has been renamed to %s\n"),
1968fcf3ce44SJohn Forte name);
1969fcf3ce44SJohn Forte }
1970fcf3ce44SJohn Forte }
1971fcf3ce44SJohn Forte
1972fcf3ce44SJohn Forte
1973fcf3ce44SJohn Forte static int
get_enclStatus(char * phys_path,char * encl_name,int off_flag)1974fcf3ce44SJohn Forte get_enclStatus(char *phys_path, char *encl_name, int off_flag)
1975fcf3ce44SJohn Forte {
1976fcf3ce44SJohn Forte int found_pwrOnDrv = 0, slot;
1977fcf3ce44SJohn Forte int found_pwrOffDrv = 0, err = 0;
1978fcf3ce44SJohn Forte L_state l_state;
1979fcf3ce44SJohn Forte
1980fcf3ce44SJohn Forte if ((err = l_get_status(phys_path,
1981fcf3ce44SJohn Forte &l_state, Options & PVERBOSE)) != 0) {
1982fcf3ce44SJohn Forte (void) print_errString(err, encl_name);
1983fcf3ce44SJohn Forte return (err);
1984fcf3ce44SJohn Forte }
1985fcf3ce44SJohn Forte
1986fcf3ce44SJohn Forte if (off_flag) {
1987fcf3ce44SJohn Forte for (slot = 0; slot < l_state.total_num_drv/2;
1988fcf3ce44SJohn Forte slot++) {
1989fcf3ce44SJohn Forte if (((l_state.drv_front[slot].ib_status.code !=
1990fcf3ce44SJohn Forte S_NOT_INSTALLED) &&
1991fcf3ce44SJohn Forte (!l_state.drv_front[slot].ib_status.dev_off)) ||
1992fcf3ce44SJohn Forte ((l_state.drv_rear[slot].ib_status.code !=
1993fcf3ce44SJohn Forte S_NOT_INSTALLED) &&
1994fcf3ce44SJohn Forte (!l_state.drv_rear[slot].ib_status.dev_off))) {
1995fcf3ce44SJohn Forte found_pwrOnDrv++;
1996fcf3ce44SJohn Forte break;
1997fcf3ce44SJohn Forte }
1998fcf3ce44SJohn Forte }
1999fcf3ce44SJohn Forte if (!found_pwrOnDrv) {
2000fcf3ce44SJohn Forte (void) fprintf(stdout,
2001fcf3ce44SJohn Forte MSGSTR(2051,
2002fcf3ce44SJohn Forte "Notice: Drives in enclosure"
2003fcf3ce44SJohn Forte " \"%s\" have already been"
2004fcf3ce44SJohn Forte " powered off.\n\n"),
2005fcf3ce44SJohn Forte encl_name);
2006fcf3ce44SJohn Forte return (-1);
2007fcf3ce44SJohn Forte }
2008fcf3ce44SJohn Forte } else {
2009fcf3ce44SJohn Forte for (slot = 0; slot < l_state.total_num_drv/2;
2010fcf3ce44SJohn Forte slot++) {
2011fcf3ce44SJohn Forte if (((l_state.drv_front[slot].ib_status.code !=
2012fcf3ce44SJohn Forte S_NOT_INSTALLED) &&
2013fcf3ce44SJohn Forte (l_state.drv_front[slot].ib_status.dev_off)) ||
2014fcf3ce44SJohn Forte ((l_state.drv_rear[slot].ib_status.code !=
2015fcf3ce44SJohn Forte S_NOT_INSTALLED) &&
2016fcf3ce44SJohn Forte (l_state.drv_rear[slot].ib_status.dev_off))) {
2017fcf3ce44SJohn Forte found_pwrOffDrv++;
2018fcf3ce44SJohn Forte break;
2019fcf3ce44SJohn Forte }
2020fcf3ce44SJohn Forte }
2021fcf3ce44SJohn Forte if (!found_pwrOffDrv) {
2022fcf3ce44SJohn Forte (void) fprintf(stdout,
2023fcf3ce44SJohn Forte MSGSTR(2052,
2024fcf3ce44SJohn Forte "Notice: Drives in enclosure"
2025fcf3ce44SJohn Forte " \"%s\" have already been"
2026fcf3ce44SJohn Forte " powered on.\n\n"),
2027fcf3ce44SJohn Forte encl_name);
2028fcf3ce44SJohn Forte return (-1);
2029fcf3ce44SJohn Forte }
2030fcf3ce44SJohn Forte }
2031fcf3ce44SJohn Forte return (0);
2032fcf3ce44SJohn Forte }
2033fcf3ce44SJohn Forte
2034fcf3ce44SJohn Forte
2035fcf3ce44SJohn Forte
2036fcf3ce44SJohn Forte
2037fcf3ce44SJohn Forte
2038fcf3ce44SJohn Forte /*
2039fcf3ce44SJohn Forte * adm_led() The led_request subcommand requests the subsystem
2040fcf3ce44SJohn Forte * to display the current state or turn off, on, or blink
2041fcf3ce44SJohn Forte * the yellow LED associated with the disk specified by the
2042fcf3ce44SJohn Forte * enclosure or pathname.
2043fcf3ce44SJohn Forte *
2044fcf3ce44SJohn Forte * RETURNS:
2045fcf3ce44SJohn Forte * none.
2046fcf3ce44SJohn Forte */
2047fcf3ce44SJohn Forte void
adm_led(char ** argv,int led_action)2048fcf3ce44SJohn Forte adm_led(char **argv, int led_action)
2049fcf3ce44SJohn Forte {
2050fcf3ce44SJohn Forte int path_index = 0, err = 0;
2051fcf3ce44SJohn Forte gfc_map_t map;
2052fcf3ce44SJohn Forte L_inquiry inq;
2053fcf3ce44SJohn Forte Dev_elem_st status;
2054fcf3ce44SJohn Forte char *path_phys = NULL;
2055fcf3ce44SJohn Forte Path_struct *path_struct;
2056fcf3ce44SJohn Forte int enc_t = 0; /* enclosure type */
2057fcf3ce44SJohn Forte char ses_path[MAXPATHLEN];
2058fcf3ce44SJohn Forte L_inquiry ses_inq;
2059fcf3ce44SJohn Forte
2060fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
2061fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
2062fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
2063fcf3ce44SJohn Forte /* Make sure we have a device path. */
2064fcf3ce44SJohn Forte if (path_struct->ib_path_flag) {
2065fcf3ce44SJohn Forte path_phys = path_struct->p_physical_path;
2066fcf3ce44SJohn Forte } else {
2067fcf3ce44SJohn Forte (void) fprintf(stderr,
2068fcf3ce44SJohn Forte MSGSTR(33,
2069fcf3ce44SJohn Forte " Error: converting"
2070fcf3ce44SJohn Forte " %s to physical path.\n"
2071fcf3ce44SJohn Forte " Invalid pathname.\n"),
2072fcf3ce44SJohn Forte argv[path_index]);
2073fcf3ce44SJohn Forte if (err != -1) {
2074fcf3ce44SJohn Forte (void) print_errString(err,
2075fcf3ce44SJohn Forte argv[path_index]);
2076fcf3ce44SJohn Forte }
2077fcf3ce44SJohn Forte exit(-1);
2078fcf3ce44SJohn Forte }
2079fcf3ce44SJohn Forte }
2080fcf3ce44SJohn Forte if (!path_struct->ib_path_flag) {
2081fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
2082fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2083fcf3ce44SJohn Forte exit(-1);
2084fcf3ce44SJohn Forte }
2085fcf3ce44SJohn Forte if ((inq.inq_dtype & DTYPE_MASK) != DTYPE_DIRECT) {
2086fcf3ce44SJohn Forte (void) fprintf(stderr,
2087fcf3ce44SJohn Forte MSGSTR(2053,
2088fcf3ce44SJohn Forte "Error: pathname must be to a disk device.\n"
2089fcf3ce44SJohn Forte " %s\n"), argv[path_index]);
2090fcf3ce44SJohn Forte exit(-1);
2091fcf3ce44SJohn Forte }
2092fcf3ce44SJohn Forte }
2093fcf3ce44SJohn Forte /*
2094fcf3ce44SJohn Forte * See if we are in fact talking to a loop or not.
2095fcf3ce44SJohn Forte */
2096fcf3ce44SJohn Forte if (err = g_get_dev_map(path_phys, &map,
2097fcf3ce44SJohn Forte (Options & PVERBOSE))) {
2098fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2099fcf3ce44SJohn Forte
2100fcf3ce44SJohn Forte }
2101fcf3ce44SJohn Forte if (led_action == L_LED_ON) {
2102fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(2054,
2103fcf3ce44SJohn Forte "The led_on functionality is not applicable "
2104fcf3ce44SJohn Forte "to this subsystem.\n"));
2105fcf3ce44SJohn Forte exit(-1);
2106fcf3ce44SJohn Forte }
2107fcf3ce44SJohn Forte if (err = l_led(path_struct, led_action, &status,
2108fcf3ce44SJohn Forte (Options & PVERBOSE))) {
2109fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2110fcf3ce44SJohn Forte exit(-1);
2111fcf3ce44SJohn Forte }
2112fcf3ce44SJohn Forte
2113fcf3ce44SJohn Forte /* Check to see if we have a daktari */
2114fcf3ce44SJohn Forte if (l_get_ses_path(path_phys, ses_path, &map,
2115fcf3ce44SJohn Forte (Options & PVERBOSE)) == 0) {
2116fcf3ce44SJohn Forte if (g_get_inquiry(ses_path, &ses_inq) == 0) {
2117fcf3ce44SJohn Forte enc_t = l_get_enc_type(ses_inq);
2118fcf3ce44SJohn Forte }
2119fcf3ce44SJohn Forte }
2120fcf3ce44SJohn Forte switch (led_action) {
2121fcf3ce44SJohn Forte case L_LED_STATUS:
2122fcf3ce44SJohn Forte if (status.fault || status.fault_req) {
2123fcf3ce44SJohn Forte if (!path_struct->slot_valid) {
2124fcf3ce44SJohn Forte (void) fprintf(stdout,
2125fcf3ce44SJohn Forte MSGSTR(2055, "LED state is ON for "
2126fcf3ce44SJohn Forte "device:\n %s\n"), path_phys);
2127fcf3ce44SJohn Forte } else {
2128fcf3ce44SJohn Forte if (enc_t == DAK_ENC_TYPE) {
2129fcf3ce44SJohn Forte if (path_struct->f_flag) {
2130fcf3ce44SJohn Forte (void) fprintf(stdout,
2131fcf3ce44SJohn Forte MSGSTR(2236, "LED state is ON for "
2132fcf3ce44SJohn Forte "device in location: slot %d\n"),
2133fcf3ce44SJohn Forte path_struct->slot);
2134fcf3ce44SJohn Forte } else {
2135fcf3ce44SJohn Forte (void) fprintf(stdout,
2136fcf3ce44SJohn Forte MSGSTR(2236, "LED state is ON for "
2137fcf3ce44SJohn Forte "device in location: slot %d\n"),
2138fcf3ce44SJohn Forte path_struct->slot +
2139fcf3ce44SJohn Forte (MAX_DRIVES_DAK/2));
2140fcf3ce44SJohn Forte }
2141fcf3ce44SJohn Forte } else {
2142fcf3ce44SJohn Forte (void) fprintf(stdout,
2143fcf3ce44SJohn Forte (path_struct->f_flag) ?
2144fcf3ce44SJohn Forte MSGSTR(2056, "LED state is ON for "
2145fcf3ce44SJohn Forte "device in location: front,slot %d\n")
2146fcf3ce44SJohn Forte : MSGSTR(2057, "LED state is ON for "
2147fcf3ce44SJohn Forte "device in location: rear,slot %d\n"),
2148fcf3ce44SJohn Forte path_struct->slot);
2149fcf3ce44SJohn Forte }
2150fcf3ce44SJohn Forte }
2151fcf3ce44SJohn Forte } else if (status.ident || status.rdy_to_ins ||
2152fcf3ce44SJohn Forte status.rmv) {
2153fcf3ce44SJohn Forte if (!path_struct->slot_valid) {
2154fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2058,
2155fcf3ce44SJohn Forte "LED state is BLINKING for "
2156fcf3ce44SJohn Forte "device:\n %s\n"), path_phys);
2157fcf3ce44SJohn Forte } else {
2158fcf3ce44SJohn Forte if (enc_t == DAK_ENC_TYPE) {
2159fcf3ce44SJohn Forte if (path_struct->f_flag) {
2160fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2237,
2161fcf3ce44SJohn Forte "LED state is BLINKING for "
2162fcf3ce44SJohn Forte "device in location: slot %d\n"),
2163fcf3ce44SJohn Forte path_struct->slot);
2164fcf3ce44SJohn Forte } else {
2165fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2237,
2166fcf3ce44SJohn Forte "LED state is BLINKING for "
2167fcf3ce44SJohn Forte "device in location: slot %d\n"),
2168fcf3ce44SJohn Forte path_struct->slot + (MAX_DRIVES_DAK/2));
2169fcf3ce44SJohn Forte }
2170fcf3ce44SJohn Forte } else {
2171fcf3ce44SJohn Forte (void) fprintf(stdout,
2172fcf3ce44SJohn Forte (path_struct->f_flag) ?
2173fcf3ce44SJohn Forte MSGSTR(2059, "LED state is BLINKING for "
2174fcf3ce44SJohn Forte "device in location: front,slot %d\n")
2175fcf3ce44SJohn Forte : MSGSTR(2060, "LED state is BLINKING for "
2176fcf3ce44SJohn Forte "device in location: rear,slot %d\n"),
2177fcf3ce44SJohn Forte path_struct->slot);
2178fcf3ce44SJohn Forte }
2179fcf3ce44SJohn Forte }
2180fcf3ce44SJohn Forte } else {
2181fcf3ce44SJohn Forte if (!path_struct->slot_valid) {
2182fcf3ce44SJohn Forte (void) fprintf(stdout,
2183fcf3ce44SJohn Forte MSGSTR(2061, "LED state is OFF for "
2184fcf3ce44SJohn Forte "device:\n %s\n"), path_phys);
2185fcf3ce44SJohn Forte } else {
2186fcf3ce44SJohn Forte if (enc_t == DAK_ENC_TYPE) {
2187fcf3ce44SJohn Forte if (path_struct->f_flag) {
2188fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2238,
2189fcf3ce44SJohn Forte "LED state is OFF for "
2190fcf3ce44SJohn Forte "device in location: slot %d\n"),
2191fcf3ce44SJohn Forte path_struct->slot);
2192fcf3ce44SJohn Forte } else {
2193fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2238,
2194fcf3ce44SJohn Forte "LED state is OFF for "
2195fcf3ce44SJohn Forte "device in location: slot %d\n"),
2196fcf3ce44SJohn Forte path_struct->slot + MAX_DRIVES_DAK/2);
2197fcf3ce44SJohn Forte }
2198fcf3ce44SJohn Forte } else {
2199fcf3ce44SJohn Forte (void) fprintf(stdout,
2200fcf3ce44SJohn Forte (path_struct->f_flag) ?
2201fcf3ce44SJohn Forte MSGSTR(2062, "LED state is OFF for "
2202fcf3ce44SJohn Forte "device in location: front,slot %d\n")
2203fcf3ce44SJohn Forte : MSGSTR(2063, "LED state is OFF for "
2204fcf3ce44SJohn Forte "device in location: rear,slot %d\n"),
2205fcf3ce44SJohn Forte path_struct->slot);
2206fcf3ce44SJohn Forte }
2207fcf3ce44SJohn Forte }
2208fcf3ce44SJohn Forte }
2209fcf3ce44SJohn Forte break;
2210fcf3ce44SJohn Forte }
2211fcf3ce44SJohn Forte free((void *)map.dev_addr);
2212fcf3ce44SJohn Forte path_index++;
2213fcf3ce44SJohn Forte }
2214fcf3ce44SJohn Forte }
2215fcf3ce44SJohn Forte
2216fcf3ce44SJohn Forte
2217fcf3ce44SJohn Forte
2218fcf3ce44SJohn Forte
2219fcf3ce44SJohn Forte
2220fcf3ce44SJohn Forte /*
2221fcf3ce44SJohn Forte * dump() Dump information
2222fcf3ce44SJohn Forte *
2223fcf3ce44SJohn Forte * RETURNS:
2224fcf3ce44SJohn Forte * none.
2225fcf3ce44SJohn Forte */
2226fcf3ce44SJohn Forte void
dump(char ** argv)2227fcf3ce44SJohn Forte dump(char **argv)
2228fcf3ce44SJohn Forte {
2229fcf3ce44SJohn Forte uchar_t *buf;
2230fcf3ce44SJohn Forte int path_index = 0, err = 0;
2231fcf3ce44SJohn Forte L_inquiry inq;
2232fcf3ce44SJohn Forte char hdr_buf[MAXNAMELEN];
2233fcf3ce44SJohn Forte Rec_diag_hdr *hdr, *hdr_ptr;
2234fcf3ce44SJohn Forte char *path_phys = NULL;
2235fcf3ce44SJohn Forte Path_struct *path_struct;
2236fcf3ce44SJohn Forte
2237fcf3ce44SJohn Forte /*
2238fcf3ce44SJohn Forte * get big buffer
2239fcf3ce44SJohn Forte */
2240fcf3ce44SJohn Forte if ((hdr = (struct rec_diag_hdr *)calloc(1, MAX_REC_DIAG_LENGTH)) ==
2241fcf3ce44SJohn Forte NULL) {
2242fcf3ce44SJohn Forte (void) print_errString(L_MALLOC_FAILED, NULL);
2243fcf3ce44SJohn Forte exit(-1);
2244fcf3ce44SJohn Forte }
2245fcf3ce44SJohn Forte buf = (uchar_t *)hdr;
2246fcf3ce44SJohn Forte
2247fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
2248fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
2249fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
2250fcf3ce44SJohn Forte (void) fprintf(stderr,
2251fcf3ce44SJohn Forte MSGSTR(33,
2252fcf3ce44SJohn Forte " Error: converting"
2253fcf3ce44SJohn Forte " %s to physical path.\n"
2254fcf3ce44SJohn Forte " Invalid pathname.\n"),
2255fcf3ce44SJohn Forte argv[path_index]);
2256fcf3ce44SJohn Forte if (err != -1) {
2257fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2258fcf3ce44SJohn Forte }
2259fcf3ce44SJohn Forte exit(-1);
2260fcf3ce44SJohn Forte }
2261fcf3ce44SJohn Forte if (err = g_get_inquiry(path_phys, &inq)) {
2262fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2263fcf3ce44SJohn Forte } else {
2264fcf3ce44SJohn Forte (void) g_dump(MSGSTR(2065, "INQUIRY data: "),
2265fcf3ce44SJohn Forte (uchar_t *)&inq, 5 + inq.inq_len, HEX_ASCII);
2266fcf3ce44SJohn Forte }
2267fcf3ce44SJohn Forte
2268fcf3ce44SJohn Forte (void) memset(buf, 0, MAX_REC_DIAG_LENGTH);
2269fcf3ce44SJohn Forte if (err = l_get_envsen(path_phys, buf, MAX_REC_DIAG_LENGTH,
2270fcf3ce44SJohn Forte (Options & PVERBOSE))) {
2271fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2272fcf3ce44SJohn Forte exit(-1);
2273fcf3ce44SJohn Forte }
2274fcf3ce44SJohn Forte (void) fprintf(stdout,
2275fcf3ce44SJohn Forte MSGSTR(2066, "\t\tEnvironmental Sense Information\n"));
2276fcf3ce44SJohn Forte
2277fcf3ce44SJohn Forte /*
2278fcf3ce44SJohn Forte * Dump all pages.
2279fcf3ce44SJohn Forte */
2280fcf3ce44SJohn Forte hdr_ptr = hdr;
2281fcf3ce44SJohn Forte
2282fcf3ce44SJohn Forte while (hdr_ptr->page_len != 0) {
2283fcf3ce44SJohn Forte (void) sprintf(hdr_buf, MSGSTR(2067, "Page %d: "),
2284fcf3ce44SJohn Forte hdr_ptr->page_code);
2285fcf3ce44SJohn Forte (void) g_dump(hdr_buf, (uchar_t *)hdr_ptr,
2286fcf3ce44SJohn Forte HEADER_LEN + hdr_ptr->page_len, HEX_ASCII);
2287fcf3ce44SJohn Forte hdr_ptr += ((HEADER_LEN + hdr_ptr->page_len) /
2288fcf3ce44SJohn Forte sizeof (struct rec_diag_hdr));
2289fcf3ce44SJohn Forte }
2290fcf3ce44SJohn Forte path_index++;
2291fcf3ce44SJohn Forte }
2292fcf3ce44SJohn Forte (void) free(buf);
2293fcf3ce44SJohn Forte }
2294fcf3ce44SJohn Forte
2295fcf3ce44SJohn Forte
2296fcf3ce44SJohn Forte
2297fcf3ce44SJohn Forte /*
2298fcf3ce44SJohn Forte * display_socal_stats() Display socal driver kstat information.
2299fcf3ce44SJohn Forte *
2300fcf3ce44SJohn Forte * RETURNS:
2301fcf3ce44SJohn Forte * none.
2302fcf3ce44SJohn Forte */
2303fcf3ce44SJohn Forte void
display_socal_stats(int port,char * socal_path,struct socal_stats * fc_stats)2304fcf3ce44SJohn Forte display_socal_stats(int port, char *socal_path, struct socal_stats *fc_stats)
2305fcf3ce44SJohn Forte {
2306fcf3ce44SJohn Forte int i;
2307fcf3ce44SJohn Forte int header_flag = 0;
2308fcf3ce44SJohn Forte char status_msg_buf[MAXNAMELEN];
2309fcf3ce44SJohn Forte int num_status_entries;
2310fcf3ce44SJohn Forte
2311fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2068,
2312fcf3ce44SJohn Forte "\tInformation for FC Loop on port %d of"
2313fcf3ce44SJohn Forte " FC100/S Host Adapter\n\tat path: %s\n"),
2314fcf3ce44SJohn Forte port, socal_path);
2315fcf3ce44SJohn Forte if (fc_stats->version > 1) {
2316fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
2317fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(32,
2318fcf3ce44SJohn Forte "Information from %s"), fc_stats->drvr_name);
2319fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
2320fcf3ce44SJohn Forte if ((*fc_stats->node_wwn != NULL) &&
2321fcf3ce44SJohn Forte (*fc_stats->port_wwn[port] != NULL)) {
2322fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(104,
2323fcf3ce44SJohn Forte " Host Adapter WWN's: Node:%s"
2324fcf3ce44SJohn Forte " Port:%s\n"),
2325fcf3ce44SJohn Forte fc_stats->node_wwn,
2326fcf3ce44SJohn Forte fc_stats->port_wwn[port]);
2327fcf3ce44SJohn Forte }
2328fcf3ce44SJohn Forte if (*fc_stats->fw_revision != NULL) {
2329fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(105,
2330fcf3ce44SJohn Forte " Host Adapter Firmware Revision: %s\n"),
2331fcf3ce44SJohn Forte fc_stats->fw_revision);
2332fcf3ce44SJohn Forte }
2333fcf3ce44SJohn Forte if (fc_stats->parity_chk_enabled != 0) {
2334fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2069,
2335fcf3ce44SJohn Forte " This Host Adapter checks S-Bus parity.\n"));
2336fcf3ce44SJohn Forte }
2337fcf3ce44SJohn Forte }
2338fcf3ce44SJohn Forte
2339fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2070,
2340fcf3ce44SJohn Forte " Version Resets Req_Q_Intrpts Qfulls"
2341fcf3ce44SJohn Forte " Unsol_Resps Lips\n"));
2342fcf3ce44SJohn Forte
2343fcf3ce44SJohn Forte (void) fprintf(stdout, " %4d%8d%11d%13d%10d%7d\n",
2344fcf3ce44SJohn Forte fc_stats->version,
2345fcf3ce44SJohn Forte fc_stats->resets,
2346fcf3ce44SJohn Forte fc_stats->reqq_intrs,
2347fcf3ce44SJohn Forte fc_stats->qfulls,
2348fcf3ce44SJohn Forte fc_stats->pstats[port].unsol_resps,
2349fcf3ce44SJohn Forte fc_stats->pstats[port].lips);
2350fcf3ce44SJohn Forte
2351fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2071,
2352fcf3ce44SJohn Forte " Els_rcvd Abts"
2353fcf3ce44SJohn Forte " Abts_ok Offlines Loop_onlines Onlines\n"));
2354fcf3ce44SJohn Forte
2355fcf3ce44SJohn Forte (void) fprintf(stdout, " %4d%9d%10d%9d%13d%10d\n",
2356fcf3ce44SJohn Forte fc_stats->pstats[port].els_rcvd,
2357fcf3ce44SJohn Forte fc_stats->pstats[port].abts,
2358fcf3ce44SJohn Forte fc_stats->pstats[port].abts_ok,
2359fcf3ce44SJohn Forte fc_stats->pstats[port].offlines,
2360fcf3ce44SJohn Forte fc_stats->pstats[port].online_loops,
2361fcf3ce44SJohn Forte fc_stats->pstats[port].onlines);
2362fcf3ce44SJohn Forte
2363fcf3ce44SJohn Forte /* If any status conditions exist then display */
2364fcf3ce44SJohn Forte if (fc_stats->version > 1) {
2365fcf3ce44SJohn Forte num_status_entries = FC_STATUS_ENTRIES;
2366fcf3ce44SJohn Forte } else {
2367fcf3ce44SJohn Forte num_status_entries = 64;
2368fcf3ce44SJohn Forte }
2369fcf3ce44SJohn Forte
2370fcf3ce44SJohn Forte for (i = 0; i < num_status_entries; i++) {
2371fcf3ce44SJohn Forte if (fc_stats->pstats[port].resp_status[i] != 0) {
2372fcf3ce44SJohn Forte if (header_flag++ == 0) {
2373fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2072,
2374fcf3ce44SJohn Forte " Fibre Channel Transport status:\n "
2375fcf3ce44SJohn Forte "Status Value"
2376fcf3ce44SJohn Forte " Count\n"));
2377fcf3ce44SJohn Forte }
2378fcf3ce44SJohn Forte (void) l_format_fc_status_msg(status_msg_buf,
2379fcf3ce44SJohn Forte fc_stats->pstats[port].resp_status[i], i);
2380fcf3ce44SJohn Forte (void) fprintf(stdout, " %s\n",
2381fcf3ce44SJohn Forte status_msg_buf);
2382fcf3ce44SJohn Forte }
2383fcf3ce44SJohn Forte }
2384fcf3ce44SJohn Forte }
2385fcf3ce44SJohn Forte
2386fcf3ce44SJohn Forte
2387fcf3ce44SJohn Forte
2388fcf3ce44SJohn Forte /*
2389fcf3ce44SJohn Forte * display_sf_stats() Display sf driver kstat information.
2390fcf3ce44SJohn Forte *
2391fcf3ce44SJohn Forte * This routine is called by private loop device only
2392fcf3ce44SJohn Forte *
2393fcf3ce44SJohn Forte * RETURNS:
2394fcf3ce44SJohn Forte * none.
2395fcf3ce44SJohn Forte */
2396fcf3ce44SJohn Forte void
display_sf_stats(char * path_phys,int dtype,struct sf_stats * sf_stats)2397fcf3ce44SJohn Forte display_sf_stats(char *path_phys, int dtype, struct sf_stats *sf_stats)
2398fcf3ce44SJohn Forte {
2399fcf3ce44SJohn Forte int i, al_pa, err = 0;
2400fcf3ce44SJohn Forte gfc_map_t map;
2401fcf3ce44SJohn Forte uchar_t node_wwn[WWN_SIZE];
2402fcf3ce44SJohn Forte uchar_t port_wwn[WWN_SIZE];
2403fcf3ce44SJohn Forte gfc_port_dev_info_t *dev_addr_list;
2404fcf3ce44SJohn Forte
2405fcf3ce44SJohn Forte if (sf_stats->version > 1) {
2406fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t");
2407fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(32,
2408fcf3ce44SJohn Forte "Information from %s"),
2409fcf3ce44SJohn Forte sf_stats->drvr_name);
2410fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
2411fcf3ce44SJohn Forte } else {
2412fcf3ce44SJohn Forte (void) fprintf(stdout,
2413fcf3ce44SJohn Forte MSGSTR(2073, "\n\t\tInformation from sf driver:\n"));
2414fcf3ce44SJohn Forte }
2415fcf3ce44SJohn Forte
2416fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2074,
2417fcf3ce44SJohn Forte " Version Lip_count Lip_fail"
2418fcf3ce44SJohn Forte " Alloc_fail #_cmds "
2419fcf3ce44SJohn Forte "Throttle_limit Pool_size\n"));
2420fcf3ce44SJohn Forte
2421fcf3ce44SJohn Forte (void) fprintf(stdout, " %4d%9d%12d%11d%10d%11d%12d\n",
2422fcf3ce44SJohn Forte sf_stats->version,
2423fcf3ce44SJohn Forte sf_stats->lip_count,
2424fcf3ce44SJohn Forte sf_stats->lip_failures,
2425fcf3ce44SJohn Forte sf_stats->cralloc_failures,
2426fcf3ce44SJohn Forte sf_stats->ncmds,
2427fcf3ce44SJohn Forte sf_stats->throttle_limit,
2428fcf3ce44SJohn Forte sf_stats->cr_pool_size);
2429fcf3ce44SJohn Forte
2430fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2075,
2431fcf3ce44SJohn Forte "\n\t\tTARGET ERROR INFORMATION:\n"));
2432fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2076,
2433fcf3ce44SJohn Forte "AL_PA Els_fail Timouts Abts_fail"
2434fcf3ce44SJohn Forte " Tsk_m_fail "
2435fcf3ce44SJohn Forte " Data_ro_mis Dl_len_mis Logouts\n"));
2436fcf3ce44SJohn Forte
2437fcf3ce44SJohn Forte if (err = g_get_dev_map(path_phys, &map, (Options & PVERBOSE))) {
2438fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
2439fcf3ce44SJohn Forte exit(-1);
2440fcf3ce44SJohn Forte }
2441fcf3ce44SJohn Forte
2442fcf3ce44SJohn Forte if (dtype == DTYPE_DIRECT) {
2443fcf3ce44SJohn Forte if (err = g_get_wwn(path_phys, port_wwn, node_wwn, &al_pa,
2444fcf3ce44SJohn Forte Options & PVERBOSE)) {
2445fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
2446fcf3ce44SJohn Forte exit(-1);
2447fcf3ce44SJohn Forte }
2448fcf3ce44SJohn Forte /* for san toleration, only need to modify the code */
2449fcf3ce44SJohn Forte /* such that the current sf_al_map structure replaced */
2450fcf3ce44SJohn Forte /* by the new gfc_map structure for private loop device */
2451fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr; i < map.count;
2452fcf3ce44SJohn Forte i++, dev_addr_list++) {
2453fcf3ce44SJohn Forte if (dev_addr_list->gfc_port_dev.priv_port.sf_al_pa
2454fcf3ce44SJohn Forte == al_pa) {
2455fcf3ce44SJohn Forte (void) fprintf(stdout,
2456fcf3ce44SJohn Forte "%3x%10d%8d%10d%11d%13d%11d%9d\n",
2457fcf3ce44SJohn Forte al_pa,
2458fcf3ce44SJohn Forte sf_stats->tstats[i].els_failures,
2459fcf3ce44SJohn Forte sf_stats->tstats[i].timeouts,
2460fcf3ce44SJohn Forte sf_stats->tstats[i].abts_failures,
2461fcf3ce44SJohn Forte sf_stats->tstats[i].task_mgmt_failures,
2462fcf3ce44SJohn Forte sf_stats->tstats[i].data_ro_mismatches,
2463fcf3ce44SJohn Forte sf_stats->tstats[i].dl_len_mismatches,
2464fcf3ce44SJohn Forte sf_stats->tstats[i].logouts_recvd);
2465fcf3ce44SJohn Forte break;
2466fcf3ce44SJohn Forte }
2467fcf3ce44SJohn Forte }
2468fcf3ce44SJohn Forte if (i >= map.count) {
2469fcf3ce44SJohn Forte (void) print_errString(L_INVALID_LOOP_MAP, path_phys);
2470fcf3ce44SJohn Forte exit(-1);
2471fcf3ce44SJohn Forte }
2472fcf3ce44SJohn Forte } else {
2473fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr; i < map.count;
2474fcf3ce44SJohn Forte i++, dev_addr_list++) {
2475fcf3ce44SJohn Forte (void) fprintf(stdout,
2476fcf3ce44SJohn Forte "%3x%10d%8d%10d%11d%13d%11d%9d\n",
2477fcf3ce44SJohn Forte dev_addr_list->gfc_port_dev.priv_port.sf_al_pa,
2478fcf3ce44SJohn Forte sf_stats->tstats[i].els_failures,
2479fcf3ce44SJohn Forte sf_stats->tstats[i].timeouts,
2480fcf3ce44SJohn Forte sf_stats->tstats[i].abts_failures,
2481fcf3ce44SJohn Forte sf_stats->tstats[i].task_mgmt_failures,
2482fcf3ce44SJohn Forte sf_stats->tstats[i].data_ro_mismatches,
2483fcf3ce44SJohn Forte sf_stats->tstats[i].dl_len_mismatches,
2484fcf3ce44SJohn Forte sf_stats->tstats[i].logouts_recvd);
2485fcf3ce44SJohn Forte }
2486fcf3ce44SJohn Forte }
2487fcf3ce44SJohn Forte free((void *)map.dev_addr);
2488fcf3ce44SJohn Forte }
2489fcf3ce44SJohn Forte
2490fcf3ce44SJohn Forte
2491fcf3ce44SJohn Forte
2492fcf3ce44SJohn Forte /*
2493fcf3ce44SJohn Forte * adm_display_err() Displays enclosure specific
2494fcf3ce44SJohn Forte * error information.
2495fcf3ce44SJohn Forte *
2496fcf3ce44SJohn Forte * RETURNS:
2497fcf3ce44SJohn Forte * none.
2498fcf3ce44SJohn Forte */
2499fcf3ce44SJohn Forte static void
adm_display_err(char * path_phys,int dtype)2500fcf3ce44SJohn Forte adm_display_err(char *path_phys, int dtype)
2501fcf3ce44SJohn Forte {
2502fcf3ce44SJohn Forte int i, drvr_inst, sf_inst, socal_inst, port, al_pa, err = 0;
2503fcf3ce44SJohn Forte char *char_ptr, socal_path[MAXPATHLEN], drvr_path[MAXPATHLEN];
2504fcf3ce44SJohn Forte struct stat sbuf;
2505fcf3ce44SJohn Forte kstat_ctl_t *kc;
2506fcf3ce44SJohn Forte kstat_t *ifp_ks, *sf_ks, *fc_ks;
2507fcf3ce44SJohn Forte sf_stats_t sf_stats;
2508fcf3ce44SJohn Forte socal_stats_t fc_stats;
2509fcf3ce44SJohn Forte ifp_stats_t ifp_stats;
2510fcf3ce44SJohn Forte int header_flag = 0, pathcnt = 1;
2511fcf3ce44SJohn Forte char status_msg_buf[MAXNAMELEN];
2512fcf3ce44SJohn Forte gfc_map_t map;
2513fcf3ce44SJohn Forte uchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE];
2514fcf3ce44SJohn Forte uint_t path_type;
2515fcf3ce44SJohn Forte gfc_port_dev_info_t *dev_addr_list;
2516fcf3ce44SJohn Forte mp_pathlist_t pathlist;
2517fcf3ce44SJohn Forte int p_on = 0, p_st = 0;
2518fcf3ce44SJohn Forte
2519fcf3ce44SJohn Forte if ((kc = kstat_open()) == (kstat_ctl_t *)NULL) {
2520fcf3ce44SJohn Forte (void) fprintf(stderr,
2521fcf3ce44SJohn Forte MSGSTR(2077, " Error: can't open kstat\n"));
2522fcf3ce44SJohn Forte exit(-1);
2523fcf3ce44SJohn Forte }
2524fcf3ce44SJohn Forte
2525fcf3ce44SJohn Forte if (strstr(path_phys, SCSI_VHCI)) {
2526fcf3ce44SJohn Forte (void) strcpy(drvr_path, path_phys);
2527fcf3ce44SJohn Forte if (err = g_get_pathlist(drvr_path, &pathlist)) {
2528fcf3ce44SJohn Forte (void) print_errString(err, NULL);
2529fcf3ce44SJohn Forte exit(-1);
2530fcf3ce44SJohn Forte }
2531fcf3ce44SJohn Forte pathcnt = pathlist.path_count;
2532fcf3ce44SJohn Forte p_on = p_st = 0;
2533fcf3ce44SJohn Forte for (i = 0; i < pathcnt; i++) {
2534fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
2535fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state ==
2536fcf3ce44SJohn Forte MDI_PATHINFO_STATE_ONLINE) {
2537fcf3ce44SJohn Forte p_on = i;
2538fcf3ce44SJohn Forte break;
2539fcf3ce44SJohn Forte } else if (pathlist.path_info[i].path_state ==
2540fcf3ce44SJohn Forte MDI_PATHINFO_STATE_STANDBY) {
2541fcf3ce44SJohn Forte p_st = i;
2542fcf3ce44SJohn Forte }
2543fcf3ce44SJohn Forte }
2544fcf3ce44SJohn Forte }
2545fcf3ce44SJohn Forte if (pathlist.path_info[p_on].path_state ==
2546fcf3ce44SJohn Forte MDI_PATHINFO_STATE_ONLINE) {
2547fcf3ce44SJohn Forte /* on_line path */
2548fcf3ce44SJohn Forte (void) strcpy(drvr_path,
2549fcf3ce44SJohn Forte pathlist.path_info[p_on].path_hba);
2550fcf3ce44SJohn Forte } else {
2551fcf3ce44SJohn Forte /* standby or path0 */
2552fcf3ce44SJohn Forte (void) strcpy(drvr_path,
2553fcf3ce44SJohn Forte pathlist.path_info[p_st].path_hba);
2554fcf3ce44SJohn Forte }
2555fcf3ce44SJohn Forte free(pathlist.path_info);
2556fcf3ce44SJohn Forte } else {
2557fcf3ce44SJohn Forte
2558fcf3ce44SJohn Forte (void) strcpy(drvr_path, path_phys);
2559fcf3ce44SJohn Forte
2560fcf3ce44SJohn Forte if ((char_ptr = strrchr(drvr_path, '/')) == NULL) {
2561fcf3ce44SJohn Forte (void) print_errString(L_INVLD_PATH_NO_SLASH_FND,
2562fcf3ce44SJohn Forte path_phys);
2563fcf3ce44SJohn Forte exit(-1);
2564fcf3ce44SJohn Forte }
2565fcf3ce44SJohn Forte *char_ptr = '\0'; /* Make into nexus or HBA driver path. */
2566fcf3ce44SJohn Forte }
2567fcf3ce44SJohn Forte /*
2568fcf3ce44SJohn Forte * Each HBA and driver stack has its own structures
2569fcf3ce44SJohn Forte * for this, so we have to handle each one individually.
2570fcf3ce44SJohn Forte */
2571fcf3ce44SJohn Forte path_type = g_get_path_type(drvr_path);
2572fcf3ce44SJohn Forte
2573fcf3ce44SJohn Forte if (path_type) { /* Quick sanity check for valid path */
2574fcf3ce44SJohn Forte if ((err = g_get_nexus_path(drvr_path, &char_ptr)) != 0) {
2575fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
2576fcf3ce44SJohn Forte exit(-1);
2577fcf3ce44SJohn Forte }
2578fcf3ce44SJohn Forte (void) strcpy(socal_path, char_ptr);
2579fcf3ce44SJohn Forte
2580fcf3ce44SJohn Forte }
2581fcf3ce44SJohn Forte
2582fcf3ce44SJohn Forte /* attach :devctl to get node stat instead of dir stat. */
2583fcf3ce44SJohn Forte (void) strcat(drvr_path, FC_CTLR);
2584fcf3ce44SJohn Forte
2585fcf3ce44SJohn Forte if (stat(drvr_path, &sbuf) < 0) {
2586fcf3ce44SJohn Forte (void) print_errString(L_LSTAT_ERROR, path_phys);
2587fcf3ce44SJohn Forte exit(-1);
2588fcf3ce44SJohn Forte }
2589fcf3ce44SJohn Forte
2590fcf3ce44SJohn Forte drvr_inst = minor(sbuf.st_rdev);
2591fcf3ce44SJohn Forte
2592fcf3ce44SJohn Forte
2593fcf3ce44SJohn Forte /*
2594fcf3ce44SJohn Forte * first take care of ifp card.
2595fcf3ce44SJohn Forte */
2596fcf3ce44SJohn Forte if (path_type & FC4_PCI_FCA) {
2597fcf3ce44SJohn Forte if ((ifp_ks = kstat_lookup(kc, "ifp",
2598fcf3ce44SJohn Forte drvr_inst, "statistics")) != NULL) {
2599fcf3ce44SJohn Forte
2600*863dc479SJan Schlien if (kstat_read(kc, ifp_ks, &ifp_stats) == -1) {
2601fcf3ce44SJohn Forte (void) fprintf(stderr,
2602fcf3ce44SJohn Forte MSGSTR(2082,
2603fcf3ce44SJohn Forte "Error: could not read ifp%d\n"), drvr_inst);
2604fcf3ce44SJohn Forte exit(-1);
2605fcf3ce44SJohn Forte }
2606fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2083,
2607fcf3ce44SJohn Forte "\tInformation for FC Loop of"
2608fcf3ce44SJohn Forte " FC100/P Host Adapter\n\tat path: %s\n"),
2609fcf3ce44SJohn Forte drvr_path);
2610fcf3ce44SJohn Forte if (ifp_stats.version > 1) {
2611fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
2612fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(32,
2613fcf3ce44SJohn Forte "Information from %s"),
2614fcf3ce44SJohn Forte ifp_stats.drvr_name);
2615fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
2616fcf3ce44SJohn Forte if ((*ifp_stats.node_wwn != NULL) &&
2617fcf3ce44SJohn Forte (*ifp_stats.port_wwn != NULL)) {
2618fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(104,
2619fcf3ce44SJohn Forte " Host Adapter WWN's: Node:%s"
2620fcf3ce44SJohn Forte " Port:%s\n"),
2621fcf3ce44SJohn Forte ifp_stats.node_wwn,
2622fcf3ce44SJohn Forte ifp_stats.port_wwn);
2623fcf3ce44SJohn Forte }
2624fcf3ce44SJohn Forte if (*ifp_stats.fw_revision != NULL) {
2625fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(105,
2626fcf3ce44SJohn Forte " Host Adapter Firmware Revision: %s\n"),
2627fcf3ce44SJohn Forte ifp_stats.fw_revision);
2628fcf3ce44SJohn Forte }
2629fcf3ce44SJohn Forte if (ifp_stats.parity_chk_enabled != 0) {
2630fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2084,
2631fcf3ce44SJohn Forte " This Host Adapter checks "
2632fcf3ce44SJohn Forte "PCI-Bus parity.\n"));
2633fcf3ce44SJohn Forte }
2634fcf3ce44SJohn Forte }
2635fcf3ce44SJohn Forte
2636fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2085,
2637fcf3ce44SJohn Forte " Version Lips\n"));
2638fcf3ce44SJohn Forte (void) fprintf(stdout, " %10d%7d\n",
2639fcf3ce44SJohn Forte ifp_stats.version,
2640fcf3ce44SJohn Forte ifp_stats.lip_count);
2641fcf3ce44SJohn Forte /* If any status conditions exist then display */
2642fcf3ce44SJohn Forte for (i = 0; i < FC_STATUS_ENTRIES; i++) {
2643fcf3ce44SJohn Forte if (ifp_stats.resp_status[i] != 0) {
2644fcf3ce44SJohn Forte if (header_flag++ == 0) {
2645fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2086,
2646fcf3ce44SJohn Forte " Fibre Channel Transport "
2647fcf3ce44SJohn Forte "status:\n "
2648fcf3ce44SJohn Forte "Status "
2649fcf3ce44SJohn Forte " Value"
2650fcf3ce44SJohn Forte " Count\n"));
2651fcf3ce44SJohn Forte }
2652fcf3ce44SJohn Forte (void) l_format_ifp_status_msg(
2653fcf3ce44SJohn Forte status_msg_buf,
2654fcf3ce44SJohn Forte ifp_stats.resp_status[i], i);
2655fcf3ce44SJohn Forte (void) fprintf(stdout, " %s\n",
2656fcf3ce44SJohn Forte status_msg_buf);
2657fcf3ce44SJohn Forte }
2658fcf3ce44SJohn Forte }
2659fcf3ce44SJohn Forte
2660fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2087,
2661fcf3ce44SJohn Forte "\n\t\tTARGET ERROR INFORMATION:\n"));
2662fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2088,
2663fcf3ce44SJohn Forte "AL_PA logouts_recvd task_mgmt_failures"
2664fcf3ce44SJohn Forte " data_ro_mismatches data_len_mismatch\n"));
2665fcf3ce44SJohn Forte
2666fcf3ce44SJohn Forte if (err = g_get_dev_map(path_phys, &map,
2667fcf3ce44SJohn Forte (Options & PVERBOSE))) {
2668fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
2669fcf3ce44SJohn Forte exit(-1);
2670fcf3ce44SJohn Forte }
2671fcf3ce44SJohn Forte
2672fcf3ce44SJohn Forte
2673fcf3ce44SJohn Forte if (dtype == DTYPE_DIRECT) {
2674fcf3ce44SJohn Forte if (err = g_get_wwn(path_phys, port_wwn,
2675fcf3ce44SJohn Forte node_wwn, &al_pa,
2676fcf3ce44SJohn Forte Options & PVERBOSE)) {
2677fcf3ce44SJohn Forte (void) print_errString(err,
2678fcf3ce44SJohn Forte path_phys);
2679fcf3ce44SJohn Forte exit(-1);
2680fcf3ce44SJohn Forte }
2681fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr;
2682fcf3ce44SJohn Forte i < map.count; i++,
2683fcf3ce44SJohn Forte dev_addr_list++) {
2684fcf3ce44SJohn Forte if (dev_addr_list->gfc_port_dev.
2685fcf3ce44SJohn Forte priv_port.sf_al_pa
2686fcf3ce44SJohn Forte == al_pa) {
2687fcf3ce44SJohn Forte (void) fprintf
2688fcf3ce44SJohn Forte (stdout,
2689fcf3ce44SJohn Forte "%3x%14d%18d%20d%20d\n",
2690fcf3ce44SJohn Forte al_pa,
2691fcf3ce44SJohn Forte ifp_stats.tstats[i].
2692fcf3ce44SJohn Forte logouts_recvd,
2693fcf3ce44SJohn Forte ifp_stats.tstats[i].
2694fcf3ce44SJohn Forte task_mgmt_failures,
2695fcf3ce44SJohn Forte ifp_stats.tstats[i].
2696fcf3ce44SJohn Forte data_ro_mismatches,
2697fcf3ce44SJohn Forte ifp_stats.tstats[i].
2698fcf3ce44SJohn Forte dl_len_mismatches);
2699fcf3ce44SJohn Forte break;
2700fcf3ce44SJohn Forte }
2701fcf3ce44SJohn Forte }
2702fcf3ce44SJohn Forte if (i >= map.count) {
2703fcf3ce44SJohn Forte
2704fcf3ce44SJohn Forte (void) print_errString(
2705fcf3ce44SJohn Forte L_INVALID_LOOP_MAP, path_phys);
2706fcf3ce44SJohn Forte exit(-1);
2707fcf3ce44SJohn Forte }
2708fcf3ce44SJohn Forte
2709fcf3ce44SJohn Forte } else {
2710fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr;
2711fcf3ce44SJohn Forte i < map.count; i++,
2712fcf3ce44SJohn Forte dev_addr_list++) {
2713fcf3ce44SJohn Forte (void) fprintf(stdout,
2714fcf3ce44SJohn Forte "%3x%14d%18d%20d%20d\n",
2715fcf3ce44SJohn Forte dev_addr_list->gfc_port_dev.
2716fcf3ce44SJohn Forte priv_port.sf_al_pa,
2717fcf3ce44SJohn Forte ifp_stats.tstats[i].logouts_recvd,
2718fcf3ce44SJohn Forte ifp_stats.tstats[i].task_mgmt_failures,
2719fcf3ce44SJohn Forte ifp_stats.tstats[i].data_ro_mismatches,
2720fcf3ce44SJohn Forte ifp_stats.tstats[i].dl_len_mismatches);
2721fcf3ce44SJohn Forte }
2722fcf3ce44SJohn Forte }
2723fcf3ce44SJohn Forte
2724fcf3ce44SJohn Forte free((void *)map.dev_addr);
2725fcf3ce44SJohn Forte }
2726fcf3ce44SJohn Forte } else if (path_type & FC4_SF_XPORT) {
2727fcf3ce44SJohn Forte /*
2728fcf3ce44SJohn Forte * process cards with sf xport nodes.
2729fcf3ce44SJohn Forte */
2730fcf3ce44SJohn Forte if (stat(socal_path, &sbuf) < 0) {
2731fcf3ce44SJohn Forte (void) print_errString(L_LSTAT_ERROR, path_phys);
2732fcf3ce44SJohn Forte exit(-1);
2733fcf3ce44SJohn Forte }
2734fcf3ce44SJohn Forte socal_inst = minor(sbuf.st_rdev)/2;
2735fcf3ce44SJohn Forte port = socal_inst%2;
2736fcf3ce44SJohn Forte
2737fcf3ce44SJohn Forte sf_inst = LUX_SF_MINOR2INST(minor(sbuf.st_rdev));
2738fcf3ce44SJohn Forte if (!(sf_ks = kstat_lookup(kc, "sf", sf_inst,
2739fcf3ce44SJohn Forte "statistics"))) {
2740fcf3ce44SJohn Forte (void) fprintf(stderr,
2741fcf3ce44SJohn Forte MSGSTR(2078,
2742fcf3ce44SJohn Forte " Error: could not lookup driver stats for sf%d\n"),
2743fcf3ce44SJohn Forte sf_inst);
2744fcf3ce44SJohn Forte exit(-1);
2745fcf3ce44SJohn Forte }
2746fcf3ce44SJohn Forte if (!(fc_ks = kstat_lookup(kc, "socal", socal_inst,
2747fcf3ce44SJohn Forte "statistics"))) {
2748fcf3ce44SJohn Forte (void) fprintf(stderr,
2749fcf3ce44SJohn Forte MSGSTR(2079,
2750fcf3ce44SJohn Forte " Error: could not lookup driver stats for socal%d\n"),
2751fcf3ce44SJohn Forte socal_inst);
2752fcf3ce44SJohn Forte exit(-1);
2753fcf3ce44SJohn Forte }
2754*863dc479SJan Schlien if (kstat_read(kc, sf_ks, &sf_stats) == -1) {
2755fcf3ce44SJohn Forte (void) fprintf(stderr,
2756fcf3ce44SJohn Forte MSGSTR(2080,
2757fcf3ce44SJohn Forte " Error: could not read driver stats for sf%d\n"),
2758fcf3ce44SJohn Forte sf_inst);
2759fcf3ce44SJohn Forte exit(-1);
2760fcf3ce44SJohn Forte }
2761*863dc479SJan Schlien if (kstat_read(kc, fc_ks, &fc_stats) == -1) {
2762fcf3ce44SJohn Forte (void) fprintf(stderr,
2763fcf3ce44SJohn Forte MSGSTR(2081,
2764fcf3ce44SJohn Forte " Error: could not read driver stats for socal%d\n"),
2765fcf3ce44SJohn Forte socal_inst);
2766fcf3ce44SJohn Forte exit(-1);
2767fcf3ce44SJohn Forte }
2768fcf3ce44SJohn Forte (void) display_socal_stats(port, socal_path, &fc_stats);
2769fcf3ce44SJohn Forte (void) display_sf_stats(path_phys, dtype, &sf_stats);
2770fcf3ce44SJohn Forte } else if ((path_type & FC_FCA_MASK) == FC_PCI_FCA) {
2771fcf3ce44SJohn Forte fprintf(stderr, MSGSTR(2252,
2772fcf3ce44SJohn Forte "\n WARNING!! display -r on qlc is"
2773fcf3ce44SJohn Forte " currently not supported.\n"));
2774fcf3ce44SJohn Forte } else {
2775fcf3ce44SJohn Forte fprintf(stderr, MSGSTR(2253,
2776fcf3ce44SJohn Forte "\n WARNING!! display -r is not supported on path\n"
2777fcf3ce44SJohn Forte " %s\n"), drvr_path);
2778fcf3ce44SJohn Forte }
2779fcf3ce44SJohn Forte (void) kstat_close(kc);
2780fcf3ce44SJohn Forte
2781fcf3ce44SJohn Forte }
2782fcf3ce44SJohn Forte
2783fcf3ce44SJohn Forte
2784fcf3ce44SJohn Forte
2785fcf3ce44SJohn Forte /*ARGSUSED*/
2786fcf3ce44SJohn Forte /*
2787fcf3ce44SJohn Forte * adm_display_verbose_disk() Gets the mode page information
2788fcf3ce44SJohn Forte * for a SENA disk and prints that information.
2789fcf3ce44SJohn Forte *
2790fcf3ce44SJohn Forte * RETURNS:
2791fcf3ce44SJohn Forte * none.
2792fcf3ce44SJohn Forte */
2793fcf3ce44SJohn Forte void
adm_display_verbose_disk(char * path,int verbose)2794fcf3ce44SJohn Forte adm_display_verbose_disk(char *path, int verbose)
2795fcf3ce44SJohn Forte {
2796fcf3ce44SJohn Forte uchar_t *pg_buf;
2797fcf3ce44SJohn Forte Mode_header_10 *mode_header_ptr;
2798fcf3ce44SJohn Forte Mp_01 *pg1_buf;
2799fcf3ce44SJohn Forte Mp_04 *pg4_buf;
2800fcf3ce44SJohn Forte struct mode_page *pg_hdr;
2801fcf3ce44SJohn Forte int offset, hdr_printed = 0, err = 0;
2802fcf3ce44SJohn Forte
2803fcf3ce44SJohn Forte if ((err = l_get_mode_pg(path, &pg_buf, verbose)) == 0) {
2804fcf3ce44SJohn Forte
2805fcf3ce44SJohn Forte mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
2806fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
2807fcf3ce44SJohn Forte (uchar_t)sizeof (struct mode_header_10_struct) +
2808fcf3ce44SJohn Forte (uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
2809fcf3ce44SJohn Forte offset = sizeof (struct mode_header_10_struct) +
2810fcf3ce44SJohn Forte mode_header_ptr->bdesc_length;
2811fcf3ce44SJohn Forte while (offset < (mode_header_ptr->length +
2812fcf3ce44SJohn Forte sizeof (mode_header_ptr->length))) {
2813fcf3ce44SJohn Forte switch (pg_hdr->code) {
2814fcf3ce44SJohn Forte case 0x01:
2815fcf3ce44SJohn Forte pg1_buf = (struct mode_page_01_struct *)
2816fcf3ce44SJohn Forte (int)pg_hdr;
2817fcf3ce44SJohn Forte P_DPRINTF(" adm_display_verbose_disk:"
2818fcf3ce44SJohn Forte "Mode Sense page 1 found.\n");
2819fcf3ce44SJohn Forte if (hdr_printed++ == 0) {
2820fcf3ce44SJohn Forte (void) fprintf(stdout,
2821fcf3ce44SJohn Forte MSGSTR(2089,
2822fcf3ce44SJohn Forte " Mode Sense data:\n"));
2823fcf3ce44SJohn Forte }
2824fcf3ce44SJohn Forte (void) fprintf(stdout,
2825fcf3ce44SJohn Forte MSGSTR(2090,
2826fcf3ce44SJohn Forte " AWRE:\t\t\t%d\n"
2827fcf3ce44SJohn Forte " ARRE:\t\t\t%d\n"
2828fcf3ce44SJohn Forte " Read Retry Count:\t\t"
2829fcf3ce44SJohn Forte "%d\n"
2830fcf3ce44SJohn Forte " Write Retry Count:\t\t"
2831fcf3ce44SJohn Forte "%d\n"),
2832fcf3ce44SJohn Forte pg1_buf->awre,
2833fcf3ce44SJohn Forte pg1_buf->arre,
2834fcf3ce44SJohn Forte pg1_buf->read_retry_count,
2835fcf3ce44SJohn Forte pg1_buf->write_retry_count);
2836fcf3ce44SJohn Forte break;
2837fcf3ce44SJohn Forte case MODEPAGE_GEOMETRY:
2838fcf3ce44SJohn Forte pg4_buf = (struct mode_page_04_struct *)
2839fcf3ce44SJohn Forte (int)pg_hdr;
2840fcf3ce44SJohn Forte P_DPRINTF(" adm_display_verbose_disk:"
2841fcf3ce44SJohn Forte "Mode Sense page 4 found.\n");
2842fcf3ce44SJohn Forte if (hdr_printed++ == 0) {
2843fcf3ce44SJohn Forte (void) fprintf(stdout,
2844fcf3ce44SJohn Forte MSGSTR(2091,
2845fcf3ce44SJohn Forte " Mode Sense data:\n"));
2846fcf3ce44SJohn Forte }
2847fcf3ce44SJohn Forte if (pg4_buf->rpm) {
2848fcf3ce44SJohn Forte (void) fprintf(stdout,
2849fcf3ce44SJohn Forte MSGSTR(2092,
2850fcf3ce44SJohn Forte " Medium rotation rate:\t"
2851fcf3ce44SJohn Forte "%d RPM\n"), pg4_buf->rpm);
2852fcf3ce44SJohn Forte }
2853fcf3ce44SJohn Forte break;
2854fcf3ce44SJohn Forte }
2855fcf3ce44SJohn Forte offset += pg_hdr->length + sizeof (struct mode_page);
2856fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
2857fcf3ce44SJohn Forte (uchar_t)offset));
2858fcf3ce44SJohn Forte }
2859fcf3ce44SJohn Forte
2860fcf3ce44SJohn Forte
2861fcf3ce44SJohn Forte
2862fcf3ce44SJohn Forte
2863fcf3ce44SJohn Forte
2864fcf3ce44SJohn Forte } else if (getenv("_LUX_P_DEBUG") != NULL) {
2865fcf3ce44SJohn Forte (void) print_errString(err, path);
2866fcf3ce44SJohn Forte }
2867fcf3ce44SJohn Forte }
2868fcf3ce44SJohn Forte
2869fcf3ce44SJohn Forte /*
2870fcf3ce44SJohn Forte * Print out the port_wwn or node_wwn
2871fcf3ce44SJohn Forte */
2872fcf3ce44SJohn Forte void
print_wwn(FILE * fd,uchar_t * pn_wwn)2873fcf3ce44SJohn Forte print_wwn(FILE *fd, uchar_t *pn_wwn)
2874fcf3ce44SJohn Forte {
2875fcf3ce44SJohn Forte
2876fcf3ce44SJohn Forte (void) fprintf(fd,
2877fcf3ce44SJohn Forte " %1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
2878fcf3ce44SJohn Forte pn_wwn[0], pn_wwn[1], pn_wwn[2], pn_wwn[3],
2879fcf3ce44SJohn Forte pn_wwn[4], pn_wwn[5], pn_wwn[6], pn_wwn[7]);
2880fcf3ce44SJohn Forte }
2881fcf3ce44SJohn Forte
2882fcf3ce44SJohn Forte /*
2883fcf3ce44SJohn Forte * Print out the fabric dev port_id, hard_addr, port_wwn and node_wwn
2884fcf3ce44SJohn Forte */
2885fcf3ce44SJohn Forte void
print_fabric_prop(int pos,uchar_t * port_wwn,uchar_t * node_wwn,int port_addr,int hard_addr)2886fcf3ce44SJohn Forte print_fabric_prop(int pos, uchar_t *port_wwn, uchar_t *node_wwn, int port_addr,
2887fcf3ce44SJohn Forte int hard_addr)
2888fcf3ce44SJohn Forte {
2889fcf3ce44SJohn Forte (void) fprintf(stdout, "%-4d %-6x %-6x ",
2890fcf3ce44SJohn Forte pos, port_addr, hard_addr);
2891fcf3ce44SJohn Forte print_wwn(stdout, port_wwn);
2892fcf3ce44SJohn Forte print_wwn(stdout, node_wwn);
2893fcf3ce44SJohn Forte }
2894fcf3ce44SJohn Forte
2895fcf3ce44SJohn Forte /*
2896fcf3ce44SJohn Forte * Print out the private loop dev port_id, hard_addr, port_wwn and node_wwn
2897fcf3ce44SJohn Forte */
2898fcf3ce44SJohn Forte void
print_private_loop_prop(int pos,uchar_t * port_wwn,uchar_t * node_wwn,int port_addr,int hard_addr)2899fcf3ce44SJohn Forte print_private_loop_prop(int pos, uchar_t *port_wwn, uchar_t *node_wwn,
2900fcf3ce44SJohn Forte int port_addr, int hard_addr)
2901fcf3ce44SJohn Forte {
2902fcf3ce44SJohn Forte (void) fprintf(stdout, "%-3d %-2x %-2x %-2x ",
2903fcf3ce44SJohn Forte pos, port_addr, g_sf_alpa_to_switch[port_addr], hard_addr);
2904fcf3ce44SJohn Forte print_wwn(stdout, port_wwn);
2905fcf3ce44SJohn Forte print_wwn(stdout, node_wwn);
2906fcf3ce44SJohn Forte }
2907fcf3ce44SJohn Forte
2908fcf3ce44SJohn Forte /*
2909fcf3ce44SJohn Forte * Get the device map from
2910fcf3ce44SJohn Forte * fc nexus driver and prints the map.
2911fcf3ce44SJohn Forte *
2912fcf3ce44SJohn Forte * RETURNS:
2913fcf3ce44SJohn Forte * none.
2914fcf3ce44SJohn Forte */
2915fcf3ce44SJohn Forte void
dump_map(char ** argv)2916fcf3ce44SJohn Forte dump_map(char **argv)
2917fcf3ce44SJohn Forte {
2918fcf3ce44SJohn Forte int i = 0, path_index = 0, pathcnt = 1;
2919fcf3ce44SJohn Forte int limited_map_flag = 0, err = 0;
2920fcf3ce44SJohn Forte char *path_phys = NULL;
2921fcf3ce44SJohn Forte Path_struct *path_struct;
2922fcf3ce44SJohn Forte struct lilpmap limited_map;
2923fcf3ce44SJohn Forte uint_t dev_type;
2924fcf3ce44SJohn Forte char temp2path[MAXPATHLEN];
2925fcf3ce44SJohn Forte mp_pathlist_t pathlist;
2926fcf3ce44SJohn Forte int p_pw = 0, p_on = 0, p_st = 0;
2927fcf3ce44SJohn Forte gfc_dev_t map_root, map_dev;
2928fcf3ce44SJohn Forte int *port_addr, *hard_addr, pos = 0, count;
2929fcf3ce44SJohn Forte uchar_t *hba_port_wwn, *port_wwn, *node_wwn, *dtype_prop;
2930fcf3ce44SJohn Forte uint_t map_topo;
2931fcf3ce44SJohn Forte
2932fcf3ce44SJohn Forte while (argv[path_index] != NULL) {
2933fcf3ce44SJohn Forte if ((err = l_convert_name(argv[path_index], &path_phys,
2934fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
2935fcf3ce44SJohn Forte (void) fprintf(stderr,
2936fcf3ce44SJohn Forte MSGSTR(33,
2937fcf3ce44SJohn Forte " Error: converting"
2938fcf3ce44SJohn Forte " %s to physical path.\n"
2939fcf3ce44SJohn Forte " Invalid pathname.\n"),
2940fcf3ce44SJohn Forte argv[path_index]);
2941fcf3ce44SJohn Forte if (err != -1) {
2942fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
2943fcf3ce44SJohn Forte }
2944fcf3ce44SJohn Forte exit(-1);
2945fcf3ce44SJohn Forte }
2946fcf3ce44SJohn Forte
2947fcf3ce44SJohn Forte if (strstr(path_phys, SCSI_VHCI) != NULL) {
2948fcf3ce44SJohn Forte /* obtain phci */
2949fcf3ce44SJohn Forte (void) strcpy(temp2path, path_phys);
2950fcf3ce44SJohn Forte if (err = g_get_pathlist(temp2path, &pathlist)) {
2951fcf3ce44SJohn Forte (void) print_errString(err, NULL);
2952fcf3ce44SJohn Forte exit(-1);
2953fcf3ce44SJohn Forte }
2954fcf3ce44SJohn Forte pathcnt = pathlist.path_count;
2955fcf3ce44SJohn Forte p_pw = p_on = p_st = 0;
2956fcf3ce44SJohn Forte for (i = 0; i < pathcnt; i++) {
2957fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state <
2958fcf3ce44SJohn Forte MAXPATHSTATE) {
2959fcf3ce44SJohn Forte if (strstr(pathlist.path_info[i].
2960fcf3ce44SJohn Forte path_addr,
2961fcf3ce44SJohn Forte path_struct->argv) != NULL) {
2962fcf3ce44SJohn Forte p_pw = i;
2963fcf3ce44SJohn Forte break;
2964fcf3ce44SJohn Forte }
2965fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state ==
2966fcf3ce44SJohn Forte MDI_PATHINFO_STATE_ONLINE) {
2967fcf3ce44SJohn Forte p_on = i;
2968fcf3ce44SJohn Forte }
2969fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state ==
2970fcf3ce44SJohn Forte MDI_PATHINFO_STATE_STANDBY) {
2971fcf3ce44SJohn Forte p_st = i;
2972fcf3ce44SJohn Forte }
2973fcf3ce44SJohn Forte }
2974fcf3ce44SJohn Forte }
2975fcf3ce44SJohn Forte if (strstr(pathlist.path_info[p_pw].path_addr,
2976fcf3ce44SJohn Forte path_struct->argv) != NULL) {
2977fcf3ce44SJohn Forte /* matching input pwwn */
2978fcf3ce44SJohn Forte (void) strcpy(temp2path,
2979fcf3ce44SJohn Forte pathlist.path_info[p_pw].path_hba);
2980fcf3ce44SJohn Forte } else if (pathlist.path_info[p_on].path_state ==
2981fcf3ce44SJohn Forte MDI_PATHINFO_STATE_ONLINE) {
2982fcf3ce44SJohn Forte /* on_line path */
2983fcf3ce44SJohn Forte (void) strcpy(temp2path,
2984fcf3ce44SJohn Forte pathlist.path_info[p_on].path_hba);
2985fcf3ce44SJohn Forte } else {
2986fcf3ce44SJohn Forte /* standby or path0 */
2987fcf3ce44SJohn Forte (void) strcpy(temp2path,
2988fcf3ce44SJohn Forte pathlist.path_info[p_st].path_hba);
2989fcf3ce44SJohn Forte }
2990fcf3ce44SJohn Forte free(pathlist.path_info);
2991fcf3ce44SJohn Forte (void) strcat(temp2path, FC_CTLR);
2992fcf3ce44SJohn Forte } else {
2993fcf3ce44SJohn Forte (void) strcpy(temp2path, path_phys);
2994fcf3ce44SJohn Forte }
2995fcf3ce44SJohn Forte
2996fcf3ce44SJohn Forte if ((dev_type = g_get_path_type(temp2path)) == 0) {
2997fcf3ce44SJohn Forte (void) print_errString(L_INVALID_PATH,
2998fcf3ce44SJohn Forte argv[path_index]);
2999fcf3ce44SJohn Forte exit(-1);
3000fcf3ce44SJohn Forte }
3001fcf3ce44SJohn Forte
3002fcf3ce44SJohn Forte if ((map_root = g_dev_map_init(temp2path, &err,
3003fcf3ce44SJohn Forte MAP_FORMAT_LILP)) == NULL) {
3004fcf3ce44SJohn Forte if (dev_type & FC_FCA_MASK) {
3005fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3006fcf3ce44SJohn Forte exit(-1);
3007fcf3ce44SJohn Forte } else {
3008fcf3ce44SJohn Forte /*
3009fcf3ce44SJohn Forte * This did not work so try the FCIO_GETMAP
3010fcf3ce44SJohn Forte * type ioctl.
3011fcf3ce44SJohn Forte */
3012fcf3ce44SJohn Forte if (err = g_get_limited_map(path_phys,
3013fcf3ce44SJohn Forte &limited_map, (Options & PVERBOSE))) {
3014fcf3ce44SJohn Forte (void) print_errString(err,
3015fcf3ce44SJohn Forte argv[path_index]);
3016fcf3ce44SJohn Forte exit(-1);
3017fcf3ce44SJohn Forte }
3018fcf3ce44SJohn Forte limited_map_flag++;
3019fcf3ce44SJohn Forte }
3020fcf3ce44SJohn Forte
3021fcf3ce44SJohn Forte }
3022fcf3ce44SJohn Forte
3023fcf3ce44SJohn Forte if (limited_map_flag) {
3024fcf3ce44SJohn Forte (void) fprintf(stdout,
3025fcf3ce44SJohn Forte MSGSTR(2093,
3026fcf3ce44SJohn Forte "Host Adapter AL_PA: %x\n"),
3027fcf3ce44SJohn Forte limited_map.lilp_myalpa);
3028fcf3ce44SJohn Forte
3029fcf3ce44SJohn Forte (void) fprintf(stdout,
3030fcf3ce44SJohn Forte MSGSTR(2094,
3031fcf3ce44SJohn Forte "Pos AL_PA\n"));
3032fcf3ce44SJohn Forte for (i = 0; i < (uint_t)limited_map.lilp_length; i++) {
3033fcf3ce44SJohn Forte (void) fprintf(stdout, "%-3d %-2x\n",
3034fcf3ce44SJohn Forte i, limited_map.lilp_list[i]);
3035fcf3ce44SJohn Forte }
3036fcf3ce44SJohn Forte } else {
3037fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_root,
3038fcf3ce44SJohn Forte PORT_WWN_PROP, &count, &hba_port_wwn)) != 0) {
3039fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3040fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3041fcf3ce44SJohn Forte exit(-1);
3042fcf3ce44SJohn Forte }
3043fcf3ce44SJohn Forte if ((err = g_get_map_topology(
3044fcf3ce44SJohn Forte map_root, &map_topo)) != 0) {
3045fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3046fcf3ce44SJohn Forte exit(-1);
3047fcf3ce44SJohn Forte }
3048fcf3ce44SJohn Forte
3049fcf3ce44SJohn Forte if ((map_dev = g_get_first_dev(map_root, &err)) == NULL) {
3050fcf3ce44SJohn Forte if (err == L_NO_SUCH_DEV_FOUND) {
3051fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3052fcf3ce44SJohn Forte (void) fprintf(stderr,
3053fcf3ce44SJohn Forte MSGSTR(2308, " No devices are found on %s.\n"),
3054fcf3ce44SJohn Forte argv[path_index]);
3055fcf3ce44SJohn Forte exit(-1);
3056fcf3ce44SJohn Forte } else {
3057fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3058fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3059fcf3ce44SJohn Forte exit(-1);
3060fcf3ce44SJohn Forte }
3061fcf3ce44SJohn Forte }
3062fcf3ce44SJohn Forte
3063fcf3ce44SJohn Forte switch (map_topo) {
3064fcf3ce44SJohn Forte case FC_TOP_FABRIC:
3065fcf3ce44SJohn Forte case FC_TOP_PUBLIC_LOOP:
3066fcf3ce44SJohn Forte case FC_TOP_PT_PT:
3067fcf3ce44SJohn Forte (void) fprintf(stdout,
3068fcf3ce44SJohn Forte MSGSTR(2095, "Pos Port_ID Hard_Addr Port WWN"
3069fcf3ce44SJohn Forte " Node WWN Type\n"));
3070fcf3ce44SJohn Forte while (map_dev) {
3071fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_ints(
3072fcf3ce44SJohn Forte map_dev, PORT_ADDR_PROP, &port_addr)) != 0) {
3073fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3074fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3075fcf3ce44SJohn Forte exit(-1);
3076fcf3ce44SJohn Forte }
3077fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3078fcf3ce44SJohn Forte PORT_WWN_PROP, &count, &port_wwn)) != 0) {
3079fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3080fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3081fcf3ce44SJohn Forte exit(-1);
3082fcf3ce44SJohn Forte }
3083fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3084fcf3ce44SJohn Forte NODE_WWN_PROP, &count, &node_wwn)) != 0) {
3085fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3086fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3087fcf3ce44SJohn Forte exit(-1);
3088fcf3ce44SJohn Forte }
3089fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_ints(
3090fcf3ce44SJohn Forte map_dev, HARD_ADDR_PROP, &hard_addr)) != 0) {
3091fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3092fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3093fcf3ce44SJohn Forte exit(-1);
3094fcf3ce44SJohn Forte }
3095fcf3ce44SJohn Forte print_fabric_prop(pos++, port_wwn,
3096fcf3ce44SJohn Forte node_wwn, *port_addr, *hard_addr);
3097fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3098fcf3ce44SJohn Forte INQ_DTYPE_PROP, &count, &dtype_prop)) != 0) {
3099fcf3ce44SJohn Forte (void) fprintf(stdout,
3100fcf3ce44SJohn Forte MSGSTR(2307, " Failed to get the type.\n"));
3101fcf3ce44SJohn Forte } else {
3102fcf3ce44SJohn Forte print_fabric_dtype_prop(hba_port_wwn, port_wwn,
3103fcf3ce44SJohn Forte *dtype_prop);
3104fcf3ce44SJohn Forte }
3105fcf3ce44SJohn Forte
3106fcf3ce44SJohn Forte if (((map_dev = g_get_next_dev(
3107fcf3ce44SJohn Forte map_dev, &err)) == NULL) &&
3108fcf3ce44SJohn Forte (err != L_NO_SUCH_DEV_FOUND)) {
3109fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3110fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3111fcf3ce44SJohn Forte exit(-1);
3112fcf3ce44SJohn Forte }
3113fcf3ce44SJohn Forte }
3114fcf3ce44SJohn Forte break;
3115fcf3ce44SJohn Forte case FC_TOP_PRIVATE_LOOP:
3116fcf3ce44SJohn Forte (void) fprintf(stdout,
3117fcf3ce44SJohn Forte MSGSTR(2295,
3118fcf3ce44SJohn Forte "Pos AL_PA ID Hard_Addr "
3119fcf3ce44SJohn Forte "Port WWN Node WWN Type\n"));
3120fcf3ce44SJohn Forte
3121fcf3ce44SJohn Forte while (map_dev) {
3122fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_ints(
3123fcf3ce44SJohn Forte map_dev, PORT_ADDR_PROP, &port_addr)) != 0) {
3124fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3125fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3126fcf3ce44SJohn Forte exit(-1);
3127fcf3ce44SJohn Forte }
3128fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3129fcf3ce44SJohn Forte PORT_WWN_PROP, &count, &port_wwn)) != 0) {
3130fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3131fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3132fcf3ce44SJohn Forte exit(-1);
3133fcf3ce44SJohn Forte }
3134fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3135fcf3ce44SJohn Forte NODE_WWN_PROP, &count, &node_wwn)) != 0) {
3136fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3137fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3138fcf3ce44SJohn Forte exit(-1);
3139fcf3ce44SJohn Forte }
3140fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_ints(
3141fcf3ce44SJohn Forte map_dev, HARD_ADDR_PROP, &hard_addr)) != 0) {
3142fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3143fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3144fcf3ce44SJohn Forte exit(-1);
3145fcf3ce44SJohn Forte }
3146fcf3ce44SJohn Forte print_private_loop_prop(pos++, port_wwn,
3147fcf3ce44SJohn Forte node_wwn, *port_addr, *hard_addr);
3148fcf3ce44SJohn Forte if ((err = g_dev_prop_lookup_bytes(map_dev,
3149fcf3ce44SJohn Forte INQ_DTYPE_PROP, &count, &dtype_prop)) != 0) {
3150fcf3ce44SJohn Forte (void) fprintf(stdout,
3151fcf3ce44SJohn Forte MSGSTR(2307, " Failed to get the type.\n"));
3152fcf3ce44SJohn Forte } else {
3153fcf3ce44SJohn Forte print_private_loop_dtype_prop(hba_port_wwn,
3154fcf3ce44SJohn Forte port_wwn, *dtype_prop);
3155fcf3ce44SJohn Forte }
3156fcf3ce44SJohn Forte
3157fcf3ce44SJohn Forte if (((map_dev = g_get_next_dev(
3158fcf3ce44SJohn Forte map_dev, &err)) == NULL) &&
3159fcf3ce44SJohn Forte (err != L_NO_SUCH_DEV_FOUND)) {
3160fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3161fcf3ce44SJohn Forte (void) print_errString(err, argv[path_index]);
3162fcf3ce44SJohn Forte exit(-1);
3163fcf3ce44SJohn Forte }
3164fcf3ce44SJohn Forte }
3165fcf3ce44SJohn Forte break;
3166fcf3ce44SJohn Forte default:
3167fcf3ce44SJohn Forte (void) print_errString(L_UNEXPECTED_FC_TOPOLOGY,
3168fcf3ce44SJohn Forte argv[path_index]);
3169fcf3ce44SJohn Forte exit(-1);
3170fcf3ce44SJohn Forte }
3171fcf3ce44SJohn Forte g_dev_map_fini(map_root);
3172fcf3ce44SJohn Forte }
3173fcf3ce44SJohn Forte limited_map_flag = 0;
3174fcf3ce44SJohn Forte path_index++;
3175fcf3ce44SJohn Forte }
3176fcf3ce44SJohn Forte }
3177fcf3ce44SJohn Forte
3178fcf3ce44SJohn Forte /*
3179fcf3ce44SJohn Forte * Gets a list of non-SENA fcal devices
3180fcf3ce44SJohn Forte * found on the system.
3181fcf3ce44SJohn Forte *
3182fcf3ce44SJohn Forte * OUTPUT:
3183fcf3ce44SJohn Forte * wwn_list pointer
3184fcf3ce44SJohn Forte * NULL: No non-enclosure devices found.
3185fcf3ce44SJohn Forte * !NULL: Devices found
3186fcf3ce44SJohn Forte * wwn_list points to a linked list of wwn's.
3187fcf3ce44SJohn Forte * RETURNS:
3188fcf3ce44SJohn Forte * 0 O.K.
3189fcf3ce44SJohn Forte */
3190fcf3ce44SJohn Forte int
n_get_non_encl_list(WWN_list ** wwn_list_ptr,int verbose)3191fcf3ce44SJohn Forte n_get_non_encl_list(WWN_list **wwn_list_ptr, int verbose)
3192fcf3ce44SJohn Forte {
3193fcf3ce44SJohn Forte int i, j, k, err, found_ib = 0, pathcnt = 1;
3194fcf3ce44SJohn Forte WWN_list *wwn_list;
3195fcf3ce44SJohn Forte Box_list *b_list = NULL;
3196fcf3ce44SJohn Forte gfc_map_t map;
3197fcf3ce44SJohn Forte uchar_t box_id;
3198fcf3ce44SJohn Forte gfc_port_dev_info_t *dev_addr_list;
3199fcf3ce44SJohn Forte char phci_path[MAXPATHLEN], oldphci_path[MAXPATHLEN];
3200fcf3ce44SJohn Forte mp_pathlist_t pathlist;
3201fcf3ce44SJohn Forte
3202fcf3ce44SJohn Forte
3203fcf3ce44SJohn Forte /*
3204fcf3ce44SJohn Forte * Only interested in devices that are not part of
3205fcf3ce44SJohn Forte * a Photon enclosure.
3206fcf3ce44SJohn Forte */
3207fcf3ce44SJohn Forte if ((err = l_get_box_list(&b_list, verbose)) != 0) {
3208fcf3ce44SJohn Forte return (err); /* Failure */
3209fcf3ce44SJohn Forte }
3210fcf3ce44SJohn Forte
3211fcf3ce44SJohn Forte if (err = g_get_wwn_list(&wwn_list, verbose)) {
3212fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
3213fcf3ce44SJohn Forte return (err);
3214fcf3ce44SJohn Forte }
3215fcf3ce44SJohn Forte
3216fcf3ce44SJohn Forte while (b_list != NULL) {
3217fcf3ce44SJohn Forte
3218fcf3ce44SJohn Forte pathcnt = 1;
3219fcf3ce44SJohn Forte if (strstr(b_list->b_physical_path, SCSI_VHCI) != NULL) {
3220fcf3ce44SJohn Forte (void) strcpy(phci_path, b_list->b_physical_path);
3221fcf3ce44SJohn Forte if (err = g_get_pathlist(phci_path, &pathlist)) {
3222fcf3ce44SJohn Forte (void) print_errString(err, NULL);
3223fcf3ce44SJohn Forte exit(-1);
3224fcf3ce44SJohn Forte }
3225fcf3ce44SJohn Forte pathcnt = pathlist.path_count;
3226fcf3ce44SJohn Forte }
3227fcf3ce44SJohn Forte
3228fcf3ce44SJohn Forte for (k = 0; k < pathcnt; k++) {
3229fcf3ce44SJohn Forte
3230fcf3ce44SJohn Forte if ((k > 0) && (strstr(oldphci_path,
3231fcf3ce44SJohn Forte pathlist.path_info[k].path_hba))) {
3232fcf3ce44SJohn Forte continue;
3233fcf3ce44SJohn Forte }
3234fcf3ce44SJohn Forte
3235fcf3ce44SJohn Forte if (strstr(b_list->b_physical_path, SCSI_VHCI) == NULL) {
3236fcf3ce44SJohn Forte if ((err = g_get_dev_map(b_list->b_physical_path,
3237fcf3ce44SJohn Forte &map, verbose)) != 0) {
3238fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
3239fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
3240fcf3ce44SJohn Forte return (err);
3241fcf3ce44SJohn Forte }
3242fcf3ce44SJohn Forte } else {
3243fcf3ce44SJohn Forte (void) strcpy(phci_path,
3244fcf3ce44SJohn Forte pathlist.path_info[k].path_hba);
3245fcf3ce44SJohn Forte (void) strcpy(oldphci_path, phci_path);
3246fcf3ce44SJohn Forte (void) strcat(phci_path, FC_CTLR);
3247fcf3ce44SJohn Forte if (g_get_dev_map(phci_path, &map, verbose)) {
3248fcf3ce44SJohn Forte continue;
3249fcf3ce44SJohn Forte }
3250fcf3ce44SJohn Forte if (pathcnt == 1) {
3251fcf3ce44SJohn Forte free(pathlist.path_info);
3252fcf3ce44SJohn Forte }
3253fcf3ce44SJohn Forte }
3254fcf3ce44SJohn Forte
3255fcf3ce44SJohn Forte
3256fcf3ce44SJohn Forte switch (map.hba_addr.port_topology) {
3257fcf3ce44SJohn Forte case FC_TOP_FABRIC:
3258fcf3ce44SJohn Forte case FC_TOP_PUBLIC_LOOP:
3259fcf3ce44SJohn Forte
3260fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr;
3261fcf3ce44SJohn Forte i < map.count; i++, dev_addr_list++) {
3262fcf3ce44SJohn Forte for (found_ib = 1, j = 0; j < WWN_SIZE;
3263fcf3ce44SJohn Forte j++) {
3264fcf3ce44SJohn Forte if (b_list->b_node_wwn[j] !=
3265fcf3ce44SJohn Forte dev_addr_list->gfc_port_dev.
3266fcf3ce44SJohn Forte pub_port.dev_nwwn.raw_wwn[j]) {
3267fcf3ce44SJohn Forte found_ib = 0;
3268fcf3ce44SJohn Forte }
3269fcf3ce44SJohn Forte }
3270fcf3ce44SJohn Forte if (found_ib) {
3271fcf3ce44SJohn Forte (void) n_rem_list_entry_fabric(
3272fcf3ce44SJohn Forte dev_addr_list->gfc_port_dev.
3273fcf3ce44SJohn Forte pub_port.dev_did.port_id, &map,
3274fcf3ce44SJohn Forte &wwn_list);
3275fcf3ce44SJohn Forte }
3276fcf3ce44SJohn Forte }
3277fcf3ce44SJohn Forte break;
3278fcf3ce44SJohn Forte
3279fcf3ce44SJohn Forte case FC_TOP_PRIVATE_LOOP:
3280fcf3ce44SJohn Forte
3281fcf3ce44SJohn Forte for (i = 0, dev_addr_list = map.dev_addr;
3282fcf3ce44SJohn Forte i < map.count; i++, dev_addr_list++) {
3283fcf3ce44SJohn Forte for (found_ib = 1, j = 0; j < WWN_SIZE;
3284fcf3ce44SJohn Forte j++) {
3285fcf3ce44SJohn Forte if (b_list->b_node_wwn[j] !=
3286fcf3ce44SJohn Forte dev_addr_list->gfc_port_dev.
3287fcf3ce44SJohn Forte priv_port.sf_node_wwn[j]) {
3288fcf3ce44SJohn Forte found_ib = 0;
3289fcf3ce44SJohn Forte }
3290fcf3ce44SJohn Forte }
3291fcf3ce44SJohn Forte if (found_ib) {
3292fcf3ce44SJohn Forte box_id = g_sf_alpa_to_switch
3293fcf3ce44SJohn Forte [dev_addr_list->gfc_port_dev.
3294fcf3ce44SJohn Forte priv_port.sf_al_pa] &
3295fcf3ce44SJohn Forte BOX_ID_MASK;
3296fcf3ce44SJohn Forte /* This function has been added */
3297fcf3ce44SJohn Forte /* here only to keep from having */
3298fcf3ce44SJohn Forte /* to tab over farther */
3299fcf3ce44SJohn Forte (void) n_rem_list_entry(box_id, &map,
3300fcf3ce44SJohn Forte &wwn_list);
3301fcf3ce44SJohn Forte if (wwn_list == NULL) {
3302fcf3ce44SJohn Forte /* Return the list */
3303fcf3ce44SJohn Forte *wwn_list_ptr = NULL;
3304fcf3ce44SJohn Forte break;
3305fcf3ce44SJohn Forte }
3306fcf3ce44SJohn Forte }
3307fcf3ce44SJohn Forte }
3308fcf3ce44SJohn Forte break;
3309fcf3ce44SJohn Forte case FC_TOP_PT_PT:
3310fcf3ce44SJohn Forte (void) free((void *)map.dev_addr);
3311fcf3ce44SJohn Forte return (L_PT_PT_FC_TOP_NOT_SUPPORTED);
3312fcf3ce44SJohn Forte default:
3313fcf3ce44SJohn Forte (void) free((void *)map.dev_addr);
3314fcf3ce44SJohn Forte return (L_UNEXPECTED_FC_TOPOLOGY);
3315fcf3ce44SJohn Forte }
3316fcf3ce44SJohn Forte free((void *)map.dev_addr);
3317fcf3ce44SJohn Forte
3318fcf3ce44SJohn Forte }
3319fcf3ce44SJohn Forte if (pathcnt > 1) {
3320fcf3ce44SJohn Forte free(pathlist.path_info);
3321fcf3ce44SJohn Forte }
3322fcf3ce44SJohn Forte
3323fcf3ce44SJohn Forte b_list = b_list->box_next;
3324fcf3ce44SJohn Forte }
3325fcf3ce44SJohn Forte /* Return the list */
3326fcf3ce44SJohn Forte *wwn_list_ptr = wwn_list;
3327fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
3328fcf3ce44SJohn Forte return (0);
3329fcf3ce44SJohn Forte }
3330fcf3ce44SJohn Forte
3331fcf3ce44SJohn Forte
3332fcf3ce44SJohn Forte
3333fcf3ce44SJohn Forte /*
3334fcf3ce44SJohn Forte * n_rem_list_entry() We found an IB so remove disks that
3335fcf3ce44SJohn Forte * are in the Photon from the individual device list.
3336fcf3ce44SJohn Forte *
3337fcf3ce44SJohn Forte * OUTPUT:
3338fcf3ce44SJohn Forte * wwn_list - removes the fcal disks that are in SENA enclosure
3339fcf3ce44SJohn Forte *
3340fcf3ce44SJohn Forte * RETURNS:
3341fcf3ce44SJohn Forte * none
3342fcf3ce44SJohn Forte */
3343fcf3ce44SJohn Forte void
n_rem_list_entry(uchar_t box_id,struct gfc_map * map,struct wwn_list_struct ** wwn_list)3344fcf3ce44SJohn Forte n_rem_list_entry(uchar_t box_id, struct gfc_map *map,
3345fcf3ce44SJohn Forte struct wwn_list_struct **wwn_list)
3346fcf3ce44SJohn Forte {
3347fcf3ce44SJohn Forte int k;
3348fcf3ce44SJohn Forte gfc_port_dev_info_t *dev_addr_list;
3349fcf3ce44SJohn Forte
3350fcf3ce44SJohn Forte N_DPRINTF(" n_rem_list_entry: Removing devices"
3351fcf3ce44SJohn Forte " with box_id=0x%x from device list.\n", box_id);
3352fcf3ce44SJohn Forte
3353fcf3ce44SJohn Forte
3354fcf3ce44SJohn Forte for (k = 0, dev_addr_list = map->dev_addr; k < map->count;
3355fcf3ce44SJohn Forte k++, dev_addr_list++) {
3356fcf3ce44SJohn Forte if ((g_sf_alpa_to_switch[dev_addr_list->gfc_port_dev.
3357fcf3ce44SJohn Forte priv_port.sf_hard_address] & BOX_ID_MASK)
3358fcf3ce44SJohn Forte == box_id) {
3359fcf3ce44SJohn Forte n_rem_wwn_entry(dev_addr_list->gfc_port_dev.
3360fcf3ce44SJohn Forte priv_port.sf_node_wwn, wwn_list);
3361fcf3ce44SJohn Forte }
3362fcf3ce44SJohn Forte }
3363fcf3ce44SJohn Forte
3364fcf3ce44SJohn Forte }
3365fcf3ce44SJohn Forte
3366fcf3ce44SJohn Forte
3367fcf3ce44SJohn Forte
3368fcf3ce44SJohn Forte /*
3369fcf3ce44SJohn Forte * n_rem_list_entry_fabric() We found an IB so remove disks that
3370fcf3ce44SJohn Forte * are in the Photon from the individual device list.
3371fcf3ce44SJohn Forte *
3372fcf3ce44SJohn Forte * OUTPUT:
3373fcf3ce44SJohn Forte * wwn_list - removes the fcal disks that are in SENA enclosure
3374fcf3ce44SJohn Forte *
3375fcf3ce44SJohn Forte * RETURNS:
3376fcf3ce44SJohn Forte * none
3377fcf3ce44SJohn Forte */
3378fcf3ce44SJohn Forte void
n_rem_list_entry_fabric(int pa,struct gfc_map * map,struct wwn_list_struct ** wwn_list)3379fcf3ce44SJohn Forte n_rem_list_entry_fabric(int pa, struct gfc_map *map,
3380fcf3ce44SJohn Forte struct wwn_list_struct **wwn_list)
3381fcf3ce44SJohn Forte {
3382fcf3ce44SJohn Forte int k;
3383fcf3ce44SJohn Forte gfc_port_dev_info_t *dev_addr_ptr;
3384fcf3ce44SJohn Forte
3385fcf3ce44SJohn Forte N_DPRINTF(" n_rem_list_entry: Removing devices"
3386fcf3ce44SJohn Forte " with the same domain and area ID as"
3387fcf3ce44SJohn Forte " 0x%x PA from device list.\n", pa);
3388fcf3ce44SJohn Forte for (k = 0, dev_addr_ptr = map->dev_addr; k < map->count;
3389fcf3ce44SJohn Forte k++, dev_addr_ptr++) {
3390fcf3ce44SJohn Forte
3391fcf3ce44SJohn Forte /* matching the domain and area id with input alpa, */
3392fcf3ce44SJohn Forte /* ignoring last 8 bits. */
3393fcf3ce44SJohn Forte if ((dev_addr_ptr->gfc_port_dev.pub_port.dev_did.port_id |
3394fcf3ce44SJohn Forte 0xff) == (pa | 0xff)) {
3395fcf3ce44SJohn Forte n_rem_wwn_entry(dev_addr_ptr->
3396fcf3ce44SJohn Forte gfc_port_dev.pub_port.dev_nwwn.raw_wwn,
3397fcf3ce44SJohn Forte wwn_list);
3398fcf3ce44SJohn Forte }
3399fcf3ce44SJohn Forte }
3400fcf3ce44SJohn Forte }
3401fcf3ce44SJohn Forte
3402fcf3ce44SJohn Forte
3403fcf3ce44SJohn Forte /*
3404fcf3ce44SJohn Forte * n_rem_wwn_entry() removes input wwn from wwn_list.
3405fcf3ce44SJohn Forte *
3406fcf3ce44SJohn Forte * OUTPUT:
3407fcf3ce44SJohn Forte * wwn_list - removes the input wwn from wwn_list if found.
3408fcf3ce44SJohn Forte *
3409fcf3ce44SJohn Forte * RETURNS:
3410fcf3ce44SJohn Forte * none
3411fcf3ce44SJohn Forte */
3412fcf3ce44SJohn Forte void
n_rem_wwn_entry(uchar_t node_wwn[],struct wwn_list_struct ** wwn_list)3413fcf3ce44SJohn Forte n_rem_wwn_entry(uchar_t node_wwn[], struct wwn_list_struct **wwn_list)
3414fcf3ce44SJohn Forte {
3415fcf3ce44SJohn Forte int l, found_dev;
3416fcf3ce44SJohn Forte WWN_list *inner, *l1;
3417fcf3ce44SJohn Forte
3418fcf3ce44SJohn Forte inner = *wwn_list;
3419fcf3ce44SJohn Forte while (inner != NULL) {
3420fcf3ce44SJohn Forte for (found_dev = 1, l = 0; l < WWN_SIZE; l++) {
3421fcf3ce44SJohn Forte if (inner->w_node_wwn[l] != node_wwn[l]) {
3422fcf3ce44SJohn Forte found_dev = 0;
3423fcf3ce44SJohn Forte }
3424fcf3ce44SJohn Forte }
3425fcf3ce44SJohn Forte if (found_dev) {
3426fcf3ce44SJohn Forte /* Remove this entry from the list */
3427fcf3ce44SJohn Forte if (inner->wwn_prev != NULL) {
3428fcf3ce44SJohn Forte inner->wwn_prev->wwn_next =
3429fcf3ce44SJohn Forte inner->wwn_next;
3430fcf3ce44SJohn Forte } else {
3431fcf3ce44SJohn Forte *wwn_list = inner->wwn_next;
3432fcf3ce44SJohn Forte }
3433fcf3ce44SJohn Forte if (inner->wwn_next != NULL) {
3434fcf3ce44SJohn Forte inner->wwn_next->wwn_prev =
3435fcf3ce44SJohn Forte inner->wwn_prev;
3436fcf3ce44SJohn Forte }
3437fcf3ce44SJohn Forte l1 = inner;
3438fcf3ce44SJohn Forte N_DPRINTF(" n_rem_wwn_entry: "
3439fcf3ce44SJohn Forte "Removing Logical=%s "
3440fcf3ce44SJohn Forte "Current=0x%x, "
3441fcf3ce44SJohn Forte "Prev=0x%x, Next=0x%x\n",
3442fcf3ce44SJohn Forte l1->logical_path,
3443fcf3ce44SJohn Forte l1,
3444fcf3ce44SJohn Forte l1->wwn_prev,
3445fcf3ce44SJohn Forte l1->wwn_next);
3446fcf3ce44SJohn Forte inner = inner->wwn_next;
3447fcf3ce44SJohn Forte if ((l1->wwn_prev == NULL) &&
3448fcf3ce44SJohn Forte (l1->wwn_next) == NULL) {
3449fcf3ce44SJohn Forte (void) free(l1->physical_path);
3450fcf3ce44SJohn Forte (void) free(l1->logical_path);
3451fcf3ce44SJohn Forte (void) free(l1);
3452fcf3ce44SJohn Forte *wwn_list = NULL;
3453fcf3ce44SJohn Forte N_DPRINTF(" n_rem_list_entry: "
3454fcf3ce44SJohn Forte "No non-Photon "
3455fcf3ce44SJohn Forte "devices left"
3456fcf3ce44SJohn Forte " in the list.\n");
3457fcf3ce44SJohn Forte return;
3458fcf3ce44SJohn Forte }
3459fcf3ce44SJohn Forte (void) free(l1->physical_path);
3460fcf3ce44SJohn Forte (void) free(l1->logical_path);
3461fcf3ce44SJohn Forte (void) free(l1);
3462fcf3ce44SJohn Forte } else {
3463fcf3ce44SJohn Forte inner = inner->wwn_next;
3464fcf3ce44SJohn Forte }
3465fcf3ce44SJohn Forte }
3466fcf3ce44SJohn Forte }
3467fcf3ce44SJohn Forte
3468fcf3ce44SJohn Forte
3469fcf3ce44SJohn Forte /*
3470fcf3ce44SJohn Forte * non_encl_probe() Finds and displays a list of
3471fcf3ce44SJohn Forte * non-SENA fcal devices which is found on the
3472fcf3ce44SJohn Forte * system.
3473fcf3ce44SJohn Forte *
3474fcf3ce44SJohn Forte * RETURNS:
3475fcf3ce44SJohn Forte * none.
3476fcf3ce44SJohn Forte */
3477fcf3ce44SJohn Forte void
non_encl_probe()3478fcf3ce44SJohn Forte non_encl_probe()
3479fcf3ce44SJohn Forte {
3480fcf3ce44SJohn Forte WWN_list *wwn_list, *wwn_listh, *inner, *l1;
3481fcf3ce44SJohn Forte int err = 0;
3482fcf3ce44SJohn Forte char lun_a[MAXPATHLEN], lun_b[MAXPATHLEN], temppath[MAXPATHLEN];
3483fcf3ce44SJohn Forte char *tempptra, *tempptrb, *tempptr;
3484fcf3ce44SJohn Forte mp_pathlist_t pathlist;
3485fcf3ce44SJohn Forte int compare_result, retr_outer = 0;
3486fcf3ce44SJohn Forte ddi_devid_t devid1 = NULL, devid2 = NULL;
3487fcf3ce44SJohn Forte di_node_t root = DI_NODE_NIL;
3488fcf3ce44SJohn Forte
3489fcf3ce44SJohn Forte if (err = n_get_non_encl_list(&wwn_list, (Options & PVERBOSE))) {
3490fcf3ce44SJohn Forte (void) print_errString(err, NULL);
3491fcf3ce44SJohn Forte exit(-1);
3492fcf3ce44SJohn Forte }
3493fcf3ce44SJohn Forte
3494fcf3ce44SJohn Forte g_sort_wwn_list(&wwn_list);
3495fcf3ce44SJohn Forte
3496fcf3ce44SJohn Forte wwn_listh = wwn_list;
3497fcf3ce44SJohn Forte
3498fcf3ce44SJohn Forte if (wwn_list != NULL) {
3499fcf3ce44SJohn Forte if (wwn_list->wwn_next != NULL) {
3500fcf3ce44SJohn Forte (void) fprintf(stdout,
3501fcf3ce44SJohn Forte MSGSTR(2098, "\nFound Fibre Channel device(s):\n"));
3502fcf3ce44SJohn Forte } else {
3503fcf3ce44SJohn Forte (void) fprintf(stdout,
3504fcf3ce44SJohn Forte MSGSTR(2099, "\nFound Fibre Channel device:\n"));
3505fcf3ce44SJohn Forte }
3506fcf3ce44SJohn Forte } else {
3507fcf3ce44SJohn Forte return;
3508fcf3ce44SJohn Forte }
3509fcf3ce44SJohn Forte
3510fcf3ce44SJohn Forte while (wwn_list != NULL) {
3511fcf3ce44SJohn Forte if (strstr(wwn_list->physical_path, SCSI_VHCI) != NULL) {
3512fcf3ce44SJohn Forte (void) strcpy(temppath, wwn_list->physical_path);
3513fcf3ce44SJohn Forte if ((!g_get_pathlist(temppath,
3514fcf3ce44SJohn Forte &pathlist)) &&
3515fcf3ce44SJohn Forte ((tempptra = strchr(pathlist.path_info[0].
3516fcf3ce44SJohn Forte path_addr, ','))) != NULL) {
3517fcf3ce44SJohn Forte tempptra++;
3518fcf3ce44SJohn Forte (void) strcpy(lun_a, tempptra);
3519fcf3ce44SJohn Forte free(pathlist.path_info);
3520fcf3ce44SJohn Forte }
3521fcf3ce44SJohn Forte } else {
3522fcf3ce44SJohn Forte if ((((tempptr = strstr(wwn_list->physical_path,
3523fcf3ce44SJohn Forte SLSH_DRV_NAME_ST)) != NULL) ||
3524fcf3ce44SJohn Forte ((tempptr = strstr(wwn_list->physical_path,
3525fcf3ce44SJohn Forte SLSH_DRV_NAME_SSD)) != NULL)) &&
3526fcf3ce44SJohn Forte ((tempptra = strchr(tempptr, ',')) != NULL)) {
3527fcf3ce44SJohn Forte tempptra++;
3528fcf3ce44SJohn Forte (void) strcpy(lun_a, tempptra);
3529fcf3ce44SJohn Forte }
3530fcf3ce44SJohn Forte }
3531fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
3532fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(90, "Node WWN:"));
3533fcf3ce44SJohn Forte (void) fprintf(stdout, "%s ", wwn_list->node_wwn_s);
3534fcf3ce44SJohn Forte
3535fcf3ce44SJohn Forte if (wwn_list->device_type < 0x10) {
3536fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(35, "Device Type:"));
3537fcf3ce44SJohn Forte (void) fprintf(stdout, "%s",
3538fcf3ce44SJohn Forte dtype[wwn_list->device_type]);
3539fcf3ce44SJohn Forte } else if (wwn_list->device_type < 0x1f) {
3540fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2100,
3541fcf3ce44SJohn Forte "Type:Reserved"));
3542fcf3ce44SJohn Forte } else {
3543fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2101,
3544fcf3ce44SJohn Forte "Type:Unknown"));
3545fcf3ce44SJohn Forte }
3546fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
3547fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(31, "Logical Path:%s"),
3548fcf3ce44SJohn Forte wwn_list->logical_path);
3549fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
3550fcf3ce44SJohn Forte
3551fcf3ce44SJohn Forte if (Options & OPTION_P) {
3552fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
3553fcf3ce44SJohn Forte (void) fprintf(stdout,
3554fcf3ce44SJohn Forte MSGSTR(5, "Physical Path:"));
3555fcf3ce44SJohn Forte (void) fprintf(stdout, "\n %s\n", wwn_list->physical_path);
3556fcf3ce44SJohn Forte }
3557fcf3ce44SJohn Forte inner = wwn_list->wwn_next;
3558fcf3ce44SJohn Forte
3559fcf3ce44SJohn Forte while (inner != NULL) {
3560fcf3ce44SJohn Forte if (strcmp(inner->node_wwn_s, wwn_list->node_wwn_s) == 0) {
3561fcf3ce44SJohn Forte
3562fcf3ce44SJohn Forte if (tempptra != NULL) {
3563fcf3ce44SJohn Forte if (strstr(inner->physical_path,
3564fcf3ce44SJohn Forte SCSI_VHCI) != NULL) {
3565fcf3ce44SJohn Forte (void) strcpy(temppath,
3566fcf3ce44SJohn Forte inner->physical_path);
3567fcf3ce44SJohn Forte
3568fcf3ce44SJohn Forte if ((!g_get_pathlist(temppath, &pathlist)) &&
3569fcf3ce44SJohn Forte ((tempptrb = strchr(
3570fcf3ce44SJohn Forte pathlist.path_info[0].path_addr, ','))) !=
3571fcf3ce44SJohn Forte NULL) {
3572fcf3ce44SJohn Forte tempptrb++;
3573fcf3ce44SJohn Forte (void) strcpy(lun_b, tempptrb);
3574fcf3ce44SJohn Forte free(pathlist.path_info);
3575fcf3ce44SJohn Forte }
3576fcf3ce44SJohn Forte } else {
3577fcf3ce44SJohn Forte if ((((tempptr = strstr(inner->physical_path,
3578fcf3ce44SJohn Forte SLSH_DRV_NAME_ST)) != NULL) ||
3579fcf3ce44SJohn Forte ((tempptr = strstr(inner->physical_path,
3580fcf3ce44SJohn Forte SLSH_DRV_NAME_SSD)) != NULL)) &&
3581fcf3ce44SJohn Forte ((tempptrb = strchr(tempptr, ',')) != NULL)) {
3582fcf3ce44SJohn Forte tempptrb++;
3583fcf3ce44SJohn Forte (void) strcpy(lun_b, tempptrb);
3584fcf3ce44SJohn Forte }
3585fcf3ce44SJohn Forte }
3586fcf3ce44SJohn Forte }
3587fcf3ce44SJohn Forte
3588fcf3ce44SJohn Forte if (((tempptra == NULL) || (strcmp(lun_a, lun_b)) == 0)) {
3589fcf3ce44SJohn Forte
3590fcf3ce44SJohn Forte /*
3591fcf3ce44SJohn Forte * Have we retrieved a snapshot yet?
3592fcf3ce44SJohn Forte */
3593fcf3ce44SJohn Forte if (root == DI_NODE_NIL) {
3594fcf3ce44SJohn Forte if ((root = di_init("/", DINFOCPYALL)) ==
3595fcf3ce44SJohn Forte DI_NODE_NIL) {
3596fcf3ce44SJohn Forte (void) fprintf(stdout,
3597fcf3ce44SJohn Forte MSGSTR(2319,
3598fcf3ce44SJohn Forte "\nFailed to get device tree snapshot:\n"));
3599fcf3ce44SJohn Forte exit(1);
3600fcf3ce44SJohn Forte }
3601fcf3ce44SJohn Forte }
3602fcf3ce44SJohn Forte
3603fcf3ce44SJohn Forte /* Apply devid to ssd devices only */
3604fcf3ce44SJohn Forte if (!retr_outer && strstr(wwn_list->physical_path,
3605fcf3ce44SJohn Forte SLSH_DRV_NAME_SSD) != NULL) {
3606fcf3ce44SJohn Forte if ((err = g_devid_get(wwn_list->physical_path,
3607fcf3ce44SJohn Forte &devid1, root, SSD_DRVR_NAME)) != 0) {
3608fcf3ce44SJohn Forte (void) print_errString(err,
3609fcf3ce44SJohn Forte wwn_list->physical_path);
3610fcf3ce44SJohn Forte }
3611fcf3ce44SJohn Forte /*
3612fcf3ce44SJohn Forte * Try retrieve of devid only once. If it fails
3613fcf3ce44SJohn Forte * don't try it again but print error,
3614fcf3ce44SJohn Forte * There should be a devid prop.
3615fcf3ce44SJohn Forte */
3616fcf3ce44SJohn Forte retr_outer = 1;
3617fcf3ce44SJohn Forte }
3618fcf3ce44SJohn Forte /*
3619fcf3ce44SJohn Forte * Apply devid to block devices only.
3620fcf3ce44SJohn Forte * Get devid of inner path and compare
3621fcf3ce44SJohn Forte * with outer path's devid.
3622fcf3ce44SJohn Forte */
3623fcf3ce44SJohn Forte if ((strstr(inner->physical_path,
3624fcf3ce44SJohn Forte SLSH_DRV_NAME_SSD) != NULL) &&
3625fcf3ce44SJohn Forte devid1 != NULL) {
3626fcf3ce44SJohn Forte
3627fcf3ce44SJohn Forte if ((err = g_devid_get(inner->physical_path,
3628fcf3ce44SJohn Forte &devid2, root, SSD_DRVR_NAME)) != 0) {
3629fcf3ce44SJohn Forte
3630fcf3ce44SJohn Forte (void) print_errString(err,
3631fcf3ce44SJohn Forte inner->physical_path);
3632fcf3ce44SJohn Forte compare_result = 0;
3633fcf3ce44SJohn Forte } else {
3634fcf3ce44SJohn Forte compare_result = devid_compare(devid1, devid2);
3635fcf3ce44SJohn Forte }
3636fcf3ce44SJohn Forte } else {
3637fcf3ce44SJohn Forte /* devid isn't applied */
3638fcf3ce44SJohn Forte compare_result = 0;
3639fcf3ce44SJohn Forte }
3640fcf3ce44SJohn Forte
3641fcf3ce44SJohn Forte if (compare_result == 0) {
3642fcf3ce44SJohn Forte
3643fcf3ce44SJohn Forte if (strcmp(wwn_list->logical_path,
3644fcf3ce44SJohn Forte inner->logical_path)) {
3645fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
3646fcf3ce44SJohn Forte (void) fprintf(stdout,
3647fcf3ce44SJohn Forte MSGSTR(31, "Logical Path:%s"),
3648fcf3ce44SJohn Forte inner->logical_path);
3649fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
3650fcf3ce44SJohn Forte
3651fcf3ce44SJohn Forte if (Options & OPTION_P) {
3652fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
3653fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(5,
3654fcf3ce44SJohn Forte "Physical Path:"));
3655fcf3ce44SJohn Forte (void) fprintf(stdout, "\n %s\n",
3656fcf3ce44SJohn Forte inner->physical_path);
3657fcf3ce44SJohn Forte }
3658fcf3ce44SJohn Forte }
3659fcf3ce44SJohn Forte
3660fcf3ce44SJohn Forte /* Remove this entry from the list */
3661fcf3ce44SJohn Forte if (inner->wwn_prev != NULL) {
3662fcf3ce44SJohn Forte inner->wwn_prev->wwn_next =
3663fcf3ce44SJohn Forte inner->wwn_next;
3664fcf3ce44SJohn Forte }
3665fcf3ce44SJohn Forte
3666fcf3ce44SJohn Forte if (inner->wwn_next != NULL) {
3667fcf3ce44SJohn Forte inner->wwn_next->wwn_prev =
3668fcf3ce44SJohn Forte inner->wwn_prev;
3669fcf3ce44SJohn Forte }
3670fcf3ce44SJohn Forte free(inner->physical_path);
3671fcf3ce44SJohn Forte free(inner->logical_path);
3672fcf3ce44SJohn Forte l1 = inner;
3673fcf3ce44SJohn Forte inner = inner->wwn_next;
3674fcf3ce44SJohn Forte (void) free(l1);
3675fcf3ce44SJohn Forte
3676fcf3ce44SJohn Forte } else {
3677fcf3ce44SJohn Forte inner = inner->wwn_next;
3678fcf3ce44SJohn Forte } /* End if (compare_result == 0) */
3679fcf3ce44SJohn Forte
3680fcf3ce44SJohn Forte } else {
3681fcf3ce44SJohn Forte inner = inner->wwn_next;
3682fcf3ce44SJohn Forte }
3683fcf3ce44SJohn Forte } else {
3684fcf3ce44SJohn Forte inner = inner->wwn_next;
3685fcf3ce44SJohn Forte }
3686fcf3ce44SJohn Forte devid2 = NULL;
3687fcf3ce44SJohn Forte }
3688fcf3ce44SJohn Forte wwn_list = wwn_list->wwn_next;
3689fcf3ce44SJohn Forte retr_outer = 0;
3690fcf3ce44SJohn Forte devid1 = NULL;
3691fcf3ce44SJohn Forte } /* End while (wwn_list != NULL) */
3692fcf3ce44SJohn Forte
3693fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_listh);
3694fcf3ce44SJohn Forte (void) di_fini(root);
3695fcf3ce44SJohn Forte }
3696fcf3ce44SJohn Forte
3697fcf3ce44SJohn Forte void
pho_probe()3698fcf3ce44SJohn Forte pho_probe()
3699fcf3ce44SJohn Forte {
3700fcf3ce44SJohn Forte
3701fcf3ce44SJohn Forte Box_list *b_list, *o_list, *c_list;
3702fcf3ce44SJohn Forte int multi_path_flag, multi_print_flag;
3703fcf3ce44SJohn Forte int duplicate_names_found = 0, err = 0;
3704fcf3ce44SJohn Forte
3705fcf3ce44SJohn Forte b_list = o_list = c_list = NULL;
3706fcf3ce44SJohn Forte if ((err = l_get_box_list(&b_list, Options & PVERBOSE)) != 0) {
3707fcf3ce44SJohn Forte (void) print_errString(err, NULL);
3708fcf3ce44SJohn Forte exit(-1);
3709fcf3ce44SJohn Forte }
3710fcf3ce44SJohn Forte if (b_list == NULL) {
3711fcf3ce44SJohn Forte (void) fprintf(stdout,
3712fcf3ce44SJohn Forte MSGSTR(93, "No %s enclosures found "
3713fcf3ce44SJohn Forte "in /dev/es\n"), ENCLOSURE_PROD_NAME);
3714fcf3ce44SJohn Forte } else {
3715fcf3ce44SJohn Forte o_list = b_list;
3716fcf3ce44SJohn Forte if (b_list->box_next != NULL) {
3717fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2102,
3718fcf3ce44SJohn Forte "Found Enclosure(s)"));
3719fcf3ce44SJohn Forte } else {
3720fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2103, "Found Enclosure"));
3721fcf3ce44SJohn Forte }
3722fcf3ce44SJohn Forte (void) fprintf(stdout, ":\n");
3723fcf3ce44SJohn Forte while (b_list != NULL) {
3724fcf3ce44SJohn Forte /* Don't re-print multiple paths */
3725fcf3ce44SJohn Forte c_list = o_list;
3726fcf3ce44SJohn Forte multi_print_flag = 0;
3727fcf3ce44SJohn Forte while (c_list != b_list) {
3728fcf3ce44SJohn Forte if (strcmp(c_list->b_node_wwn_s,
3729fcf3ce44SJohn Forte b_list->b_node_wwn_s) == 0) {
3730fcf3ce44SJohn Forte multi_print_flag = 1;
3731fcf3ce44SJohn Forte break;
3732fcf3ce44SJohn Forte }
3733fcf3ce44SJohn Forte c_list = c_list->box_next;
3734fcf3ce44SJohn Forte }
3735fcf3ce44SJohn Forte if (multi_print_flag) {
3736fcf3ce44SJohn Forte b_list = b_list->box_next;
3737fcf3ce44SJohn Forte continue;
3738fcf3ce44SJohn Forte }
3739fcf3ce44SJohn Forte (void) fprintf(stdout,
3740fcf3ce44SJohn Forte MSGSTR(2104, "%s Name:%s Node WWN:%s "),
3741fcf3ce44SJohn Forte b_list->prod_id_s, b_list->b_name,
3742fcf3ce44SJohn Forte b_list->b_node_wwn_s);
3743fcf3ce44SJohn Forte /*
3744fcf3ce44SJohn Forte * Print logical path on same line if not multipathed.
3745fcf3ce44SJohn Forte */
3746fcf3ce44SJohn Forte multi_path_flag = 0;
3747fcf3ce44SJohn Forte c_list = o_list;
3748fcf3ce44SJohn Forte while (c_list != NULL) {
3749fcf3ce44SJohn Forte if ((c_list != b_list) &&
3750fcf3ce44SJohn Forte (strcmp(c_list->b_node_wwn_s,
3751fcf3ce44SJohn Forte b_list->b_node_wwn_s) == 0)) {
3752fcf3ce44SJohn Forte multi_path_flag = 1;
3753fcf3ce44SJohn Forte }
3754fcf3ce44SJohn Forte c_list = c_list->box_next;
3755fcf3ce44SJohn Forte }
3756fcf3ce44SJohn Forte if (multi_path_flag) {
3757fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
3758fcf3ce44SJohn Forte }
3759fcf3ce44SJohn Forte (void) fprintf(stdout,
3760fcf3ce44SJohn Forte MSGSTR(31, "Logical Path:%s"),
3761fcf3ce44SJohn Forte b_list->logical_path);
3762fcf3ce44SJohn Forte
3763fcf3ce44SJohn Forte if (Options & OPTION_P) {
3764fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
3765fcf3ce44SJohn Forte (void) fprintf(stdout,
3766fcf3ce44SJohn Forte MSGSTR(5, "Physical Path:"));
3767fcf3ce44SJohn Forte (void) fprintf(stdout, "%s",
3768fcf3ce44SJohn Forte b_list->b_physical_path);
3769fcf3ce44SJohn Forte }
3770fcf3ce44SJohn Forte c_list = o_list;
3771fcf3ce44SJohn Forte while (c_list != NULL) {
3772fcf3ce44SJohn Forte if ((c_list != b_list) &&
3773fcf3ce44SJohn Forte (strcmp(c_list->b_node_wwn_s,
3774fcf3ce44SJohn Forte b_list->b_node_wwn_s) == 0)) {
3775fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
3776fcf3ce44SJohn Forte (void) fprintf(stdout,
3777fcf3ce44SJohn Forte MSGSTR(31, "Logical Path:%s"),
3778fcf3ce44SJohn Forte c_list->logical_path);
3779fcf3ce44SJohn Forte if (Options & OPTION_P) {
3780fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
3781fcf3ce44SJohn Forte (void) fprintf(stdout,
3782fcf3ce44SJohn Forte MSGSTR(5, "Physical Path:"));
3783fcf3ce44SJohn Forte (void) fprintf(stdout, "%s",
3784fcf3ce44SJohn Forte c_list->b_physical_path);
3785fcf3ce44SJohn Forte }
3786fcf3ce44SJohn Forte }
3787fcf3ce44SJohn Forte c_list = c_list->box_next;
3788fcf3ce44SJohn Forte }
3789fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
3790fcf3ce44SJohn Forte /* Check for duplicate names */
3791fcf3ce44SJohn Forte if (l_duplicate_names(o_list, b_list->b_node_wwn_s,
3792fcf3ce44SJohn Forte (char *)b_list->b_name,
3793fcf3ce44SJohn Forte Options & PVERBOSE)) {
3794fcf3ce44SJohn Forte duplicate_names_found++;
3795fcf3ce44SJohn Forte }
3796fcf3ce44SJohn Forte b_list = b_list->box_next;
3797fcf3ce44SJohn Forte }
3798fcf3ce44SJohn Forte }
3799fcf3ce44SJohn Forte if (duplicate_names_found) {
3800fcf3ce44SJohn Forte (void) fprintf(stdout,
3801fcf3ce44SJohn Forte MSGSTR(2105, "\nWARNING: There are enclosures with "
3802fcf3ce44SJohn Forte "the same names.\n"
3803fcf3ce44SJohn Forte "You can not use the \"enclosure\""
3804fcf3ce44SJohn Forte " name to specify these subsystems.\n"
3805fcf3ce44SJohn Forte "Please use the \"enclosure_name\""
3806fcf3ce44SJohn Forte " subcommand to select unique names.\n\n"));
3807fcf3ce44SJohn Forte }
3808fcf3ce44SJohn Forte (void) l_free_box_list(&b_list);
3809fcf3ce44SJohn Forte }
3810fcf3ce44SJohn Forte
3811fcf3ce44SJohn Forte /*
3812fcf3ce44SJohn Forte * display_port_status() Prints the device's
3813fcf3ce44SJohn Forte * port status.
3814fcf3ce44SJohn Forte *
3815fcf3ce44SJohn Forte * RETURNS:
3816fcf3ce44SJohn Forte * none.
3817fcf3ce44SJohn Forte */
3818fcf3ce44SJohn Forte void
display_port_status(int d_state_flag)3819fcf3ce44SJohn Forte display_port_status(int d_state_flag)
3820fcf3ce44SJohn Forte {
3821fcf3ce44SJohn Forte
3822fcf3ce44SJohn Forte if (d_state_flag & L_OPEN_FAIL) {
3823fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(28, "Open Failed"));
3824fcf3ce44SJohn Forte } else if (d_state_flag & L_NOT_READY) {
3825fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(20, "Not Ready"));
3826fcf3ce44SJohn Forte } else if (d_state_flag & L_NOT_READABLE) {
3827fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(88, "Not Readable"));
3828fcf3ce44SJohn Forte } else if (d_state_flag & L_SPUN_DWN_D) {
3829fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(68, "Spun Down"));
3830fcf3ce44SJohn Forte } else if (d_state_flag & L_SCSI_ERR) {
3831fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(70, "SCSI Error"));
3832fcf3ce44SJohn Forte } else if (d_state_flag & L_RESERVED) {
3833fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(73, "Reservation conflict"));
3834fcf3ce44SJohn Forte } else if (d_state_flag & L_NO_LABEL) {
3835fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(92, "No UNIX Label"));
3836fcf3ce44SJohn Forte } else {
3837fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(29, "O.K."));
3838fcf3ce44SJohn Forte }
3839fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
3840fcf3ce44SJohn Forte }
3841fcf3ce44SJohn Forte
3842fcf3ce44SJohn Forte /*
3843fcf3ce44SJohn Forte * Displays individual SENA
3844fcf3ce44SJohn Forte * FC disk information.
3845fcf3ce44SJohn Forte *
3846fcf3ce44SJohn Forte * Caller to this routine should free the storage due to
3847fcf3ce44SJohn Forte * the use of g_get_dev_map
3848fcf3ce44SJohn Forte *
3849fcf3ce44SJohn Forte * RETURNS:
3850fcf3ce44SJohn Forte * none.
3851fcf3ce44SJohn Forte */
3852fcf3ce44SJohn Forte void
display_fc_disk(struct path_struct * path_struct,char * ses_path,gfc_map_t * map,L_inquiry inq,int verbose)3853fcf3ce44SJohn Forte display_fc_disk(struct path_struct *path_struct, char *ses_path,
3854fcf3ce44SJohn Forte gfc_map_t *map, L_inquiry inq, int verbose)
3855fcf3ce44SJohn Forte {
3856fcf3ce44SJohn Forte static WWN_list *wwn_list = NULL;
3857fcf3ce44SJohn Forte static char path_phys[MAXPATHLEN];
3858fcf3ce44SJohn Forte static L_disk_state l_disk_state;
3859fcf3ce44SJohn Forte static L_inquiry local_inq;
3860fcf3ce44SJohn Forte static uchar_t node_wwn[WWN_SIZE];
3861fcf3ce44SJohn Forte char same_path_phys = B_FALSE; /* To chk for repeat args */
3862fcf3ce44SJohn Forte uchar_t port_wwn[WWN_SIZE], *pg_buf;
3863fcf3ce44SJohn Forte char logical_path[MAXPATHLEN];
3864fcf3ce44SJohn Forte int al_pa, port_a_flag = 0;
3865fcf3ce44SJohn Forte int offset, mode_data_avail = 0;
3866fcf3ce44SJohn Forte int no_path_flag = 0, err = 0;
3867fcf3ce44SJohn Forte L_state l_state;
3868fcf3ce44SJohn Forte Mode_header_10 *mode_header_ptr = NULL;
3869fcf3ce44SJohn Forte struct mode_page *pg_hdr;
3870fcf3ce44SJohn Forte
3871fcf3ce44SJohn Forte /*
3872fcf3ce44SJohn Forte * Do a quick check to see if its the same path as in last call.
3873fcf3ce44SJohn Forte * path_phys is a static array and so dont worry about its
3874fcf3ce44SJohn Forte * initialization.
3875fcf3ce44SJohn Forte */
3876fcf3ce44SJohn Forte if (strcmp(path_phys, path_struct->p_physical_path) == 0)
3877fcf3ce44SJohn Forte same_path_phys = B_TRUE;
3878fcf3ce44SJohn Forte
3879fcf3ce44SJohn Forte (void) strcpy(path_phys, path_struct->p_physical_path);
3880fcf3ce44SJohn Forte (void) memset((char *)logical_path, 0, sizeof (logical_path));
3881fcf3ce44SJohn Forte
3882fcf3ce44SJohn Forte /*
3883fcf3ce44SJohn Forte * slot_valid is 1 when argument is of the form 'enclosure,[f|r]<n>'.
3884fcf3ce44SJohn Forte * If slot_valid != 1, g_get_dev_map and l_get_ses_path would
3885fcf3ce44SJohn Forte * already have been called
3886fcf3ce44SJohn Forte */
3887fcf3ce44SJohn Forte if (path_struct->slot_valid == 1) {
3888fcf3ce44SJohn Forte /* Get the location information. */
3889fcf3ce44SJohn Forte if (err = g_get_dev_map(path_phys, map, (Options & PVERBOSE))) {
3890fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
3891fcf3ce44SJohn Forte exit(-1);
3892fcf3ce44SJohn Forte }
3893fcf3ce44SJohn Forte if (err = l_get_ses_path(path_phys, ses_path, map,
3894fcf3ce44SJohn Forte (Options & PVERBOSE))) {
3895fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
3896fcf3ce44SJohn Forte exit(-1);
3897fcf3ce44SJohn Forte }
3898fcf3ce44SJohn Forte }
3899fcf3ce44SJohn Forte
3900fcf3ce44SJohn Forte /*
3901fcf3ce44SJohn Forte * Get the WWN for our disk if we already haven't or if there was an
3902fcf3ce44SJohn Forte * error earlier
3903fcf3ce44SJohn Forte */
3904fcf3ce44SJohn Forte if (same_path_phys == B_FALSE) {
3905fcf3ce44SJohn Forte if (err = g_get_wwn(path_phys, port_wwn, node_wwn,
3906fcf3ce44SJohn Forte &al_pa, (Options & PVERBOSE))) {
3907fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
3908fcf3ce44SJohn Forte exit(-1);
3909fcf3ce44SJohn Forte }
3910fcf3ce44SJohn Forte
3911fcf3ce44SJohn Forte if (err = g_get_inquiry(ses_path, &local_inq)) {
3912fcf3ce44SJohn Forte (void) print_errString(err, ses_path);
3913fcf3ce44SJohn Forte exit(-1);
3914fcf3ce44SJohn Forte }
3915fcf3ce44SJohn Forte }
3916fcf3ce44SJohn Forte
3917fcf3ce44SJohn Forte /*
3918fcf3ce44SJohn Forte * We are interested only a couple of ib_tbl fields and
3919fcf3ce44SJohn Forte * those get filled using l_get_ib_status.
3920fcf3ce44SJohn Forte * Note that NOT ALL of ib_tbl fields get filled here
3921fcf3ce44SJohn Forte */
3922fcf3ce44SJohn Forte if ((err = l_get_ib_status(ses_path, &l_state,
3923fcf3ce44SJohn Forte Options & PVERBOSE)) != 0) {
3924fcf3ce44SJohn Forte (void) print_errString(err, ses_path);
3925fcf3ce44SJohn Forte exit(-1);
3926fcf3ce44SJohn Forte }
3927fcf3ce44SJohn Forte
3928fcf3ce44SJohn Forte /*
3929fcf3ce44SJohn Forte * Get path to all the FC disk and tape devices.
3930fcf3ce44SJohn Forte * if we haven't already done so in a previous pass
3931fcf3ce44SJohn Forte */
3932fcf3ce44SJohn Forte if ((wwn_list == NULL) && (err = g_get_wwn_list(&wwn_list, verbose))) {
3933fcf3ce44SJohn Forte (void) print_errString(err, ses_path);
3934fcf3ce44SJohn Forte exit(-1); /* Failure */
3935fcf3ce44SJohn Forte }
3936fcf3ce44SJohn Forte
3937fcf3ce44SJohn Forte /*
3938fcf3ce44SJohn Forte * Get the disk status if it is a different path_phys from
3939fcf3ce44SJohn Forte * last time.
3940fcf3ce44SJohn Forte */
3941fcf3ce44SJohn Forte if (same_path_phys == B_FALSE) {
3942fcf3ce44SJohn Forte (void) memset(&l_disk_state, 0,
3943fcf3ce44SJohn Forte sizeof (struct l_disk_state_struct));
3944fcf3ce44SJohn Forte if (err = l_get_disk_status(path_phys, &l_disk_state,
3945fcf3ce44SJohn Forte wwn_list, (Options & PVERBOSE))) {
3946fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
3947fcf3ce44SJohn Forte exit(-1);
3948fcf3ce44SJohn Forte }
3949fcf3ce44SJohn Forte }
3950fcf3ce44SJohn Forte
3951fcf3ce44SJohn Forte if (l_disk_state.l_state_flag & L_NO_PATH_FOUND) {
3952fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(2106,
3953fcf3ce44SJohn Forte "\nWARNING: No path found "
3954fcf3ce44SJohn Forte "in /dev/rdsk directory\n"
3955fcf3ce44SJohn Forte " Please check the logical links in /dev/rdsk\n"
3956fcf3ce44SJohn Forte " (It may be necessary to run the \"disks\" "
3957fcf3ce44SJohn Forte "program.)\n\n"));
3958fcf3ce44SJohn Forte
3959fcf3ce44SJohn Forte /* Just call to get the status directly. */
3960fcf3ce44SJohn Forte if (err = l_get_port(ses_path, &port_a_flag, verbose)) {
3961fcf3ce44SJohn Forte (void) print_errString(err, ses_path);
3962fcf3ce44SJohn Forte exit(-1);
3963fcf3ce44SJohn Forte }
3964fcf3ce44SJohn Forte if (err = l_get_disk_port_status(path_phys,
3965fcf3ce44SJohn Forte &l_disk_state, port_a_flag,
3966fcf3ce44SJohn Forte (Options & PVERBOSE))) {
3967fcf3ce44SJohn Forte (void) print_errString(err, path_phys);
3968fcf3ce44SJohn Forte exit(-1);
3969fcf3ce44SJohn Forte }
3970fcf3ce44SJohn Forte no_path_flag++;
3971fcf3ce44SJohn Forte }
3972fcf3ce44SJohn Forte
3973fcf3ce44SJohn Forte if (strlen(l_disk_state.g_disk_state.node_wwn_s) == 0) {
3974fcf3ce44SJohn Forte (void) sprintf(l_disk_state.g_disk_state.node_wwn_s,
3975fcf3ce44SJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
3976fcf3ce44SJohn Forte node_wwn[0], node_wwn[1], node_wwn[2], node_wwn[3],
3977fcf3ce44SJohn Forte node_wwn[4], node_wwn[5], node_wwn[6], node_wwn[7]);
3978fcf3ce44SJohn Forte }
3979fcf3ce44SJohn Forte
3980fcf3ce44SJohn Forte /* get mode page information for FC device */
3981fcf3ce44SJohn Forte if (l_get_mode_pg(path_phys, &pg_buf, Options & PVERBOSE) == 0) {
3982fcf3ce44SJohn Forte mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
3983fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
3984fcf3ce44SJohn Forte (uchar_t)sizeof (struct mode_header_10_struct) +
3985fcf3ce44SJohn Forte (uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
3986fcf3ce44SJohn Forte offset = sizeof (struct mode_header_10_struct) +
3987fcf3ce44SJohn Forte mode_header_ptr->bdesc_length;
3988fcf3ce44SJohn Forte while (offset < (mode_header_ptr->length +
3989fcf3ce44SJohn Forte sizeof (mode_header_ptr->length)) &&
3990fcf3ce44SJohn Forte !mode_data_avail) {
3991fcf3ce44SJohn Forte if (pg_hdr->code == MODEPAGE_CACHING) {
3992fcf3ce44SJohn Forte mode_data_avail++;
3993fcf3ce44SJohn Forte break;
3994fcf3ce44SJohn Forte }
3995fcf3ce44SJohn Forte offset += pg_hdr->length + sizeof (struct mode_page);
3996fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
3997fcf3ce44SJohn Forte (uchar_t)offset));
3998fcf3ce44SJohn Forte }
3999fcf3ce44SJohn Forte }
4000fcf3ce44SJohn Forte
4001fcf3ce44SJohn Forte switch ((inq.inq_dtype & DTYPE_MASK)) {
4002fcf3ce44SJohn Forte case DTYPE_DIRECT:
4003fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
4004fcf3ce44SJohn Forte path_struct->argv);
4005fcf3ce44SJohn Forte break;
4006fcf3ce44SJohn Forte case DTYPE_SEQUENTIAL: /* Tape */
4007fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
4008fcf3ce44SJohn Forte path_struct->argv);
4009fcf3ce44SJohn Forte break;
4010fcf3ce44SJohn Forte default:
4011fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
4012fcf3ce44SJohn Forte path_struct->argv);
4013fcf3ce44SJohn Forte break;
4014fcf3ce44SJohn Forte }
4015fcf3ce44SJohn Forte
4016fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_a_valid) {
4017fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4018fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4019fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4020fcf3ce44SJohn Forte display_port_status(
4021fcf3ce44SJohn Forte l_disk_state.g_disk_state.d_state_flags[PORT_A]);
4022fcf3ce44SJohn Forte } else {
4023fcf3ce44SJohn Forte if (path_struct->f_flag) {
4024fcf3ce44SJohn Forte if ((ib_present_chk(&l_state, 0) == 1) &&
4025fcf3ce44SJohn Forte (l_state.drv_front[path_struct->slot].ib_status.bypass_a_en)) {
4026fcf3ce44SJohn Forte (void) fprintf(stdout,
4027fcf3ce44SJohn Forte MSGSTR(66,
4028fcf3ce44SJohn Forte " Status(Port A):\tBYPASSED\n"));
4029fcf3ce44SJohn Forte }
4030fcf3ce44SJohn Forte } else {
4031fcf3ce44SJohn Forte if ((ib_present_chk(&l_state, 0) == 1) &&
4032fcf3ce44SJohn Forte (l_state.drv_rear[path_struct->slot].ib_status.bypass_a_en)) {
4033fcf3ce44SJohn Forte (void) fprintf(stdout,
4034fcf3ce44SJohn Forte MSGSTR(66,
4035fcf3ce44SJohn Forte " Status(Port A):\tBYPASSED\n"));
4036fcf3ce44SJohn Forte }
4037fcf3ce44SJohn Forte }
4038fcf3ce44SJohn Forte }
4039fcf3ce44SJohn Forte
4040fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_b_valid) {
4041fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4042fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4043fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4044fcf3ce44SJohn Forte display_port_status(l_disk_state.g_disk_state.d_state_flags[PORT_B]);
4045fcf3ce44SJohn Forte } else {
4046fcf3ce44SJohn Forte if (path_struct->f_flag) {
4047fcf3ce44SJohn Forte if ((ib_present_chk(&l_state, 1) == 1) &&
4048fcf3ce44SJohn Forte (l_state.drv_front[path_struct->slot].ib_status.bypass_b_en)) {
4049fcf3ce44SJohn Forte (void) fprintf(stdout,
4050fcf3ce44SJohn Forte MSGSTR(65,
4051fcf3ce44SJohn Forte " Status(Port B):\tBYPASSED\n"));
4052fcf3ce44SJohn Forte }
4053fcf3ce44SJohn Forte } else {
4054fcf3ce44SJohn Forte if ((ib_present_chk(&l_state, 1) == 1) &&
4055fcf3ce44SJohn Forte (l_state.drv_rear[path_struct->slot].ib_status.bypass_b_en)) {
4056fcf3ce44SJohn Forte (void) fprintf(stdout,
4057fcf3ce44SJohn Forte MSGSTR(65,
4058fcf3ce44SJohn Forte " Status(Port B):\tBYPASSED\n"));
4059fcf3ce44SJohn Forte }
4060fcf3ce44SJohn Forte }
4061fcf3ce44SJohn Forte }
4062fcf3ce44SJohn Forte
4063fcf3ce44SJohn Forte if (no_path_flag) {
4064fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4065fcf3ce44SJohn Forte if (port_a_flag != NULL) {
4066fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4067fcf3ce44SJohn Forte } else {
4068fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4069fcf3ce44SJohn Forte }
4070fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4071fcf3ce44SJohn Forte display_port_status(
4072fcf3ce44SJohn Forte l_disk_state.g_disk_state.d_state_flags[port_a_flag]);
4073fcf3ce44SJohn Forte } else if ((!l_disk_state.g_disk_state.port_a_valid) &&
4074fcf3ce44SJohn Forte (!l_disk_state.g_disk_state.port_b_valid)) {
4075fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2107, " Status:\t\t"
4076fcf3ce44SJohn Forte "No state available.\n"));
4077fcf3ce44SJohn Forte }
4078fcf3ce44SJohn Forte
4079fcf3ce44SJohn Forte (void) display_disk_info(inq, l_disk_state, path_struct, pg_hdr,
4080fcf3ce44SJohn Forte mode_data_avail, (char *)local_inq.inq_box_name, verbose);
4081fcf3ce44SJohn Forte }
4082fcf3ce44SJohn Forte
4083fcf3ce44SJohn Forte
4084fcf3ce44SJohn Forte
4085fcf3ce44SJohn Forte
4086fcf3ce44SJohn Forte
4087fcf3ce44SJohn Forte /*
4088fcf3ce44SJohn Forte * non_encl_fc_disk_display() Prints the device specific
4089fcf3ce44SJohn Forte * information for an individual fcal device.
4090fcf3ce44SJohn Forte *
4091fcf3ce44SJohn Forte * RETURNS:
4092fcf3ce44SJohn Forte * none.
4093fcf3ce44SJohn Forte */
4094fcf3ce44SJohn Forte static int
non_encl_fc_disk_display(Path_struct * path_struct,L_inquiry inq_struct,int verbose)4095fcf3ce44SJohn Forte non_encl_fc_disk_display(Path_struct *path_struct,
4096fcf3ce44SJohn Forte L_inquiry inq_struct, int verbose)
4097fcf3ce44SJohn Forte {
4098fcf3ce44SJohn Forte
4099fcf3ce44SJohn Forte char phys_path[MAXPATHLEN];
4100fcf3ce44SJohn Forte uchar_t node_wwn[WWN_SIZE], port_wwn[WWN_SIZE], *pg_buf = NULL;
4101fcf3ce44SJohn Forte L_disk_state l_disk_state;
4102fcf3ce44SJohn Forte struct dlist *mlist;
4103fcf3ce44SJohn Forte int i = 0, al_pa, offset, mode_data_avail = 0, err = 0;
4104fcf3ce44SJohn Forte int path_a_found = 0, path_b_found = 0, argpwwn = 0,
4105fcf3ce44SJohn Forte argnwwn = 0, pathcnt = 1;
4106fcf3ce44SJohn Forte L_inquiry local_inq;
4107fcf3ce44SJohn Forte Mode_header_10 *mode_header_ptr;
4108fcf3ce44SJohn Forte struct mode_page *pg_hdr;
4109fcf3ce44SJohn Forte WWN_list *wwn_list, *wwn_list_ptr, *list_start;
4110fcf3ce44SJohn Forte char temppath[MAXPATHLEN], last_logical_path[MAXPATHLEN];
4111fcf3ce44SJohn Forte mp_pathlist_t pathlist;
4112fcf3ce44SJohn Forte
4113fcf3ce44SJohn Forte (void) strcpy(phys_path, path_struct->p_physical_path);
4114fcf3ce44SJohn Forte
4115fcf3ce44SJohn Forte /* Get path to all the FC disk and tape devices. */
4116fcf3ce44SJohn Forte if (err = g_get_wwn_list(&wwn_list, verbose)) {
4117fcf3ce44SJohn Forte return (err);
4118fcf3ce44SJohn Forte }
4119fcf3ce44SJohn Forte
4120fcf3ce44SJohn Forte g_sort_wwn_list(&wwn_list);
4121fcf3ce44SJohn Forte
4122fcf3ce44SJohn Forte list_start = wwn_list;
4123fcf3ce44SJohn Forte (void) strcpy(last_logical_path, phys_path);
4124fcf3ce44SJohn Forte
4125fcf3ce44SJohn Forte for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
4126fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
4127fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s,
4128fcf3ce44SJohn Forte path_struct->argv) == 0) {
4129fcf3ce44SJohn Forte list_start = wwn_list_ptr;
4130fcf3ce44SJohn Forte argpwwn = 1;
4131fcf3ce44SJohn Forte break;
4132fcf3ce44SJohn Forte } else if (strcasecmp(wwn_list_ptr->node_wwn_s,
4133fcf3ce44SJohn Forte path_struct->argv) == 0) {
4134fcf3ce44SJohn Forte list_start = wwn_list_ptr;
4135fcf3ce44SJohn Forte argnwwn = 1;
4136fcf3ce44SJohn Forte break;
4137fcf3ce44SJohn Forte }
4138fcf3ce44SJohn Forte }
4139fcf3ce44SJohn Forte
4140fcf3ce44SJohn Forte for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
4141fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
4142fcf3ce44SJohn Forte
4143fcf3ce44SJohn Forte
4144fcf3ce44SJohn Forte if (argpwwn) {
4145fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s,
4146fcf3ce44SJohn Forte path_struct->argv) != 0) {
4147fcf3ce44SJohn Forte continue;
4148fcf3ce44SJohn Forte }
4149fcf3ce44SJohn Forte (void) strcpy(phys_path, wwn_list_ptr->physical_path);
4150fcf3ce44SJohn Forte path_a_found = 0;
4151fcf3ce44SJohn Forte path_b_found = 0;
4152fcf3ce44SJohn Forte mode_data_avail = 0;
4153fcf3ce44SJohn Forte } else if (argnwwn) {
4154fcf3ce44SJohn Forte if (strstr(wwn_list_ptr->logical_path,
4155fcf3ce44SJohn Forte last_logical_path) != NULL) {
4156fcf3ce44SJohn Forte continue;
4157fcf3ce44SJohn Forte }
4158fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->node_wwn_s,
4159fcf3ce44SJohn Forte path_struct->argv) != 0) {
4160fcf3ce44SJohn Forte continue;
4161fcf3ce44SJohn Forte }
4162fcf3ce44SJohn Forte (void) strcpy(phys_path, wwn_list_ptr->physical_path);
4163fcf3ce44SJohn Forte (void) strcpy(last_logical_path,
4164fcf3ce44SJohn Forte wwn_list_ptr->logical_path);
4165fcf3ce44SJohn Forte path_a_found = 0;
4166fcf3ce44SJohn Forte path_b_found = 0;
4167fcf3ce44SJohn Forte mode_data_avail = 0;
4168fcf3ce44SJohn Forte }
4169fcf3ce44SJohn Forte
4170fcf3ce44SJohn Forte (void) memset(&l_disk_state, 0, sizeof (struct l_disk_state_struct));
4171fcf3ce44SJohn Forte
4172fcf3ce44SJohn Forte if ((err = g_get_multipath(phys_path,
4173fcf3ce44SJohn Forte &(l_disk_state.g_disk_state.multipath_list),
4174fcf3ce44SJohn Forte wwn_list, verbose)) != 0) {
4175fcf3ce44SJohn Forte return (err);
4176fcf3ce44SJohn Forte }
4177fcf3ce44SJohn Forte mlist = l_disk_state.g_disk_state.multipath_list;
4178fcf3ce44SJohn Forte if (mlist == NULL) {
4179fcf3ce44SJohn Forte l_disk_state.l_state_flag = L_NO_PATH_FOUND;
4180fcf3ce44SJohn Forte N_DPRINTF(" non_encl_fc_disk_display: Error finding"
4181fcf3ce44SJohn Forte " multiple paths to the disk.\n");
4182fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
4183fcf3ce44SJohn Forte return (-1);
4184fcf3ce44SJohn Forte }
4185fcf3ce44SJohn Forte
4186fcf3ce44SJohn Forte /* get mode page information for FC device */
4187fcf3ce44SJohn Forte if (l_get_mode_pg(phys_path, &pg_buf, verbose) == 0) {
4188fcf3ce44SJohn Forte mode_header_ptr = (struct mode_header_10_struct *)(int)pg_buf;
4189fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
4190fcf3ce44SJohn Forte (uchar_t)sizeof (struct mode_header_10_struct) +
4191fcf3ce44SJohn Forte (uchar_t *)(uintptr_t)(mode_header_ptr->bdesc_length)));
4192fcf3ce44SJohn Forte offset = sizeof (struct mode_header_10_struct) +
4193fcf3ce44SJohn Forte mode_header_ptr->bdesc_length;
4194fcf3ce44SJohn Forte while (offset < (mode_header_ptr->length +
4195fcf3ce44SJohn Forte sizeof (mode_header_ptr->length)) &&
4196fcf3ce44SJohn Forte !mode_data_avail) {
4197fcf3ce44SJohn Forte if (pg_hdr->code == MODEPAGE_CACHING) {
4198fcf3ce44SJohn Forte mode_data_avail++;
4199fcf3ce44SJohn Forte break;
4200fcf3ce44SJohn Forte }
4201fcf3ce44SJohn Forte offset += pg_hdr->length + sizeof (struct mode_page);
4202fcf3ce44SJohn Forte pg_hdr = ((struct mode_page *)((int)pg_buf +
4203fcf3ce44SJohn Forte (uchar_t)offset));
4204fcf3ce44SJohn Forte }
4205fcf3ce44SJohn Forte }
4206fcf3ce44SJohn Forte
4207fcf3ce44SJohn Forte switch ((inq_struct.inq_dtype & DTYPE_MASK)) {
4208fcf3ce44SJohn Forte case DTYPE_DIRECT:
4209fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
4210fcf3ce44SJohn Forte path_struct->argv);
4211fcf3ce44SJohn Forte break;
4212fcf3ce44SJohn Forte case DTYPE_SEQUENTIAL: /* Tape */
4213fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
4214fcf3ce44SJohn Forte path_struct->argv);
4215fcf3ce44SJohn Forte break;
4216fcf3ce44SJohn Forte default:
4217fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
4218fcf3ce44SJohn Forte path_struct->argv);
4219fcf3ce44SJohn Forte break;
4220fcf3ce44SJohn Forte }
4221fcf3ce44SJohn Forte while ((mlist != NULL) && (!(path_a_found && path_b_found))) {
4222fcf3ce44SJohn Forte (void) strcpy(phys_path, mlist->dev_path);
4223fcf3ce44SJohn Forte if (err = g_get_inquiry(phys_path, &local_inq)) {
4224fcf3ce44SJohn Forte (void) fprintf(stderr,
4225fcf3ce44SJohn Forte MSGSTR(2114,
4226fcf3ce44SJohn Forte "non_encl_fc_disk_display: Inquiry failed\n"));
4227fcf3ce44SJohn Forte (void) print_errString(err, phys_path);
4228fcf3ce44SJohn Forte (void) g_free_multipath(
4229fcf3ce44SJohn Forte l_disk_state.g_disk_state.multipath_list);
4230fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
4231fcf3ce44SJohn Forte return (-1);
4232fcf3ce44SJohn Forte }
4233fcf3ce44SJohn Forte if ((err = g_get_wwn(mlist->dev_path, port_wwn, node_wwn,
4234fcf3ce44SJohn Forte &al_pa, verbose)) != 0) {
4235fcf3ce44SJohn Forte (void) print_errString(err, mlist->dev_path);
4236fcf3ce44SJohn Forte (void) g_free_multipath(
4237fcf3ce44SJohn Forte l_disk_state.g_disk_state.multipath_list);
4238fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
4239fcf3ce44SJohn Forte return (-1);
4240fcf3ce44SJohn Forte }
4241fcf3ce44SJohn Forte if (strlen(l_disk_state.g_disk_state.node_wwn_s) == 0) {
4242fcf3ce44SJohn Forte (void) sprintf(l_disk_state.g_disk_state.node_wwn_s,
4243fcf3ce44SJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4244fcf3ce44SJohn Forte node_wwn[0], node_wwn[1], node_wwn[2], node_wwn[3],
4245fcf3ce44SJohn Forte node_wwn[4], node_wwn[5], node_wwn[6], node_wwn[7]);
4246fcf3ce44SJohn Forte }
4247fcf3ce44SJohn Forte if ((err = l_get_disk_port_status(phys_path, &l_disk_state,
4248fcf3ce44SJohn Forte (local_inq.inq_port) ? FC_PORT_B : FC_PORT_A,
4249fcf3ce44SJohn Forte verbose)) != 0) {
4250fcf3ce44SJohn Forte (void) print_errString(err, phys_path);
4251fcf3ce44SJohn Forte (void) g_free_multipath(
4252fcf3ce44SJohn Forte l_disk_state.g_disk_state.multipath_list);
4253fcf3ce44SJohn Forte exit(-1);
4254fcf3ce44SJohn Forte }
4255fcf3ce44SJohn Forte
4256fcf3ce44SJohn Forte if ((!local_inq.inq_port) && (!path_a_found)) {
4257fcf3ce44SJohn Forte (void) sprintf(l_disk_state.g_disk_state.port_a_wwn_s,
4258fcf3ce44SJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4259fcf3ce44SJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
4260fcf3ce44SJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
4261fcf3ce44SJohn Forte path_a_found = l_disk_state.g_disk_state.port_a_valid = 1;
4262fcf3ce44SJohn Forte }
4263fcf3ce44SJohn Forte if ((local_inq.inq_port) && (!path_b_found)) {
4264fcf3ce44SJohn Forte path_b_found = l_disk_state.g_disk_state.port_b_valid = 1;
4265fcf3ce44SJohn Forte (void) sprintf(l_disk_state.g_disk_state.port_b_wwn_s,
4266fcf3ce44SJohn Forte "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
4267fcf3ce44SJohn Forte port_wwn[0], port_wwn[1], port_wwn[2], port_wwn[3],
4268fcf3ce44SJohn Forte port_wwn[4], port_wwn[5], port_wwn[6], port_wwn[7]);
4269fcf3ce44SJohn Forte }
4270fcf3ce44SJohn Forte
4271fcf3ce44SJohn Forte if ((strstr(mlist->dev_path, SCSI_VHCI) != NULL) &&
4272fcf3ce44SJohn Forte (!l_get_disk_port_status(phys_path, &l_disk_state,
4273fcf3ce44SJohn Forte (!local_inq.inq_port) ? FC_PORT_B : FC_PORT_A,
4274fcf3ce44SJohn Forte verbose))) {
4275fcf3ce44SJohn Forte (void) strcpy(temppath, mlist->dev_path);
4276fcf3ce44SJohn Forte if (err = g_get_pathlist(temppath, &pathlist)) {
4277fcf3ce44SJohn Forte (void) print_errString(err, NULL);
4278fcf3ce44SJohn Forte exit(-1);
4279fcf3ce44SJohn Forte }
4280fcf3ce44SJohn Forte pathcnt = pathlist.path_count;
4281fcf3ce44SJohn Forte if (pathcnt > 1) {
4282fcf3ce44SJohn Forte for (i = 0; i < pathcnt; i++) {
4283fcf3ce44SJohn Forte if ((!path_a_found) &&
4284fcf3ce44SJohn Forte (path_b_found) &&
4285fcf3ce44SJohn Forte (strstr(pathlist.path_info[i].
4286fcf3ce44SJohn Forte path_addr,
4287fcf3ce44SJohn Forte l_disk_state.g_disk_state.
4288fcf3ce44SJohn Forte port_b_wwn_s) == NULL)) {
4289fcf3ce44SJohn Forte
4290fcf3ce44SJohn Forte (void) strncpy(l_disk_state.
4291fcf3ce44SJohn Forte g_disk_state.port_a_wwn_s,
4292fcf3ce44SJohn Forte pathlist.path_info[i].
4293fcf3ce44SJohn Forte path_addr, 16);
4294fcf3ce44SJohn Forte path_a_found = l_disk_state.
4295fcf3ce44SJohn Forte g_disk_state.port_a_valid = 1;
4296fcf3ce44SJohn Forte }
4297fcf3ce44SJohn Forte if ((path_a_found) &&
4298fcf3ce44SJohn Forte (!path_b_found) &&
4299fcf3ce44SJohn Forte (strstr(pathlist.path_info[i].
4300fcf3ce44SJohn Forte path_addr,
4301fcf3ce44SJohn Forte l_disk_state.g_disk_state.
4302fcf3ce44SJohn Forte port_a_wwn_s) == NULL)) {
4303fcf3ce44SJohn Forte
4304fcf3ce44SJohn Forte (void) strncpy(l_disk_state.
4305fcf3ce44SJohn Forte g_disk_state.port_b_wwn_s,
4306fcf3ce44SJohn Forte pathlist.path_info[i].
4307fcf3ce44SJohn Forte path_addr, 16);
4308fcf3ce44SJohn Forte path_b_found = l_disk_state.
4309fcf3ce44SJohn Forte g_disk_state.port_b_valid = 1;
4310fcf3ce44SJohn Forte }
4311fcf3ce44SJohn Forte if ((path_a_found) && (path_b_found)) {
4312fcf3ce44SJohn Forte break;
4313fcf3ce44SJohn Forte }
4314fcf3ce44SJohn Forte }
4315fcf3ce44SJohn Forte }
4316fcf3ce44SJohn Forte free(pathlist.path_info);
4317fcf3ce44SJohn Forte }
4318fcf3ce44SJohn Forte
4319fcf3ce44SJohn Forte mlist = mlist->next;
4320fcf3ce44SJohn Forte }
4321fcf3ce44SJohn Forte
4322fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_a_valid) {
4323fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4324fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(141, "Status(Port A):"));
4325fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4326fcf3ce44SJohn Forte display_port_status(l_disk_state.g_disk_state.d_state_flags[FC_PORT_A]);
4327fcf3ce44SJohn Forte }
4328fcf3ce44SJohn Forte
4329fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_b_valid) {
4330fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4331fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(142, "Status(Port B):"));
4332fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4333fcf3ce44SJohn Forte display_port_status(l_disk_state.g_disk_state.d_state_flags[FC_PORT_B]);
4334fcf3ce44SJohn Forte }
4335fcf3ce44SJohn Forte
4336fcf3ce44SJohn Forte (void) display_disk_info(local_inq, l_disk_state, path_struct,
4337fcf3ce44SJohn Forte pg_hdr, mode_data_avail, NULL, verbose);
4338fcf3ce44SJohn Forte (void) g_free_multipath(l_disk_state.g_disk_state.multipath_list);
4339fcf3ce44SJohn Forte
4340fcf3ce44SJohn Forte if (!(argpwwn || argnwwn)) {
4341fcf3ce44SJohn Forte break;
4342fcf3ce44SJohn Forte }
4343fcf3ce44SJohn Forte
4344fcf3ce44SJohn Forte }
4345fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
4346fcf3ce44SJohn Forte return (0);
4347fcf3ce44SJohn Forte }
4348fcf3ce44SJohn Forte
4349fcf3ce44SJohn Forte
4350fcf3ce44SJohn Forte
4351fcf3ce44SJohn Forte /*
4352fcf3ce44SJohn Forte * display_disk_info() Prints the device specific information
4353fcf3ce44SJohn Forte * for any FC_AL disk device.
4354fcf3ce44SJohn Forte *
4355fcf3ce44SJohn Forte * RETURNS:
4356fcf3ce44SJohn Forte * none.
4357fcf3ce44SJohn Forte */
4358fcf3ce44SJohn Forte void
display_disk_info(L_inquiry inq,L_disk_state l_disk_state,Path_struct * path_struct,struct mode_page * pg_hdr,int mode_data_avail,char * name_buf,int options)4359fcf3ce44SJohn Forte display_disk_info(L_inquiry inq, L_disk_state l_disk_state,
4360fcf3ce44SJohn Forte Path_struct *path_struct, struct mode_page *pg_hdr,
4361fcf3ce44SJohn Forte int mode_data_avail, char *name_buf, int options)
4362fcf3ce44SJohn Forte {
4363fcf3ce44SJohn Forte float num_blks;
4364fcf3ce44SJohn Forte struct dlist *mlist;
4365fcf3ce44SJohn Forte int port_a, port_b;
4366fcf3ce44SJohn Forte struct my_mode_caching *pg8_buf;
4367fcf3ce44SJohn Forte L_inquiry enc_inq;
4368fcf3ce44SJohn Forte char *enc_phys_path;
4369fcf3ce44SJohn Forte Path_struct *enc_path_struct;
4370fcf3ce44SJohn Forte int enc_type = 0;
4371fcf3ce44SJohn Forte L_inquiry80 inq80;
4372fcf3ce44SJohn Forte size_t serial_len;
4373fcf3ce44SJohn Forte int err;
4374fcf3ce44SJohn Forte
4375fcf3ce44SJohn Forte serial_len = sizeof (inq80.inq_serial);
4376fcf3ce44SJohn Forte err = g_get_serial_number(path_struct->p_physical_path,
4377fcf3ce44SJohn Forte inq80.inq_serial, &serial_len);
4378fcf3ce44SJohn Forte if (err) {
4379fcf3ce44SJohn Forte fprintf(stderr, "\n");
4380fcf3ce44SJohn Forte print_errString(err, path_struct->p_physical_path);
4381fcf3ce44SJohn Forte fprintf(stderr, "\n");
4382fcf3ce44SJohn Forte exit(1);
4383fcf3ce44SJohn Forte }
4384fcf3ce44SJohn Forte (void) fprintf(stdout, " ");
4385fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(3, "Vendor:"));
4386fcf3ce44SJohn Forte (void) fprintf(stdout, "\t\t");
4387fcf3ce44SJohn Forte print_chars(inq.inq_vid, sizeof (inq.inq_vid), 0);
4388fcf3ce44SJohn Forte
4389fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2115, "\n Product ID:\t\t"));
4390fcf3ce44SJohn Forte print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
4391fcf3ce44SJohn Forte
4392fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2116, "\n WWN(Node):\t\t%s"),
4393fcf3ce44SJohn Forte l_disk_state.g_disk_state.node_wwn_s);
4394fcf3ce44SJohn Forte
4395fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_a_valid) {
4396fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2117, "\n WWN(Port A):\t\t%s"),
4397fcf3ce44SJohn Forte l_disk_state.g_disk_state.port_a_wwn_s);
4398fcf3ce44SJohn Forte }
4399fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.port_b_valid) {
4400fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2118, "\n WWN(Port B):\t\t%s"),
4401fcf3ce44SJohn Forte l_disk_state.g_disk_state.port_b_wwn_s);
4402fcf3ce44SJohn Forte }
4403fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
4404fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2119, "Revision:"));
4405fcf3ce44SJohn Forte (void) fprintf(stdout, "\t\t");
4406fcf3ce44SJohn Forte print_chars(inq.inq_revision, sizeof (inq.inq_revision), 0);
4407fcf3ce44SJohn Forte
4408fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
4409fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(17, "Serial Num:"));
4410fcf3ce44SJohn Forte (void) fprintf(stdout, "\t\t");
4411fcf3ce44SJohn Forte print_chars(inq80.inq_serial, serial_len, 0);
4412fcf3ce44SJohn Forte num_blks = l_disk_state.g_disk_state.num_blocks;
4413fcf3ce44SJohn Forte if (num_blks) {
4414fcf3ce44SJohn Forte num_blks /= 2048; /* get Mbytes */
4415fcf3ce44SJohn Forte (void) fprintf(stdout, "\n ");
4416fcf3ce44SJohn Forte (void) fprintf(stdout,
4417fcf3ce44SJohn Forte MSGSTR(60,
4418fcf3ce44SJohn Forte "Unformatted capacity:\t%6.3f MBytes"), num_blks);
4419fcf3ce44SJohn Forte }
4420fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4421fcf3ce44SJohn Forte
4422fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.persistent_reserv_flag) {
4423fcf3ce44SJohn Forte (void) fprintf(stdout,
4424fcf3ce44SJohn Forte MSGSTR(2120, " Persistent Reserve:\t"));
4425fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.persistent_active) {
4426fcf3ce44SJohn Forte (void) fprintf(stdout,
4427fcf3ce44SJohn Forte MSGSTR(39, "Active"));
4428fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4429fcf3ce44SJohn Forte }
4430fcf3ce44SJohn Forte if (l_disk_state.g_disk_state.persistent_registered) {
4431fcf3ce44SJohn Forte (void) fprintf(stdout,
4432fcf3ce44SJohn Forte MSGSTR(2121, "Found Registered Keys"));
4433fcf3ce44SJohn Forte } else {
4434fcf3ce44SJohn Forte (void) fprintf(stdout,
4435fcf3ce44SJohn Forte MSGSTR(87, "Not being used"));
4436fcf3ce44SJohn Forte }
4437fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4438fcf3ce44SJohn Forte }
4439fcf3ce44SJohn Forte
4440fcf3ce44SJohn Forte if ((mode_data_avail) && (pg_hdr->code == MODEPAGE_CACHING)) {
4441fcf3ce44SJohn Forte pg8_buf = (struct my_mode_caching *)(int)pg_hdr;
4442fcf3ce44SJohn Forte if (pg8_buf->wce) {
4443fcf3ce44SJohn Forte (void) fprintf(stdout,
4444fcf3ce44SJohn Forte MSGSTR(2122,
4445fcf3ce44SJohn Forte " Write Cache:\t\t"
4446fcf3ce44SJohn Forte "Enabled\n"));
4447fcf3ce44SJohn Forte }
4448fcf3ce44SJohn Forte if (pg8_buf->rcd == 0) {
4449fcf3ce44SJohn Forte (void) fprintf(stdout,
4450fcf3ce44SJohn Forte MSGSTR(2123,
4451fcf3ce44SJohn Forte " Read Cache:\t\t"
4452fcf3ce44SJohn Forte "Enabled\n"));
4453fcf3ce44SJohn Forte (void) fprintf(stdout,
4454fcf3ce44SJohn Forte MSGSTR(2320,
4455fcf3ce44SJohn Forte " Minimum prefetch:"
4456fcf3ce44SJohn Forte "\t0x%x\n"
4457fcf3ce44SJohn Forte " Maximum prefetch:"
4458fcf3ce44SJohn Forte "\t0x%x\n"),
4459fcf3ce44SJohn Forte pg8_buf->min_prefetch,
4460fcf3ce44SJohn Forte pg8_buf->max_prefetch);
4461fcf3ce44SJohn Forte }
4462fcf3ce44SJohn Forte }
4463fcf3ce44SJohn Forte
4464fcf3ce44SJohn Forte /*
4465fcf3ce44SJohn Forte * When /dev/rdsk/cxtxdxsx form of input is specified
4466fcf3ce44SJohn Forte * for display command the initial library version didn't
4467fcf3ce44SJohn Forte * display Location information. The change is made
4468fcf3ce44SJohn Forte * to display the same Location info as the non-library version.
4469fcf3ce44SJohn Forte */
4470fcf3ce44SJohn Forte
4471fcf3ce44SJohn Forte if (name_buf != NULL) {
4472fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2125, " Location:\t\t"));
4473fcf3ce44SJohn Forte if (path_struct->slot_valid) {
4474fcf3ce44SJohn Forte /*
4475fcf3ce44SJohn Forte * We have to do another inquiry on the enclosure (name_buf)
4476fcf3ce44SJohn Forte * to determine if this device is within a daktari, or
4477fcf3ce44SJohn Forte * a two sided device.
4478fcf3ce44SJohn Forte */
4479fcf3ce44SJohn Forte if (!l_convert_name(name_buf, &enc_phys_path,
4480fcf3ce44SJohn Forte &enc_path_struct, 0)) {
4481fcf3ce44SJohn Forte if (!g_get_inquiry(enc_phys_path, &enc_inq)) {
4482fcf3ce44SJohn Forte enc_type = l_get_enc_type(enc_inq);
4483fcf3ce44SJohn Forte }
4484fcf3ce44SJohn Forte }
4485fcf3ce44SJohn Forte /* If either of the above fail, we just assume the default */
4486fcf3ce44SJohn Forte free(enc_phys_path);
4487fcf3ce44SJohn Forte free(enc_path_struct);
4488fcf3ce44SJohn Forte if (enc_type == DAK_ENC_TYPE) {
4489fcf3ce44SJohn Forte if (path_struct->f_flag) {
4490fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2239,
4491fcf3ce44SJohn Forte "In slot %d in the enclosure named: %s\n"),
4492fcf3ce44SJohn Forte path_struct->slot, name_buf);
4493fcf3ce44SJohn Forte } else {
4494fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2239,
4495fcf3ce44SJohn Forte "In slot %d in the enclosure named: %s\n"),
4496fcf3ce44SJohn Forte path_struct->slot + (MAX_DRIVES_DAK/2),
4497fcf3ce44SJohn Forte name_buf);
4498fcf3ce44SJohn Forte }
4499fcf3ce44SJohn Forte } else { /* Default enclosure type */
4500fcf3ce44SJohn Forte (void) fprintf(stdout, path_struct->f_flag ?
4501fcf3ce44SJohn Forte MSGSTR(2126,
4502fcf3ce44SJohn Forte "In slot %d in the Front of the enclosure named: %s\n")
4503fcf3ce44SJohn Forte : MSGSTR(2127,
4504fcf3ce44SJohn Forte "In slot %d in the Rear of the enclosure named: %s\n"),
4505fcf3ce44SJohn Forte path_struct->slot, name_buf);
4506fcf3ce44SJohn Forte }
4507fcf3ce44SJohn Forte } else {
4508fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2228,
4509fcf3ce44SJohn Forte "In the enclosure named: %s\n"),
4510fcf3ce44SJohn Forte name_buf);
4511fcf3ce44SJohn Forte }
4512fcf3ce44SJohn Forte }
4513fcf3ce44SJohn Forte
4514fcf3ce44SJohn Forte (void) fprintf(stdout, " %s\t\t%s\n",
4515fcf3ce44SJohn Forte MSGSTR(35, "Device Type:"),
4516fcf3ce44SJohn Forte dtype[inq.inq_dtype & DTYPE_MASK]);
4517fcf3ce44SJohn Forte
4518fcf3ce44SJohn Forte mlist = l_disk_state.g_disk_state.multipath_list;
4519fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2128, " Path(s):\n"));
4520fcf3ce44SJohn Forte if (strstr(mlist->dev_path, SCSI_VHCI) != NULL) {
4521fcf3ce44SJohn Forte (void) fprintf(stdout, " %s\n %s\n",
4522fcf3ce44SJohn Forte mlist->logical_path, mlist->dev_path);
4523fcf3ce44SJohn Forte (void) adm_print_pathlist(mlist->dev_path);
4524fcf3ce44SJohn Forte } else {
4525fcf3ce44SJohn Forte while (mlist) {
4526fcf3ce44SJohn Forte (void) fprintf(stdout, " %s\n %s\n",
4527fcf3ce44SJohn Forte mlist->logical_path, mlist->dev_path);
4528fcf3ce44SJohn Forte mlist = mlist->next;
4529fcf3ce44SJohn Forte }
4530fcf3ce44SJohn Forte }
4531fcf3ce44SJohn Forte
4532fcf3ce44SJohn Forte if (Options & OPTION_V) {
4533fcf3ce44SJohn Forte if (path_struct->slot_valid) {
4534fcf3ce44SJohn Forte port_a = PORT_A;
4535fcf3ce44SJohn Forte port_b = PORT_B;
4536fcf3ce44SJohn Forte } else {
4537fcf3ce44SJohn Forte port_a = FC_PORT_A;
4538fcf3ce44SJohn Forte port_b = FC_PORT_B;
4539fcf3ce44SJohn Forte }
4540fcf3ce44SJohn Forte /* Only bother if the state is O.K. */
4541fcf3ce44SJohn Forte if ((l_disk_state.g_disk_state.port_a_valid) &&
4542fcf3ce44SJohn Forte (l_disk_state.g_disk_state.d_state_flags[port_a] == 0))
4543fcf3ce44SJohn Forte adm_display_verbose_disk(path_struct->p_physical_path, options);
4544fcf3ce44SJohn Forte else if ((l_disk_state.g_disk_state.port_b_valid) &&
4545fcf3ce44SJohn Forte (l_disk_state.g_disk_state.d_state_flags[port_b] == 0))
4546fcf3ce44SJohn Forte adm_display_verbose_disk(path_struct->p_physical_path, options);
4547fcf3ce44SJohn Forte }
4548fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4549fcf3ce44SJohn Forte
4550fcf3ce44SJohn Forte }
4551fcf3ce44SJohn Forte
4552fcf3ce44SJohn Forte
4553fcf3ce44SJohn Forte
4554fcf3ce44SJohn Forte /*
4555fcf3ce44SJohn Forte * temp_decode() Display temperature bytes 1-3 state.
4556fcf3ce44SJohn Forte *
4557fcf3ce44SJohn Forte * RETURNS:
4558fcf3ce44SJohn Forte * none.
4559fcf3ce44SJohn Forte */
4560fcf3ce44SJohn Forte void
temp_decode(Temp_elem_st * temp)4561fcf3ce44SJohn Forte temp_decode(Temp_elem_st *temp)
4562fcf3ce44SJohn Forte {
4563fcf3ce44SJohn Forte if (temp->ot_fail) {
4564fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2129,
4565fcf3ce44SJohn Forte ": FAILURE - Over Temperature"));
4566fcf3ce44SJohn Forte }
4567fcf3ce44SJohn Forte if (temp->ut_fail) {
4568fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2130,
4569fcf3ce44SJohn Forte ": FAILURE - Under Temperature"));
4570fcf3ce44SJohn Forte }
4571fcf3ce44SJohn Forte if (temp->ot_warn) {
4572fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2131,
4573fcf3ce44SJohn Forte ": WARNING - Over Temperature"));
4574fcf3ce44SJohn Forte }
4575fcf3ce44SJohn Forte if (temp->ut_warn) {
4576fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2132,
4577fcf3ce44SJohn Forte ": WARNING - Under Temperature"));
4578fcf3ce44SJohn Forte }
4579fcf3ce44SJohn Forte }
4580fcf3ce44SJohn Forte
4581fcf3ce44SJohn Forte
4582fcf3ce44SJohn Forte
4583fcf3ce44SJohn Forte /*
4584fcf3ce44SJohn Forte * disp_degree() Display temperature in Degrees Celsius.
4585fcf3ce44SJohn Forte *
4586fcf3ce44SJohn Forte * RETURNS:
4587fcf3ce44SJohn Forte * none.
4588fcf3ce44SJohn Forte */
4589fcf3ce44SJohn Forte void
disp_degree(Temp_elem_st * temp)4590fcf3ce44SJohn Forte disp_degree(Temp_elem_st *temp)
4591fcf3ce44SJohn Forte {
4592fcf3ce44SJohn Forte int t;
4593fcf3ce44SJohn Forte
4594fcf3ce44SJohn Forte t = temp->degrees;
4595fcf3ce44SJohn Forte t -= 20; /* re-adjust */
4596fcf3ce44SJohn Forte /*
4597fcf3ce44SJohn Forte * NL_Comment
4598fcf3ce44SJohn Forte * The %c is the degree symbol.
4599fcf3ce44SJohn Forte */
4600fcf3ce44SJohn Forte (void) fprintf(stdout, ":%1.2d%cC ", t, 186);
4601fcf3ce44SJohn Forte }
4602fcf3ce44SJohn Forte
4603fcf3ce44SJohn Forte
4604fcf3ce44SJohn Forte
4605fcf3ce44SJohn Forte /*
4606fcf3ce44SJohn Forte * trans_decode() Display tranceivers state.
4607fcf3ce44SJohn Forte *
4608fcf3ce44SJohn Forte * RETURNS:
4609fcf3ce44SJohn Forte * none.
4610fcf3ce44SJohn Forte */
4611fcf3ce44SJohn Forte void
trans_decode(Trans_elem_st * trans)4612fcf3ce44SJohn Forte trans_decode(Trans_elem_st *trans)
4613fcf3ce44SJohn Forte {
4614fcf3ce44SJohn Forte if (trans->disabled) {
4615fcf3ce44SJohn Forte (void) fprintf(stdout, ": ");
4616fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(34,
4617fcf3ce44SJohn Forte "Disabled"));
4618fcf3ce44SJohn Forte }
4619fcf3ce44SJohn Forte if (trans->lol) {
4620fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2133,
4621fcf3ce44SJohn Forte ": Not receiving a signal"));
4622fcf3ce44SJohn Forte }
4623fcf3ce44SJohn Forte if (trans->lsr_fail) {
4624fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2134,
4625fcf3ce44SJohn Forte ": Laser failed"));
4626fcf3ce44SJohn Forte }
4627fcf3ce44SJohn Forte }
4628fcf3ce44SJohn Forte
4629fcf3ce44SJohn Forte
4630fcf3ce44SJohn Forte
4631fcf3ce44SJohn Forte /*
4632fcf3ce44SJohn Forte * trans_messages() Display tranceiver status.
4633fcf3ce44SJohn Forte *
4634fcf3ce44SJohn Forte * NOTE: The decoding of the status assumes that the elements
4635fcf3ce44SJohn Forte * are in order with the first two elements are for the
4636fcf3ce44SJohn Forte * "A" IB. It also assumes the tranceivers are numbered
4637fcf3ce44SJohn Forte * 0 and 1.
4638fcf3ce44SJohn Forte *
4639fcf3ce44SJohn Forte * RETURNS:
4640fcf3ce44SJohn Forte * none.
4641fcf3ce44SJohn Forte */
4642fcf3ce44SJohn Forte void
trans_messages(struct l_state_struct * l_state,int ib_a_flag)4643fcf3ce44SJohn Forte trans_messages(struct l_state_struct *l_state, int ib_a_flag)
4644fcf3ce44SJohn Forte {
4645fcf3ce44SJohn Forte Trans_elem_st trans;
4646fcf3ce44SJohn Forte int i, j, k;
4647fcf3ce44SJohn Forte int count = 0;
4648fcf3ce44SJohn Forte int elem_index = 0;
4649fcf3ce44SJohn Forte
4650fcf3ce44SJohn Forte /* Get and print messages */
4651fcf3ce44SJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
4652fcf3ce44SJohn Forte elem_index++;
4653fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_FL) {
4654fcf3ce44SJohn Forte
4655fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[i].text_len != 0) {
4656fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t\t%s\n",
4657fcf3ce44SJohn Forte l_state->ib_tbl.config.text[i]);
4658fcf3ce44SJohn Forte }
4659fcf3ce44SJohn Forte count = k = 0;
4660fcf3ce44SJohn Forte
4661fcf3ce44SJohn Forte for (j = 0; j <
4662fcf3ce44SJohn Forte (int)l_state->ib_tbl.config.type_hdr[i].num; j++) {
4663fcf3ce44SJohn Forte /*
4664fcf3ce44SJohn Forte * Only display the status for the selected IB.
4665fcf3ce44SJohn Forte */
4666fcf3ce44SJohn Forte if ((count < 2 && ib_a_flag) ||
4667fcf3ce44SJohn Forte (count >= 2 && !ib_a_flag)) {
4668fcf3ce44SJohn Forte (void) bcopy((const void *)
4669fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
4670fcf3ce44SJohn Forte (void *)&trans, sizeof (trans));
4671fcf3ce44SJohn Forte
4672fcf3ce44SJohn Forte if (k == 0) {
4673fcf3ce44SJohn Forte (void) fprintf(stdout, "\t\t%d ", k);
4674fcf3ce44SJohn Forte } else {
4675fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t\t%d ", k);
4676fcf3ce44SJohn Forte }
4677fcf3ce44SJohn Forte if (trans.code == S_OK) {
4678fcf3ce44SJohn Forte (void) fprintf(stdout,
4679fcf3ce44SJohn Forte MSGSTR(29, "O.K."));
4680fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4681fcf3ce44SJohn Forte } else if ((trans.code == S_CRITICAL) ||
4682fcf3ce44SJohn Forte (trans.code == S_NONCRITICAL)) {
4683fcf3ce44SJohn Forte (void) fprintf(stdout,
4684fcf3ce44SJohn Forte MSGSTR(2135, "Failed"));
4685fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4686fcf3ce44SJohn Forte trans_decode(&trans);
4687fcf3ce44SJohn Forte } else if (trans.code == S_NOT_INSTALLED) {
4688fcf3ce44SJohn Forte (void) fprintf(stdout,
4689fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
4690fcf3ce44SJohn Forte } else if (trans.code == S_NOT_AVAILABLE) {
4691fcf3ce44SJohn Forte (void) fprintf(stdout,
4692fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
4693fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4694fcf3ce44SJohn Forte } else {
4695fcf3ce44SJohn Forte (void) fprintf(stdout,
4696fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
4697fcf3ce44SJohn Forte }
4698fcf3ce44SJohn Forte k++;
4699fcf3ce44SJohn Forte }
4700fcf3ce44SJohn Forte count++;
4701fcf3ce44SJohn Forte }
4702fcf3ce44SJohn Forte }
4703fcf3ce44SJohn Forte /*
4704fcf3ce44SJohn Forte * Calculate the index to each element.
4705fcf3ce44SJohn Forte */
4706fcf3ce44SJohn Forte elem_index += l_state->ib_tbl.config.type_hdr[i].num;
4707fcf3ce44SJohn Forte }
4708fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4709fcf3ce44SJohn Forte }
4710fcf3ce44SJohn Forte
4711fcf3ce44SJohn Forte
4712fcf3ce44SJohn Forte
4713fcf3ce44SJohn Forte /*
4714fcf3ce44SJohn Forte * temperature_messages() Display temperature status.
4715fcf3ce44SJohn Forte *
4716fcf3ce44SJohn Forte * RETURNS:
4717fcf3ce44SJohn Forte * none.
4718fcf3ce44SJohn Forte */
4719fcf3ce44SJohn Forte void
temperature_messages(struct l_state_struct * l_state,int rear_flag)4720fcf3ce44SJohn Forte temperature_messages(struct l_state_struct *l_state, int rear_flag)
4721fcf3ce44SJohn Forte {
4722fcf3ce44SJohn Forte Temp_elem_st temp;
4723fcf3ce44SJohn Forte int i, j, last_ok = 0;
4724fcf3ce44SJohn Forte int all_ok = 1;
4725fcf3ce44SJohn Forte int elem_index = 0;
4726fcf3ce44SJohn Forte
4727fcf3ce44SJohn Forte /* Get and print messages */
4728fcf3ce44SJohn Forte for (i = 0; i < (int)l_state->ib_tbl.config.enc_num_elem; i++) {
4729fcf3ce44SJohn Forte elem_index++; /* skip global */
4730fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[i].type == ELM_TYP_TS) {
4731fcf3ce44SJohn Forte if (!rear_flag) {
4732fcf3ce44SJohn Forte rear_flag = 1; /* only do front or rear backplane */
4733fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[i].text_len != 0) {
4734fcf3ce44SJohn Forte (void) fprintf(stdout, "\t %s",
4735fcf3ce44SJohn Forte l_state->ib_tbl.config.text[i]);
4736fcf3ce44SJohn Forte }
4737fcf3ce44SJohn Forte
4738fcf3ce44SJohn Forte /*
4739fcf3ce44SJohn Forte * Check global status and if not all O.K.
4740fcf3ce44SJohn Forte * then print individually.
4741fcf3ce44SJohn Forte */
4742fcf3ce44SJohn Forte (void) bcopy((const void *)&l_state->ib_tbl.p2_s.element[i],
4743fcf3ce44SJohn Forte (void *)&temp, sizeof (temp));
4744fcf3ce44SJohn Forte for (j = 0; j <
4745fcf3ce44SJohn Forte (int)l_state->ib_tbl.config.type_hdr[i].num; j++) {
4746fcf3ce44SJohn Forte (void) bcopy((const void *)
4747fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
4748fcf3ce44SJohn Forte (void *)&temp, sizeof (temp));
4749fcf3ce44SJohn Forte
4750fcf3ce44SJohn Forte if ((j == 0) && (temp.code == S_OK) &&
4751fcf3ce44SJohn Forte (!(temp.ot_fail || temp.ot_warn ||
4752fcf3ce44SJohn Forte temp.ut_fail || temp.ut_warn))) {
4753fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t %d", j);
4754fcf3ce44SJohn Forte } else if ((j == 6) && (temp.code == S_OK) &&
4755fcf3ce44SJohn Forte all_ok) {
4756fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t %d", j);
4757fcf3ce44SJohn Forte } else if (last_ok && (temp.code == S_OK)) {
4758fcf3ce44SJohn Forte (void) fprintf(stdout, "%d", j);
4759fcf3ce44SJohn Forte } else {
4760fcf3ce44SJohn Forte (void) fprintf(stdout, "\n\t\t%d", j);
4761fcf3ce44SJohn Forte }
4762fcf3ce44SJohn Forte if (temp.code == S_OK) {
4763fcf3ce44SJohn Forte disp_degree(&temp);
4764fcf3ce44SJohn Forte if (temp.ot_fail || temp.ot_warn ||
4765fcf3ce44SJohn Forte temp.ut_fail || temp.ut_warn) {
4766fcf3ce44SJohn Forte temp_decode(&temp);
4767fcf3ce44SJohn Forte all_ok = 0;
4768fcf3ce44SJohn Forte last_ok = 0;
4769fcf3ce44SJohn Forte } else {
4770fcf3ce44SJohn Forte last_ok++;
4771fcf3ce44SJohn Forte }
4772fcf3ce44SJohn Forte } else if (temp.code == S_CRITICAL) {
4773fcf3ce44SJohn Forte (void) fprintf(stdout,
4774fcf3ce44SJohn Forte MSGSTR(122, "Critical failure"));
4775fcf3ce44SJohn Forte last_ok = 0;
4776fcf3ce44SJohn Forte all_ok = 0;
4777fcf3ce44SJohn Forte } else if (temp.code == S_NONCRITICAL) {
4778fcf3ce44SJohn Forte (void) fprintf(stdout,
4779fcf3ce44SJohn Forte MSGSTR(89, "Non-Critical Failure"));
4780fcf3ce44SJohn Forte last_ok = 0;
4781fcf3ce44SJohn Forte all_ok = 0;
4782fcf3ce44SJohn Forte } else if (temp.code == S_NOT_INSTALLED) {
4783fcf3ce44SJohn Forte (void) fprintf(stdout,
4784fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
4785fcf3ce44SJohn Forte last_ok = 0;
4786fcf3ce44SJohn Forte all_ok = 0;
4787fcf3ce44SJohn Forte } else if (temp.code == S_NOT_AVAILABLE) {
4788fcf3ce44SJohn Forte (void) fprintf(stdout,
4789fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
4790fcf3ce44SJohn Forte last_ok = 0;
4791fcf3ce44SJohn Forte all_ok = 0;
4792fcf3ce44SJohn Forte } else {
4793fcf3ce44SJohn Forte (void) fprintf(stdout,
4794fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
4795fcf3ce44SJohn Forte last_ok = 0;
4796fcf3ce44SJohn Forte all_ok = 0;
4797fcf3ce44SJohn Forte }
4798fcf3ce44SJohn Forte }
4799fcf3ce44SJohn Forte if (all_ok) {
4800fcf3ce44SJohn Forte (void) fprintf(stdout,
4801fcf3ce44SJohn Forte MSGSTR(2136, " (All temperatures are "
4802fcf3ce44SJohn Forte "NORMAL.)"));
4803fcf3ce44SJohn Forte }
4804fcf3ce44SJohn Forte all_ok = 1;
4805fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4806fcf3ce44SJohn Forte } else {
4807fcf3ce44SJohn Forte rear_flag = 0;
4808fcf3ce44SJohn Forte }
4809fcf3ce44SJohn Forte }
4810fcf3ce44SJohn Forte elem_index += l_state->ib_tbl.config.type_hdr[i].num;
4811fcf3ce44SJohn Forte }
4812fcf3ce44SJohn Forte }
4813fcf3ce44SJohn Forte
4814fcf3ce44SJohn Forte
4815fcf3ce44SJohn Forte
4816fcf3ce44SJohn Forte /*
4817fcf3ce44SJohn Forte * ib_decode() Display IB byte 3 state.
4818fcf3ce44SJohn Forte *
4819fcf3ce44SJohn Forte * RETURNS:
4820fcf3ce44SJohn Forte * none.
4821fcf3ce44SJohn Forte */
4822fcf3ce44SJohn Forte void
ib_decode(Ctlr_elem_st * ctlr)4823fcf3ce44SJohn Forte ib_decode(Ctlr_elem_st *ctlr)
4824fcf3ce44SJohn Forte {
4825fcf3ce44SJohn Forte if (ctlr->overtemp_alart) {
4826fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2137,
4827fcf3ce44SJohn Forte " - IB Over Temperature Alert "));
4828fcf3ce44SJohn Forte }
4829fcf3ce44SJohn Forte if (ctlr->ib_loop_1_fail) {
4830fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2138,
4831fcf3ce44SJohn Forte " - IB Loop 1 has failed "));
4832fcf3ce44SJohn Forte }
4833fcf3ce44SJohn Forte if (ctlr->ib_loop_0_fail) {
4834fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2139,
4835fcf3ce44SJohn Forte " - IB Loop 0 has failed "));
4836fcf3ce44SJohn Forte }
4837fcf3ce44SJohn Forte }
4838fcf3ce44SJohn Forte
4839fcf3ce44SJohn Forte
4840fcf3ce44SJohn Forte
4841fcf3ce44SJohn Forte /*
4842fcf3ce44SJohn Forte * mb_messages() Display motherboard
4843fcf3ce44SJohn Forte * (interconnect assembly) messages.
4844fcf3ce44SJohn Forte *
4845fcf3ce44SJohn Forte * RETURNS:
4846fcf3ce44SJohn Forte * none.
4847fcf3ce44SJohn Forte */
4848fcf3ce44SJohn Forte void
mb_messages(struct l_state_struct * l_state,int index,int elem_index)4849fcf3ce44SJohn Forte mb_messages(struct l_state_struct *l_state, int index, int elem_index)
4850fcf3ce44SJohn Forte {
4851fcf3ce44SJohn Forte int j;
4852fcf3ce44SJohn Forte Interconnect_st interconnect;
4853fcf3ce44SJohn Forte
4854fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4855fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
4856fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
4857fcf3ce44SJohn Forte }
4858fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4859fcf3ce44SJohn Forte j++) {
4860fcf3ce44SJohn Forte (void) bcopy((const void *)
4861fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
4862fcf3ce44SJohn Forte (void *)&interconnect, sizeof (interconnect));
4863fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
4864fcf3ce44SJohn Forte
4865fcf3ce44SJohn Forte if (interconnect.code == S_OK) {
4866fcf3ce44SJohn Forte (void) fprintf(stdout,
4867fcf3ce44SJohn Forte MSGSTR(29, "O.K."));
4868fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4869fcf3ce44SJohn Forte } else if (interconnect.code == S_NOT_INSTALLED) {
4870fcf3ce44SJohn Forte (void) fprintf(stdout,
4871fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
4872fcf3ce44SJohn Forte } else if (interconnect.code == S_CRITICAL) {
4873fcf3ce44SJohn Forte if (interconnect.eprom_fail != NULL) {
4874fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2140,
4875fcf3ce44SJohn Forte "Critical Failure: EEPROM failure"));
4876fcf3ce44SJohn Forte } else {
4877fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2141,
4878fcf3ce44SJohn Forte "Critical Failure: Unknown failure"));
4879fcf3ce44SJohn Forte }
4880fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4881fcf3ce44SJohn Forte } else if (interconnect.code == S_NONCRITICAL) {
4882fcf3ce44SJohn Forte if (interconnect.eprom_fail != NULL) {
4883fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2142,
4884fcf3ce44SJohn Forte "Non-Critical Failure: EEPROM failure"));
4885fcf3ce44SJohn Forte } else {
4886fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2143,
4887fcf3ce44SJohn Forte "Non-Critical Failure: Unknown failure"));
4888fcf3ce44SJohn Forte }
4889fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4890fcf3ce44SJohn Forte } else if (interconnect.code == S_NOT_AVAILABLE) {
4891fcf3ce44SJohn Forte (void) fprintf(stdout,
4892fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
4893fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4894fcf3ce44SJohn Forte } else {
4895fcf3ce44SJohn Forte (void) fprintf(stdout,
4896fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
4897fcf3ce44SJohn Forte }
4898fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4899fcf3ce44SJohn Forte }
4900fcf3ce44SJohn Forte
4901fcf3ce44SJohn Forte
4902fcf3ce44SJohn Forte }
4903fcf3ce44SJohn Forte
4904fcf3ce44SJohn Forte
4905fcf3ce44SJohn Forte
4906fcf3ce44SJohn Forte /*
4907fcf3ce44SJohn Forte * back_plane_messages() Display back_plane messages
4908fcf3ce44SJohn Forte * including the temperature's.
4909fcf3ce44SJohn Forte *
4910fcf3ce44SJohn Forte * RETURNS:
4911fcf3ce44SJohn Forte * none.
4912fcf3ce44SJohn Forte */
4913fcf3ce44SJohn Forte void
back_plane_messages(struct l_state_struct * l_state,int index,int elem_index)4914fcf3ce44SJohn Forte back_plane_messages(struct l_state_struct *l_state, int index, int elem_index)
4915fcf3ce44SJohn Forte {
4916fcf3ce44SJohn Forte Bp_elem_st bp;
4917fcf3ce44SJohn Forte int j;
4918fcf3ce44SJohn Forte char status_string[MAXPATHLEN];
4919fcf3ce44SJohn Forte
4920fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4921fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
4922fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
4923fcf3ce44SJohn Forte }
4924fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4925fcf3ce44SJohn Forte j++) {
4926fcf3ce44SJohn Forte (void) bcopy((const void *)
4927fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
4928fcf3ce44SJohn Forte (void *)&bp, sizeof (bp));
4929fcf3ce44SJohn Forte if (j == 0) {
4930fcf3ce44SJohn Forte (void) fprintf(stdout,
4931fcf3ce44SJohn Forte MSGSTR(2144, "\tFront Backplane: "));
4932fcf3ce44SJohn Forte } else {
4933fcf3ce44SJohn Forte (void) fprintf(stdout,
4934fcf3ce44SJohn Forte MSGSTR(2145, "\tRear Backplane: "));
4935fcf3ce44SJohn Forte }
4936fcf3ce44SJohn Forte
4937fcf3ce44SJohn Forte (void) l_element_msg_string(bp.code, status_string);
4938fcf3ce44SJohn Forte (void) fprintf(stdout, "%s", status_string);
4939fcf3ce44SJohn Forte
4940fcf3ce44SJohn Forte if (bp.code != S_NOT_INSTALLED) {
4941fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4942fcf3ce44SJohn Forte if ((bp.byp_a_enabled || bp.en_bypass_a) &&
4943fcf3ce44SJohn Forte !(bp.byp_b_enabled || bp.en_bypass_b)) {
4944fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
4945fcf3ce44SJohn Forte (void) fprintf(stdout,
4946fcf3ce44SJohn Forte MSGSTR(130, "Bypass A enabled"));
4947fcf3ce44SJohn Forte (void) fprintf(stdout, ")");
4948fcf3ce44SJohn Forte } else if ((bp.byp_b_enabled || bp.en_bypass_b) &&
4949fcf3ce44SJohn Forte !(bp.byp_a_enabled || bp.en_bypass_a)) {
4950fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
4951fcf3ce44SJohn Forte (void) fprintf(stdout,
4952fcf3ce44SJohn Forte MSGSTR(129, "Bypass B enabled"));
4953fcf3ce44SJohn Forte (void) fprintf(stdout, ")");
4954fcf3ce44SJohn Forte /* This case covers where a and b are bypassed */
4955fcf3ce44SJohn Forte } else if (bp.byp_b_enabled || bp.en_bypass_b) {
4956fcf3ce44SJohn Forte (void) fprintf(stdout,
4957fcf3ce44SJohn Forte MSGSTR(2146, " (Bypass's A & B enabled)"));
4958fcf3ce44SJohn Forte }
4959fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4960fcf3ce44SJohn Forte temperature_messages(l_state, j);
4961fcf3ce44SJohn Forte } else {
4962fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
4963fcf3ce44SJohn Forte }
4964fcf3ce44SJohn Forte }
4965fcf3ce44SJohn Forte }
4966fcf3ce44SJohn Forte
4967fcf3ce44SJohn Forte
4968fcf3ce44SJohn Forte /*
4969fcf3ce44SJohn Forte * dpm_SSC100_messages() Display SSC100 messages
4970fcf3ce44SJohn Forte * including the temperature's.
4971fcf3ce44SJohn Forte *
4972fcf3ce44SJohn Forte * RETURNS:
4973fcf3ce44SJohn Forte * none.
4974fcf3ce44SJohn Forte */
4975fcf3ce44SJohn Forte void
dpm_SSC100_messages(struct l_state_struct * l_state,int index,int elem_index)4976fcf3ce44SJohn Forte dpm_SSC100_messages(struct l_state_struct *l_state, int index, int elem_index)
4977fcf3ce44SJohn Forte {
4978fcf3ce44SJohn Forte Bp_elem_st bp;
4979fcf3ce44SJohn Forte int j;
4980fcf3ce44SJohn Forte char status_string[MAXPATHLEN];
4981fcf3ce44SJohn Forte
4982fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
4983fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
4984fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
4985fcf3ce44SJohn Forte }
4986fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
4987fcf3ce44SJohn Forte j++) {
4988fcf3ce44SJohn Forte (void) bcopy((const void *)
4989fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
4990fcf3ce44SJohn Forte (void *)&bp, sizeof (bp));
4991fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2246, " SSC100 #%d: "), j);
4992fcf3ce44SJohn Forte
4993fcf3ce44SJohn Forte (void) l_element_msg_string(bp.code, status_string);
4994fcf3ce44SJohn Forte (void) fprintf(stdout, "%s", status_string);
4995fcf3ce44SJohn Forte
4996fcf3ce44SJohn Forte if (bp.code != S_NOT_INSTALLED) {
4997fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
4998fcf3ce44SJohn Forte if ((bp.byp_a_enabled || bp.en_bypass_a) &&
4999fcf3ce44SJohn Forte !(bp.byp_b_enabled || bp.en_bypass_b)) {
5000fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
5001fcf3ce44SJohn Forte (void) fprintf(stdout,
5002fcf3ce44SJohn Forte MSGSTR(130, "Bypass A enabled"));
5003fcf3ce44SJohn Forte (void) fprintf(stdout, ")");
5004fcf3ce44SJohn Forte } else if ((bp.byp_b_enabled || bp.en_bypass_b) &&
5005fcf3ce44SJohn Forte !(bp.byp_a_enabled || bp.en_bypass_a)) {
5006fcf3ce44SJohn Forte (void) fprintf(stdout, " (");
5007fcf3ce44SJohn Forte (void) fprintf(stdout,
5008fcf3ce44SJohn Forte MSGSTR(129, "Bypass B enabled"));
5009fcf3ce44SJohn Forte (void) fprintf(stdout, ")");
5010fcf3ce44SJohn Forte /* This case covers where a and b are bypassed */
5011fcf3ce44SJohn Forte } else if (bp.byp_b_enabled || bp.en_bypass_b) {
5012fcf3ce44SJohn Forte (void) fprintf(stdout,
5013fcf3ce44SJohn Forte MSGSTR(2146, " (Bypass's A & B enabled)"));
5014fcf3ce44SJohn Forte }
5015fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5016fcf3ce44SJohn Forte } else {
5017fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5018fcf3ce44SJohn Forte }
5019fcf3ce44SJohn Forte }
5020fcf3ce44SJohn Forte temperature_messages(l_state, 0);
5021fcf3ce44SJohn Forte }
5022fcf3ce44SJohn Forte
5023fcf3ce44SJohn Forte
5024fcf3ce44SJohn Forte
5025fcf3ce44SJohn Forte
5026fcf3ce44SJohn Forte /*
5027fcf3ce44SJohn Forte * loop_messages() Display loop messages.
5028fcf3ce44SJohn Forte *
5029fcf3ce44SJohn Forte * RETURNS:
5030fcf3ce44SJohn Forte * none.
5031fcf3ce44SJohn Forte */
5032fcf3ce44SJohn Forte void
loop_messages(struct l_state_struct * l_state,int index,int elem_index)5033fcf3ce44SJohn Forte loop_messages(struct l_state_struct *l_state, int index, int elem_index)
5034fcf3ce44SJohn Forte {
5035fcf3ce44SJohn Forte Loop_elem_st loop;
5036fcf3ce44SJohn Forte int j;
5037fcf3ce44SJohn Forte
5038fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5039fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
5040fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
5041fcf3ce44SJohn Forte }
5042fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5043fcf3ce44SJohn Forte j++) {
5044fcf3ce44SJohn Forte (void) bcopy((const void *)
5045fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
5046fcf3ce44SJohn Forte (void *)&loop, sizeof (loop));
5047fcf3ce44SJohn Forte
5048fcf3ce44SJohn Forte (void) fprintf(stdout, "\t");
5049fcf3ce44SJohn Forte if (j == 0) {
5050fcf3ce44SJohn Forte if (loop.code == S_NOT_INSTALLED) {
5051fcf3ce44SJohn Forte (void) fprintf(stdout,
5052fcf3ce44SJohn Forte MSGSTR(2147, "Loop A is not installed"));
5053fcf3ce44SJohn Forte } else {
5054fcf3ce44SJohn Forte if (loop.split) {
5055fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2148,
5056fcf3ce44SJohn Forte "Loop A is configured as two separate loops."));
5057fcf3ce44SJohn Forte } else {
5058fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2149,
5059fcf3ce44SJohn Forte "Loop A is configured as a single loop."));
5060fcf3ce44SJohn Forte }
5061fcf3ce44SJohn Forte }
5062fcf3ce44SJohn Forte } else {
5063fcf3ce44SJohn Forte if (loop.code == S_NOT_INSTALLED) {
5064fcf3ce44SJohn Forte (void) fprintf(stdout,
5065fcf3ce44SJohn Forte MSGSTR(2150, "Loop B is not installed"));
5066fcf3ce44SJohn Forte } else {
5067fcf3ce44SJohn Forte if (loop.split) {
5068fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2151,
5069fcf3ce44SJohn Forte "Loop B is configured as two separate loops."));
5070fcf3ce44SJohn Forte } else {
5071fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2152,
5072fcf3ce44SJohn Forte "Loop B is configured as a single loop."));
5073fcf3ce44SJohn Forte }
5074fcf3ce44SJohn Forte }
5075fcf3ce44SJohn Forte }
5076fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5077fcf3ce44SJohn Forte }
5078fcf3ce44SJohn Forte }
5079fcf3ce44SJohn Forte
5080fcf3ce44SJohn Forte
5081fcf3ce44SJohn Forte
5082fcf3ce44SJohn Forte /*
5083fcf3ce44SJohn Forte * ctlr_messages() Display ESI Controller status.
5084fcf3ce44SJohn Forte *
5085fcf3ce44SJohn Forte * RETURNS:
5086fcf3ce44SJohn Forte * none.
5087fcf3ce44SJohn Forte */
5088fcf3ce44SJohn Forte void
ctlr_messages(struct l_state_struct * l_state,int index,int elem_index)5089fcf3ce44SJohn Forte ctlr_messages(struct l_state_struct *l_state, int index, int elem_index)
5090fcf3ce44SJohn Forte {
5091fcf3ce44SJohn Forte Ctlr_elem_st ctlr;
5092fcf3ce44SJohn Forte int j;
5093fcf3ce44SJohn Forte int ib_a_flag = 1;
5094fcf3ce44SJohn Forte
5095fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5096fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
5097fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
5098fcf3ce44SJohn Forte }
5099fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5100fcf3ce44SJohn Forte j++) {
5101fcf3ce44SJohn Forte (void) bcopy((const void *)
5102fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
5103fcf3ce44SJohn Forte (void *)&ctlr, sizeof (ctlr));
5104fcf3ce44SJohn Forte if (j == 0) {
5105fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2153, "\tA: "));
5106fcf3ce44SJohn Forte } else {
5107fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2154, "\tB: "));
5108fcf3ce44SJohn Forte ib_a_flag = 0;
5109fcf3ce44SJohn Forte }
5110fcf3ce44SJohn Forte if (ctlr.code == S_OK) {
5111fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(29, "O.K."));
5112fcf3ce44SJohn Forte /* If any byte 3 bits set display */
5113fcf3ce44SJohn Forte ib_decode(&ctlr);
5114fcf3ce44SJohn Forte /* Display Version message */
5115fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5116fcf3ce44SJohn Forte /*
5117fcf3ce44SJohn Forte * Display the tranciver module state for this
5118fcf3ce44SJohn Forte * IB.
5119fcf3ce44SJohn Forte */
5120fcf3ce44SJohn Forte trans_messages(l_state, ib_a_flag);
5121fcf3ce44SJohn Forte } else if (ctlr.code == S_CRITICAL) {
5122fcf3ce44SJohn Forte (void) fprintf(stdout,
5123fcf3ce44SJohn Forte MSGSTR(122, "Critical failure"));
5124fcf3ce44SJohn Forte ib_decode(&ctlr);
5125fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5126fcf3ce44SJohn Forte } else if (ctlr.code == S_NONCRITICAL) {
5127fcf3ce44SJohn Forte (void) fprintf(stdout,
5128fcf3ce44SJohn Forte MSGSTR(89, "Non-Critical Failure"));
5129fcf3ce44SJohn Forte ib_decode(&ctlr);
5130fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5131fcf3ce44SJohn Forte } else if (ctlr.code == S_NOT_INSTALLED) {
5132fcf3ce44SJohn Forte (void) fprintf(stdout,
5133fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
5134fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5135fcf3ce44SJohn Forte } else if (ctlr.code == S_NOT_AVAILABLE) {
5136fcf3ce44SJohn Forte (void) fprintf(stdout,
5137fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
5138fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5139fcf3ce44SJohn Forte } else {
5140fcf3ce44SJohn Forte (void) fprintf(stdout,
5141fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
5142fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5143fcf3ce44SJohn Forte }
5144fcf3ce44SJohn Forte }
5145fcf3ce44SJohn Forte }
5146fcf3ce44SJohn Forte
5147fcf3ce44SJohn Forte
5148fcf3ce44SJohn Forte
5149fcf3ce44SJohn Forte /*
5150fcf3ce44SJohn Forte * fan_decode() Display Fans bytes 1-3 state.
5151fcf3ce44SJohn Forte *
5152fcf3ce44SJohn Forte * RETURNS:
5153fcf3ce44SJohn Forte * none.
5154fcf3ce44SJohn Forte */
5155fcf3ce44SJohn Forte void
fan_decode(Fan_elem_st * fan)5156fcf3ce44SJohn Forte fan_decode(Fan_elem_st *fan)
5157fcf3ce44SJohn Forte {
5158fcf3ce44SJohn Forte if (fan->fail) {
5159fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2155,
5160fcf3ce44SJohn Forte ":Yellow LED is on"));
5161fcf3ce44SJohn Forte }
5162fcf3ce44SJohn Forte if (fan->speed == 0) {
5163fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2156,
5164fcf3ce44SJohn Forte ":Fan stopped"));
5165fcf3ce44SJohn Forte } else if (fan->speed < S_HI_SPEED) {
5166fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2157,
5167fcf3ce44SJohn Forte ":Fan speed Low"));
5168fcf3ce44SJohn Forte } else {
5169fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2158,
5170fcf3ce44SJohn Forte ":Fan speed Hi"));
5171fcf3ce44SJohn Forte }
5172fcf3ce44SJohn Forte }
5173fcf3ce44SJohn Forte
5174fcf3ce44SJohn Forte /*
5175fcf3ce44SJohn Forte * fan_messages() Display Fan status.
5176fcf3ce44SJohn Forte *
5177fcf3ce44SJohn Forte * RETURNS:
5178fcf3ce44SJohn Forte * none.
5179fcf3ce44SJohn Forte */
5180fcf3ce44SJohn Forte void
fan_messages(struct l_state_struct * l_state,int hdr_index,int elem_index)5181fcf3ce44SJohn Forte fan_messages(struct l_state_struct *l_state, int hdr_index, int elem_index)
5182fcf3ce44SJohn Forte {
5183fcf3ce44SJohn Forte Fan_elem_st fan;
5184fcf3ce44SJohn Forte int j;
5185fcf3ce44SJohn Forte
5186fcf3ce44SJohn Forte /* Get and print messages */
5187fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[hdr_index].text_len != 0) {
5188fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
5189fcf3ce44SJohn Forte l_state->ib_tbl.config.text[hdr_index]);
5190fcf3ce44SJohn Forte }
5191fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[hdr_index].num;
5192fcf3ce44SJohn Forte j++) {
5193fcf3ce44SJohn Forte (void) bcopy((const void *)
5194fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
5195fcf3ce44SJohn Forte (void *)&fan, sizeof (fan));
5196fcf3ce44SJohn Forte (void) fprintf(stdout, "\t%d ", j);
5197fcf3ce44SJohn Forte if (fan.code == S_OK) {
5198fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(29, "O.K."));
5199fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5200fcf3ce44SJohn Forte } else if (fan.code == S_CRITICAL) {
5201fcf3ce44SJohn Forte (void) fprintf(stdout,
5202fcf3ce44SJohn Forte MSGSTR(122, "Critical failure"));
5203fcf3ce44SJohn Forte fan_decode(&fan);
5204fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5205fcf3ce44SJohn Forte } else if (fan.code == S_NONCRITICAL) {
5206fcf3ce44SJohn Forte (void) fprintf(stdout,
5207fcf3ce44SJohn Forte MSGSTR(89, "Non-Critical Failure"));
5208fcf3ce44SJohn Forte fan_decode(&fan);
5209fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5210fcf3ce44SJohn Forte } else if (fan.code == S_NOT_INSTALLED) {
5211fcf3ce44SJohn Forte (void) fprintf(stdout,
5212fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
5213fcf3ce44SJohn Forte } else if (fan.code == S_NOT_AVAILABLE) {
5214fcf3ce44SJohn Forte (void) fprintf(stdout,
5215fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
5216fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5217fcf3ce44SJohn Forte } else {
5218fcf3ce44SJohn Forte (void) fprintf(stdout,
5219fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
5220fcf3ce44SJohn Forte }
5221fcf3ce44SJohn Forte }
5222fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5223fcf3ce44SJohn Forte }
5224fcf3ce44SJohn Forte
5225fcf3ce44SJohn Forte
5226fcf3ce44SJohn Forte
5227fcf3ce44SJohn Forte /*
5228fcf3ce44SJohn Forte * ps_decode() Display Power Supply bytes 1-3 state.
5229fcf3ce44SJohn Forte *
5230fcf3ce44SJohn Forte * RETURNS:
5231fcf3ce44SJohn Forte * none.
5232fcf3ce44SJohn Forte */
5233fcf3ce44SJohn Forte void
ps_decode(Ps_elem_st * ps)5234fcf3ce44SJohn Forte ps_decode(Ps_elem_st *ps)
5235fcf3ce44SJohn Forte {
5236fcf3ce44SJohn Forte if (ps->dc_over) {
5237fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2159,
5238fcf3ce44SJohn Forte ": DC Voltage too high"));
5239fcf3ce44SJohn Forte }
5240fcf3ce44SJohn Forte if (ps->dc_under) {
5241fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2160,
5242fcf3ce44SJohn Forte ": DC Voltage too low"));
5243fcf3ce44SJohn Forte }
5244fcf3ce44SJohn Forte if (ps->dc_over_i) {
5245fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2161,
5246fcf3ce44SJohn Forte ": DC Current too high"));
5247fcf3ce44SJohn Forte }
5248fcf3ce44SJohn Forte if (ps->ovrtmp_fail || ps->temp_warn) {
5249fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2162,
5250fcf3ce44SJohn Forte ": Temperature too high"));
5251fcf3ce44SJohn Forte }
5252fcf3ce44SJohn Forte if (ps->ac_fail) {
5253fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2163,
5254fcf3ce44SJohn Forte ": AC Failed"));
5255fcf3ce44SJohn Forte }
5256fcf3ce44SJohn Forte if (ps->dc_fail) {
5257fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2164,
5258fcf3ce44SJohn Forte ": DC Failed"));
5259fcf3ce44SJohn Forte }
5260fcf3ce44SJohn Forte }
5261fcf3ce44SJohn Forte
5262fcf3ce44SJohn Forte
5263fcf3ce44SJohn Forte
5264fcf3ce44SJohn Forte /*
5265fcf3ce44SJohn Forte * revision_msg() Print the revision message from page 7.
5266fcf3ce44SJohn Forte *
5267fcf3ce44SJohn Forte * RETURNS:
5268fcf3ce44SJohn Forte * none.
5269fcf3ce44SJohn Forte */
5270fcf3ce44SJohn Forte void
revision_msg(struct l_state_struct * l_state,int index)5271fcf3ce44SJohn Forte revision_msg(struct l_state_struct *l_state, int index)
5272fcf3ce44SJohn Forte {
5273fcf3ce44SJohn Forte if (strlen((const char *)
5274fcf3ce44SJohn Forte l_state->ib_tbl.p7_s.element_desc[index].desc_string)) {
5275fcf3ce44SJohn Forte (void) fprintf(stdout, "(%s)",
5276fcf3ce44SJohn Forte l_state->ib_tbl.p7_s.element_desc[index].desc_string);
5277fcf3ce44SJohn Forte }
5278fcf3ce44SJohn Forte }
5279fcf3ce44SJohn Forte
5280fcf3ce44SJohn Forte
5281fcf3ce44SJohn Forte
5282fcf3ce44SJohn Forte /*
5283fcf3ce44SJohn Forte * ps_messages() Display Power Supply status.
5284fcf3ce44SJohn Forte *
5285fcf3ce44SJohn Forte * RETURNS:
5286fcf3ce44SJohn Forte * none.
5287fcf3ce44SJohn Forte */
5288fcf3ce44SJohn Forte void
ps_messages(struct l_state_struct * l_state,int index,int elem_index)5289fcf3ce44SJohn Forte ps_messages(struct l_state_struct *l_state, int index, int elem_index)
5290fcf3ce44SJohn Forte {
5291fcf3ce44SJohn Forte Ps_elem_st ps;
5292fcf3ce44SJohn Forte int j;
5293fcf3ce44SJohn Forte
5294fcf3ce44SJohn Forte /* Get and print Power Supply messages */
5295fcf3ce44SJohn Forte
5296fcf3ce44SJohn Forte if (l_state->ib_tbl.config.type_hdr[index].text_len != 0) {
5297fcf3ce44SJohn Forte (void) fprintf(stdout, "%s\n",
5298fcf3ce44SJohn Forte l_state->ib_tbl.config.text[index]);
5299fcf3ce44SJohn Forte }
5300fcf3ce44SJohn Forte
5301fcf3ce44SJohn Forte for (j = 0; j < (int)l_state->ib_tbl.config.type_hdr[index].num;
5302fcf3ce44SJohn Forte j++) {
5303fcf3ce44SJohn Forte (void) bcopy((const void *)
5304fcf3ce44SJohn Forte &l_state->ib_tbl.p2_s.element[elem_index + j],
5305fcf3ce44SJohn Forte (void *)&ps, sizeof (ps));
5306fcf3ce44SJohn Forte (void) fprintf(stdout, "\t%d ", j);
5307fcf3ce44SJohn Forte if (ps.code == S_OK) {
5308fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(29, "O.K."));
5309fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5310fcf3ce44SJohn Forte } else if (ps.code == S_CRITICAL) {
5311fcf3ce44SJohn Forte (void) fprintf(stdout,
5312fcf3ce44SJohn Forte MSGSTR(122, "Critical failure"));
5313fcf3ce44SJohn Forte ps_decode(&ps);
5314fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5315fcf3ce44SJohn Forte } else if (ps.code == S_NONCRITICAL) {
5316fcf3ce44SJohn Forte (void) fprintf(stdout,
5317fcf3ce44SJohn Forte MSGSTR(89, "Non-Critical Failure"));
5318fcf3ce44SJohn Forte ps_decode(&ps);
5319fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5320fcf3ce44SJohn Forte } else if (ps.code == S_NOT_INSTALLED) {
5321fcf3ce44SJohn Forte (void) fprintf(stdout,
5322fcf3ce44SJohn Forte MSGSTR(30, "Not Installed"));
5323fcf3ce44SJohn Forte } else if (ps.code == S_NOT_AVAILABLE) {
5324fcf3ce44SJohn Forte (void) fprintf(stdout,
5325fcf3ce44SJohn Forte MSGSTR(34, "Disabled"));
5326fcf3ce44SJohn Forte revision_msg(l_state, elem_index + j);
5327fcf3ce44SJohn Forte } else {
5328fcf3ce44SJohn Forte (void) fprintf(stdout,
5329fcf3ce44SJohn Forte MSGSTR(4, "Unknown status"));
5330fcf3ce44SJohn Forte }
5331fcf3ce44SJohn Forte
5332fcf3ce44SJohn Forte }
5333fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5334fcf3ce44SJohn Forte }
5335fcf3ce44SJohn Forte
5336fcf3ce44SJohn Forte
5337fcf3ce44SJohn Forte
5338fcf3ce44SJohn Forte /*
5339fcf3ce44SJohn Forte * abnormal_condition() Display any abnormal condition messages.
5340fcf3ce44SJohn Forte *
5341fcf3ce44SJohn Forte * RETURNS:
5342fcf3ce44SJohn Forte * none.
5343fcf3ce44SJohn Forte */
5344fcf3ce44SJohn Forte void
abnormal_condition_display(struct l_state_struct * l_state)5345fcf3ce44SJohn Forte abnormal_condition_display(struct l_state_struct *l_state)
5346fcf3ce44SJohn Forte {
5347fcf3ce44SJohn Forte
5348fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5349fcf3ce44SJohn Forte if (l_state->ib_tbl.p2_s.ui.crit) {
5350fcf3ce44SJohn Forte (void) fprintf(stdout,
5351fcf3ce44SJohn Forte MSGSTR(2165, " "
5352fcf3ce44SJohn Forte "CRITICAL CONDITION DETECTED\n"));
5353fcf3ce44SJohn Forte }
5354fcf3ce44SJohn Forte if (l_state->ib_tbl.p2_s.ui.non_crit) {
5355fcf3ce44SJohn Forte (void) fprintf(stdout,
5356fcf3ce44SJohn Forte MSGSTR(2166, " "
5357fcf3ce44SJohn Forte "WARNING: NON-CRITICAL CONDITION DETECTED\n"));
5358fcf3ce44SJohn Forte }
5359fcf3ce44SJohn Forte if (l_state->ib_tbl.p2_s.ui.invop) {
5360fcf3ce44SJohn Forte (void) fprintf(stdout,
5361fcf3ce44SJohn Forte MSGSTR(2167, " "
5362fcf3ce44SJohn Forte "WARNING: Invalid Operation bit set.\n"
5363fcf3ce44SJohn Forte "\tThis means an Enclosure Control page"
5364fcf3ce44SJohn Forte " or an Array Control page with an invalid\n"
5365fcf3ce44SJohn Forte "\tformat has previously been transmitted to the"
5366fcf3ce44SJohn Forte " Enclosure Services card by a\n\tSend Diagnostic"
5367fcf3ce44SJohn Forte " SCSI command.\n"));
5368fcf3ce44SJohn Forte }
5369fcf3ce44SJohn Forte (void) fprintf(stdout, "\n");
5370fcf3ce44SJohn Forte }
5371fcf3ce44SJohn Forte
5372fcf3ce44SJohn Forte
5373fcf3ce44SJohn Forte
5374fcf3ce44SJohn Forte
5375fcf3ce44SJohn Forte
5376fcf3ce44SJohn Forte /*
5377fcf3ce44SJohn Forte * adm_start() Spin up the given list
5378fcf3ce44SJohn Forte * of SENA devices.
5379fcf3ce44SJohn Forte *
5380fcf3ce44SJohn Forte * RETURNS:
5381fcf3ce44SJohn Forte * none.
5382fcf3ce44SJohn Forte */
5383fcf3ce44SJohn Forte int
adm_start(char ** argv)5384fcf3ce44SJohn Forte adm_start(char **argv)
5385fcf3ce44SJohn Forte {
5386fcf3ce44SJohn Forte char *path_phys = NULL;
5387fcf3ce44SJohn Forte Path_struct *path_struct;
5388fcf3ce44SJohn Forte int err = 0, retval = 0;
5389fcf3ce44SJohn Forte
5390fcf3ce44SJohn Forte while (*argv != NULL) {
5391fcf3ce44SJohn Forte if ((err = l_convert_name(*argv, &path_phys,
5392fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
5393fcf3ce44SJohn Forte (void) fprintf(stderr, MSGSTR(33,
5394fcf3ce44SJohn Forte " Error: converting"
5395fcf3ce44SJohn Forte " %s to physical path.\n"
5396fcf3ce44SJohn Forte " Invalid pathname.\n"),
5397fcf3ce44SJohn Forte *argv);
5398fcf3ce44SJohn Forte if (err != -1) {
5399fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5400fcf3ce44SJohn Forte }
5401fcf3ce44SJohn Forte (argv)++;
5402fcf3ce44SJohn Forte retval++;
5403fcf3ce44SJohn Forte continue;
5404fcf3ce44SJohn Forte }
5405fcf3ce44SJohn Forte VERBPRINT(MSGSTR(101, "Issuing start to:\n %s\n"), *argv);
5406fcf3ce44SJohn Forte if (err = g_start(path_phys)) {
5407fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5408fcf3ce44SJohn Forte (argv)++;
5409fcf3ce44SJohn Forte retval++;
5410fcf3ce44SJohn Forte continue;
5411fcf3ce44SJohn Forte }
5412fcf3ce44SJohn Forte (argv)++;
5413fcf3ce44SJohn Forte }
5414fcf3ce44SJohn Forte return (retval);
5415fcf3ce44SJohn Forte }
5416fcf3ce44SJohn Forte
5417fcf3ce44SJohn Forte
5418fcf3ce44SJohn Forte
5419fcf3ce44SJohn Forte /*
5420fcf3ce44SJohn Forte * adm_stop() Spin down a
5421fcf3ce44SJohn Forte * given list of SENA devices.
5422fcf3ce44SJohn Forte *
5423fcf3ce44SJohn Forte * RETURNS:
5424fcf3ce44SJohn Forte * none.
5425fcf3ce44SJohn Forte */
5426fcf3ce44SJohn Forte int
adm_stop(char ** argv)5427fcf3ce44SJohn Forte adm_stop(char **argv)
5428fcf3ce44SJohn Forte {
5429fcf3ce44SJohn Forte char *path_phys = NULL;
5430fcf3ce44SJohn Forte Path_struct *path_struct;
5431fcf3ce44SJohn Forte int err = 0, retval = 0;
5432fcf3ce44SJohn Forte
5433fcf3ce44SJohn Forte while (*argv != NULL) {
5434fcf3ce44SJohn Forte if ((err = l_convert_name(*argv, &path_phys,
5435fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
5436fcf3ce44SJohn Forte (void) fprintf(stderr,
5437fcf3ce44SJohn Forte MSGSTR(33,
5438fcf3ce44SJohn Forte " Error: converting"
5439fcf3ce44SJohn Forte " %s to physical path.\n"
5440fcf3ce44SJohn Forte " Invalid pathname.\n"),
5441fcf3ce44SJohn Forte *argv);
5442fcf3ce44SJohn Forte if (err != -1) {
5443fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5444fcf3ce44SJohn Forte }
5445fcf3ce44SJohn Forte (argv)++;
5446fcf3ce44SJohn Forte retval++;
5447fcf3ce44SJohn Forte continue;
5448fcf3ce44SJohn Forte }
5449fcf3ce44SJohn Forte
5450fcf3ce44SJohn Forte /*
5451fcf3ce44SJohn Forte * scsi stop is not supported for tape drives.
5452fcf3ce44SJohn Forte * The scsi unload op code for tape is the same as a
5453fcf3ce44SJohn Forte * scsi stop for disk so this command will eject the tape.
5454fcf3ce44SJohn Forte * If an eject is the desired behavior then remove the
5455fcf3ce44SJohn Forte * following if block. ('mt offline' will give you
5456fcf3ce44SJohn Forte * the same eject functionality).
5457fcf3ce44SJohn Forte */
5458fcf3ce44SJohn Forte if (strstr(path_phys, SLSH_DRV_NAME_ST)) {
5459fcf3ce44SJohn Forte errno = ENOTSUP;
5460fcf3ce44SJohn Forte (void) print_errString(0, path_phys);
5461fcf3ce44SJohn Forte (argv)++;
5462fcf3ce44SJohn Forte continue;
5463fcf3ce44SJohn Forte }
5464fcf3ce44SJohn Forte
5465fcf3ce44SJohn Forte VERBPRINT(MSGSTR(100, "Issuing stop to:\n %s\n"), *argv);
5466fcf3ce44SJohn Forte if (err = g_stop(path_phys, 1)) {
5467fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5468fcf3ce44SJohn Forte (argv)++;
5469fcf3ce44SJohn Forte retval++;
5470fcf3ce44SJohn Forte continue;
5471fcf3ce44SJohn Forte }
5472fcf3ce44SJohn Forte (argv)++;
5473fcf3ce44SJohn Forte }
5474fcf3ce44SJohn Forte return (retval);
5475fcf3ce44SJohn Forte }
5476fcf3ce44SJohn Forte
5477fcf3ce44SJohn Forte
5478fcf3ce44SJohn Forte /*
5479fcf3ce44SJohn Forte * On a SOC+ chip, the port is either put into (offline) or pulled out
5480fcf3ce44SJohn Forte * of (online) a loopback mode since the laser cannot be turned on or off.
5481fcf3ce44SJohn Forte * As of this writing, this feature is yet to be supported by the ifp
5482fcf3ce44SJohn Forte * driver on a QLogic card.
5483fcf3ce44SJohn Forte *
5484fcf3ce44SJohn Forte * INPUT :
5485fcf3ce44SJohn Forte * Command line args and flag - LUX_P_ONLINE or LUX_P_OFFLINE
5486fcf3ce44SJohn Forte * The path that is passed has to be the physical path to the port.
5487fcf3ce44SJohn Forte * For example :
5488fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,socal@2,0:0
5489fcf3ce44SJohn Forte * /devices/io-unit@f,e0200000/sbi@0,0/SUNW,socal@2,0:0
5490fcf3ce44SJohn Forte * /devices/pci@1f,4000/SUNW,ifp@2:devctl
5491fcf3ce44SJohn Forte * RETURNS :
5492fcf3ce44SJohn Forte * Nothing
5493fcf3ce44SJohn Forte */
5494fcf3ce44SJohn Forte int
adm_port_offline_online(char * argv[],int flag)5495fcf3ce44SJohn Forte adm_port_offline_online(char *argv[], int flag)
5496fcf3ce44SJohn Forte {
5497fcf3ce44SJohn Forte int err, retval = 0;
5498fcf3ce44SJohn Forte char *path_phys = NULL;
5499fcf3ce44SJohn Forte char *nexus_path_ptr = NULL;
5500fcf3ce44SJohn Forte Path_struct *path_struct = NULL;
5501fcf3ce44SJohn Forte
5502fcf3ce44SJohn Forte while (*argv != NULL) {
5503fcf3ce44SJohn Forte if ((err = l_convert_name(*argv, &path_phys,
5504fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
5505fcf3ce44SJohn Forte (void) fprintf(stderr,
5506fcf3ce44SJohn Forte MSGSTR(33,
5507fcf3ce44SJohn Forte " Error: converting"
5508fcf3ce44SJohn Forte " %s to physical path.\n"
5509fcf3ce44SJohn Forte " Invalid pathname.\n"),
5510fcf3ce44SJohn Forte *argv);
5511fcf3ce44SJohn Forte if (err != -1) {
5512fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5513fcf3ce44SJohn Forte }
5514fcf3ce44SJohn Forte argv++;
5515fcf3ce44SJohn Forte retval++;
5516fcf3ce44SJohn Forte continue;
5517fcf3ce44SJohn Forte }
5518fcf3ce44SJohn Forte
5519fcf3ce44SJohn Forte /* Get the nexus path - need this to print messages */
5520fcf3ce44SJohn Forte if ((err = g_get_nexus_path(path_phys, &nexus_path_ptr)) != 0) {
5521fcf3ce44SJohn Forte (void) print_errString(err, *argv);
5522fcf3ce44SJohn Forte retval++;
5523fcf3ce44SJohn Forte goto cleanup_and_go;
5524fcf3ce44SJohn Forte }
5525fcf3ce44SJohn Forte
5526fcf3ce44SJohn Forte if (flag == LUX_P_OFFLINE) {
5527fcf3ce44SJohn Forte if ((err = g_port_offline(nexus_path_ptr))) {
5528fcf3ce44SJohn Forte (void) print_errString(err, nexus_path_ptr);
5529fcf3ce44SJohn Forte retval++;
5530fcf3ce44SJohn Forte goto cleanup_and_go;
5531fcf3ce44SJohn Forte }
5532fcf3ce44SJohn Forte fprintf(stdout,
5533fcf3ce44SJohn Forte MSGSTR(2223, "Port %s has been disabled\n"),
5534fcf3ce44SJohn Forte nexus_path_ptr);
5535fcf3ce44SJohn Forte } else if (flag == LUX_P_ONLINE) {
5536fcf3ce44SJohn Forte if ((err = g_port_online(nexus_path_ptr))) {
5537fcf3ce44SJohn Forte (void) print_errString(err, nexus_path_ptr);
5538fcf3ce44SJohn Forte retval++;
5539fcf3ce44SJohn Forte goto cleanup_and_go;
5540fcf3ce44SJohn Forte }
5541fcf3ce44SJohn Forte fprintf(stdout,
5542fcf3ce44SJohn Forte MSGSTR(2224, "Port %s has been enabled\n"),
5543fcf3ce44SJohn Forte nexus_path_ptr);
5544fcf3ce44SJohn Forte } else {
5545fcf3ce44SJohn Forte (void) fprintf(stderr,
5546fcf3ce44SJohn Forte MSGSTR(2225,
5547fcf3ce44SJohn Forte "Unknown action requested "
5548fcf3ce44SJohn Forte "on port - %d\nIgnoring."),
5549fcf3ce44SJohn Forte flag);
5550fcf3ce44SJohn Forte retval++;
5551fcf3ce44SJohn Forte }
5552fcf3ce44SJohn Forte cleanup_and_go:
5553fcf3ce44SJohn Forte free(path_phys);
5554fcf3ce44SJohn Forte free(path_struct);
5555fcf3ce44SJohn Forte free(nexus_path_ptr);
5556fcf3ce44SJohn Forte argv++;
5557fcf3ce44SJohn Forte }
5558fcf3ce44SJohn Forte return (retval);
5559fcf3ce44SJohn Forte }
5560fcf3ce44SJohn Forte
5561fcf3ce44SJohn Forte /*
5562fcf3ce44SJohn Forte * Expert level subcommand 'luxadm -e port'
5563fcf3ce44SJohn Forte * which displays all FC ports on a host and state information for
5564fcf3ce44SJohn Forte * connectivity (CONNECTED or NOT CONNECTED) indicating whether there
5565fcf3ce44SJohn Forte * are devices attached to the port.
5566fcf3ce44SJohn Forte *
5567fcf3ce44SJohn Forte * Sample output for ifp:
5568fcf3ce44SJohn Forte *
5569fcf3ce44SJohn Forte * /devices/pci@1f,4000/SUNW,ifp@2:devctl CONNECTED
5570fcf3ce44SJohn Forte * /devices/pci@1f,2000/SUNW,ifp@1:devctl NOT CONNECTED
5571fcf3ce44SJohn Forte *
5572fcf3ce44SJohn Forte * Sample output for socal:
5573fcf3ce44SJohn Forte *
5574fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,socal@d,10000:0 CONNECTED
5575fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,socal@d,10000:1 NOT CONNECTED
5576fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,socal@2,0:0 NOT CONNECTED
5577fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,socal@2,0:1 CONNECTED
5578fcf3ce44SJohn Forte *
5579fcf3ce44SJohn Forte * Note: for socal the path returned is not a devctl path as there is no
5580fcf3ce44SJohn Forte * devctl path for socal.
5581fcf3ce44SJohn Forte *
5582fcf3ce44SJohn Forte * Sample output for fp:
5583fcf3ce44SJohn Forte *
5584fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,qlc@5/fp@0,0:devctl CONNECTED
5585fcf3ce44SJohn Forte * /devices/sbus@2,0/SUNW,qlc@4/fp@1,0:devctl CONNECTED
5586fcf3ce44SJohn Forte */
5587fcf3ce44SJohn Forte int
adm_display_port(int verbose)5588fcf3ce44SJohn Forte adm_display_port(int verbose)
5589fcf3ce44SJohn Forte {
5590fcf3ce44SJohn Forte /*
5591fcf3ce44SJohn Forte * If another port driver needs to be searched, add it here
5592fcf3ce44SJohn Forte */
5593fcf3ce44SJohn Forte static char *portdrvr_list[] = {"socal",
5594fcf3ce44SJohn Forte "fp",
5595fcf3ce44SJohn Forte "ifp",
5596fcf3ce44SJohn Forte NULL};
5597fcf3ce44SJohn Forte portlist_t portlist;
5598fcf3ce44SJohn Forte int x = 0, err = 0, retval = 0;
5599fcf3ce44SJohn Forte int port_state;
5600fcf3ce44SJohn Forte
5601fcf3ce44SJohn Forte portlist.hbacnt = 0;
5602fcf3ce44SJohn Forte
5603fcf3ce44SJohn Forte /*
5604fcf3ce44SJohn Forte * Look for all HBA ports as listed in portdrvr_list[]
5605fcf3ce44SJohn Forte */
5606fcf3ce44SJohn Forte while (portdrvr_list[x]) {
5607fcf3ce44SJohn Forte if (err = g_get_port_path(portdrvr_list[x], &portlist)) {
5608fcf3ce44SJohn Forte if (err != L_PORT_DRIVER_NOT_FOUND &&
5609fcf3ce44SJohn Forte err != L_PHYS_PATH_NOT_FOUND) {
5610fcf3ce44SJohn Forte (void) print_errString(err, portdrvr_list[x]);
5611fcf3ce44SJohn Forte retval++;
5612fcf3ce44SJohn Forte }
5613fcf3ce44SJohn Forte }
5614fcf3ce44SJohn Forte x++;
5615fcf3ce44SJohn Forte }
5616fcf3ce44SJohn Forte
5617fcf3ce44SJohn Forte
5618fcf3ce44SJohn Forte /*
5619fcf3ce44SJohn Forte * For each port path found get the connection state.
5620fcf3ce44SJohn Forte * If there are devices attached the state is considered connected.
5621fcf3ce44SJohn Forte */
5622fcf3ce44SJohn Forte for (x = 0; x < portlist.hbacnt; x++) {
5623fcf3ce44SJohn Forte if (err = g_get_port_state(portlist.physpath[x],
5624fcf3ce44SJohn Forte &port_state, verbose)) {
5625fcf3ce44SJohn Forte (void) print_errString(err, portlist.physpath[x]);
5626fcf3ce44SJohn Forte retval++;
5627fcf3ce44SJohn Forte } else {
5628fcf3ce44SJohn Forte fprintf(stdout, "%-65s ", portlist.physpath[x]);
5629fcf3ce44SJohn Forte if (port_state == PORT_CONNECTED) {
5630fcf3ce44SJohn Forte (void) fprintf(stdout,
5631fcf3ce44SJohn Forte MSGSTR(2233,
5632fcf3ce44SJohn Forte "CONNECTED\n"));
5633fcf3ce44SJohn Forte } else {
5634fcf3ce44SJohn Forte (void) fprintf(stdout,
5635fcf3ce44SJohn Forte MSGSTR(2234,
5636fcf3ce44SJohn Forte "NOT CONNECTED\n"));
5637fcf3ce44SJohn Forte }
5638fcf3ce44SJohn Forte }
5639fcf3ce44SJohn Forte }
5640fcf3ce44SJohn Forte g_free_portlist(&portlist);
5641fcf3ce44SJohn Forte return (retval);
5642fcf3ce44SJohn Forte }
5643fcf3ce44SJohn Forte
5644fcf3ce44SJohn Forte /*
5645fcf3ce44SJohn Forte * Expert level subcommand 'luxadm -e external_loopback <portpath>
5646fcf3ce44SJohn Forte * internal_loopback
5647fcf3ce44SJohn Forte * no_loopback
5648fcf3ce44SJohn Forte * Does just what you would think. Sets port in designated loopback
5649fcf3ce44SJohn Forte * mode.
5650fcf3ce44SJohn Forte * INPUT: portpath - path to device on which to set loopback mode
5651fcf3ce44SJohn Forte * flag - loopback mode to set. Values are:
5652fcf3ce44SJohn Forte * EXT_LOOPBACK
5653fcf3ce44SJohn Forte * INT_LOOPBACK
5654fcf3ce44SJohn Forte * NO_LOOPBACK
5655fcf3ce44SJohn Forte *
5656fcf3ce44SJohn Forte * RETURN: 0 on success
5657fcf3ce44SJohn Forte * non-zero on failure
5658fcf3ce44SJohn Forte */
5659fcf3ce44SJohn Forte int
adm_port_loopback(char * portpath,int flag)5660fcf3ce44SJohn Forte adm_port_loopback(char *portpath, int flag)
5661fcf3ce44SJohn Forte {
5662fcf3ce44SJohn Forte int err;
5663fcf3ce44SJohn Forte char *path_phys = NULL;
5664fcf3ce44SJohn Forte Path_struct *path_struct = NULL;
5665fcf3ce44SJohn Forte int cmd;
5666fcf3ce44SJohn Forte
5667fcf3ce44SJohn Forte if ((err = l_convert_name(portpath, &path_phys,
5668fcf3ce44SJohn Forte &path_struct, Options & PVERBOSE)) != 0) {
5669fcf3ce44SJohn Forte (void) fprintf(stderr,
5670fcf3ce44SJohn Forte MSGSTR(33,
5671fcf3ce44SJohn Forte " Error: converting"
5672fcf3ce44SJohn Forte " %s to physical path.\n"
5673fcf3ce44SJohn Forte " Invalid pathname.\n"),
5674fcf3ce44SJohn Forte portpath);
5675fcf3ce44SJohn Forte if (err != -1) {
5676fcf3ce44SJohn Forte (void) print_errString(err, portpath);
5677fcf3ce44SJohn Forte }
5678fcf3ce44SJohn Forte return (-1);
5679fcf3ce44SJohn Forte }
5680fcf3ce44SJohn Forte
5681fcf3ce44SJohn Forte switch (flag) {
5682fcf3ce44SJohn Forte case EXT_LOOPBACK:
5683fcf3ce44SJohn Forte cmd = EXT_LPBACK;
5684fcf3ce44SJohn Forte break;
5685fcf3ce44SJohn Forte case INT_LOOPBACK:
5686fcf3ce44SJohn Forte cmd = INT_LPBACK;
5687fcf3ce44SJohn Forte break;
5688fcf3ce44SJohn Forte case NO_LOOPBACK:
5689fcf3ce44SJohn Forte cmd = NO_LPBACK;
5690fcf3ce44SJohn Forte break;
5691fcf3ce44SJohn Forte default:
5692fcf3ce44SJohn Forte (void) fprintf(stderr,
5693fcf3ce44SJohn Forte MSGSTR(2225,
5694fcf3ce44SJohn Forte "Unknown action requested "
5695fcf3ce44SJohn Forte "on port - %d\nIgnoring."),
5696fcf3ce44SJohn Forte flag);
5697fcf3ce44SJohn Forte free(path_phys);
5698fcf3ce44SJohn Forte free(path_struct);
5699fcf3ce44SJohn Forte return (-1);
5700fcf3ce44SJohn Forte }
5701fcf3ce44SJohn Forte
5702fcf3ce44SJohn Forte
5703fcf3ce44SJohn Forte if ((err = g_loopback_mode(path_phys, cmd)) != 0) {
5704fcf3ce44SJohn Forte (void) print_errString(err, portpath);
5705fcf3ce44SJohn Forte free(path_phys);
5706fcf3ce44SJohn Forte free(path_struct);
5707fcf3ce44SJohn Forte return (-1);
5708fcf3ce44SJohn Forte } else {
5709fcf3ce44SJohn Forte switch (flag) {
5710fcf3ce44SJohn Forte case EXT_LOOPBACK:
5711fcf3ce44SJohn Forte (void) fprintf(stdout,
5712fcf3ce44SJohn Forte MSGSTR(2230,
5713fcf3ce44SJohn Forte "External loopback mode set "
5714fcf3ce44SJohn Forte "on:\n%s\n"),
5715fcf3ce44SJohn Forte portpath);
5716fcf3ce44SJohn Forte break;
5717fcf3ce44SJohn Forte case INT_LOOPBACK:
5718fcf3ce44SJohn Forte (void) fprintf(stdout,
5719fcf3ce44SJohn Forte MSGSTR(2231,
5720fcf3ce44SJohn Forte "Internal loopback mode set "
5721fcf3ce44SJohn Forte "on:\n%s\n"),
5722fcf3ce44SJohn Forte portpath);
5723fcf3ce44SJohn Forte break;
5724fcf3ce44SJohn Forte case NO_LOOPBACK:
5725fcf3ce44SJohn Forte (void) fprintf(stdout,
5726fcf3ce44SJohn Forte MSGSTR(2232,
5727fcf3ce44SJohn Forte "Loopback mode unset "
5728fcf3ce44SJohn Forte "on:\n%s\n"),
5729fcf3ce44SJohn Forte portpath);
5730fcf3ce44SJohn Forte break;
5731fcf3ce44SJohn Forte default:
5732fcf3ce44SJohn Forte fprintf(stderr,
5733fcf3ce44SJohn Forte MSGSTR(2248, "Undefined command\n"));
5734fcf3ce44SJohn Forte break;
5735fcf3ce44SJohn Forte }
5736fcf3ce44SJohn Forte }
5737fcf3ce44SJohn Forte free(path_phys);
5738fcf3ce44SJohn Forte free(path_struct);
5739fcf3ce44SJohn Forte return (0);
5740fcf3ce44SJohn Forte }
5741fcf3ce44SJohn Forte
5742fcf3ce44SJohn Forte
5743fcf3ce44SJohn Forte
5744fcf3ce44SJohn Forte /*
5745fcf3ce44SJohn Forte * To print the pathlist and mpxio path attributes
5746fcf3ce44SJohn Forte */
5747fcf3ce44SJohn Forte void
adm_print_pathlist(char * dev_path)5748fcf3ce44SJohn Forte adm_print_pathlist(char *dev_path)
5749fcf3ce44SJohn Forte {
5750fcf3ce44SJohn Forte int i, pathcnt = 1;
5751fcf3ce44SJohn Forte mp_pathlist_t pathlist;
5752fcf3ce44SJohn Forte int retval = 0;
5753fcf3ce44SJohn Forte char temppath[MAXPATHLEN];
5754fcf3ce44SJohn Forte char wwns[(WWN_SIZE *2) +1];
5755fcf3ce44SJohn Forte uchar_t wwn_data[WWN_SIZE];
5756fcf3ce44SJohn Forte int err;
5757fcf3ce44SJohn Forte int state, ext_state = 0;
5758fcf3ce44SJohn Forte char *path_state[5];
5759fcf3ce44SJohn Forte
5760fcf3ce44SJohn Forte path_state[0] = MSGSTR(2400, "INIT");
5761fcf3ce44SJohn Forte path_state[1] = MSGSTR(2401, "ONLINE");
5762fcf3ce44SJohn Forte path_state[2] = MSGSTR(2402, "STANDBY");
5763fcf3ce44SJohn Forte path_state[3] = MSGSTR(2403, "FAULT");
5764fcf3ce44SJohn Forte path_state[4] = MSGSTR(2404, "OFFLINE");
5765fcf3ce44SJohn Forte
5766fcf3ce44SJohn Forte (void) strcpy(temppath, dev_path);
5767fcf3ce44SJohn Forte retval = g_get_pathlist(temppath, &pathlist);
5768fcf3ce44SJohn Forte if (retval != 0) {
5769fcf3ce44SJohn Forte (void) print_errString(retval, NULL);
5770fcf3ce44SJohn Forte exit(-1);
5771fcf3ce44SJohn Forte }
5772fcf3ce44SJohn Forte pathcnt = pathlist.path_count;
5773fcf3ce44SJohn Forte for (i = 0; i < pathcnt; i++) {
5774fcf3ce44SJohn Forte (void) fprintf(stdout,
5775fcf3ce44SJohn Forte MSGSTR(2303, " Controller \t%s\n"),
5776fcf3ce44SJohn Forte pathlist.path_info[i].path_hba);
5777fcf3ce44SJohn Forte
5778fcf3ce44SJohn Forte (void) fprintf(stdout,
5779fcf3ce44SJohn Forte MSGSTR(2304, " Device Address\t\t%s\n"),
5780fcf3ce44SJohn Forte pathlist.path_info[i].path_addr);
5781fcf3ce44SJohn Forte
5782fcf3ce44SJohn Forte if ((err = get_host_controller_pwwn(
5783fcf3ce44SJohn Forte pathlist.path_info[i].path_hba,
5784fcf3ce44SJohn Forte (uchar_t *)&wwn_data)) != 0) {
5785fcf3ce44SJohn Forte if (err != ENOTSUP) {
5786fcf3ce44SJohn Forte (void) print_errString(err,
5787fcf3ce44SJohn Forte pathlist.path_info[i].path_hba);
5788fcf3ce44SJohn Forte exit(1);
5789fcf3ce44SJohn Forte }
5790fcf3ce44SJohn Forte }
5791fcf3ce44SJohn Forte
5792fcf3ce44SJohn Forte if (!err) {
5793fcf3ce44SJohn Forte copy_wwn_data_to_str(wwns, wwn_data);
5794fcf3ce44SJohn Forte (void) fprintf(stdout,
5795fcf3ce44SJohn Forte MSGSTR(2326, " Host controller port WWN\t%s\n"),
5796fcf3ce44SJohn Forte wwns);
5797fcf3ce44SJohn Forte }
5798fcf3ce44SJohn Forte
5799fcf3ce44SJohn Forte (void) fprintf(stdout,
5800fcf3ce44SJohn Forte MSGSTR(2305, " Class\t\t\t%s\n"),
5801fcf3ce44SJohn Forte pathlist.path_info[i].path_class);
5802fcf3ce44SJohn Forte if (pathlist.path_info[i].path_state < MAXPATHSTATE) {
5803fcf3ce44SJohn Forte (void) fprintf(stdout,
5804fcf3ce44SJohn Forte MSGSTR(2306, " State\t\t\t%s\n"),
5805fcf3ce44SJohn Forte path_state[pathlist.path_info[i].path_state]);
5806fcf3ce44SJohn Forte }
5807fcf3ce44SJohn Forte if ((err = g_stms_get_path_state(dev_path,
5808fcf3ce44SJohn Forte pathlist.path_info[i].path_hba, &state,
5809fcf3ce44SJohn Forte &ext_state)) != 0) {
5810fcf3ce44SJohn Forte (void) print_errString(err,
5811fcf3ce44SJohn Forte pathlist.path_info[i].path_hba);
5812fcf3ce44SJohn Forte exit(1);
5813fcf3ce44SJohn Forte } else {
5814fcf3ce44SJohn Forte if ((ext_state & MDI_PATHINFO_STATE_USER_DISABLE)
5815fcf3ce44SJohn Forte == MDI_PATHINFO_STATE_USER_DISABLE) {
5816fcf3ce44SJohn Forte ext_state = 0;
5817fcf3ce44SJohn Forte fprintf(stdout,
5818fcf3ce44SJohn Forte MSGSTR(2327,
5819fcf3ce44SJohn Forte " I/Os disabled on this %s path\n\n"),
5820fcf3ce44SJohn Forte path_state[pathlist.path_info[i].path_state]);
5821fcf3ce44SJohn Forte }
5822fcf3ce44SJohn Forte }
5823fcf3ce44SJohn Forte }
5824fcf3ce44SJohn Forte /* Free memory for per path info properties */
5825fcf3ce44SJohn Forte free(pathlist.path_info);
5826fcf3ce44SJohn Forte }
5827fcf3ce44SJohn Forte
5828fcf3ce44SJohn Forte /*
5829fcf3ce44SJohn Forte * compare_multipath
5830fcf3ce44SJohn Forte * compares path with all paths in pathlist
5831fcf3ce44SJohn Forte * If there is a match, 0 is returned, otherwise 1 is returned
5832fcf3ce44SJohn Forte */
5833fcf3ce44SJohn Forte int
compare_multipath(char * path,struct mplist_struct * pathlist)5834fcf3ce44SJohn Forte compare_multipath(char *path, struct mplist_struct *pathlist)
5835fcf3ce44SJohn Forte {
5836fcf3ce44SJohn Forte
5837fcf3ce44SJohn Forte while (pathlist != NULL) {
5838fcf3ce44SJohn Forte if (strncmp(path, pathlist->devpath, MAXPATHLEN) == 0) {
5839fcf3ce44SJohn Forte return (0);
5840fcf3ce44SJohn Forte }
5841fcf3ce44SJohn Forte pathlist = pathlist->next;
5842fcf3ce44SJohn Forte }
5843fcf3ce44SJohn Forte return (1);
5844fcf3ce44SJohn Forte }
5845fcf3ce44SJohn Forte
5846fcf3ce44SJohn Forte /*
5847fcf3ce44SJohn Forte * lun_display() Prints the
5848fcf3ce44SJohn Forte * information for an individual lun.
5849fcf3ce44SJohn Forte *
5850fcf3ce44SJohn Forte * RETURNS:
5851fcf3ce44SJohn Forte * none.
5852fcf3ce44SJohn Forte */
5853fcf3ce44SJohn Forte static int
lun_display(Path_struct * path_struct,L_inquiry inq_struct,int verbose)5854fcf3ce44SJohn Forte lun_display(Path_struct *path_struct, L_inquiry inq_struct, int verbose)
5855fcf3ce44SJohn Forte {
5856fcf3ce44SJohn Forte
5857fcf3ce44SJohn Forte char phys_path[MAXPATHLEN], last_logical_path[MAXPATHLEN];
5858fcf3ce44SJohn Forte uchar_t *pg_buf = NULL;
5859fcf3ce44SJohn Forte L_disk_state l_disk_state;
5860fcf3ce44SJohn Forte struct dlist *mlist;
5861fcf3ce44SJohn Forte int offset, mode_data_avail, err = 0;
5862fcf3ce44SJohn Forte Mode_header_10 *mode_header_ptr;
5863fcf3ce44SJohn Forte struct mode_page *pg_hdr;
5864fcf3ce44SJohn Forte WWN_list *wwn_list, *list_start, *wwn_list_ptr;
5865fcf3ce44SJohn Forte WWN_list *wwn_list_find;
5866fcf3ce44SJohn Forte int found = 0;
5867fcf3ce44SJohn Forte int argpwwn = 0, argnwwn = 0;
5868fcf3ce44SJohn Forte struct mplist_struct *mplistp, *mpl, *mpln;
5869fcf3ce44SJohn Forte struct dlist *dlist;
5870fcf3ce44SJohn Forte
5871fcf3ce44SJohn Forte
5872fcf3ce44SJohn Forte
5873fcf3ce44SJohn Forte strcpy(phys_path, path_struct->p_physical_path);
5874fcf3ce44SJohn Forte strcpy(last_logical_path, phys_path);
5875fcf3ce44SJohn Forte
5876fcf3ce44SJohn Forte mplistp = mpl = mpln = (struct mplist_struct *)NULL;
5877fcf3ce44SJohn Forte /*
5878fcf3ce44SJohn Forte * Get path to all the FC disk and tape devices.
5879fcf3ce44SJohn Forte * If there is no slash in the argument in this routine, we assume
5880fcf3ce44SJohn Forte * it is a wwn argument.
5881fcf3ce44SJohn Forte */
5882fcf3ce44SJohn Forte if (strstr(path_struct->argv, "/") != NULL) {
5883fcf3ce44SJohn Forte if ((err = g_devices_get_all(&wwn_list)) != 0) {
5884fcf3ce44SJohn Forte return (err);
5885fcf3ce44SJohn Forte }
5886fcf3ce44SJohn Forte } else {
5887fcf3ce44SJohn Forte if ((err = g_get_wwn_list(&wwn_list, verbose)) != 0) {
5888fcf3ce44SJohn Forte return (err);
5889fcf3ce44SJohn Forte }
5890fcf3ce44SJohn Forte }
5891fcf3ce44SJohn Forte
5892fcf3ce44SJohn Forte g_sort_wwn_list(&wwn_list);
5893fcf3ce44SJohn Forte
5894fcf3ce44SJohn Forte list_start = wwn_list;
5895fcf3ce44SJohn Forte
5896fcf3ce44SJohn Forte for (wwn_list_ptr = wwn_list; wwn_list_ptr != NULL;
5897fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
5898fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s,
5899fcf3ce44SJohn Forte path_struct->argv) == 0) {
5900fcf3ce44SJohn Forte list_start = wwn_list_ptr;
5901fcf3ce44SJohn Forte argpwwn = 1;
5902fcf3ce44SJohn Forte break;
5903fcf3ce44SJohn Forte } else if (strcasecmp(wwn_list_ptr->node_wwn_s,
5904fcf3ce44SJohn Forte path_struct->argv) == 0) {
5905fcf3ce44SJohn Forte list_start = wwn_list_ptr;
5906fcf3ce44SJohn Forte argnwwn = 1;
5907fcf3ce44SJohn Forte break;
5908fcf3ce44SJohn Forte }
5909fcf3ce44SJohn Forte }
5910fcf3ce44SJohn Forte
5911fcf3ce44SJohn Forte for (wwn_list_ptr = list_start; wwn_list_ptr != NULL;
5912fcf3ce44SJohn Forte wwn_list_ptr = wwn_list_ptr->wwn_next) {
5913fcf3ce44SJohn Forte
5914fcf3ce44SJohn Forte
5915fcf3ce44SJohn Forte if (argpwwn) {
5916fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->port_wwn_s,
5917fcf3ce44SJohn Forte path_struct->argv) != 0) {
5918fcf3ce44SJohn Forte continue;
5919fcf3ce44SJohn Forte }
5920fcf3ce44SJohn Forte (void) strcpy(phys_path, wwn_list_ptr->physical_path);
5921fcf3ce44SJohn Forte } else if (argnwwn) {
5922fcf3ce44SJohn Forte if (strstr(wwn_list_ptr->logical_path,
5923fcf3ce44SJohn Forte last_logical_path) != NULL) {
5924fcf3ce44SJohn Forte continue;
5925fcf3ce44SJohn Forte }
5926fcf3ce44SJohn Forte if (strcasecmp(wwn_list_ptr->node_wwn_s,
5927fcf3ce44SJohn Forte path_struct->argv) != 0) {
5928fcf3ce44SJohn Forte continue;
5929fcf3ce44SJohn Forte }
5930fcf3ce44SJohn Forte (void) strcpy(phys_path, wwn_list_ptr->physical_path);
5931fcf3ce44SJohn Forte (void) strcpy(last_logical_path,
5932fcf3ce44SJohn Forte wwn_list_ptr->logical_path);
5933fcf3ce44SJohn Forte }
5934fcf3ce44SJohn Forte
5935fcf3ce44SJohn Forte if (argnwwn || argpwwn) {
5936fcf3ce44SJohn Forte if (compare_multipath(wwn_list_ptr->logical_path,
5937fcf3ce44SJohn Forte mplistp) == 0) {
5938fcf3ce44SJohn Forte continue;
5939fcf3ce44SJohn Forte }
5940fcf3ce44SJohn Forte }
5941fcf3ce44SJohn Forte
5942fcf3ce44SJohn Forte mode_data_avail = 0;
5943fcf3ce44SJohn Forte
5944fcf3ce44SJohn Forte (void) memset(&l_disk_state, 0, sizeof (struct l_disk_state_struct));
5945fcf3ce44SJohn Forte
5946fcf3ce44SJohn Forte /*
5947fcf3ce44SJohn Forte * Don't call g_get_multipath if this is a SCSI_VHCI device
5948fcf3ce44SJohn Forte * dlist gets alloc'ed here to retain the free at the end
5949fcf3ce44SJohn Forte */
5950fcf3ce44SJohn Forte if (strstr(phys_path, SCSI_VHCI) == NULL) {
5951fcf3ce44SJohn Forte if ((err = g_get_multipath(phys_path,
5952fcf3ce44SJohn Forte &(l_disk_state.g_disk_state.multipath_list),
5953fcf3ce44SJohn Forte wwn_list, verbose)) != 0) {
5954fcf3ce44SJohn Forte return (err);
5955fcf3ce44SJohn Forte }
5956fcf3ce44SJohn Forte
5957fcf3ce44SJohn Forte mlist = l_disk_state.g_disk_state.multipath_list;
5958fcf3ce44SJohn Forte if (mlist == NULL) {
5959fcf3ce44SJohn Forte l_disk_state.l_state_flag = L_NO_PATH_FOUND;
5960fcf3ce44SJohn Forte N_DPRINTF(" lun_display: Error finding"
5961fcf3ce44SJohn Forte " multiple paths to the disk.\n");
5962fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
5963fcf3ce44SJohn Forte return (L_NO_VALID_PATH);
5964fcf3ce44SJohn Forte }
5965fcf3ce44SJohn Forte } else {
5966fcf3ce44SJohn Forte /* Search for match on physical path name */
5967fcf3ce44SJohn Forte for (wwn_list_find = list_start; wwn_list_find != NULL;
5968fcf3ce44SJohn Forte wwn_list_find = wwn_list_find->wwn_next) {
5969fcf3ce44SJohn Forte if (strncmp(wwn_list_find->physical_path, phys_path,
5970fcf3ce44SJohn Forte strlen(wwn_list_find->physical_path))
5971fcf3ce44SJohn Forte == 0) {
5972fcf3ce44SJohn Forte found++;
5973fcf3ce44SJohn Forte break;
5974fcf3ce44SJohn Forte }
5975fcf3ce44SJohn Forte }
5976fcf3ce44SJohn Forte
5977fcf3ce44SJohn Forte if (!found) {
5978fcf3ce44SJohn Forte return (L_NO_VALID_PATH);
5979fcf3ce44SJohn Forte } else {
5980fcf3ce44SJohn Forte found = 0;
5981fcf3ce44SJohn Forte }
5982fcf3ce44SJohn Forte
5983fcf3ce44SJohn Forte if ((dlist = (struct dlist *)
5984fcf3ce44SJohn Forte calloc(1, sizeof (struct dlist))) == NULL) {
5985fcf3ce44SJohn Forte return (L_MALLOC_FAILED);
5986fcf3ce44SJohn Forte }
5987fcf3ce44SJohn Forte if ((dlist->logical_path = (char *)calloc(1,
5988fcf3ce44SJohn Forte strlen(wwn_list_find->logical_path) + 1)) == NULL) {
5989fcf3ce44SJohn Forte return (L_MALLOC_FAILED);
5990fcf3ce44SJohn Forte }
5991fcf3ce44SJohn Forte if ((dlist->dev_path = (char *)calloc(1,
5992fcf3ce44SJohn Forte strlen(phys_path) + 1)) == NULL) {
5993fcf3ce44SJohn Forte return (L_MALLOC_FAILED);
5994fcf3ce44SJohn Forte }
5995fcf3ce44SJohn Forte strncpy(dlist->logical_path, wwn_list_find->logical_path,
5996fcf3ce44SJohn Forte strlen(wwn_list_find->logical_path));
5997fcf3ce44SJohn Forte strncpy(dlist->dev_path, phys_path, strlen(phys_path));
5998fcf3ce44SJohn Forte l_disk_state.g_disk_state.multipath_list = dlist;
5999fcf3ce44SJohn Forte }
6000fcf3ce44SJohn Forte
6001fcf3ce44SJohn Forte if (argnwwn || argpwwn) {
6002fcf3ce44SJohn Forte for (mlist = l_disk_state.g_disk_state.multipath_list;
6003fcf3ce44SJohn Forte mlist != NULL; mlist = mlist->next) {
6004fcf3ce44SJohn Forte /* add the path to the list for compare */
6005fcf3ce44SJohn Forte if ((mpl = (struct mplist_struct *)
6006fcf3ce44SJohn Forte calloc(1, sizeof (struct mplist_struct)))
6007fcf3ce44SJohn Forte == NULL) {
6008fcf3ce44SJohn Forte adm_mplist_free(mplistp);
6009fcf3ce44SJohn Forte return (L_MALLOC_FAILED);
6010fcf3ce44SJohn Forte }
6011fcf3ce44SJohn Forte
6012fcf3ce44SJohn Forte mpl->devpath = (char *)calloc(1, MAXPATHLEN+1);
6013fcf3ce44SJohn Forte if (mpl->devpath == NULL) {
6014fcf3ce44SJohn Forte adm_mplist_free(mplistp);
6015fcf3ce44SJohn Forte return (L_MALLOC_FAILED);
6016fcf3ce44SJohn Forte }
6017fcf3ce44SJohn Forte strncpy(mpl->devpath, mlist->logical_path,
6018fcf3ce44SJohn Forte strlen(mlist->logical_path));
6019fcf3ce44SJohn Forte if (mplistp == NULL) {
6020fcf3ce44SJohn Forte mplistp = mpln = mpl;
6021fcf3ce44SJohn Forte } else {
6022fcf3ce44SJohn Forte mpln->next = mpl;
6023fcf3ce44SJohn Forte mpln = mpl;
6024fcf3ce44SJohn Forte }
6025fcf3ce44SJohn Forte }
6026fcf3ce44SJohn Forte }
6027fcf3ce44SJohn Forte
6028fcf3ce44SJohn Forte /* get mode page information for FC device */
6029fcf3ce44SJohn Forte if (l_get_mode_pg(phys_path, &pg_buf, verbose) == 0) {
6030fcf3ce44SJohn Forte mode_header_ptr = (struct mode_header_10_struct *)
6031fcf3ce44SJohn Forte (void *)pg_buf;
6032fcf3ce44SJohn Forte offset = sizeof (struct mode_header_10_struct) +
6033fcf3ce44SJohn Forte mode_header_ptr->bdesc_length;
6034fcf3ce44SJohn Forte pg_hdr = (struct mode_page *)&pg_buf[offset];
6035fcf3ce44SJohn Forte
6036fcf3ce44SJohn Forte while (offset < (mode_header_ptr->length +
6037fcf3ce44SJohn Forte sizeof (mode_header_ptr->length)) &&
6038fcf3ce44SJohn Forte !mode_data_avail) {
6039fcf3ce44SJohn Forte if (pg_hdr->code == MODEPAGE_CACHING) {
6040fcf3ce44SJohn Forte mode_data_avail++;
6041fcf3ce44SJohn Forte break;
6042fcf3ce44SJohn Forte }
6043fcf3ce44SJohn Forte offset += pg_hdr->length + sizeof (struct mode_page);
6044fcf3ce44SJohn Forte pg_hdr = (struct mode_page *)&pg_buf[offset];
6045fcf3ce44SJohn Forte }
6046fcf3ce44SJohn Forte }
6047fcf3ce44SJohn Forte
6048fcf3ce44SJohn Forte switch ((inq_struct.inq_dtype & DTYPE_MASK)) {
6049fcf3ce44SJohn Forte case DTYPE_DIRECT:
6050fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(121, "DEVICE PROPERTIES for disk: %s\n"),
6051fcf3ce44SJohn Forte path_struct->argv);
6052fcf3ce44SJohn Forte break;
6053fcf3ce44SJohn Forte case DTYPE_SEQUENTIAL: /* Tape */
6054fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2249, "DEVICE PROPERTIES for tape: %s\n"),
6055fcf3ce44SJohn Forte path_struct->argv);
6056fcf3ce44SJohn Forte break;
6057fcf3ce44SJohn Forte default:
6058fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2250, "DEVICE PROPERTIES for: %s\n"),
6059fcf3ce44SJohn Forte path_struct->argv);
6060fcf3ce44SJohn Forte break;
6061fcf3ce44SJohn Forte }
6062fcf3ce44SJohn Forte
6063fcf3ce44SJohn Forte (void) display_lun_info(l_disk_state, path_struct, pg_hdr,
6064fcf3ce44SJohn Forte mode_data_avail, wwn_list, phys_path);
6065fcf3ce44SJohn Forte
6066fcf3ce44SJohn Forte (void) g_free_multipath(l_disk_state.g_disk_state.multipath_list);
6067fcf3ce44SJohn Forte
6068fcf3ce44SJohn Forte if (!(argpwwn || argnwwn)) {
6069fcf3ce44SJohn Forte break;
6070fcf3ce44SJohn Forte }
6071fcf3ce44SJohn Forte
6072fcf3ce44SJohn Forte } /* End for wwn_list_ptr = list_start... */
6073fcf3ce44SJohn Forte
6074fcf3ce44SJohn Forte (void) g_free_wwn_list(&wwn_list);
6075fcf3ce44SJohn Forte adm_mplist_free(mplistp);
6076fcf3ce44SJohn Forte return (0);
6077fcf3ce44SJohn Forte }
6078fcf3ce44SJohn Forte
6079fcf3ce44SJohn Forte /*
6080fcf3ce44SJohn Forte * display_lun_info() Prints the device specific information
6081fcf3ce44SJohn Forte * for a lun.
6082fcf3ce44SJohn Forte *
6083fcf3ce44SJohn Forte * RETURNS:
6084fcf3ce44SJohn Forte * none.
6085fcf3ce44SJohn Forte */
6086fcf3ce44SJohn Forte void
display_lun_info(L_disk_state l_disk_state,Path_struct * path_struct,struct mode_page * pg_hdr,int mode_data_avail,WWN_list * wwn_list,char * phys_path)6087fcf3ce44SJohn Forte display_lun_info(L_disk_state l_disk_state, Path_struct *path_struct,
6088fcf3ce44SJohn Forte struct mode_page *pg_hdr, int mode_data_avail, WWN_list
6089fcf3ce44SJohn Forte *wwn_list, char *phys_path)
6090fcf3ce44SJohn Forte {
6091fcf3ce44SJohn Forte float lunMbytes;
6092fcf3ce44SJohn Forte struct scsi_capacity_16 cap_data;
6093fcf3ce44SJohn Forte struct dlist *mlist;
6094fcf3ce44SJohn Forte struct my_mode_caching *pg8_buf;
6095fcf3ce44SJohn Forte int err;
6096fcf3ce44SJohn Forte L_inquiry inq;
6097fcf3ce44SJohn Forte hrtime_t start_time, end_time;
6098fcf3ce44SJohn Forte char *envdb = NULL;
6099fcf3ce44SJohn Forte int peripheral_qual;
6100fcf3ce44SJohn Forte L_inquiry80 inq80;
6101fcf3ce44SJohn Forte size_t serial_len = sizeof (inq80.inq_serial);
6102fcf3ce44SJohn Forte
6103fcf3ce44SJohn Forte if ((envdb = getenv("_LUX_T_DEBUG")) != NULL) {
6104fcf3ce44SJohn Forte start_time = gethrtime();
6105fcf3ce44SJohn Forte }
6106fcf3ce44SJohn Forte
6107fcf3ce44SJohn Forte memset(&cap_data, 0, sizeof (cap_data));
6108fcf3ce44SJohn Forte
6109fcf3ce44SJohn Forte if (err = g_get_inquiry(phys_path, &inq)) {
6110fcf3ce44SJohn Forte fprintf(stderr, "\n");
6111fcf3ce44SJohn Forte print_errString(err, phys_path);
6112fcf3ce44SJohn Forte fprintf(stderr, "\n");
6113fcf3ce44SJohn Forte exit(1);
6114fcf3ce44SJohn Forte }
6115fcf3ce44SJohn Forte
6116fcf3ce44SJohn Forte if (err = g_get_serial_number(phys_path, inq80.inq_serial,
6117fcf3ce44SJohn Forte &serial_len)) {
6118fcf3ce44SJohn Forte fprintf(stderr, "\n");
6119fcf3ce44SJohn Forte print_errString(err, phys_path);
6120fcf3ce44SJohn Forte fprintf(stderr, "\n");
6121fcf3ce44SJohn Forte exit(1);
6122fcf3ce44SJohn Forte }
6123fcf3ce44SJohn Forte /*
6124fcf3ce44SJohn Forte * check to see if the peripheral qualifier is zero
6125fcf3ce44SJohn Forte * if it is non-zero, we will return with an error.
6126fcf3ce44SJohn Forte */
6127fcf3ce44SJohn Forte peripheral_qual = inq.inq_dtype & ~DTYPE_MASK;
6128fcf3ce44SJohn Forte if (peripheral_qual != DPQ_POSSIBLE) {
6129fcf3ce44SJohn Forte fprintf(stderr, MSGSTR(2254, "\n Error: Logical Unit "
6130fcf3ce44SJohn Forte "(%s) is not available.\n"), phys_path);
6131fcf3ce44SJohn Forte exit(1);
6132fcf3ce44SJohn Forte }
6133fcf3ce44SJohn Forte
6134fcf3ce44SJohn Forte fprintf(stdout, " ");
6135fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(3, "Vendor:"));
6136fcf3ce44SJohn Forte fprintf(stdout, "\t\t");
6137fcf3ce44SJohn Forte print_chars(inq.inq_vid, sizeof (inq.inq_vid), 0);
6138fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2115, "\n Product ID:\t\t"));
6139fcf3ce44SJohn Forte print_chars(inq.inq_pid, sizeof (inq.inq_pid), 0);
6140fcf3ce44SJohn Forte
6141fcf3ce44SJohn Forte fprintf(stdout, "\n ");
6142fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2119, "Revision:"));
6143fcf3ce44SJohn Forte fprintf(stdout, "\t\t");
6144fcf3ce44SJohn Forte print_chars(inq.inq_revision, sizeof (inq.inq_revision), 0);
6145fcf3ce44SJohn Forte
6146fcf3ce44SJohn Forte fprintf(stdout, "\n ");
6147fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(17, "Serial Num:"));
6148fcf3ce44SJohn Forte fprintf(stdout, "\t\t");
6149fcf3ce44SJohn Forte print_chars(inq80.inq_serial, serial_len, 0);
6150fcf3ce44SJohn Forte
6151fcf3ce44SJohn Forte if ((inq.inq_dtype & DTYPE_MASK) == DTYPE_DIRECT) {
6152fcf3ce44SJohn Forte if ((err = get_lun_capacity(phys_path, &cap_data)) != 0) {
6153fcf3ce44SJohn Forte print_errString(err, phys_path);
6154fcf3ce44SJohn Forte exit(1);
6155fcf3ce44SJohn Forte }
6156fcf3ce44SJohn Forte
6157fcf3ce44SJohn Forte if (cap_data.sc_capacity > 0 && cap_data.sc_lbasize > 0) {
6158fcf3ce44SJohn Forte lunMbytes = cap_data.sc_capacity + 1;
6159fcf3ce44SJohn Forte lunMbytes *= cap_data.sc_lbasize;
6160fcf3ce44SJohn Forte lunMbytes /= (float)(1024*1024);
6161fcf3ce44SJohn Forte fprintf(stdout, "\n ");
6162fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(60,
6163fcf3ce44SJohn Forte "Unformatted capacity:\t%6.3f MBytes"), lunMbytes);
6164fcf3ce44SJohn Forte }
6165fcf3ce44SJohn Forte }
6166fcf3ce44SJohn Forte
6167fcf3ce44SJohn Forte fprintf(stdout, "\n");
6168fcf3ce44SJohn Forte
6169fcf3ce44SJohn Forte if ((mode_data_avail) && (pg_hdr->code == MODEPAGE_CACHING)) {
6170fcf3ce44SJohn Forte pg8_buf = (struct my_mode_caching *)(void *)pg_hdr;
6171fcf3ce44SJohn Forte if (pg8_buf->wce) {
6172fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2122, " Write Cache:\t\t"
6173fcf3ce44SJohn Forte "Enabled\n"));
6174fcf3ce44SJohn Forte }
6175fcf3ce44SJohn Forte if (pg8_buf->rcd == 0) {
6176fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2123, " Read Cache:\t\t"
6177fcf3ce44SJohn Forte "Enabled\n"));
6178fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2124, " Minimum prefetch:"
6179fcf3ce44SJohn Forte "\t0x%x\n Maximum prefetch:\t0x%x\n"),
6180fcf3ce44SJohn Forte pg8_buf->min_prefetch,
6181fcf3ce44SJohn Forte pg8_buf->max_prefetch);
6182fcf3ce44SJohn Forte }
6183fcf3ce44SJohn Forte }
6184fcf3ce44SJohn Forte
6185fcf3ce44SJohn Forte fprintf(stdout, " %s\t\t%s\n", MSGSTR(35, "Device Type:"),
6186fcf3ce44SJohn Forte dtype[inq.inq_dtype & DTYPE_MASK]);
6187fcf3ce44SJohn Forte
6188fcf3ce44SJohn Forte
6189fcf3ce44SJohn Forte fprintf(stdout, MSGSTR(2128, " Path(s):\n"));
6190fcf3ce44SJohn Forte fprintf(stdout, "\n");
6191fcf3ce44SJohn Forte
6192fcf3ce44SJohn Forte if ((mlist = l_disk_state.g_disk_state.multipath_list) == NULL) {
6193fcf3ce44SJohn Forte fprintf(stderr, MSGSTR(2323, "Error: No paths found (%s)"),
6194fcf3ce44SJohn Forte path_struct->argv);
6195fcf3ce44SJohn Forte exit(1);
6196fcf3ce44SJohn Forte }
6197fcf3ce44SJohn Forte
6198fcf3ce44SJohn Forte
6199fcf3ce44SJohn Forte if (strstr(mlist->dev_path, SCSI_VHCI) != NULL) {
6200fcf3ce44SJohn Forte fprintf(stdout, " %s\n %s\n",
6201fcf3ce44SJohn Forte mlist->logical_path, mlist->dev_path);
6202fcf3ce44SJohn Forte adm_print_pathlist(mlist->dev_path);
6203fcf3ce44SJohn Forte } else {
6204fcf3ce44SJohn Forte /*
6205fcf3ce44SJohn Forte * first display user's requested path
6206fcf3ce44SJohn Forte * This will avoid duplicate inquiries as well
6207fcf3ce44SJohn Forte */
6208fcf3ce44SJohn Forte for (mlist = l_disk_state.g_disk_state.multipath_list;
6209fcf3ce44SJohn Forte mlist != NULL; mlist = mlist->next) {
6210fcf3ce44SJohn Forte if ((strcmp(mlist->dev_path, path_struct->p_physical_path))
6211fcf3ce44SJohn Forte == 0) {
6212fcf3ce44SJohn Forte display_path_info(mlist->dev_path, mlist->logical_path,
6213fcf3ce44SJohn Forte wwn_list);
6214fcf3ce44SJohn Forte break;
6215fcf3ce44SJohn Forte }
6216fcf3ce44SJohn Forte }
6217fcf3ce44SJohn Forte
6218fcf3ce44SJohn Forte /*
6219fcf3ce44SJohn Forte * Now display rest of paths
6220fcf3ce44SJohn Forte * skipping one already displayed
6221fcf3ce44SJohn Forte */
6222fcf3ce44SJohn Forte for (mlist = l_disk_state.g_disk_state.multipath_list;
6223fcf3ce44SJohn Forte mlist != NULL; mlist = mlist->next) {
6224fcf3ce44SJohn Forte if ((strcmp(mlist->dev_path, path_struct->p_physical_path))
6225fcf3ce44SJohn Forte == 0) {
6226fcf3ce44SJohn Forte continue;
6227fcf3ce44SJohn Forte }
6228fcf3ce44SJohn Forte if (err = g_get_inquiry(mlist->dev_path, &inq)) {
6229fcf3ce44SJohn Forte fprintf(stderr, "\n");
6230fcf3ce44SJohn Forte print_errString(err, mlist->dev_path);
6231fcf3ce44SJohn Forte fprintf(stderr, "\n");
6232fcf3ce44SJohn Forte exit(1);
6233fcf3ce44SJohn Forte }
6234fcf3ce44SJohn Forte display_path_info(mlist->dev_path, mlist->logical_path,
6235fcf3ce44SJohn Forte wwn_list);
6236fcf3ce44SJohn Forte }
6237fcf3ce44SJohn Forte }
6238fcf3ce44SJohn Forte fprintf(stdout, "\n");
6239fcf3ce44SJohn Forte
6240fcf3ce44SJohn Forte if (envdb != NULL) {
6241fcf3ce44SJohn Forte end_time = gethrtime();
6242fcf3ce44SJohn Forte fprintf(stdout, " display_lun_info: "
6243fcf3ce44SJohn Forte "\t\tTime = %lld millisec\n",
6244fcf3ce44SJohn Forte (end_time - start_time)/1000000);
6245fcf3ce44SJohn Forte }
6246fcf3ce44SJohn Forte }
6247fcf3ce44SJohn Forte
6248fcf3ce44SJohn Forte /*
6249fcf3ce44SJohn Forte * display_path_info() Prints the path specific information
6250fcf3ce44SJohn Forte * for a lun.
6251fcf3ce44SJohn Forte * Note: Only applies to ssd nodes currently
6252fcf3ce44SJohn Forte *
6253fcf3ce44SJohn Forte * RETURNS:
6254fcf3ce44SJohn Forte * none.
6255fcf3ce44SJohn Forte */
6256fcf3ce44SJohn Forte static void
display_path_info(char * devpath,char * logicalpath,WWN_list * wwn_list)6257fcf3ce44SJohn Forte display_path_info(char *devpath, char *logicalpath, WWN_list *wwn_list)
6258fcf3ce44SJohn Forte {
6259fcf3ce44SJohn Forte WWN_list *wwn_list_walk;
6260fcf3ce44SJohn Forte int err;
6261fcf3ce44SJohn Forte uchar_t wwn_data[WWN_SIZE];
6262fcf3ce44SJohn Forte char wwns[(WWN_SIZE *2) +1];
6263fcf3ce44SJohn Forte char drvr_path[MAXPATHLEN];
6264fcf3ce44SJohn Forte char *cptr;
6265fcf3ce44SJohn Forte int status;
6266fcf3ce44SJohn Forte
6267fcf3ce44SJohn Forte fprintf(stdout, " %s\n", logicalpath);
6268fcf3ce44SJohn Forte fprintf(stdout, " %s\n", devpath);
6269fcf3ce44SJohn Forte fprintf(stdout, " %s\t\t", MSGSTR(2321, "LUN path port WWN:"));
6270fcf3ce44SJohn Forte
6271fcf3ce44SJohn Forte /*
6272fcf3ce44SJohn Forte * Walk the wwn list passed in and print the
6273fcf3ce44SJohn Forte * port wwn matching the device path
6274fcf3ce44SJohn Forte */
6275fcf3ce44SJohn Forte for (wwn_list_walk = wwn_list; wwn_list_walk != NULL;
6276fcf3ce44SJohn Forte wwn_list_walk = wwn_list_walk->wwn_next) {
6277fcf3ce44SJohn Forte if (strcmp(wwn_list_walk->physical_path, devpath) == 0) {
6278fcf3ce44SJohn Forte fprintf(stdout, "%s", wwn_list_walk->port_wwn_s);
6279fcf3ce44SJohn Forte break;
6280fcf3ce44SJohn Forte }
6281fcf3ce44SJohn Forte }
6282fcf3ce44SJohn Forte /*
6283fcf3ce44SJohn Forte * newline here in case port wwn not found
6284fcf3ce44SJohn Forte */
6285fcf3ce44SJohn Forte fprintf(stdout, "\n");
6286fcf3ce44SJohn Forte
6287fcf3ce44SJohn Forte drvr_path[0] = '\0';
6288fcf3ce44SJohn Forte (void) strcat(drvr_path, devpath);
6289fcf3ce44SJohn Forte if (((cptr = strstr(drvr_path, SLSH_DRV_NAME_SSD)) != NULL) ||
6290fcf3ce44SJohn Forte ((cptr = strstr(drvr_path, SLSH_DRV_NAME_ST)) != NULL)) {;
6291fcf3ce44SJohn Forte *cptr = '\0';
6292fcf3ce44SJohn Forte } else {
6293fcf3ce44SJohn Forte fprintf(stderr, MSGSTR(2324, "Error: Incorrect path (%s)\n"),
6294fcf3ce44SJohn Forte drvr_path);
6295fcf3ce44SJohn Forte exit(1);
6296fcf3ce44SJohn Forte }
6297fcf3ce44SJohn Forte *cptr = '\0';
6298fcf3ce44SJohn Forte
6299fcf3ce44SJohn Forte if ((err = get_host_controller_pwwn(drvr_path,
6300fcf3ce44SJohn Forte (uchar_t *)&wwn_data)) != 0) {
6301fcf3ce44SJohn Forte print_errString(err, drvr_path);
6302fcf3ce44SJohn Forte exit(1);
6303fcf3ce44SJohn Forte }
6304fcf3ce44SJohn Forte
6305fcf3ce44SJohn Forte copy_wwn_data_to_str(wwns, wwn_data);
6306fcf3ce44SJohn Forte fprintf(stdout, " %s\t%s\n",
6307fcf3ce44SJohn Forte MSGSTR(2322, "Host controller port WWN:"), wwns);
6308fcf3ce44SJohn Forte
6309fcf3ce44SJohn Forte /*
6310fcf3ce44SJohn Forte * Determine path status
6311fcf3ce44SJohn Forte */
6312fcf3ce44SJohn Forte if ((err = get_path_status(devpath, &status)) != 0) {
6313fcf3ce44SJohn Forte print_errString(err, devpath);
6314fcf3ce44SJohn Forte exit(1);
6315fcf3ce44SJohn Forte } else {
6316fcf3ce44SJohn Forte fprintf(stdout, " %s\t\t", MSGSTR(2329, "Path status:"));
6317fcf3ce44SJohn Forte display_port_status(status);
6318fcf3ce44SJohn Forte }
6319fcf3ce44SJohn Forte }
6320fcf3ce44SJohn Forte
6321fcf3ce44SJohn Forte /*
6322fcf3ce44SJohn Forte * Retrieves the lun capacity
6323fcf3ce44SJohn Forte */
6324fcf3ce44SJohn Forte static int
get_lun_capacity(char * devpath,struct scsi_capacity_16 * cap_data)6325fcf3ce44SJohn Forte get_lun_capacity(char *devpath, struct scsi_capacity_16 *cap_data)
6326fcf3ce44SJohn Forte {
6327fcf3ce44SJohn Forte int fd;
6328fcf3ce44SJohn Forte
6329fcf3ce44SJohn Forte if (devpath == NULL || cap_data == NULL) {
6330fcf3ce44SJohn Forte return (L_INVALID_PATH);
6331fcf3ce44SJohn Forte }
6332fcf3ce44SJohn Forte
6333fcf3ce44SJohn Forte if ((fd = g_object_open(devpath, O_RDONLY | O_NDELAY)) == -1) {
6334fcf3ce44SJohn Forte return (L_OPEN_PATH_FAIL);
6335fcf3ce44SJohn Forte } else {
6336fcf3ce44SJohn Forte (void) g_scsi_read_capacity_1016_cmd(fd, cap_data,
6337fcf3ce44SJohn Forte sizeof (struct scsi_capacity_16));
6338fcf3ce44SJohn Forte close(fd);
6339fcf3ce44SJohn Forte }
6340fcf3ce44SJohn Forte return (0);
6341fcf3ce44SJohn Forte }
6342fcf3ce44SJohn Forte
6343fcf3ce44SJohn Forte /*
6344fcf3ce44SJohn Forte * Retrieves the reservation status
6345fcf3ce44SJohn Forte */
6346fcf3ce44SJohn Forte static int
get_path_status(char * devpath,int * status)6347fcf3ce44SJohn Forte get_path_status(char *devpath, int *status)
6348fcf3ce44SJohn Forte {
6349fcf3ce44SJohn Forte int fd, mystatus = 0;
6350fcf3ce44SJohn Forte
6351fcf3ce44SJohn Forte
6352fcf3ce44SJohn Forte if (devpath == NULL || status == NULL) {
6353fcf3ce44SJohn Forte return (L_INVALID_PATH);
6354fcf3ce44SJohn Forte }
6355fcf3ce44SJohn Forte
6356fcf3ce44SJohn Forte *status = 0;
6357fcf3ce44SJohn Forte if ((fd = g_object_open(devpath, O_RDONLY | O_NDELAY)) == -1) {
6358fcf3ce44SJohn Forte return (L_OPEN_PATH_FAIL);
6359fcf3ce44SJohn Forte } else {
6360fcf3ce44SJohn Forte if ((mystatus = g_scsi_tur(fd)) != 0) {
6361fcf3ce44SJohn Forte if ((mystatus & L_SCSI_ERROR) &&
6362fcf3ce44SJohn Forte ((mystatus & ~L_SCSI_ERROR) == STATUS_CHECK)) {
6363fcf3ce44SJohn Forte *status = L_NOT_READY;
6364fcf3ce44SJohn Forte } else if ((mystatus & L_SCSI_ERROR) &&
6365fcf3ce44SJohn Forte ((mystatus & ~L_SCSI_ERROR) ==
6366fcf3ce44SJohn Forte STATUS_RESERVATION_CONFLICT)) {
6367fcf3ce44SJohn Forte *status = L_RESERVED;
6368fcf3ce44SJohn Forte } else {
6369fcf3ce44SJohn Forte *status = L_SCSI_ERR;
6370fcf3ce44SJohn Forte }
6371fcf3ce44SJohn Forte }
6372fcf3ce44SJohn Forte }
6373fcf3ce44SJohn Forte close(fd);
6374fcf3ce44SJohn Forte return (0);
6375fcf3ce44SJohn Forte }
6376fcf3ce44SJohn Forte
6377fcf3ce44SJohn Forte /*
6378fcf3ce44SJohn Forte * Description:
6379fcf3ce44SJohn Forte * Retrieves the port wwn associated with the hba node
6380fcf3ce44SJohn Forte *
6381fcf3ce44SJohn Forte * hba_path: /devices/pci@8,600000/SUNW,qlc@4/fp@0,0
6382fcf3ce44SJohn Forte * pwwn: ptr to a uchar_t array of size WWN_SIZE
6383fcf3ce44SJohn Forte */
6384fcf3ce44SJohn Forte static int
get_host_controller_pwwn(char * hba_path,uchar_t * pwwn)6385fcf3ce44SJohn Forte get_host_controller_pwwn(char *hba_path, uchar_t *pwwn)
6386fcf3ce44SJohn Forte {
6387fcf3ce44SJohn Forte char *cptr, *portptr;
6388fcf3ce44SJohn Forte int found = 0, err, devlen;
6389fcf3ce44SJohn Forte char my_hba_path[MAXPATHLEN];
6390fcf3ce44SJohn Forte di_node_t node;
6391fcf3ce44SJohn Forte di_prom_prop_t promprop;
6392fcf3ce44SJohn Forte uchar_t *port_wwn_data = NULL;
6393fcf3ce44SJohn Forte int di_ret;
6394fcf3ce44SJohn Forte di_prom_handle_t ph;
6395fcf3ce44SJohn Forte char *promname;
6396fcf3ce44SJohn Forte uchar_t *promdata;
6397fcf3ce44SJohn Forte uint_t path_type;
6398fcf3ce44SJohn Forte fc_port_dev_t hba_port;
6399fcf3ce44SJohn Forte
6400fcf3ce44SJohn Forte if (hba_path == NULL || pwwn == NULL) {
6401fcf3ce44SJohn Forte return (L_INVALID_PATH);
6402fcf3ce44SJohn Forte }
6403fcf3ce44SJohn Forte
6404fcf3ce44SJohn Forte if ((path_type = g_get_path_type(hba_path)) == 0) {
6405fcf3ce44SJohn Forte return (L_INVALID_PATH);
6406fcf3ce44SJohn Forte }
6407fcf3ce44SJohn Forte
6408fcf3ce44SJohn Forte /*
6409fcf3ce44SJohn Forte * ifp nodes do not have a port-wwn prom property
6410fcf3ce44SJohn Forte * so handle them via FC4 device map
6411fcf3ce44SJohn Forte */
6412fcf3ce44SJohn Forte if (path_type & FC4_XPORT_MASK) {
6413fcf3ce44SJohn Forte if ((err = get_FC4_host_controller_pwwn(hba_path, pwwn)) != 0) {
6414fcf3ce44SJohn Forte return (err);
6415fcf3ce44SJohn Forte } else {
6416fcf3ce44SJohn Forte return (0);
6417fcf3ce44SJohn Forte }
6418fcf3ce44SJohn Forte /* For Leadville path get the port wwn through g_get_host param. */
6419fcf3ce44SJohn Forte } else if ((path_type & FC_GEN_XPORT) &&
6420fcf3ce44SJohn Forte ((path_type & FC_FCA_MASK) == FC_FCA_MASK)) {
6421fcf3ce44SJohn Forte /*
6422fcf3ce44SJohn Forte * For Leadville path, get the port wwn through
6423fcf3ce44SJohn Forte * g_get_host param. This is a general solution
6424fcf3ce44SJohn Forte * to support 3rd party vendor Leadville FCA.
6425fcf3ce44SJohn Forte */
6426fcf3ce44SJohn Forte my_hba_path[0] = '\0';
6427fcf3ce44SJohn Forte (void) strlcat(my_hba_path, hba_path, sizeof (my_hba_path));
6428fcf3ce44SJohn Forte (void) snprintf(my_hba_path, sizeof (my_hba_path), "%s%s",
6429fcf3ce44SJohn Forte hba_path, FC_CTLR);
6430fcf3ce44SJohn Forte if ((err = g_get_host_params(
6431fcf3ce44SJohn Forte my_hba_path, &hba_port, 0)) != 0) {
6432fcf3ce44SJohn Forte return (err);
6433fcf3ce44SJohn Forte } else {
6434fcf3ce44SJohn Forte (void) memcpy(pwwn, &hba_port.dev_pwwn.raw_wwn[0],
6435fcf3ce44SJohn Forte WWN_SIZE);
6436fcf3ce44SJohn Forte return (0);
6437fcf3ce44SJohn Forte }
6438fcf3ce44SJohn Forte } else if ((path_type & FC_FCA_MASK) == FC_PCI_FCA) {
6439fcf3ce44SJohn Forte /*
6440fcf3ce44SJohn Forte * Get port WWN through prom property
6441fcf3ce44SJohn Forte */
6442fcf3ce44SJohn Forte my_hba_path[0] = '\0';
6443fcf3ce44SJohn Forte (void) strlcat(my_hba_path, hba_path, sizeof (my_hba_path));
6444fcf3ce44SJohn Forte /*
6445fcf3ce44SJohn Forte * sanity check for /devices mount point
6446fcf3ce44SJohn Forte */
6447fcf3ce44SJohn Forte if (strlen(my_hba_path) > (devlen = strlen("/devices"))) {
6448fcf3ce44SJohn Forte cptr = &my_hba_path[devlen];
6449fcf3ce44SJohn Forte } else {
6450fcf3ce44SJohn Forte return (L_INVALID_PATH);
6451fcf3ce44SJohn Forte }
6452fcf3ce44SJohn Forte
6453fcf3ce44SJohn Forte /*
6454fcf3ce44SJohn Forte * Now strip off the trailing "/fp@"
6455fcf3ce44SJohn Forte */
6456fcf3ce44SJohn Forte if ((portptr = strstr(cptr, "/fp@")) != NULL) {
6457fcf3ce44SJohn Forte *portptr = '\0';
6458fcf3ce44SJohn Forte }
6459fcf3ce44SJohn Forte
6460fcf3ce44SJohn Forte if ((node = di_init(cptr, DINFOCPYALL)) == DI_NODE_NIL) {
6461fcf3ce44SJohn Forte return (L_DEV_SNAPSHOT_FAILED);
6462fcf3ce44SJohn Forte }
6463fcf3ce44SJohn Forte
6464fcf3ce44SJohn Forte if (di_nodeid(node) == DI_SID_NODEID) {
6465fcf3ce44SJohn Forte di_ret = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
6466fcf3ce44SJohn Forte "port-wwn", &port_wwn_data);
6467fcf3ce44SJohn Forte if (di_ret == -1 || port_wwn_data == NULL) {
6468fcf3ce44SJohn Forte di_fini(node);
6469fcf3ce44SJohn Forte return (L_NO_WWN_PROP_FOUND);
6470fcf3ce44SJohn Forte } else {
6471fcf3ce44SJohn Forte (void) memcpy(pwwn, port_wwn_data, WWN_SIZE);
6472fcf3ce44SJohn Forte found++;
6473fcf3ce44SJohn Forte }
6474fcf3ce44SJohn Forte } else if (di_nodeid(node) == DI_PROM_NODEID) {
6475fcf3ce44SJohn Forte if ((ph = di_prom_init()) == DI_PROM_HANDLE_NIL) {
6476fcf3ce44SJohn Forte di_fini(node);
6477fcf3ce44SJohn Forte return (L_PROM_INIT_FAILED);
6478fcf3ce44SJohn Forte }
6479fcf3ce44SJohn Forte
6480fcf3ce44SJohn Forte for (promprop = di_prom_prop_next(ph, node,
6481fcf3ce44SJohn Forte DI_PROM_PROP_NIL);
6482fcf3ce44SJohn Forte promprop != DI_PROM_PROP_NIL;
6483fcf3ce44SJohn Forte promprop = di_prom_prop_next(ph, node, promprop)) {
6484fcf3ce44SJohn Forte if (((promname = di_prom_prop_name(
6485fcf3ce44SJohn Forte promprop)) != NULL) &&
6486fcf3ce44SJohn Forte (strcmp(promname, "port-wwn") == 0) &&
6487fcf3ce44SJohn Forte (di_prom_prop_data(promprop,
6488fcf3ce44SJohn Forte &promdata) == WWN_SIZE)) {
6489fcf3ce44SJohn Forte /* Found port-wwn */
6490fcf3ce44SJohn Forte (void) memcpy(pwwn, promdata, WWN_SIZE);
6491fcf3ce44SJohn Forte found++;
6492fcf3ce44SJohn Forte break;
6493fcf3ce44SJohn Forte }
6494fcf3ce44SJohn Forte }
6495fcf3ce44SJohn Forte di_prom_fini(ph);
6496fcf3ce44SJohn Forte }
6497fcf3ce44SJohn Forte
6498fcf3ce44SJohn Forte di_fini(node);
6499fcf3ce44SJohn Forte if (found) {
6500fcf3ce44SJohn Forte return (0);
6501fcf3ce44SJohn Forte } else {
6502fcf3ce44SJohn Forte return (L_INVALID_PATH);
6503fcf3ce44SJohn Forte }
6504fcf3ce44SJohn Forte } else {
6505fcf3ce44SJohn Forte return (L_INVALID_PATH_TYPE);
6506fcf3ce44SJohn Forte }
6507fcf3ce44SJohn Forte }
6508fcf3ce44SJohn Forte
6509fcf3ce44SJohn Forte
6510fcf3ce44SJohn Forte /*
6511fcf3ce44SJohn Forte * Description:
6512fcf3ce44SJohn Forte * Retrieve pwwn via SFIOCGMAP
6513fcf3ce44SJohn Forte */
6514fcf3ce44SJohn Forte static int
get_FC4_host_controller_pwwn(char * hba_path,uchar_t * pwwn)6515fcf3ce44SJohn Forte get_FC4_host_controller_pwwn(char *hba_path, uchar_t *pwwn)
6516fcf3ce44SJohn Forte {
6517fcf3ce44SJohn Forte sf_al_map_t sf_map;
6518fcf3ce44SJohn Forte char my_hba_path[MAXPATHLEN];
6519fcf3ce44SJohn Forte int fd;
6520fcf3ce44SJohn Forte
6521fcf3ce44SJohn Forte if (hba_path == NULL || pwwn == NULL) {
6522fcf3ce44SJohn Forte return (L_INVALID_PATH);
6523fcf3ce44SJohn Forte }
6524fcf3ce44SJohn Forte
6525fcf3ce44SJohn Forte (void) snprintf(my_hba_path, sizeof (my_hba_path), "%s%s",
6526fcf3ce44SJohn Forte hba_path, FC_CTLR);
6527fcf3ce44SJohn Forte
6528fcf3ce44SJohn Forte if ((fd = g_object_open(my_hba_path, O_NDELAY | O_RDONLY)) == -1) {
6529fcf3ce44SJohn Forte return (errno);
6530fcf3ce44SJohn Forte }
6531fcf3ce44SJohn Forte
6532fcf3ce44SJohn Forte memset(&sf_map, 0, sizeof (sf_al_map_t));
6533fcf3ce44SJohn Forte
6534fcf3ce44SJohn Forte if (ioctl(fd, SFIOCGMAP, &sf_map) != 0) {
6535fcf3ce44SJohn Forte close(fd);
6536fcf3ce44SJohn Forte return (L_SFIOCGMAP_IOCTL_FAIL);
6537fcf3ce44SJohn Forte }
6538fcf3ce44SJohn Forte
6539fcf3ce44SJohn Forte close(fd);
6540fcf3ce44SJohn Forte
6541fcf3ce44SJohn Forte if (sf_map.sf_count == 0) {
6542fcf3ce44SJohn Forte close(fd);
6543fcf3ce44SJohn Forte return (L_SFIOCGMAP_IOCTL_FAIL);
6544fcf3ce44SJohn Forte }
6545fcf3ce44SJohn Forte
6546fcf3ce44SJohn Forte (void) memcpy(pwwn, &sf_map.sf_hba_addr.sf_port_wwn[0], WWN_SIZE);
6547fcf3ce44SJohn Forte
6548fcf3ce44SJohn Forte return (0);
6549fcf3ce44SJohn Forte }
6550fcf3ce44SJohn Forte
6551fcf3ce44SJohn Forte /*
6552fcf3ce44SJohn Forte * from_ptr: ptr to uchar_t array of size WWN_SIZE
6553fcf3ce44SJohn Forte * to_ptr: char ptr to string of size WWN_SIZE*2+1
6554fcf3ce44SJohn Forte */
6555fcf3ce44SJohn Forte void
copy_wwn_data_to_str(char * to_ptr,const uchar_t * from_ptr)6556fcf3ce44SJohn Forte copy_wwn_data_to_str(char *to_ptr, const uchar_t *from_ptr)
6557fcf3ce44SJohn Forte {
6558fcf3ce44SJohn Forte if ((to_ptr == NULL) || (from_ptr == NULL))
6559fcf3ce44SJohn Forte return;
6560fcf3ce44SJohn Forte
6561fcf3ce44SJohn Forte sprintf(to_ptr, "%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x%1.2x",
6562fcf3ce44SJohn Forte from_ptr[0], from_ptr[1], from_ptr[2], from_ptr[3],
6563fcf3ce44SJohn Forte from_ptr[4], from_ptr[5], from_ptr[6], from_ptr[7]);
6564fcf3ce44SJohn Forte }
6565fcf3ce44SJohn Forte
6566fcf3ce44SJohn Forte /*
6567fcf3ce44SJohn Forte * Frees a previously allocated mplist_struct
6568fcf3ce44SJohn Forte */
6569fcf3ce44SJohn Forte void
adm_mplist_free(struct mplist_struct * mplistp)6570fcf3ce44SJohn Forte adm_mplist_free(struct mplist_struct *mplistp)
6571fcf3ce44SJohn Forte {
6572fcf3ce44SJohn Forte struct mplist_struct *mplistn;
6573fcf3ce44SJohn Forte
6574fcf3ce44SJohn Forte while (mplistp != NULL) {
6575fcf3ce44SJohn Forte mplistn = mplistp->next;
6576fcf3ce44SJohn Forte if (mplistp->devpath != NULL) {
6577fcf3ce44SJohn Forte free(mplistp->devpath);
6578fcf3ce44SJohn Forte mplistp->devpath = NULL;
6579fcf3ce44SJohn Forte }
6580fcf3ce44SJohn Forte free(mplistp);
6581fcf3ce44SJohn Forte mplistp = mplistn;
6582fcf3ce44SJohn Forte }
6583fcf3ce44SJohn Forte }
6584fcf3ce44SJohn Forte
6585fcf3ce44SJohn Forte int
adm_reserve(char * path)6586fcf3ce44SJohn Forte adm_reserve(char *path)
6587fcf3ce44SJohn Forte {
6588fcf3ce44SJohn Forte char *path_phys = NULL;
6589fcf3ce44SJohn Forte int err;
6590fcf3ce44SJohn Forte if ((path_phys =
6591fcf3ce44SJohn Forte g_get_physical_name(path)) == NULL) {
6592fcf3ce44SJohn Forte
6593fcf3ce44SJohn Forte (void) fprintf(stderr, "%s: ", whoami);
6594fcf3ce44SJohn Forte (void) fprintf(stderr,
6595fcf3ce44SJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
6596fcf3ce44SJohn Forte path);
6597fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
6598fcf3ce44SJohn Forte return (1);
6599fcf3ce44SJohn Forte }
6600fcf3ce44SJohn Forte
6601fcf3ce44SJohn Forte if ((err = g_reserve(path_phys)) != 0) {
6602fcf3ce44SJohn Forte (void) print_errString(err, path);
6603fcf3ce44SJohn Forte return (1);
6604fcf3ce44SJohn Forte }
6605fcf3ce44SJohn Forte return (0);
6606fcf3ce44SJohn Forte }
6607fcf3ce44SJohn Forte
6608fcf3ce44SJohn Forte int
adm_release(char * path)6609fcf3ce44SJohn Forte adm_release(char *path)
6610fcf3ce44SJohn Forte {
6611fcf3ce44SJohn Forte char *path_phys = NULL;
6612fcf3ce44SJohn Forte int err;
6613fcf3ce44SJohn Forte if ((path_phys =
6614fcf3ce44SJohn Forte g_get_physical_name(path)) == NULL) {
6615fcf3ce44SJohn Forte
6616fcf3ce44SJohn Forte (void) fprintf(stderr, "%s: ", whoami);
6617fcf3ce44SJohn Forte (void) fprintf(stderr,
6618fcf3ce44SJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
6619fcf3ce44SJohn Forte path);
6620fcf3ce44SJohn Forte (void) fprintf(stderr, "\n");
6621fcf3ce44SJohn Forte return (1);
6622fcf3ce44SJohn Forte }
6623fcf3ce44SJohn Forte
6624fcf3ce44SJohn Forte if ((err = g_release(path_phys)) != 0) {
6625fcf3ce44SJohn Forte (void) print_errString(err, path);
6626fcf3ce44SJohn Forte return (1);
6627fcf3ce44SJohn Forte }
6628fcf3ce44SJohn Forte return (0);
6629fcf3ce44SJohn Forte }
6630fcf3ce44SJohn Forte
6631fcf3ce44SJohn Forte void
i18n_catopen()6632fcf3ce44SJohn Forte i18n_catopen() {
6633fcf3ce44SJohn Forte (void) g_i18n_catopen();
6634fcf3ce44SJohn Forte }
6635fcf3ce44SJohn Forte
adm_check_file(char ** path,int flag)6636fcf3ce44SJohn Forte int adm_check_file(char **path, int flag) {
6637fcf3ce44SJohn Forte int err;
6638fcf3ce44SJohn Forte if (err = l_check_file(*path, flag)) {
6639fcf3ce44SJohn Forte (void) print_errString(err, *path);
6640fcf3ce44SJohn Forte return (-1);
6641fcf3ce44SJohn Forte }
6642fcf3ce44SJohn Forte
6643fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2212, "Download file O.K. \n\n"));
6644fcf3ce44SJohn Forte return (0);
6645fcf3ce44SJohn Forte }
6646fcf3ce44SJohn Forte
6647fcf3ce44SJohn Forte /*
6648fcf3ce44SJohn Forte * Print out private loop dev dtype
6649fcf3ce44SJohn Forte */
6650fcf3ce44SJohn Forte void
print_private_loop_dtype_prop(uchar_t * hba_port_wwn,uchar_t * port_wwn,uchar_t dtype_prop)6651fcf3ce44SJohn Forte print_private_loop_dtype_prop(uchar_t *hba_port_wwn, uchar_t *port_wwn,
6652fcf3ce44SJohn Forte uchar_t dtype_prop)
6653fcf3ce44SJohn Forte {
6654fcf3ce44SJohn Forte if ((dtype_prop & DTYPE_MASK) < 0x10) {
6655fcf3ce44SJohn Forte (void) fprintf(stdout, " 0x%-2x (%s",
6656fcf3ce44SJohn Forte (dtype_prop & DTYPE_MASK), dtype[(dtype_prop & DTYPE_MASK)]);
6657fcf3ce44SJohn Forte } else if ((dtype_prop & DTYPE_MASK) < 0x1f) {
6658fcf3ce44SJohn Forte (void) fprintf(stdout,
6659fcf3ce44SJohn Forte MSGSTR(2243, " 0x%-2x (Reserved"),
6660fcf3ce44SJohn Forte (dtype_prop & DTYPE_MASK));
6661fcf3ce44SJohn Forte } else {
6662fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2245,
6663fcf3ce44SJohn Forte " 0x%-2x (Unknown Type"), (dtype_prop & DTYPE_MASK));
6664fcf3ce44SJohn Forte }
6665fcf3ce44SJohn Forte /* Check to see if this is the HBA */
6666fcf3ce44SJohn Forte if (wwnConversion(hba_port_wwn) == wwnConversion(port_wwn)) {
6667fcf3ce44SJohn Forte /* MATCH */
6668fcf3ce44SJohn Forte (void) fprintf(stdout, MSGSTR(2244,
6669fcf3ce44SJohn Forte ",Host Bus Adapter)\n"));
6670fcf3ce44SJohn Forte } else {
6671fcf3ce44SJohn Forte (void) fprintf(stdout, ")\n");
6672fcf3ce44SJohn Forte }
6673fcf3ce44SJohn Forte }
6674