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