xref: /titanic_44/usr/src/uts/sun4u/starcat/sys/dman.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
1*03831d35Sstevel /*
2*03831d35Sstevel  * CDDL HEADER START
3*03831d35Sstevel  *
4*03831d35Sstevel  * The contents of this file are subject to the terms of the
5*03831d35Sstevel  * Common Development and Distribution License (the "License").
6*03831d35Sstevel  * You may not use this file except in compliance with the License.
7*03831d35Sstevel  *
8*03831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*03831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
10*03831d35Sstevel  * See the License for the specific language governing permissions
11*03831d35Sstevel  * and limitations under the License.
12*03831d35Sstevel  *
13*03831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*03831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*03831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*03831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*03831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*03831d35Sstevel  *
19*03831d35Sstevel  * CDDL HEADER END
20*03831d35Sstevel  */
21*03831d35Sstevel 
22*03831d35Sstevel /*
23*03831d35Sstevel  * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
24*03831d35Sstevel  * Use is subject to license terms.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel /*
28*03831d35Sstevel  * ****** NOTICE **** This header file is maintained in the SMS gate,
29*03831d35Sstevel  * ****** NOTICE **** the ON gate, and the ssc driver gate. Any changes
30*03831d35Sstevel  * ****** NOTICE **** to it must also be made to in all gates.
31*03831d35Sstevel  */
32*03831d35Sstevel 
33*03831d35Sstevel #ifndef	_DMAN_H
34*03831d35Sstevel #define	_DMAN_H
35*03831d35Sstevel 
36*03831d35Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
37*03831d35Sstevel 
38*03831d35Sstevel #ifdef __cplusplus
39*03831d35Sstevel extern "C" {
40*03831d35Sstevel #endif
41*03831d35Sstevel 
42*03831d35Sstevel /*
43*03831d35Sstevel  * Ethernet stuff
44*03831d35Sstevel  */
45*03831d35Sstevel 
46*03831d35Sstevel #define	ETHERHEADER_SIZE (sizeof (struct ether_header))
47*03831d35Sstevel typedef struct ether_header ehdr_t;
48*03831d35Sstevel typedef struct ether_addr eaddr_t;
49*03831d35Sstevel #define	IS_BROADCAST(eap) \
50*03831d35Sstevel 		(ether_cmp(eap, &etherbroadcast) == 0)
51*03831d35Sstevel #define	IS_MULTICAST(eap) \
52*03831d35Sstevel 		((eap->ether_addr_octet[0] & 01) == 1)
53*03831d35Sstevel #define	IS_UNICAST(eap) \
54*03831d35Sstevel 		(!IS_BROADCAST(eap) && !IS_MULTICAST(eap))
55*03831d35Sstevel 
56*03831d35Sstevel #define	MAN_IS_DATA(mp)		((DB_TYPE(mp) == M_DATA) ||		\
57*03831d35Sstevel 				    ((DB_TYPE(mp) == M_PROTO) &&	\
58*03831d35Sstevel 				    (DL_PRIM(mp) == DL_UNITDATA_IND)))
59*03831d35Sstevel 
60*03831d35Sstevel #define	MAN_ADDRL (sizeof (uint16_t) + ETHERADDRL)
61*03831d35Sstevel 
62*03831d35Sstevel /*
63*03831d35Sstevel  * Private	DLPI full dlsap address format - stolen from eri.h
64*03831d35Sstevel  */
65*03831d35Sstevel typedef struct  man_dladdr_s {
66*03831d35Sstevel 	struct  ether_addr	dl_phys;
67*03831d35Sstevel 	uint16_t		dl_sap;
68*03831d35Sstevel } man_dladdr_t;
69*03831d35Sstevel 
70*03831d35Sstevel #define	put_ether_type(ptr, value) {\
71*03831d35Sstevel 	((uint8_t *)(&((ehdr_t *)ptr)->ether_type))[0] = \
72*03831d35Sstevel 	    ((uint16_t)value & 0xff00) >> 8; \
73*03831d35Sstevel 	((uint8_t *)(&((ehdr_t *)ptr)->ether_type))[1] = (value & 0xff); }
74*03831d35Sstevel #define	ether_bcopy(a, b) (bcopy((caddr_t)a, (caddr_t)b, 6))
75*03831d35Sstevel 
76*03831d35Sstevel #define	MAN_MAX_EXPANDERS		18
77*03831d35Sstevel #define	MAN_MAX_DESTS			38 /* (MAN_NUM_EXPANDERS * 2) + 2 */
78*03831d35Sstevel #define	MAN_DEST_ARRAY_SIZE		(MAN_MAX_DESTS * sizeof (man_dest_t))
79*03831d35Sstevel #define	TRUE		1
80*03831d35Sstevel #define	FALSE		0
81*03831d35Sstevel 
82*03831d35Sstevel /*
83*03831d35Sstevel  * Caller IDs for man_sendit processing decision on canput failure.
84*03831d35Sstevel  */
85*03831d35Sstevel #define	MAN_UPPER	0x1
86*03831d35Sstevel #define	MAN_LOWER	0x2
87*03831d35Sstevel 
88*03831d35Sstevel /*
89*03831d35Sstevel  * MAN device information structure, one per man instance
90*03831d35Sstevel  *
91*03831d35Sstevel  * global list pointed to by MAN_XX_head
92*03831d35Sstevel  */
93*03831d35Sstevel typedef struct man_s {
94*03831d35Sstevel 	struct man_s	*man_next;		/* next in list of devices */
95*03831d35Sstevel 	dev_info_t	*man_dip;		/* devinfo for this device */
96*03831d35Sstevel 	int		man_meta_ppa;		/* mxx device minor */
97*03831d35Sstevel 	major_t		man_meta_major;		/* mxx device major # */
98*03831d35Sstevel 	struct man_pg_s	*man_pg;		/* Pathgroups for this inst */
99*03831d35Sstevel 	int		man_refcnt;		/* DL_ATTACHes to us */
100*03831d35Sstevel 	int		man_suspended;		/* DDI_SUSPEND on device */
101*03831d35Sstevel 	kstat_t		*man_ksp;		/* meta interface statistics */
102*03831d35Sstevel 	int		man_eaddr_v;		/* ether addr valid */
103*03831d35Sstevel 	eaddr_t		man_eaddr;		/* active ether addr */
104*03831d35Sstevel 	/*
105*03831d35Sstevel 	 * Failover timers, used by man_dest_t.
106*03831d35Sstevel 	 */
107*03831d35Sstevel 	int32_t		man_init_time;		/* init time in usecs */
108*03831d35Sstevel 	int32_t		man_linkcheck_time;	/* linkcheck time in usecs */
109*03831d35Sstevel 	int32_t		man_linkstale_time;	/* linkstale time in usecs */
110*03831d35Sstevel 	int32_t		man_linkstale_retries;	/* linkstale retries/probes */
111*03831d35Sstevel 	int32_t		man_dr_delay;		/* DR retry delay in usecs */
112*03831d35Sstevel 	int32_t		man_dr_retries;		/* DR retries on EAGAIN errs */
113*03831d35Sstevel 	int32_t		man_kstat_waittime;	/* kstat_wait time in usecs */
114*03831d35Sstevel 	int32_t		man_dlpireset_time;	/* dlpireset time in usecs */
115*03831d35Sstevel } man_t;
116*03831d35Sstevel 
117*03831d35Sstevel /*
118*03831d35Sstevel  * MAN link state definitions
119*03831d35Sstevel  */
120*03831d35Sstevel #define	MAN_LINKUNKNOWN		0x0
121*03831d35Sstevel #define	MAN_LINKINIT		0x1
122*03831d35Sstevel #define	MAN_LINKGOOD		0x2
123*03831d35Sstevel #define	MAN_LINKSTALE		0x3
124*03831d35Sstevel #define	MAN_LINKFAIL		0x4
125*03831d35Sstevel 
126*03831d35Sstevel /*
127*03831d35Sstevel  * MAN timer types and times.
128*03831d35Sstevel  */
129*03831d35Sstevel #define	MAN_TIMER_INIT		0x1
130*03831d35Sstevel #define	MAN_TIMER_LINKCHECK	0x2
131*03831d35Sstevel #define	MAN_TIMER_DLPIRESET	0x4
132*03831d35Sstevel #define	MAN_INIT_TIME		1000000		/* 1 sec in usecs */
133*03831d35Sstevel #define	MAN_LINKCHECK_TIME	30000000	/* 30 secs in usecs */
134*03831d35Sstevel #define	MAN_LINKSTALE_TIME	1000000		/* 1 secs in usecs */
135*03831d35Sstevel #define	MAN_LINKSTALE_RETRIES	10		/* send 10 probes */
136*03831d35Sstevel #define	MAN_KSTAT_WAITTIME	300000		/* 0.3 secs in usecs */
137*03831d35Sstevel #define	MAN_DLPIRESET_TIME	5000000		/* 5 secs in usecs */
138*03831d35Sstevel #define	MAN_MAX_DLPIERRORS	10		/* 10 dlpi errors */
139*03831d35Sstevel 
140*03831d35Sstevel /*
141*03831d35Sstevel  * MAN DR variables
142*03831d35Sstevel  */
143*03831d35Sstevel #define	MAN_DR_DELAY		200000		/* 1/5th sec in usecs */
144*03831d35Sstevel #define	MAN_DR_RETRIES		150		/* DR retries on EAGAIN errs */
145*03831d35Sstevel 
146*03831d35Sstevel /*
147*03831d35Sstevel  * Device info - this must stay 64 bit aligned.
148*03831d35Sstevel  */
149*03831d35Sstevel typedef struct md_s {
150*03831d35Sstevel 	major_t		mdev_major;	/* Driver major */
151*03831d35Sstevel 	uint32_t	mdev_ppa;	/* Driver instance */
152*03831d35Sstevel 	uint32_t	mdev_exp_id;	/* Containing expander in domain */
153*03831d35Sstevel 	uint32_t	mdev_state;	/* Device state */
154*03831d35Sstevel } man_dev_t;
155*03831d35Sstevel 
156*03831d35Sstevel /*
157*03831d35Sstevel  * mdev_state definitions
158*03831d35Sstevel  */
159*03831d35Sstevel #define	MDEV_UNASSIGNED		0x0	/* Path assigned to a destination */
160*03831d35Sstevel #define	MDEV_ASSIGNED		0x1	/* Path assigned to a destination */
161*03831d35Sstevel #define	MDEV_ACTIVE		0x2	/* Path actively in use for dest */
162*03831d35Sstevel #define	MDEV_FAILED		0x4	/* Failure detected in past. */
163*03831d35Sstevel 
164*03831d35Sstevel /*
165*03831d35Sstevel  * MAN lower multiplexor data structure
166*03831d35Sstevel  */
167*03831d35Sstevel typedef struct man_dest_s {
168*03831d35Sstevel 	uint_t		md_state;	/* state of this destination */
169*03831d35Sstevel 	struct manstr_s	*md_msp;	/* containing upper STREAM structure */
170*03831d35Sstevel 	queue_t		*md_rq;		/* upper read queue */
171*03831d35Sstevel 	queue_t		*md_wq;		/* lower write queue  for active path */
172*03831d35Sstevel 	man_dev_t	md_device;	/* Device from active path. */
173*03831d35Sstevel 	int		md_pg_id;	/* pathgroup for destination */
174*03831d35Sstevel 	eaddr_t		md_dst_eaddr;	/* Destinations ether address */
175*03831d35Sstevel 	eaddr_t		md_src_eaddr;	/* Our ether address */
176*03831d35Sstevel 	int		md_dlpistate;	/* DLPI State of netdev below us */
177*03831d35Sstevel 	int		md_muxid;	/* muxid of netdev linked below us */
178*03831d35Sstevel 	void *		md_switch_id;	/* ID of switch request */
179*03831d35Sstevel 	kmutex_t	md_lock;	/* Lock for md_dmp_* */
180*03831d35Sstevel 	mblk_t		*md_dmp_head;	/* deferred mblk list head */
181*03831d35Sstevel 	mblk_t		*md_dmp_tail;	/* deferred mblk list tail */
182*03831d35Sstevel 	size_t		 md_dmp_count;	/* bytes in deferred mblk list */
183*03831d35Sstevel 	ulong_t		md_switches;	/* # of failover switches */
184*03831d35Sstevel 	time_t		md_lastswitch;	/* time of last switch */
185*03831d35Sstevel 	timeout_id_t	md_bc_id;	/* qbufcall timeout id */
186*03831d35Sstevel 	/*
187*03831d35Sstevel 	 * Failover variables, only valid for active path.
188*03831d35Sstevel 	 */
189*03831d35Sstevel 	timeout_id_t	md_lc_timer_id;		/* qtimeout ID */
190*03831d35Sstevel 	int		md_linkstate;		/* link state */
191*03831d35Sstevel 	ulong_t		md_lastrcvcnt;		/* snapshot of packet count */
192*03831d35Sstevel 	ulong_t		md_rcvcnt;		/* current packet count */
193*03831d35Sstevel 	ulong_t		md_linkfails;		/* # of AP link failures */
194*03831d35Sstevel 	ulong_t		md_linkstales;		/* # of AP link stales */
195*03831d35Sstevel 	int32_t		md_linkstale_retries;	/* # of probes to send */
196*03831d35Sstevel 	ulong_t		md_icmpv4probes;	/* # of ICMPv4 probes sent */
197*03831d35Sstevel 	ulong_t		md_icmpv6probes;	/* # of ICMPv6 probes sent */
198*03831d35Sstevel 	int		md_link_updown_msg;	/* Last up/down message */
199*03831d35Sstevel 	int		md_dlpierrors;		/* # of DLPI errors */
200*03831d35Sstevel } man_dest_t;
201*03831d35Sstevel 
202*03831d35Sstevel /*
203*03831d35Sstevel  * md_state values
204*03831d35Sstevel  */
205*03831d35Sstevel #define	MAN_DSTATE_NOTPRESENT	0x0	/* Destination doesnt exist */
206*03831d35Sstevel #define	MAN_DSTATE_INITIALIZING	0x1	/* Initialize lower stream for dest */
207*03831d35Sstevel #define	MAN_DSTATE_READY	0x2	/* Destination lower stream exists */
208*03831d35Sstevel #define	MAN_DSTATE_PLUMBING	0x4	/* lower stream being switched */
209*03831d35Sstevel #define	MAN_DSTATE_CLOSING	0x8	/* lower stream closing */
210*03831d35Sstevel #define	MAN_DSTATE_BUSY		(MAN_DSTATE_PLUMBING|MAN_DSTATE_CLOSING)
211*03831d35Sstevel 
212*03831d35Sstevel /*
213*03831d35Sstevel  * md_link_updwon_msg states.
214*03831d35Sstevel  */
215*03831d35Sstevel #define	MAN_LINK_UP_MSG		0x0	/* Last msg emitted was "Link up" */
216*03831d35Sstevel #define	MAN_LINK_DOWN_MSG	0x1	/* Last msg emitted was "Link down" */
217*03831d35Sstevel 
218*03831d35Sstevel /*
219*03831d35Sstevel  * Upper per-stream instance state information.
220*03831d35Sstevel  *
221*03831d35Sstevel  * Each instance is dynamically allocated at open() and free'd at close().
222*03831d35Sstevel  * Each per-stream instance points to at most one per-device structure
223*03831d35Sstevel  * using the ms_manp field.  All instances are threaded together into one
224*03831d35Sstevel  * list of active instances ordered on sequence of opens.
225*03831d35Sstevel  */
226*03831d35Sstevel typedef struct manstr_s {
227*03831d35Sstevel 	struct manstr_s	*ms_next;	/* next in list of streams */
228*03831d35Sstevel 	man_t		*ms_manp;	/* MAN device info pointer */
229*03831d35Sstevel 	man_dest_t	*ms_destp;	/* Optimization if only one ms_dests */
230*03831d35Sstevel 	man_dest_t	*ms_dests;	/* lower streams */
231*03831d35Sstevel 	int		ms_flags;	/* State for this MAN upper stream */
232*03831d35Sstevel 	queue_t		*ms_rq;		/* MAN upper read queue */
233*03831d35Sstevel 	int		ms_minor;	/* minor number of this stream */
234*03831d35Sstevel 	t_uscalar_t	ms_sap;		/* SAP bound to (if DL_BOUND) */
235*03831d35Sstevel 	int		ms_dlpistate;	/* DLPI State of this MAN instance */
236*03831d35Sstevel 	major_t		ms_meta_maj;	/* mxx device major # */
237*03831d35Sstevel 	int		ms_meta_ppa;	/* mxx device minor # */
238*03831d35Sstevel 	mblk_t		*ms_dl_mp;	/* list of DLPI ATTACH/BIND rqsts */
239*03831d35Sstevel 	mblk_t		*ms_dlioc_mp;	/* list of DL_IOC rqsts */
240*03831d35Sstevel 	uint_t		ms_dp;		/* # of pending DL_DETACH_REQs */
241*03831d35Sstevel 	ulong_t		ms_switches;	/* number of switches so far	*/
242*03831d35Sstevel } manstr_t;
243*03831d35Sstevel 
244*03831d35Sstevel /*
245*03831d35Sstevel  * ms_flags values.
246*03831d35Sstevel  */
247*03831d35Sstevel #define	MAN_SFLAG_FAST		0x1	/* M_DATA fastpath mode */
248*03831d35Sstevel #define	MAN_SFLAG_RAW		0x2	/* M_DATA plain raw mode */
249*03831d35Sstevel #define	MAN_SFLAG_ALLPHYS	0x4	/* promiscuous mode */
250*03831d35Sstevel #define	MAN_SFLAG_ALLMULTI	0x8	/* enable all multicast addresses */
251*03831d35Sstevel #define	MAN_SFLAG_ALLSAP	0x10	/* enable all ether type values */
252*03831d35Sstevel #define	MAN_SFLAG_CKSUM		0x20	/* enable hardware tcp checksumming */
253*03831d35Sstevel #define	MAN_SFLAG_MULTI		0x40	/* enable multicast addresses */
254*03831d35Sstevel #define	MAN_SFLAG_SERLPBK	0x80	/* enable SERDES looopback (DIAG) */
255*03831d35Sstevel #define	MAN_SFLAG_MACLPBK	0x100	/* enable MAC int loopback (DIAG) */
256*03831d35Sstevel 
257*03831d35Sstevel #define	MAN_SFLAG_PROMISC	(MAN_SFLAG_ALLPHYS|MAN_SFLAG_ALLMULTI| \
258*03831d35Sstevel 					MAN_SFLAG_ALLSAP)
259*03831d35Sstevel #define	MAN_SFLAG_CLOSING	0x200	/* Stream in process of closing */
260*03831d35Sstevel #define	MAN_SFLAG_CLOSE_DONE	0x400	/* Stream in process of closing */
261*03831d35Sstevel #define	MAN_SFLAG_CONTROL	0x800	/* Stream is control stream */
262*03831d35Sstevel 
263*03831d35Sstevel /*
264*03831d35Sstevel  * Paths in pathgroup lists.
265*03831d35Sstevel  */
266*03831d35Sstevel typedef struct mpa_s {
267*03831d35Sstevel 	struct mpa_s	*mp_next;	/* Next in linked list */
268*03831d35Sstevel 	man_dev_t	mp_device;	/* Device for this path */
269*03831d35Sstevel 	kstat_named_t	*mp_last_knp;	/* last named kstats from mp_phys_ksp */
270*03831d35Sstevel 	time_t		mp_lru;		/* Last time used */
271*03831d35Sstevel } man_path_t;
272*03831d35Sstevel 
273*03831d35Sstevel /*
274*03831d35Sstevel  * Pathgroup list, one per destination ID. Each pathgroup connects
275*03831d35Sstevel  * to one destination. Hence we put that destination ethernet address
276*03831d35Sstevel  * here. It is read from here and stored in man_dest_t.md_dst_eaddr
277*03831d35Sstevel  * each time a new path is switched to.
278*03831d35Sstevel  */
279*03831d35Sstevel typedef struct man_pg_s {
280*03831d35Sstevel 	struct man_pg_s		*mpg_next;
281*03831d35Sstevel 	int			mpg_flags;
282*03831d35Sstevel 	uint_t			mpg_pg_id;
283*03831d35Sstevel 	uint_t			mpg_man_ppa;	/* MAN instance for pathgroup */
284*03831d35Sstevel 	eaddr_t			mpg_dst_eaddr;
285*03831d35Sstevel 	man_path_t		*mpg_pathp;
286*03831d35Sstevel } man_pg_t;
287*03831d35Sstevel /*
288*03831d35Sstevel  *  mpg_pg_flags fields.
289*03831d35Sstevel  */
290*03831d35Sstevel #define	MAN_PG_IDLE		0x0
291*03831d35Sstevel #define	MAN_PG_SWITCHING	0x1
292*03831d35Sstevel 
293*03831d35Sstevel /*
294*03831d35Sstevel  * MAN IOCTL Definitions.
295*03831d35Sstevel  */
296*03831d35Sstevel #define	MIOC			('M'<< 16)
297*03831d35Sstevel #define	MAN_SETPATH		(MIOC|0x1)
298*03831d35Sstevel #define	MAN_GETEADDR		(MIOC|0x2)
299*03831d35Sstevel #define	MAN_SET_LINKCHECK_TIME	(MIOC|0x3)
300*03831d35Sstevel #define	MAN_SET_SC_IPADDRS	(MIOC|0x4)
301*03831d35Sstevel #define	MAN_SET_SC_IP6ADDRS	(MIOC|0x8)
302*03831d35Sstevel 
303*03831d35Sstevel /*
304*03831d35Sstevel  * Pathgroup assignment data structure - this must stay 64 bit aligned.
305*03831d35Sstevel  */
306*03831d35Sstevel typedef struct mi_path_t {
307*03831d35Sstevel 	uchar_t		mip_cmd;	/* Cmd for this pathgroup */
308*03831d35Sstevel 	uchar_t		pad1[3];
309*03831d35Sstevel 	uint32_t	mip_man_ppa;	/* Man instance to apply cmd to */
310*03831d35Sstevel 	uint32_t	mip_pg_id;	/* pathgroup ID this path is for */
311*03831d35Sstevel 	eaddr_t		mip_eaddr;	/* Eaddr for this destination */
312*03831d35Sstevel 	uchar_t		pad2[2];
313*03831d35Sstevel 	man_dev_t	mip_devs[MAN_MAX_DESTS]; /* Array of devices */
314*03831d35Sstevel 	uint32_t	mip_ndevs;	/* #devs at mip_devs */
315*03831d35Sstevel } mi_path_t;
316*03831d35Sstevel 
317*03831d35Sstevel #define	MI_PATH_READ		0x0	/* Fill in devs for destID */
318*03831d35Sstevel #define	MI_PATH_ASSIGN		0x1	/* Assign devs for destID */
319*03831d35Sstevel #define	MI_PATH_ACTIVATE	0x2	/* Mark a dev as active for destID */
320*03831d35Sstevel #define	MI_PATH_DEACTIVATE	0x3	/* Deactivate active dev for destID */
321*03831d35Sstevel #define	MI_PATH_UNASSIGN	0x4	/* Unassign assigned dev for destID */
322*03831d35Sstevel #define	MI_PATH_ADD		0x5	/* Just Add devs for destID */
323*03831d35Sstevel 
324*03831d35Sstevel /*
325*03831d35Sstevel  * Linkcheck time assignment data structure - this must stay 64 bit aligned.
326*03831d35Sstevel  */
327*03831d35Sstevel typedef struct mi_time_t {
328*03831d35Sstevel 	int32_t		mtp_man_ppa;	/* Man instance to apply cmd to */
329*03831d35Sstevel 	int32_t		mtp_time;	/* Time in usecs to */
330*03831d35Sstevel } mi_time_t;
331*03831d35Sstevel 
332*03831d35Sstevel /*
333*03831d35Sstevel  * SC IP address assignment data structure. See man_pinger().
334*03831d35Sstevel  */
335*03831d35Sstevel typedef struct man_sc_ipaddrs_s {
336*03831d35Sstevel 	in_addr_t	ip_other_sc_ipaddr;
337*03831d35Sstevel 	in_addr_t	ip_my_sc_ipaddr;
338*03831d35Sstevel } man_sc_ipaddrs_t;
339*03831d35Sstevel 
340*03831d35Sstevel /*
341*03831d35Sstevel  * SC IPv6 address assignment data structure. See man_pinger().
342*03831d35Sstevel  */
343*03831d35Sstevel typedef struct man_sc_ip6addrs_s {
344*03831d35Sstevel 	in6_addr_t	ip6_other_sc_ipaddr;
345*03831d35Sstevel 	in6_addr_t	ip6_my_sc_ipaddr;
346*03831d35Sstevel } man_sc_ip6addrs_t;
347*03831d35Sstevel 
348*03831d35Sstevel /*
349*03831d35Sstevel  * Array of dests to apply operation to.
350*03831d35Sstevel  */
351*03831d35Sstevel typedef struct man_adest_s {
352*03831d35Sstevel 	int		a_man_ppa;	/* man instance */
353*03831d35Sstevel 	int		a_pg_id;	/* pg_id of dests */
354*03831d35Sstevel 	uint32_t	a_exp_id;	/* Used for DR requests */
355*03831d35Sstevel 	man_dev_t	a_sf_dev;	/* Switch from device */
356*03831d35Sstevel 	man_dev_t	a_st_dev;	/* Switch to device */
357*03831d35Sstevel 	man_dest_t	*a_mdp;		/* array of dests for mw_type */
358*03831d35Sstevel 	uint_t		a_ndests;	/* size of array */
359*03831d35Sstevel } man_adest_t;
360*03831d35Sstevel 
361*03831d35Sstevel /*
362*03831d35Sstevel  * work structure for MAN background thread.
363*03831d35Sstevel  */
364*03831d35Sstevel typedef struct man_work_s {
365*03831d35Sstevel 	struct	man_work_s	*mw_next;	/* next request on q */
366*03831d35Sstevel 	queue_t			*mw_q;		/* For qwait-ers */
367*03831d35Sstevel 	int			mw_type;	/* work request type */
368*03831d35Sstevel 	int			mw_flags;	/* asycn/sync flags */
369*03831d35Sstevel 	int			mw_status;	/* Status of work request */
370*03831d35Sstevel 	man_adest_t		mw_arg;		/* work argument */
371*03831d35Sstevel 	kcondvar_t		mw_cv;		/* sender sleeps here */
372*03831d35Sstevel } man_work_t;
373*03831d35Sstevel 
374*03831d35Sstevel /*
375*03831d35Sstevel  * Values for mw_flags
376*03831d35Sstevel  */
377*03831d35Sstevel #define	MAN_WFLAGS_NOWAITER	0x0
378*03831d35Sstevel #define	MAN_WFLAGS_CVWAITER	0x1
379*03831d35Sstevel #define	MAN_WFLAGS_QWAITER	0x2
380*03831d35Sstevel #define	MAN_WFLAGS_DONE		0x4
381*03831d35Sstevel 
382*03831d35Sstevel /*
383*03831d35Sstevel  * Values for mw_type.
384*03831d35Sstevel  */
385*03831d35Sstevel #define	MAN_WORK_OPEN_CTL	0x0	/* Open the control stream */
386*03831d35Sstevel #define	MAN_WORK_CLOSE_CTL	0x1	/* Open the control stream */
387*03831d35Sstevel #define	MAN_WORK_SWITCH		0x2	/* Dest requests switch to new path */
388*03831d35Sstevel #define	MAN_WORK_PATH_UPDATE	0x3	/* pathgrp info changed, update dests */
389*03831d35Sstevel #define	MAN_WORK_CLOSE		0x4	/* Close destinations */
390*03831d35Sstevel #define	MAN_WORK_CLOSE_STREAM	0x5	/* man_close()-ing upper stream */
391*03831d35Sstevel #define	MAN_WORK_DRATTACH	0x6	/* DR attached new IO board */
392*03831d35Sstevel #define	MAN_WORK_DRDETACH	0x7	/* DR detached an IO board */
393*03831d35Sstevel #define	MAN_WORK_STOP		0x8	/* Stop and exit */
394*03831d35Sstevel #define	MAN_WORK_DRSWITCH	0x9	/* Switch path prior to DRDETACH */
395*03831d35Sstevel #define	MAN_WORK_KSTAT_UPDATE	0xA	/* Take kstat snapshot */
396*03831d35Sstevel 
397*03831d35Sstevel #define	MAN_IDNUM	(13138)		/* module ID number */
398*03831d35Sstevel #define	MAN_MINPSZ	(0)		/* min packet size */
399*03831d35Sstevel #define	MAN_MAXPSZ	(INFPSZ)	/* max packet size */
400*03831d35Sstevel #define	MAN_HIWAT	(64 * 1024)	/* hi-water mark */
401*03831d35Sstevel #define	MAN_LOWAT	(1)		/* lo-water mark */
402*03831d35Sstevel #define	MAN_MEDIA	"Ethernet"	/* media type */
403*03831d35Sstevel 
404*03831d35Sstevel /*
405*03831d35Sstevel  * State definitions for man_config_state
406*03831d35Sstevel  */
407*03831d35Sstevel #define	MAN_UNCONFIGURED	0x0		/* Attached but never opened */
408*03831d35Sstevel #define	MAN_CONFIGURING		0x1		/* First open */
409*03831d35Sstevel #define	MAN_CONFIGURED		0x2		/* Done configuring */
410*03831d35Sstevel #define	MAN_FINI		0x3		/* cv_waiting in _fini() */
411*03831d35Sstevel 
412*03831d35Sstevel /*
413*03831d35Sstevel  * IOSRAM definitions
414*03831d35Sstevel  */
415*03831d35Sstevel #define	MANC_VERSION		0x1
416*03831d35Sstevel #define	IOSRAM_KEY_MANC		(('M'<<24)|('A'<<16)|('N'<<8)|'C')
417*03831d35Sstevel #define	IOSRAM_KEY_SCMD		(('S'<<24)|('C'<<16)|('M'<<8)|'D')
418*03831d35Sstevel #define	IOSRAM_KEY_MDSC		(('M'<<24)|('D'<<16)|('S'<<8)|'C')
419*03831d35Sstevel #define	MAN_IOSRAM_TIMEOUT	10000		/* 10 secs in ms */
420*03831d35Sstevel 
421*03831d35Sstevel typedef struct manc_s {
422*03831d35Sstevel 	uint32_t	manc_magic;		/* MANC_MAGIC */
423*03831d35Sstevel 	uint32_t	manc_version;		/* MANC_VERSION */
424*03831d35Sstevel 	uint32_t	manc_csum;		/* TBD */
425*03831d35Sstevel 	int		manc_ip_type;		/* AF_INET or AF_INET6 */
426*03831d35Sstevel 	in_addr_t	manc_dom_ipaddr;	/* Domains IP address */
427*03831d35Sstevel 	in_addr_t	manc_dom_ip_netmask;	/* Domains IP netmask */
428*03831d35Sstevel 	in_addr_t	manc_sc_ipaddr;		/* SC's IP address */
429*03831d35Sstevel 	in6_addr_t	manc_dom_ipv6addr;	/* Domain's IPv6 address */
430*03831d35Sstevel 	in6_addr_t	manc_dom_ipv6_netmask;	/* Domain's IPv6 netmask */
431*03831d35Sstevel 	in6_addr_t	manc_sc_ipv6addr;	/* SC's IPv6 address */
432*03831d35Sstevel 	eaddr_t		manc_dom_eaddr;		/* 48 bit ethernet address */
433*03831d35Sstevel 	eaddr_t		manc_sc_eaddr;		/* 48 bit ethernet address */
434*03831d35Sstevel 	uint32_t	manc_iob_bitmap;	/* initial ioboard list */
435*03831d35Sstevel 	uchar_t		manc_golden_iob;	/* post selected ioboard */
436*03831d35Sstevel } manc_t;
437*03831d35Sstevel 
438*03831d35Sstevel 
439*03831d35Sstevel typedef struct man_mb_s {
440*03831d35Sstevel 	uint32_t		mb_status;
441*03831d35Sstevel 	uint32_t		mb_exp_id;
442*03831d35Sstevel } man_mbox_msg_t;
443*03831d35Sstevel 
444*03831d35Sstevel typedef struct ml_s {
445*03831d35Sstevel 	struct ml_s	*l_next;
446*03831d35Sstevel 	int		l_muxid;
447*03831d35Sstevel 	queue_t		*l_rq;
448*03831d35Sstevel 	queue_t		*l_wq;
449*03831d35Sstevel } man_linkrec_t;
450*03831d35Sstevel 
451*03831d35Sstevel typedef struct man_workq_s {
452*03831d35Sstevel 	man_work_t	*q_work;
453*03831d35Sstevel 	kcondvar_t	q_cv;
454*03831d35Sstevel 	bufcall_id_t	*q_id;
455*03831d35Sstevel } man_workq_t;
456*03831d35Sstevel 
457*03831d35Sstevel /*
458*03831d35Sstevel  * PCI stuff.
459*03831d35Sstevel  */
460*03831d35Sstevel 
461*03831d35Sstevel /*
462*03831d35Sstevel  * Misc defines
463*03831d35Sstevel  */
464*03831d35Sstevel #define	MAN_DDI_BUFLEN		128
465*03831d35Sstevel #define	MAN_DEVTYPE_PROP	"device_type"
466*03831d35Sstevel #define	MAN_REG_PROP		"reg"
467*03831d35Sstevel #define	MAN_PORTID_PROP		"portid"
468*03831d35Sstevel #define	MAN_DEVTYPE_PCI		"pci"
469*03831d35Sstevel #define	MAN_PCI_B_CSR_BASE	0x00700000
470*03831d35Sstevel #define	MAN_SCHIZO_MASK		0xF
471*03831d35Sstevel #define	MAN_SCHIZO_0_ID		0xC
472*03831d35Sstevel 
473*03831d35Sstevel /* ------------------------------------------------------------------------- */
474*03831d35Sstevel /*
475*03831d35Sstevel  * Patchable debug flag.
476*03831d35Sstevel  * Set this to nonzero to enable error messages.
477*03831d35Sstevel  */
478*03831d35Sstevel 
479*03831d35Sstevel /*
480*03831d35Sstevel  * The following parameters may be configured by the user. If they are not
481*03831d35Sstevel  * configured by the user, the values will be based on the capabilities of
482*03831d35Sstevel  * the transceiver.
483*03831d35Sstevel  * The value "MAN_NOTUSR" is ORed with the parameter value to indicate values
484*03831d35Sstevel  * which are NOT configured by the user.
485*03831d35Sstevel  */
486*03831d35Sstevel 
487*03831d35Sstevel /* command */
488*03831d35Sstevel 
489*03831d35Sstevel #define	MAN_ND_GET	ND_GET
490*03831d35Sstevel #define	MAN_ND_SET	ND_SET
491*03831d35Sstevel #define	MAN_NOTUSR	0x0f000000
492*03831d35Sstevel #define	MAN_MASK_1BIT	0x1
493*03831d35Sstevel #define	MAN_MASK_2BIT	0x3
494*03831d35Sstevel #define	MAN_MASK_8BIT	0xff
495*03831d35Sstevel 
496*03831d35Sstevel typedef struct param_s {
497*03831d35Sstevel 	uint32_t param_min;
498*03831d35Sstevel 	uint32_t param_max;
499*03831d35Sstevel 	uint32_t param_val;
500*03831d35Sstevel 	char   *param_name;
501*03831d35Sstevel } param_t;
502*03831d35Sstevel 
503*03831d35Sstevel #if defined(DEBUG)
504*03831d35Sstevel #define	MAN_DBG(flag, msg)	{ if (man_debug&flag) (void) printf msg; }
505*03831d35Sstevel #define	MAN_DBGCALL(flag, func)	{ if (man_debug&flag) (void) func; }
506*03831d35Sstevel 
507*03831d35Sstevel #define	MAN_INIT	0x00000001
508*03831d35Sstevel #define	MAN_OCLOSE	0x00000002
509*03831d35Sstevel #define	MAN_CONFIG	0x00000004
510*03831d35Sstevel #define	MAN_SWITCH	0x00000008
511*03831d35Sstevel #define	MAN_IOSRAM	0x00000010
512*03831d35Sstevel #define	MAN_LINK	0x00000020
513*03831d35Sstevel #define	MAN_PATH	0x00000040
514*03831d35Sstevel #define	MAN_DEST	0x00000080
515*03831d35Sstevel #define	MAN_KSTAT	0x00000100
516*03831d35Sstevel #define	MAN_KSTAT2	0x00000200
517*03831d35Sstevel #define	MAN_DDI		0x000001FF
518*03831d35Sstevel 
519*03831d35Sstevel #define	MAN_UWPUT	0x00000400
520*03831d35Sstevel #define	MAN_LWPUT	0x00000800
521*03831d35Sstevel #define	MAN_LRPUT	0x00001000
522*03831d35Sstevel #define	MAN_LRPUT2	0x00002000
523*03831d35Sstevel #define	MAN_PUT		(MAN_UWPUT | MAN_LWPUT | MAN_LRPUT)
524*03831d35Sstevel #define	MAN_UWSRV	0x00004000
525*03831d35Sstevel #define	MAN_LWSRV	0x00008000
526*03831d35Sstevel #define	MAN_LRSRV	0x00010000
527*03831d35Sstevel #define	MAN_DATA	0x00020000
528*03831d35Sstevel #define	MAN_DLPI	0x00040000
529*03831d35Sstevel #define	MAN_SRV		(MAN_UWSRV | MAN_LWSRV | MAN_LRSRV)
530*03831d35Sstevel #define	MAN_STREAMS	(MAN_PUT | MAN_SRV | MAN_OCLOSE)
531*03831d35Sstevel 
532*03831d35Sstevel #define	MAN_CALLS	(MAN_DDI | MAN_STREAMS)
533*03831d35Sstevel 
534*03831d35Sstevel #define	MAN_STATE	0x00080000
535*03831d35Sstevel #define	MAN_WARN	0x00100000
536*03831d35Sstevel #define	MAN_DEBUG	(MAN_CALLS | MAN_WARN | MAN_STATE)
537*03831d35Sstevel #define	MAN_KMEM	0x00200000
538*03831d35Sstevel #define	MAN_DR		0x00400000
539*03831d35Sstevel #define	MAN_ALL		0xFFFFFFFF
540*03831d35Sstevel 
541*03831d35Sstevel #else
542*03831d35Sstevel 
543*03831d35Sstevel #define	MAN_DBG(flag, msg)
544*03831d35Sstevel #define	MAN_DBGCALL(flag, func)
545*03831d35Sstevel 
546*03831d35Sstevel #endif  /* DEBUG */
547*03831d35Sstevel 
548*03831d35Sstevel #ifdef	__cplusplus
549*03831d35Sstevel }
550*03831d35Sstevel #endif
551*03831d35Sstevel 
552*03831d35Sstevel #endif /* _DMAN_H */
553