xref: /titanic_44/usr/src/lib/libdlpi/common/libdlpi.h (revision 948f2876ce2a3010558f4f6937e16086ebcd36f2)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * 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.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22c7e4935fSss150715  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _LIBDLPI_H
277c478bd9Sstevel@tonic-gate #define	_LIBDLPI_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate #include <sys/dlpi.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
38c7e4935fSss150715 /*
39c7e4935fSss150715  * Maximum Physical (hardware) address length, in bytes.
40c7e4935fSss150715  * Must be as large as MAXMACADDRLEN (see <sys/mac.h>).
41c7e4935fSss150715  */
42c7e4935fSss150715 #define	DLPI_PHYSADDR_MAX	64
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate /*
45c7e4935fSss150715  * Maximum link name length, including terminating NUL, in bytes.
467c478bd9Sstevel@tonic-gate  */
47c7e4935fSss150715 #define	DLPI_LINKNAME_MAX	32
48c7e4935fSss150715 
49c7e4935fSss150715 /*
50c7e4935fSss150715  * Constant used to indicate bind to any SAP value
51c7e4935fSss150715  */
52c7e4935fSss150715 #define	DLPI_ANY_SAP	(uint_t)-1
53c7e4935fSss150715 
54c7e4935fSss150715 /*
55c7e4935fSss150715  * Flag values for dlpi_open(); those not documented in dlpi_open(3DLPI)
56c7e4935fSss150715  * are Consolidation Private and subject to change or removal.
57c7e4935fSss150715  */
58c7e4935fSss150715 #define	DLPI_EXCL	0x0001	/* Exclusive open  */
59c7e4935fSss150715 #define	DLPI_PASSIVE	0x0002	/* Open DLPI link in passive mode */
60c7e4935fSss150715 #define	DLPI_RAW	0x0004	/* Open DLPI link in raw mode */
61c7e4935fSss150715 #define	DLPI_SERIAL	0x0008	/* Synchronous serial line interface */
62c7e4935fSss150715 #define	DLPI_NOATTACH	0x0010	/* Do not attach PPA */
63c7e4935fSss150715 #define	DLPI_NATIVE	0x0020	/* Open DLPI link in Native mode */
64c7e4935fSss150715 
65c7e4935fSss150715 /*
66c7e4935fSss150715  * Timeout to be used in DLPI-related operations, in seconds.
67c7e4935fSss150715  */
68c7e4935fSss150715 #define	DLPI_DEF_TIMEOUT  5
69c7e4935fSss150715 
70c7e4935fSss150715 /*
71c7e4935fSss150715  * Since this library returns error codes defined in either <sys/dlpi.h> or
72c7e4935fSss150715  * <libdlpi.h>, libdlpi specific error codes will start at value 10000 to
73c7e4935fSss150715  * avoid overlap. DLPI_SUCCESS cannot be 0 because 0 is already DL_BADSAP in
74c7e4935fSss150715  * <sys/dlpi.h>.
75c7e4935fSss150715  */
76c7e4935fSss150715 enum {
77c7e4935fSss150715 	DLPI_SUCCESS = 10000,		/* DLPI operation succeeded */
78c7e4935fSss150715 	DLPI_EINVAL,			/* invalid argument */
79c7e4935fSss150715 	DLPI_ELINKNAMEINVAL,		/* invalid DLPI linkname */
80c7e4935fSss150715 	DLPI_ENOLINK,			/* DLPI link does not exist */
81c7e4935fSss150715 	DLPI_EBADLINK,			/* bad DLPI link */
82c7e4935fSss150715 	DLPI_EINHANDLE,			/* invalid DLPI handle */
83c7e4935fSss150715 	DLPI_ETIMEDOUT,			/* DLPI operation timed out */
84c7e4935fSss150715 	DLPI_EVERNOTSUP,		/* unsupported DLPI Version */
85c7e4935fSss150715 	DLPI_EMODENOTSUP,		/* unsupported DLPI connection mode */
86c7e4935fSss150715 	DLPI_EUNAVAILSAP,		/* unavailable DLPI SAP */
87c7e4935fSss150715 	DLPI_FAILURE,			/* DLPI operation failed */
88c7e4935fSss150715 	DLPI_ENOTSTYLE2,		/* DLPI style-2 node reports style-1 */
89c7e4935fSss150715 	DLPI_EBADMSG,			/* bad DLPI message */
90c7e4935fSss150715 	DLPI_ERAWNOTSUP,		/* DLPI raw mode not supported */
91c7e4935fSss150715 	DLPI_ERRMAX			/* Highest + 1 libdlpi error code */
92c7e4935fSss150715 };
93c7e4935fSss150715 
94c7e4935fSss150715 /*
95c7e4935fSss150715  * DLPI information; see dlpi_info(3DLPI).
96c7e4935fSss150715  */
97c7e4935fSss150715 typedef struct {
98c7e4935fSss150715 	uint_t			di_opts;
99c7e4935fSss150715 	uint_t			di_max_sdu;
100c7e4935fSss150715 	uint_t			di_min_sdu;
101c7e4935fSss150715 	uint_t			di_state;
102c7e4935fSss150715 	uint_t			di_mactype;
103c7e4935fSss150715 	char			di_linkname[DLPI_LINKNAME_MAX];
104c7e4935fSss150715 	uchar_t			di_physaddr[DLPI_PHYSADDR_MAX];
105c7e4935fSss150715 	uchar_t			di_physaddrlen;
106c7e4935fSss150715 	uchar_t			di_bcastaddr[DLPI_PHYSADDR_MAX];
107c7e4935fSss150715 	uchar_t			di_bcastaddrlen;
108c7e4935fSss150715 	uint_t			di_sap;
109c7e4935fSss150715 	int			di_timeout;
110c7e4935fSss150715 	dl_qos_cl_sel1_t	di_qos_sel;
111c7e4935fSss150715 	dl_qos_cl_range1_t 	di_qos_range;
112c7e4935fSss150715 } dlpi_info_t;
113c7e4935fSss150715 
114c7e4935fSss150715 /*
115c7e4935fSss150715  * DLPI send information; see dlpi_send(3DLPI).
116c7e4935fSss150715  */
117c7e4935fSss150715 typedef struct {
118c7e4935fSss150715 	uint_t 		dsi_sap;
119c7e4935fSss150715 	dl_priority_t	dsi_prio;
120c7e4935fSss150715 } dlpi_sendinfo_t;
121c7e4935fSss150715 
122c7e4935fSss150715 /*
123c7e4935fSss150715  * Destination DLPI address type; see dlpi_recv(3DLPI).
124c7e4935fSss150715  */
125c7e4935fSss150715 typedef enum {
126c7e4935fSss150715 	DLPI_ADDRTYPE_UNICAST,
127c7e4935fSss150715 	DLPI_ADDRTYPE_GROUP
128c7e4935fSss150715 } dlpi_addrtype_t;
129c7e4935fSss150715 
130c7e4935fSss150715 /*
131c7e4935fSss150715  * DLPI receive information; see dlpi_recv(3DLPI).
132c7e4935fSss150715  */
133c7e4935fSss150715 typedef struct {
134c7e4935fSss150715 	uchar_t 	dri_destaddr[DLPI_PHYSADDR_MAX];
135c7e4935fSss150715 	uchar_t 	dri_destaddrlen;
136c7e4935fSss150715 	dlpi_addrtype_t	dri_dstaddrtype;
137c7e4935fSss150715 	size_t  	dri_totmsglen;
138c7e4935fSss150715 } dlpi_recvinfo_t;
139c7e4935fSss150715 
140c7e4935fSss150715 typedef struct __dlpi_handle *dlpi_handle_t;
141c7e4935fSss150715 
142c7e4935fSss150715 extern const char	*dlpi_mactype(uint_t);
143c7e4935fSss150715 extern const char 	*dlpi_strerror(int);
144c7e4935fSss150715 extern const char 	*dlpi_linkname(dlpi_handle_t);
145c7e4935fSss150715 
146c7e4935fSss150715 extern int dlpi_open(const char *, dlpi_handle_t *, uint_t);
147c7e4935fSss150715 extern void dlpi_close(dlpi_handle_t);
148c7e4935fSss150715 extern int dlpi_info(dlpi_handle_t, dlpi_info_t *, uint_t);
149c7e4935fSss150715 extern int dlpi_bind(dlpi_handle_t, uint_t, uint_t *);
150c7e4935fSss150715 extern int dlpi_unbind(dlpi_handle_t);
151c7e4935fSss150715 extern int dlpi_enabmulti(dlpi_handle_t, const void *, size_t);
152c7e4935fSss150715 extern int dlpi_disabmulti(dlpi_handle_t, const void *, size_t);
153c7e4935fSss150715 extern int dlpi_promiscon(dlpi_handle_t, uint_t);
154c7e4935fSss150715 extern int dlpi_promiscoff(dlpi_handle_t, uint_t);
155c7e4935fSss150715 extern int dlpi_get_physaddr(dlpi_handle_t, uint_t, void *, size_t *);
156c7e4935fSss150715 extern int dlpi_set_physaddr(dlpi_handle_t, uint_t, const void *, size_t);
157c7e4935fSss150715 extern int dlpi_recv(dlpi_handle_t, void *, size_t *, void *, size_t *,
158c7e4935fSss150715     int, dlpi_recvinfo_t *);
159c7e4935fSss150715 extern int dlpi_send(dlpi_handle_t, const void *, size_t, const void *, size_t,
160c7e4935fSss150715     const dlpi_sendinfo_t *);
161c7e4935fSss150715 extern int dlpi_fd(dlpi_handle_t);
162c7e4935fSss150715 extern int dlpi_set_timeout(dlpi_handle_t, int);
163*948f2876Sss150715 extern uint_t dlpi_arptype(uint_t);
164*948f2876Sss150715 extern uint_t dlpi_iftype(uint_t);
165c7e4935fSss150715 
166c7e4935fSss150715 /*
167c7e4935fSss150715  * These are Consolidation Private interfaces and are subject to change.
168c7e4935fSss150715  */
169c7e4935fSss150715 extern int dlpi_parselink(const char *, char *, uint_t *);
170c7e4935fSss150715 extern int dlpi_makelink(char *, const char *, uint_t);
171c7e4935fSss150715 extern uint_t dlpi_style(dlpi_handle_t);
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1747c478bd9Sstevel@tonic-gate }
1757c478bd9Sstevel@tonic-gate #endif
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate #endif /* _LIBDLPI_H */
178