4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * PHOTON CONFIGURATION MANAGER
32 * I18N message number ranges
33 * This file: 12500 - 12999
34 * Shared common messages: 1 - 1999
44 * Include any headers you depend on.
46 #include <sys/types.h>
47 #include <sys/scsi/adapters/scsi_vhci.h>
57 #define htonll(x) ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32))
58 #define ntohll(x) ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32))
62 extern char *p_error_msg_ptr
;
66 extern nl_catd l_catd
;
67 #define L_SET1 1 /* catalog set number */
68 #define MSGSTR(Num, Str) catgets(l_catd, L_SET1, Num, Str)
73 #define USEAGE() {(void) fprintf(stderr, MSGSTR(12500, \
74 "Usage: %s [-v] subcommand [option...]" \
75 " {enclosure[,dev]... | pathname...}\n"), \
77 (void) fflush(stderr); }
79 #define E_USEAGE() {(void) fprintf(stderr, MSGSTR(12501, \
80 "Usage: %s [-v] -e subcommand [option...]" \
81 " {enclosure[,dev]... | pathname...}\n"), \
83 (void) fflush(stderr); }
85 #define VERBPRINT if (Options & PVERBOSE) (void) printf
88 if (p_error_msg_ptr == NULL) { \
89 perror(MSGSTR(12502, "Error")); \
91 (void) fprintf(stderr, MSGSTR(12503, "Error: %s"), p_error_msg_ptr); \
93 p_error_msg_ptr = NULL;
95 #define P_ERR_PRINT if (p_error_msg_ptr == NULL) { \
98 (void) fprintf(stderr, MSGSTR(12504, "Error: %s"), p_error_msg_ptr); \
100 p_error_msg_ptr = NULL;
103 /* Display extended mode page information. */
104 #ifndef MODEPAGE_CACHING
105 #undef MODEPAGE_CACHING
106 #define MODEPAGE_CACHING 0x08
110 /* Primary commands */
111 #define ENCLOSURE_NAMES 100
114 #define FAST_WRITE 400 /* SSA */
116 #define FC_UPDATE 401 /* SSA */
117 #define FCAL_UPDATE 103 /* Update the Fcode on Sbus soc card */
118 #define FCODE_UPDATE 117 /* Update the Fcode on all cards */
119 #define QLGC_UPDATE 116 /* Update the Fcode on PCI card(s) */
124 #define LED_BLINK 110
125 #define NVRAM_DATA 402 /* SSA */
126 #define POWER_OFF 403 /* SSA */
129 #define PURGE 404 /* SSA */
130 #define PERF_STATISTICS 405 /* SSA */
136 #define SYNC_CACHE 406 /* SSA */
137 #define SET_BOOT_DEV 115 /* Set the boot-device variable in nvram */
138 #define INSERT_DEVICE 106 /* Hot plug */
139 #define REMOVE_DEVICE 114 /* hot plug */
141 /* Device hotplugging */
142 #define REPLACE_DEVICE 150
143 #define DEV_ONLINE 155
144 #define DEV_OFFLINE 156
145 #define DEV_GETSTATE 157
146 #define DEV_RESET 158
147 #define BUS_QUIESCE 160
148 #define BUS_UNQUIESCE 161
149 #define BUS_GETSTATE 162
150 #define BUS_RESET 163
151 #define BUS_RESETALL 164
156 #define L_LED_STATUS 0x00
157 #define L_LED_RQST_IDENTIFY 0x01
158 #define L_LED_ON 0x02
159 #define L_LED_OFF 0x04
162 /* Enclosure Specific */
163 #define ALARM 407 /* SSA */
164 #define ALARM_OFF 408 /* SSA */
165 #define ALARM_ON 409 /* SSA */
166 #define ALARM_SET 410 /* SSA */
167 #define ENV_DISPLAY 411 /* SSA */
169 /* Expert commands */
176 #define LUX_P_OFFLINE 223
177 #define LUX_P_ONLINE 224
178 #define EXT_LOOPBACK 225
179 #define INT_LOOPBACK 226
180 #define NO_LOOPBACK 227
181 #define CREATE_FAB 228
183 /* Undocumented commands */
185 #define CHECK_FILE 301 /* Undocumented - Check download file */
186 #define DUMP_MAP 302 /* Dump map of loop */
187 #define VERSION 303 /* undocumented */
188 #define AU 304 /* undocumented */
189 #define PORT 305 /* undocumented */
191 /* Undocumented diagnostic subcommands */
195 /* SSA - for adm_download */
196 /* #define SSAFIRMWARE_FILE "/usr/lib/firmware/ssa/ssafirmware" */
198 /* Global variables */
201 extern const int OPTION_A
;
202 extern const int OPTION_B
;
203 extern const int OPTION_C
;
204 extern const int OPTION_D
;
205 extern const int OPTION_E
;
206 extern const int OPTION_F
;
207 extern const int OPTION_L
;
208 extern const int OPTION_P
;
209 extern const int OPTION_R
;
210 extern const int OPTION_T
;
211 extern const int OPTION_V
;
212 extern const int OPTION_Z
;
213 extern const int OPTION_Y
;
214 extern const int OPTION_CAPF
;
215 extern const int PVERBOSE
;
216 extern const int SAVE
;
217 extern const int EXPERT
;
219 #define TARGET_ID(box_id, f_r, slot) \
220 ((box_id | ((f_r == 'f' ? 0 : 1) << 4)) | (slot + 2))
222 #define NEWER(time1, time2) (time1.tv_sec > time2.tv_sec)
224 /* used to set the behavior of get_slash_devices_from_osDevName. */
225 #define STANDARD_DEVNAME_HANDLING 1
226 #define NOT_IGNORE_DANGLING_LINK 2
230 #include <sys/scsi/generic/mode.h>
231 #include <sys/scsi/generic/sense.h>
232 #include <sys/scsi/impl/uscsi.h>
235 #include <l_common.h>
237 typedef struct l_inquiry_inq_2
{
238 #if defined(_BIT_FIELDS_HTOL)
239 uchar_t inq_2_reladdr
: 1, /* relative addressing */
240 inq_wbus32
: 1, /* 32 bit wide data xfers */
241 inq_wbus16
: 1, /* 16 bit wide data xfers */
242 inq_sync
: 1, /* synchronous data xfers */
243 inq_linked
: 1, /* linked commands */
244 inq_res1
: 1, /* reserved */
245 inq_cmdque
: 1, /* command queueing */
246 inq_sftre
: 1; /* Soft Reset option */
248 uchar_t inq_sftre
: 1, /* Soft Reset option */
249 inq_cmdque
: 1, /* command queueing */
250 inq_res1
: 1, /* reserved */
251 inq_linked
: 1, /* linked commands */
252 inq_sync
: 1, /* synchronous data xfers */
253 inq_wbus16
: 1, /* 16 bit wide data xfers */
254 inq_wbus32
: 1, /* 32 bit wide data xfers */
255 inq_2_reladdr
: 1; /* relative addressing */
256 #endif /* _BIT_FIELDS_HTOL */
259 typedef struct l_inquiry_inq_3
{
260 #if defined(_BIT_FIELDS_HTOL)
261 uchar_t inq_3_reladdr
: 1, /* relative addressing */
262 inq_SIP_2
: 3, /* Interlocked Protocol */
263 inq_3_linked
: 1, /* linked commands */
264 inq_trandis
: 1, /* Transfer Disable */
265 inq_3_cmdque
: 1, /* command queueing */
266 inq_SIP_3
: 1; /* Interlocked Protocol */
268 uchar_t inq_SIP_3
: 1, /* Interlocked Protocol */
269 inq_3_cmdque
: 1, /* command queueing */
270 inq_trandis
: 1, /* Transfer Disable */
271 inq_3_linked
: 1, /* linked commands */
272 inq_SIP_2
: 3, /* Interlocked Protocol */
273 inq_3_reladdr
: 1; /* relative addressing */
274 #endif /* _BIT_FIELDS_HTOL */
277 typedef struct l_inquiry_struct
{
281 * Bits 7-5 are the Peripheral Device Qualifier
282 * Bits 4-0 are the Peripheral Device Type
287 #if defined(_BIT_FIELDS_HTOL)
288 uchar_t inq_rmb
: 1, /* removable media */
289 inq_qual
: 7; /* device type qualifier */
291 uchar_t inq_qual
: 7, /* device type qualifier */
292 inq_rmb
: 1; /* removable media */
293 #endif /* _BIT_FIELDS_HTOL */
296 #if defined(_BIT_FIELDS_HTOL)
297 uchar_t inq_iso
: 2, /* ISO version */
298 inq_ecma
: 3, /* ECMA version */
299 inq_ansi
: 3; /* ANSI version */
301 uchar_t inq_ansi
: 3, /* ANSI version */
302 inq_ecma
: 3, /* ECMA version */
303 inq_iso
: 2; /* ISO version */
304 #endif /* _BIT_FIELDS_HTOL */
307 #define inq_aerc inq_aenc /* SCSI-3 */
308 #if defined(_BIT_FIELDS_HTOL)
309 uchar_t inq_aenc
: 1, /* async event notification cap. */
310 inq_trmiop
: 1, /* supports TERMINATE I/O PROC msg */
311 inq_normaca
: 1, /* Normal ACA Supported */
313 inq_rdf
: 4; /* response data format */
315 uchar_t inq_rdf
: 4, /* response data format */
317 inq_normaca
: 1, /* Normal ACA Supported */
318 inq_trmiop
: 1, /* supports TERMINATE I/O PROC msg */
319 inq_aenc
: 1; /* async event notification cap. */
320 #endif /* _BIT_FIELDS_HTOL */
323 uchar_t inq_len
; /* additional length */
324 uchar_t
: 8; /* reserved */
325 #if defined(_BIT_FIELDS_HTOL)
326 uchar_t
: 2, /* reserved */
327 inq_port
: 1, /* Only defined when dual_p set */
328 inq_dual_p
: 1, /* Dual Port */
329 inq_mchngr
: 1, /* Medium Changer */
330 inq_SIP_1
: 3; /* Interlocked Protocol */
332 uchar_t inq_SIP_1
: 3, /* Interlocked Protocol */
333 inq_mchngr
: 1, /* Medium Changer */
334 inq_dual_p
: 1, /* Dual Port */
335 inq_port
: 1, /* Only defined when dual_p set */
337 #endif /* _BIT_FIELDS_HTOL */
347 uchar_t inq_vid
[8]; /* vendor ID */
349 uchar_t inq_pid
[16]; /* product ID */
351 uchar_t inq_revision
[4]; /* product revision level */
354 * Bytes 36-55 are vendor-specific parameter bytes
357 /* SSA specific definitions */
359 #define inq_ven_specific_1 inq_firmware_rev
360 uchar_t inq_firmware_rev
[4]; /* firmware revision level */
363 uchar_t inq_serial
[12]; /* serial number, not used any more */
369 uchar_t inq_ssa_ports
; /* number of ports */
370 uchar_t inq_ssa_tgts
; /* number of targets */
373 * Bytes 56-95 are reserved.
375 uchar_t inq_res3
[40];
377 * 96 to 'n' are vendor-specific parameter bytes
379 uchar_t inq_box_name
[32];
380 uchar_t inq_avu
[256];
382 #define HEX_ONLY 0 /* Print Hex only */
383 #define HEX_ASCII 1 /* Print Hex and Ascii */
384 #define WWN_SIZE 8 /* # of bytes to dump per line */
386 /* NOTE: These command op codes are not defined in commands.h */
387 #define SCMD_SYNC_CACHE 0x35
388 #define SCMD_LOG_SENSE 0x4d
389 #define SCMD_PERS_RESERV_IN 0x5e
390 #define SCMD_PERS_RESERV_OUT 0x5f
392 typedef struct rls_payload
{
397 uint_t rls_primitiverr
;
398 uint_t rls_invalidword
;
399 uint_t rls_invalidcrc
;
402 typedef struct l_inquiry00_struct
{
403 #if defined(_BIT_FIELDS_LTOH)
409 #endif /* _BIT_FIELDS_LTOH */
413 uchar_t page_list
[251];
416 #define MIN(a, b) (a < b ? a : b)
417 #define ER_DPRINTF if (getenv("_LUX_ER_DEBUG") != NULL) (void) printf
418 #define O_DPRINTF if (getenv("_LUX_O_DEBUG") != NULL) (void) printf
419 #define P_DPRINTF if (getenv("_LUX_P_DEBUG") != NULL) (void) printf
420 #define R_DPRINTF if (getenv("_LUX_R_DEBUG") != NULL) (void) printf
421 #define I_DPRINTF if (getenv("_LUX_I_DEBUG") != NULL) (void) printf
422 #define S_DPRINTF if (getenv("_LUX_S_DEBUG") != NULL) (void) printf
423 #define RETRY_FCIO_IOCTL 360
424 #define WAIT_FCIO_IOCTL 250000 /* 1/4 of a second */
429 int adm_display_config(char **argv
);
430 void adm_download(char **argv
, char *file_name
);
431 void up_encl_name(char **argv
, int argc
);
432 void adm_failover(char **argv
);
434 void non_encl_probe();
435 void adm_led(char **argv
, int led_action
);
436 void up_password(char **argv
);
437 int adm_start(char **argv
);
438 int adm_stop(char **argv
);
439 int adm_power_off(char **argv
, int off_flag
);
440 int adm_forcelip(char **argv
);
441 void adm_bypass_enable(char **argv
, int bypass_flag
);
442 int adm_port_offline_online(char *argv
[], int flag
);
443 void display_link_status(char **argv
);
444 int read_repos_file(char *repos_filename
);
445 int adm_check_file(char **argv
, int flag
);
446 void dump(char **argv
);
447 void dump_map(char **argv
);
448 int adm_port_loopback(char *portpath
, int flag
);
449 int adm_inquiry(char **argv
);
450 int adm_display_port(int verbose
);
452 int adm_reserve(char *path
);
453 int adm_release(char *path
);
455 void dump_hex_data(char *, uchar_t
*, int, int);
456 void print_errString(int, char *);
457 void print_chars(uchar_t
*, int, int);
458 void print_inq_data(char *, char *, L_inquiry
, uchar_t
*, size_t);
459 void print_fabric_dtype_prop(uchar_t
*hba_port_wwn
, uchar_t
*port_wwn
,
461 void print_private_loop_dtype_prop(uchar_t
*hba_port_wwn
, uchar_t
*port_wwn
,
463 char *get_errString(int errornum
);
464 int cmp_raw_wwn(uchar_t
*wwn_1
, uchar_t
*wwn_2
);
466 /* routines in fchba*.c files */
467 int fchba_display_port(int verbose
);
468 int fchba_display_config(char **argv
, int option_t_input
, int argc
);
469 char *get_slash_devices_from_osDevName(char *osDevName
, int flag
);
470 int get_scsi_vhci_pathinfo(char *dev_path
, sv_iocdata_t
*ioc
,
472 int get_mode_page(char *path
, uchar_t
**pg_buf
);
473 int scsi_mode_sense_cmd(int fd
, uchar_t
*buf_ptr
, int buf_len
, uchar_t pc
,
475 int scsi_release(char *path
);
476 int scsi_reserve(char *path
);
477 int is_path(char *arg
);
478 int is_wwn(char *arg
);
480 uint32_t getNumberOfAdapters();
481 int getAdapterAttrs(HBA_HANDLE handle
,
482 char *name
, HBA_ADAPTERATTRIBUTES
*attrs
);
483 int getAdapterPortAttrs(HBA_HANDLE handle
, char *name
, int portIndex
,
484 HBA_PORTATTRIBUTES
*attrs
);
485 HBA_STATUS
fetch_mappings(HBA_HANDLE handle
, HBA_WWN pwwn
,
486 HBA_FCPTARGETMAPPINGV2
**map
);
487 int match_mappings(char *compare
, HBA_FCPTARGETMAPPINGV2
*map
);
488 uint64_t wwnConversion(uchar_t
*wwn
);
495 #endif /* _COMMON_H */