1/*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26/*
27 *	A5X00 Library definitions
28 */
29
30/*
31 * I18N message number ranges
32 *  This file: 16000 - 16499
33 *  Shared common messages: 1 - 1999
34 */
35
36#ifndef	_A5K_H
37#define	_A5K_H
38
39
40#ifdef	__cplusplus
41extern "C" {
42#endif
43
44
45/* Defines */
46#define	ENCLOSURE_PROD_ID	"SENA"
47#define	ENCLOSURE_PROD_NAME	"Network Array"
48#define		MAX_DRIVES_PER_BOX	22
49#define		MAX_DRIVES_DAK		12
50#define	L_WWN_LENGTH		16
51#define	BOX_ID_MASK		0x60
52#define	BOX_ID			0x0d
53#define	ALT_BOX_ID		0x10
54
55#define	MAX_IB_ELEMENTS		50
56#define	MAX_VEND_SPECIFIC_ENC	216
57#define	MAX_POSSIBLE_ELEMENTS	255
58
59#define	SET_RQST_INSRT	0
60#define	SET_RQST_RMV	1
61#define	OVERALL_STATUS	2
62#define	SET_FAULT	3
63#define	SET_DRV_ON	4
64#define	INSERT_DEVICE	106
65#define	REMOVE_DEVICE	114
66/* device specific identification for display, etc */
67#define	DAK_OFF_NAME	"Daktari official"  /* inq response, prod ident */
68#define	DAK_PROD_STR	"SUNWGS INT FCBPL"
69#define	UNDEF_ENC_TYPE	2
70#define	DAK_ENC_TYPE	1
71#define	SENA_ENC_TYPE	0
72
73
74/* Page defines */
75#define	L_PAGE_PAGE_LIST	0x00	/* Supported pages page */
76#define	L_PAGE_CONFIG		0x01	/* Configuration page */
77#define	L_PAGE_1		L_PAGE_CONFIG
78#define	L_PAGE_ENCL_CTL		0x02	/* Enclosure Control page */
79#define	L_PAGE_ENCL_STATUS	0x02	/* Enclosure status page */
80#define	L_PAGE_2		L_PAGE_ENCL_STATUS
81#define	L_PAGE_STRING		0x04
82#define	L_PAGE_4		L_PAGE_STRING
83#define	L_PAGE_7		0x07	/* Element Descriptor Page */
84
85#define	L_MAX_POSSIBLE_PAGES	255
86#define	L_MAX_SENAIB_PAGES	8
87
88/*
89 *	FRU types internal and external (host SES type)
90 */
91#define	ELM_TYP_NONE	0x0	/* Unspecified */
92#define	ELM_TYP_DD	0x01	/* Disk Drive - device */
93#define	ELM_TYP_PS	0x02	/* Power Supply */
94#define	ELM_TYP_FT	0x03	/* Fan Tray - cooling element */
95#define	ELM_TYP_TS	0x04	/* Temperature Sensors */
96#define	ELM_TYP_FP	0x0c	/* FPM screen - display */
97#define	ELM_TYP_KP	0x0d	/* keypad on FPM - keypad device */
98#define	ELM_TYP_FL	0x0f	/* Fibre Link module - SCSI port/trancvr */
99#define	ELM_TYP_LN	0x10	/* Language */
100#define	ELM_TYP_SP	0x11	/* Serial Port - communicaion port */
101#define	ELM_TYP_MB	0x80	/* Motherboard/Centerplane */
102#define	ELM_TYP_IB	0x81	/* IB(ESI) - controller electronics */
103#define	ELM_TYP_BP	0x82	/* BackPlane */
104#define	ELM_TYP_LO	0xa0	/* Loop Configuration */
105#define	ELM_TYP_OR	0xa2	/* Orientation */
106
107#define	S_HI_SPEED	0x5
108
109/* code (status code) definitions */
110#define	S_OK		0x01
111#define	S_CRITICAL	0x02
112#define	S_NONCRITICAL	0x03
113#define	S_NOT_INSTALLED	0x05
114#define	S_NOT_AVAILABLE	0x07
115
116/* String codes. */
117#define	L_WWN		0x01
118#define	L_PASSWORD	0x02
119#define	L_ENCL_NAME	0x03
120#define	L_BOX_ID	0x04
121#define	L_AUTO_LIP	0x05
122
123/* Loop states */
124#define	L_NO_LOOP		0x80	/* drive not accessable */
125#define	L_INVALID_WWN		0x100
126#define	L_INVALID_MAP		0x200
127#define	L_NO_PATH_FOUND		0x400
128
129/* d_state_flags definitions */
130#define	L_OK			0x00	/* NOTE: Must be zero. */
131#define	L_NOT_READY		0x01
132#define	L_NOT_READABLE		0x02
133#define	L_SPUN_DWN_D		0x04
134#define	L_RESERVED		0x08
135#define	L_OPEN_FAIL		0x10
136#define	L_NO_LABEL		0x20
137#define	L_SCSI_ERR		0x40
138
139/* Values used by the l_led function */
140#define	L_LED_STATUS		0x00
141#define	L_LED_RQST_IDENTIFY	0x01
142#define	L_LED_ON		0x02
143#define	L_LED_OFF		0x04
144
145/* Structure definitions */
146typedef	struct	box_list_struct {
147	uchar_t	prod_id_s[17];	/* NULL terminated string */
148	uchar_t	b_name[33];	/* NULL terminated string */
149	char	logical_path[MAXNAMELEN];
150	char	b_physical_path[MAXNAMELEN];
151	char	b_node_wwn_s[17];	/* NULL terminated string */
152	uchar_t	b_node_wwn[8];
153	char	b_port_wwn_s[17];	/* NULL terminated string */
154	uchar_t	b_port_wwn[8];
155	struct	box_list_struct	*box_prev;
156	struct	box_list_struct	*box_next;
157} Box_list;
158
159
160typedef	struct	path_struct {
161	char	*p_physical_path;
162	char	*argv;
163	int	slot_valid;	/* Slot valid flag. */
164	int	slot;
165	int	f_flag;		/* Front/rear flag. 1 = front */
166	int	ib_path_flag;
167} Path_struct;
168
169
170/*
171 * Page 0
172 */
173typedef	struct	ib_page_0 {
174	uchar_t		page_code;
175	uchar_t		sub_enclosures;
176	ushort_t	page_len;
177	uchar_t		sup_page_codes[0x100];
178} IB_page_0;
179
180/*
181 * Page 1
182 * Configuration page
183 */
184typedef	struct	type_desc_hdr {
185	uchar_t	type;
186	uchar_t	num;
187	uchar_t	sub_id;
188	uchar_t	text_len;
189} Type_desc_hdr;
190
191typedef	struct	type_desc_text {
192	uchar_t	text_element[256];
193} Type_desc_text;
194
195typedef	struct	ib_page_config {
196	uchar_t		page_code;
197	uchar_t		sub_enclosures;
198	ushort_t	page_len;
199	uint_t		gen_code;
200	/* Enclosure descriptor header */
201	uchar_t		enc_res;
202	uchar_t		enc_sub_id;
203	uchar_t		enc_num_elem;
204	uchar_t		enc_len;
205	/* Enclosure descriptor */
206	uchar_t		enc_node_wwn[8];
207	uchar_t		vend_id[8];
208	uchar_t		prod_id[16];
209	uchar_t		prod_revision[4];
210	uchar_t		res[MAX_VEND_SPECIFIC_ENC];
211	Type_desc_hdr	type_hdr[MAX_IB_ELEMENTS];
212	Type_desc_text	text[MAX_IB_ELEMENTS];
213} IB_page_config;
214
215
216/*
217 * Page 2
218 * Enclosure status/control page
219 */
220/*
221 * Loop Configuration.
222 */
223typedef struct	loop_element_status {
224	uchar_t			: 1,		/* reserved */
225		prd_fail	: 1,
226				: 2,		/* reserved */
227		code		: 4;
228	uchar_t			: 8;		/* reserved */
229	uchar_t			: 8;		/* reserved */
230	uchar_t			: 7,		/* reserved */
231		split		: 1;
232} Loop_elem_st;
233
234/*
235 * Language
236 */
237typedef struct	language_element_status {
238	uchar_t			: 1,		/* reserved */
239		prd_fail	: 1,
240				: 2,		/* reserved */
241		code		: 4;
242	uchar_t			: 8;		/* reserved */
243	ushort_t	language_code;
244} Lang_elem_st;
245
246/*
247 * Tranceiver status
248 */
249typedef struct	trans_element_status {
250	uchar_t			: 1,		/* reserved */
251		prd_fail	: 1,
252				: 2,		/* reserved */
253		code		: 4;
254	uchar_t			: 8;		/* reserved */
255	uchar_t			: 7,
256		report		: 1;
257	uchar_t			: 3,		/* reserved */
258		disabled	: 1,
259				: 2,
260		lol		: 1,
261		lsr_fail	: 1;
262} Trans_elem_st;
263
264/*
265 * ESI Controller status
266 */
267typedef struct	ctlr_element_status {
268	uchar_t			: 1,		/* reserved */
269		prd_fail	: 1,
270				: 2,		/* reserved */
271		code		: 4;
272	uchar_t			: 8;		/* reserved */
273	uchar_t			: 7,		/* reserved */
274		report		: 1;
275	uchar_t			: 4,		/* reserved */
276		overtemp_alart	: 1,
277				: 1,		/* reserved */
278		ib_loop_1_fail	: 1,
279		ib_loop_0_fail	: 1;
280} Ctlr_elem_st;
281
282/*
283 * Backplane status
284 */
285typedef struct	bp_element_status {
286	uchar_t	select		: 1,
287		prd_fail	: 1,
288				: 2,		/* reserved */
289		code		: 4;
290	uchar_t			: 8;		/* reserved */
291	uchar_t			: 8;		/* reserved */
292	uchar_t			: 3,		/* reserved */
293		disabled	: 1,
294		en_bypass_a	: 1,		/* Not in Spec. */
295		en_bypass_b	: 1,		/* Not in Spec. */
296		byp_a_enabled	: 1,
297		byp_b_enabled	: 1;
298
299} Bp_elem_st;
300
301/*
302 * Temperature sensor status
303 */
304typedef struct	temp_element_status {
305	uchar_t			: 1,		/* reserved */
306		prd_fail	: 1,
307				: 2,		/* reserved */
308		code		: 4;
309	uchar_t			: 8;		/* reserved */
310	char			degrees;
311	uchar_t			: 4,		/* reserved */
312		ot_fail		: 1,
313		ot_warn		: 1,
314		ut_fail		: 1,
315		ut_warn		: 1;
316} Temp_elem_st;
317
318typedef struct	fan_element_status {
319	uchar_t			: 1,		/* reserved */
320		prd_fail	: 1,
321				: 2,		/* reserved */
322		code		: 4;
323	uchar_t			: 8;		/* reserved */
324	uchar_t			: 8;		/* reserved */
325	uchar_t			: 1,		/* reserved */
326		fail		: 1,
327		rqsted_on	: 1,
328				: 2,
329		speed		: 3;
330} Fan_elem_st;
331
332
333typedef	struct	ps_element_status {
334	uchar_t			: 1,		/* reserved */
335		prd_fail	: 1,
336				: 1,		/* reserved */
337		swap		: 1,
338		code		: 4;
339	uchar_t			: 8;		/* reserved */
340	uchar_t			: 4,		/* reserved */
341		dc_over		: 1,
342		dc_under	: 1,
343		dc_over_i	: 1,
344				: 1;		/* reserved */
345	uchar_t			: 1,		/* reserved */
346		fail		: 1,
347		rqsted_on	: 1,
348				: 1,
349		ovrtmp_fail	: 1,
350		temp_warn	: 1,
351		ac_fail		: 1,
352		dc_fail		: 1;
353} Ps_elem_st;
354
355
356typedef	struct	device_element {
357	uchar_t	select		: 1,
358		prd_fail	: 1,
359		disable		: 1,
360		swap		: 1,
361		code		: 4;
362	uchar_t	sel_id;				/* Hard address */
363	uchar_t			: 1,
364		dont_remove	: 1,
365				: 2,
366		rdy_to_ins	: 1,
367		rmv		: 1,
368		ident		: 1,
369		report		: 1;
370	uchar_t			: 1,		/* reserved */
371		fault		: 1,
372		fault_req	: 1,
373		dev_off		: 1,
374		en_bypass_a	: 1,
375		en_bypass_b	: 1,
376		bypass_a_en	: 1,
377		bypass_b_en	: 1;
378} Dev_elem_st;
379
380
381typedef struct	interconnect_assem_status {
382	uchar_t			: 4,		/* reserved */
383		code		: 4;
384	uchar_t			: 8;		/* reserved */
385	uchar_t			: 8;		/* reserved */
386	uchar_t			: 7,		/* reserved */
387		eprom_fail	: 1;
388} Interconnect_st;
389
390
391typedef	struct	ib_page_2 {
392	uchar_t	page_code;
393	union {
394		uchar_t	res	: 3,	/* Reserved */
395			invop	: 1,
396			info	: 1,
397			non_crit	: 1,
398			crit	: 1,
399			unrec	: 1;
400		uchar_t	ab_cond;
401	} ui;
402	ushort_t	page_len;
403	uint_t		gen_code;
404	uint_t		element[MAX_POSSIBLE_ELEMENTS];
405} IB_page_2;
406
407/*
408 * Page 4
409 *
410 * String page.
411 */
412typedef	struct page4_name {
413	uchar_t		page_code;
414	uchar_t		: 8;		/* reserved */
415	ushort_t	page_len;
416	uchar_t		string_code;
417	uchar_t		: 7,
418			enable	: 1;
419	uchar_t		: 8;		/* reserved */
420	uchar_t		: 8;		/* reserved */
421	uchar_t		name[32];
422} Page4_name;
423
424
425typedef	struct	element_descriptor {
426	uchar_t		: 8;		/* reserved */
427	uchar_t		: 8;		/* reserved */
428	ushort_t	desc_len;
429	uchar_t		desc_string[0xff];
430} Elem_desc;
431
432
433typedef	struct	ib_page_7 {
434	uchar_t		page_code;
435	uchar_t		: 8;		/* reserved */
436	ushort_t	page_len;
437	uint_t		gen_code;
438	Elem_desc	element_desc[MAX_POSSIBLE_ELEMENTS];
439} IB_page_7;
440
441
442/* structure for IB */
443typedef struct ib_state_struct {
444	uchar_t	enclosure_name[33];	/* extra character is NULL */
445	IB_page_0	p0;
446	IB_page_config	config;		/* Enclosure configuration page */
447	IB_page_2	p2_s;		/* Enclosure status page */
448	IB_page_7	p7_s;		/* Element descriptor page */
449	int		res;
450	int		box_id;
451	struct dlist	*ib_multipath_list;
452} Ib_state;
453
454
455/* Individual SENA drive state */
456typedef struct l_disk_state_struct {
457	Dev_elem_st			ib_status;
458	int				l_state_flag;	/* Loop State */
459	struct g_disk_state_struct	g_disk_state;
460} L_disk_state;
461
462/*
463 *		State of the Photon
464 */
465typedef struct l_state_struct {
466	Ib_state	ib_tbl;	/* state of controller */
467
468	int		total_num_drv;
469	struct l_disk_state_struct	drv_front[MAX_DRIVES_PER_BOX/2];
470	struct l_disk_state_struct	drv_rear[MAX_DRIVES_PER_BOX/2];
471} L_state;
472
473
474/*
475 * Function Prototypes for the functions defined in libg_fc
476 * These are the functions that will be visible to an end user
477 * They are all CONTRACT PRIVATE
478 */
479
480#if defined(__STDC__)
481
482extern int	l_chk_null_wwn(Path_struct *, char *, L_state *, int);
483extern int	l_convert_name(char *, char **, struct path_struct **, int);
484extern int	l_dev_pwr_up_down(char *, struct path_struct *, int, int, int);
485extern int	l_device_present(char *, int, gfc_map_t *, int, char **);
486extern int	l_download(char *, char *, int, int);
487extern int	l_duplicate_names(Box_list *, char *, char *, int);
488extern int	l_encl_status_page_funcs(int, char *, int, char *,
489		struct l_state_struct  *, int, int, int);
490extern int	l_format_ifp_status_msg(char *, int, int);
491extern int	l_format_fc_status_msg(char *, int, int);
492extern void	l_free_box_list(struct box_list_struct **);
493extern int	l_free_lstate(L_state **);
494extern int	l_get_allses(char *, struct box_list_struct *, struct dlist **,
495		int);
496extern int	l_get_box_list(struct box_list_struct **, int);
497extern int	l_get_disk_element_index(struct l_state_struct *, int *, int *);
498extern int	l_get_disk_port_status(char *, struct l_disk_state_struct *,
499		int, int);
500extern int	l_get_disk_status(char *, struct l_disk_state_struct *,
501		WWN_list *, int);
502extern void	l_get_drive_name(char *, int, int, char *);
503extern int	l_get_envsen(char *, uchar_t *, int, int);
504extern int	l_get_envsen_page(int, uchar_t *, int, uchar_t, int);
505extern int	l_get_ib_status(char *, struct l_state_struct *, int);
506extern int	l_get_individual_state(char *, struct l_disk_state_struct *,
507		Ib_state *, int, struct box_list_struct *,
508		struct wwn_list_struct *, int);
509extern int	l_get_port(char *, int *, int);
510extern int	l_get_ses_path(char *, char *, gfc_map_t *, int);
511extern int	l_get_slot(struct path_struct *, L_state *, int);
512extern int	l_get_status(char *, struct l_state_struct *, int);
513extern int	l_led(struct path_struct *, int, struct device_element *, int);
514extern int	l_make_node(char *, int, char *, gfc_map_t *, int);
515extern int	l_new_name(char *, char *);
516extern int	l_offline_photon(struct hotplug_disk_list *,
517		struct wwn_list_struct *, int, int);
518extern int	l_get_enc_type(L_inquiry inq);
519extern int	l_pho_pwr_up_down(char *, char *, int, int, int);
520
521#else /* __STDC__ */
522
523
524extern int	l_chk_null_wwn();
525extern int	l_convert_name();
526extern int	l_dev_pwr_up_down();
527extern int	l_device_present();
528extern int	l_download();
529extern int	l_duplicate_names();
530extern int	l_encl_status_page_funcs();
531extern int	l_format_fc_status_msg();
532extern int	l_format_ifp_status_msg();
533extern void	l_free_box_list();
534extern int	l_free_lstate();
535extern int	l_get_allses();
536extern int	l_get_box_list();
537extern int	l_get_disk_element_index();
538extern int	l_get_disk_port_status();
539extern int	l_get_disk_status();
540extern void	l_get_drive_name();
541extern int	l_get_envsen();
542extern int	l_get_envsen_page();
543extern int	l_get_ib_status();
544extern int	l_get_individual_state();
545extern int	l_get_port();
546extern int	l_get_ses_path();
547extern int	l_get_slot();
548extern int	l_get_status();
549extern int	l_led();
550extern int	l_make_node();
551extern int	l_new_name();
552extern int	l_offline_photon();
553extern int	l_pho_pwr_up_down();
554extern int	l_get_enc_type();
555
556#endif /* __STDC__ */
557
558#ifdef	__cplusplus
559}
560#endif
561
562#endif	/* _A5K_H */
563