xref: /titanic_50/usr/src/lib/libdlpi/common/libdlpi.h (revision c2cb63342c63c60cee771d1af82f377e34aa1217)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _LIBDLPI_H
27 #define	_LIBDLPI_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/dlpi.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Maximum Physical (hardware) address length, in bytes.
40  * Must be as large as MAXMACADDRLEN (see <sys/mac.h>).
41  */
42 #define	DLPI_PHYSADDR_MAX	64
43 
44 /*
45  * Maximum link name length, including terminating NUL, in bytes.
46  */
47 #define	DLPI_LINKNAME_MAX	32
48 
49 /*
50  * Constant used to indicate bind to any SAP value
51  */
52 #define	DLPI_ANY_SAP	(uint_t)-1
53 
54 /*
55  * Flag values for dlpi_open(); those not documented in dlpi_open(3DLPI)
56  * are Consolidation Private and subject to change or removal.
57  */
58 #define	DLPI_EXCL	0x0001	/* Exclusive open  */
59 #define	DLPI_PASSIVE	0x0002	/* Open DLPI link in passive mode */
60 #define	DLPI_RAW	0x0004	/* Open DLPI link in raw mode */
61 #define	DLPI_SERIAL	0x0008	/* Synchronous serial line interface */
62 #define	DLPI_NOATTACH	0x0010	/* Do not attach PPA */
63 #define	DLPI_NATIVE	0x0020	/* Open DLPI link in Native mode */
64 
65 /*
66  * Timeout to be used in DLPI-related operations, in seconds.
67  */
68 #define	DLPI_DEF_TIMEOUT  5
69 
70 /*
71  * Since this library returns error codes defined in either <sys/dlpi.h> or
72  * <libdlpi.h>, libdlpi specific error codes will start at value 10000 to
73  * avoid overlap. DLPI_SUCCESS cannot be 0 because 0 is already DL_BADSAP in
74  * <sys/dlpi.h>.
75  */
76 enum {
77 	DLPI_SUCCESS = 10000,		/* DLPI operation succeeded */
78 	DLPI_EINVAL,			/* invalid argument */
79 	DLPI_ELINKNAMEINVAL,		/* invalid DLPI linkname */
80 	DLPI_ENOLINK,			/* DLPI link does not exist */
81 	DLPI_EBADLINK,			/* bad DLPI link */
82 	DLPI_EINHANDLE,			/* invalid DLPI handle */
83 	DLPI_ETIMEDOUT,			/* DLPI operation timed out */
84 	DLPI_EVERNOTSUP,		/* unsupported DLPI Version */
85 	DLPI_EMODENOTSUP,		/* unsupported DLPI connection mode */
86 	DLPI_EUNAVAILSAP,		/* unavailable DLPI SAP */
87 	DLPI_FAILURE,			/* DLPI operation failed */
88 	DLPI_ENOTSTYLE2,		/* DLPI style-2 node reports style-1 */
89 	DLPI_EBADMSG,			/* bad DLPI message */
90 	DLPI_ERAWNOTSUP,		/* DLPI raw mode not supported */
91 	DLPI_ERRMAX			/* Highest + 1 libdlpi error code */
92 };
93 
94 /*
95  * DLPI information; see dlpi_info(3DLPI).
96  */
97 typedef struct {
98 	uint_t			di_opts;
99 	uint_t			di_max_sdu;
100 	uint_t			di_min_sdu;
101 	uint_t			di_state;
102 	uint_t			di_mactype;
103 	char			di_linkname[DLPI_LINKNAME_MAX];
104 	uchar_t			di_physaddr[DLPI_PHYSADDR_MAX];
105 	uchar_t			di_physaddrlen;
106 	uchar_t			di_bcastaddr[DLPI_PHYSADDR_MAX];
107 	uchar_t			di_bcastaddrlen;
108 	uint_t			di_sap;
109 	int			di_timeout;
110 	dl_qos_cl_sel1_t	di_qos_sel;
111 	dl_qos_cl_range1_t 	di_qos_range;
112 } dlpi_info_t;
113 
114 /*
115  * DLPI send information; see dlpi_send(3DLPI).
116  */
117 typedef struct {
118 	uint_t 		dsi_sap;
119 	dl_priority_t	dsi_prio;
120 } dlpi_sendinfo_t;
121 
122 /*
123  * Destination DLPI address type; see dlpi_recv(3DLPI).
124  */
125 typedef enum {
126 	DLPI_ADDRTYPE_UNICAST,
127 	DLPI_ADDRTYPE_GROUP
128 } dlpi_addrtype_t;
129 
130 /*
131  * DLPI receive information; see dlpi_recv(3DLPI).
132  */
133 typedef struct {
134 	uchar_t 	dri_destaddr[DLPI_PHYSADDR_MAX];
135 	uchar_t 	dri_destaddrlen;
136 	dlpi_addrtype_t	dri_dstaddrtype;
137 	size_t  	dri_totmsglen;
138 } dlpi_recvinfo_t;
139 
140 typedef struct __dlpi_handle *dlpi_handle_t;
141 
142 extern const char	*dlpi_mactype(uint_t);
143 extern const char 	*dlpi_strerror(int);
144 extern const char 	*dlpi_linkname(dlpi_handle_t);
145 
146 extern int dlpi_open(const char *, dlpi_handle_t *, uint_t);
147 extern void dlpi_close(dlpi_handle_t);
148 extern int dlpi_info(dlpi_handle_t, dlpi_info_t *, uint_t);
149 extern int dlpi_bind(dlpi_handle_t, uint_t, uint_t *);
150 extern int dlpi_unbind(dlpi_handle_t);
151 extern int dlpi_enabmulti(dlpi_handle_t, const void *, size_t);
152 extern int dlpi_disabmulti(dlpi_handle_t, const void *, size_t);
153 extern int dlpi_promiscon(dlpi_handle_t, uint_t);
154 extern int dlpi_promiscoff(dlpi_handle_t, uint_t);
155 extern int dlpi_get_physaddr(dlpi_handle_t, uint_t, void *, size_t *);
156 extern int dlpi_set_physaddr(dlpi_handle_t, uint_t, const void *, size_t);
157 extern int dlpi_recv(dlpi_handle_t, void *, size_t *, void *, size_t *,
158     int, dlpi_recvinfo_t *);
159 extern int dlpi_send(dlpi_handle_t, const void *, size_t, const void *, size_t,
160     const dlpi_sendinfo_t *);
161 extern int dlpi_fd(dlpi_handle_t);
162 extern int dlpi_set_timeout(dlpi_handle_t, int);
163 
164 /*
165  * These are Consolidation Private interfaces and are subject to change.
166  */
167 extern int dlpi_parselink(const char *, char *, uint_t *);
168 extern int dlpi_makelink(char *, const char *, uint_t);
169 extern uint_t dlpi_style(dlpi_handle_t);
170 
171 #ifdef	__cplusplus
172 }
173 #endif
174 
175 #endif /* _LIBDLPI_H */
176