xref: /titanic_52/usr/src/lib/libdlpi/common/libdlpi_impl.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
1c7e4935fSss150715 /*
2c7e4935fSss150715  * CDDL HEADER START
3c7e4935fSss150715  *
4c7e4935fSss150715  * The contents of this file are subject to the terms of the
5c7e4935fSss150715  * Common Development and Distribution License (the "License").
6c7e4935fSss150715  * You may not use this file except in compliance with the License.
7c7e4935fSss150715  *
8c7e4935fSss150715  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c7e4935fSss150715  * or http://www.opensolaris.org/os/licensing.
10c7e4935fSss150715  * See the License for the specific language governing permissions
11c7e4935fSss150715  * and limitations under the License.
12c7e4935fSss150715  *
13c7e4935fSss150715  * When distributing Covered Code, include this CDDL HEADER in each
14c7e4935fSss150715  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c7e4935fSss150715  * If applicable, add the following below this CDDL HEADER, with the
16c7e4935fSss150715  * fields enclosed by brackets "[]" replaced with your own identifying
17c7e4935fSss150715  * information: Portions Copyright [yyyy] [name of copyright owner]
18c7e4935fSss150715  *
19c7e4935fSss150715  * CDDL HEADER END
20c7e4935fSss150715  */
21c7e4935fSss150715 /*
22*2b24ab6bSSebastien Roy  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23c7e4935fSss150715  * Use is subject to license terms.
24c7e4935fSss150715  */
25c7e4935fSss150715 
26c7e4935fSss150715 #ifndef	_LIBDLPI_IMPL_H
27c7e4935fSss150715 #define	_LIBDLPI_IMPL_H
28c7e4935fSss150715 
29c7e4935fSss150715 #include <libdlpi.h>
30c7e4935fSss150715 #include <sys/sysmacros.h>
31c7e4935fSss150715 
32c7e4935fSss150715 #ifdef __cplusplus
33c7e4935fSss150715 extern "C" {
34c7e4935fSss150715 #endif
35c7e4935fSss150715 
36c7e4935fSss150715 /*
37c7e4935fSss150715  * Maximum DLPI response size, in bytes.
38c7e4935fSss150715  */
39c7e4935fSss150715 #define	DLPI_CHUNKSIZE	8192
40c7e4935fSss150715 
41c7e4935fSss150715 /*
42c7e4935fSss150715  * Maximum SAP length, in bytes.
43c7e4935fSss150715  */
44c7e4935fSss150715 #define	DLPI_SAPLEN_MAX	4
45c7e4935fSss150715 
46c7e4935fSss150715 /*
47c7e4935fSss150715  * Number of elements in 'arr'.
48c7e4935fSss150715  */
49c7e4935fSss150715 #define	NELEMS(arr)	(sizeof (arr) / sizeof ((arr)[0]))
50c7e4935fSss150715 
51c7e4935fSss150715 /*
52c7e4935fSss150715  * Allocate buffer size for DLPI message, in bytes and set DLPI primitive.
53c7e4935fSss150715  */
54c7e4935fSss150715 #define	DLPI_MSG_CREATE(dlmsg, dlprimitive) \
55c7e4935fSss150715 	(dlmsg).dlm_msgsz = i_dlpi_getprimsize((dlprimitive)); \
56c7e4935fSss150715 	(dlmsg).dlm_msg = alloca((dlmsg).dlm_msgsz); \
57c7e4935fSss150715 	(dlmsg).dlm_msg->dl_primitive = (dlprimitive);
58c7e4935fSss150715 
59c7e4935fSss150715 /*
603ab45760Sss150715  * Publicly available DLPI notification types. This list may change if
613ab45760Sss150715  * new DLPI notification types are made public. See dlpi(7P).
623ab45760Sss150715  *
633ab45760Sss150715  */
643ab45760Sss150715 #define	DLPI_NOTIFICATION_TYPES	(DL_NOTE_LINK_DOWN | DL_NOTE_LINK_UP | \
653ab45760Sss150715 	DL_NOTE_PHYS_ADDR | DL_NOTE_SDU_SIZE | DL_NOTE_SPEED | \
663ab45760Sss150715 	DL_NOTE_PROMISC_ON_PHYS | DL_NOTE_PROMISC_OFF_PHYS)
673ab45760Sss150715 
683ab45760Sss150715 /*
69c7e4935fSss150715  * Used in a mactype lookup table.
70c7e4935fSss150715  */
71c7e4935fSss150715 typedef struct dlpi_mactype_s {
72c7e4935fSss150715 	uint_t	dm_mactype;	/* DLPI/Private mactype */
73c7e4935fSss150715 	char 	*dm_desc;	/* Description of mactype */
74c7e4935fSss150715 } dlpi_mactype_t;
75c7e4935fSss150715 
76c7e4935fSss150715 /*
77c7e4935fSss150715  * Used to get the maximum DLPI message buffer size, in bytes.
78c7e4935fSss150715  */
79c7e4935fSss150715 typedef struct dlpi_primsz {
80c7e4935fSss150715 	t_uscalar_t	dp_prim;	/* store DLPI primitive */
81c7e4935fSss150715 	size_t		dp_primsz;
82c7e4935fSss150715 				/* max. message size, in bytes, for dp_prim */
83c7e4935fSss150715 } dlpi_primsz_t;
84c7e4935fSss150715 
85c7e4935fSss150715 /*
86c7e4935fSss150715  * Used to create DLPI message.
87c7e4935fSss150715  */
88c7e4935fSss150715 typedef struct dlpi_msg {
89c7e4935fSss150715 	union DL_primitives	*dlm_msg;
90c7e4935fSss150715 					/* store DLPI primitive message */
91c7e4935fSss150715 	size_t			dlm_msgsz;
92c7e4935fSss150715 					/* provide buffer size for dlm_msg */
93c7e4935fSss150715 } dlpi_msg_t;
94c7e4935fSss150715 
953ab45760Sss150715 typedef struct dlpi_notifyent {
963ab45760Sss150715 	uint_t			dln_notes;
973ab45760Sss150715 					/* notification types registered */
983ab45760Sss150715 	dlpi_notifyfunc_t	*dln_fnp;
993ab45760Sss150715 					/* callback to call */
1003ab45760Sss150715 	void 			*arg;	/* argument to pass to callback */
1013ab45760Sss150715 	uint_t			dln_rm;	/* true if should be removed */
1023ab45760Sss150715 	struct dlpi_notifyent	*dln_next;
1033ab45760Sss150715 } dlpi_notifyent_t;
1043ab45760Sss150715 
105c7e4935fSss150715 /*
106c7e4935fSss150715  * Private libdlpi structure associated with each DLPI handle.
107c7e4935fSss150715  */
108c7e4935fSss150715 typedef struct dlpi_impl_s {
109c7e4935fSss150715 	int		dli_fd;		/* fd attached to stream */
110c7e4935fSss150715 	int		dli_timeout;	/* timeout for operations, in sec */
111c7e4935fSss150715 	char		dli_linkname[DLPI_LINKNAME_MAX];
112c7e4935fSss150715 					/* full linkname including PPA */
113c7e4935fSss150715 	char		dli_provider[DLPI_LINKNAME_MAX];
114c7e4935fSss150715 					/* only provider name */
115c7e4935fSss150715 	t_uscalar_t	dli_style;	/* style 1 or 2 */
116c7e4935fSss150715 	uint_t		dli_saplen;	/* bound SAP length */
117c7e4935fSss150715 	uint_t		dli_sap;	/* bound SAP value */
118c7e4935fSss150715 	boolean_t 	dli_sapbefore;	/* true if SAP precedes address */
119c7e4935fSss150715 	uint_t		dli_ppa;	/* physical point of attachment */
120c7e4935fSss150715 	uint_t		dli_mactype;	/* mac type */
121c7e4935fSss150715 	uint_t		dli_oflags;	/* flags set at open */
1223ab45760Sss150715 	uint_t		dli_note_processing;
1233ab45760Sss150715 					/* true if notification is being */
1243ab45760Sss150715 					/* processed */
1253ab45760Sss150715 	dlpi_notifyent_t *dli_notifylistp;
1263ab45760Sss150715 					/* list of registered notifications */
127c7e4935fSss150715 } dlpi_impl_t;
128c7e4935fSss150715 
129c7e4935fSss150715 #ifdef __cplusplus
130c7e4935fSss150715 }
131c7e4935fSss150715 #endif
132c7e4935fSss150715 
133c7e4935fSss150715 #endif /* _LIBDLPI_IMPL_H */
134