xref: /illumos-gate/usr/src/uts/common/sys/dls.h (revision 9dd828891378a0a6a509ab601b4c5c20ca5562ec)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_DLS_H
27 #define	_SYS_DLS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/stream.h>
33 #include <sys/mac.h>
34 
35 /*
36  * Data-Link Services Module
37  */
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Module name.
45  */
46 #define	DLS_MODULE_NAME	"dls"
47 
48 /*
49  * Data-Link Services Information (text emitted by modinfo(1m))
50  */
51 #define	DLS_INFO	"Data-Link Services v%I%"
52 
53 /*
54  * Macros for converting ppas to instance #s, Vlan ID, or minor.
55  */
56 #define	DLS_PPA2INST(ppa)	((int)((ppa) % 1000))
57 #define	DLS_PPA2VID(ppa)	((uint16_t)((ppa) / 1000))
58 #define	DLS_PPA2MINOR(ppa)	((minor_t)((DLS_PPA2INST(ppa)) + 1))
59 
60 /*
61  * Converts a minor to an instance#; makes sense only when minor <= 1000.
62  */
63 #define	DLS_MINOR2INST(minor)	((int)((minor) - 1))
64 
65 #ifdef	_KERNEL
66 
67 extern int	dls_create(const char *, const char *, uint_t);
68 extern int	dls_destroy(const char *);
69 
70 typedef	struct dls_t	*dls_channel_t;
71 
72 extern int	dls_open(const char *, dls_channel_t *);
73 extern void	dls_close(dls_channel_t);
74 
75 extern mac_handle_t	dls_mac(dls_channel_t);
76 extern uint16_t		dls_vid(dls_channel_t);
77 
78 #define	DLS_SAP_LLC	0
79 #define	DLS_SAP_PROMISC	(1 << 16)
80 
81 extern int	dls_bind(dls_channel_t, uint32_t);
82 extern void	dls_unbind(dls_channel_t);
83 
84 #define	DLS_PROMISC_SAP		0x00000001
85 #define	DLS_PROMISC_MULTI	0x00000002
86 #define	DLS_PROMISC_PHYS	0x00000004
87 
88 extern int	dls_promisc(dls_channel_t, uint32_t);
89 
90 extern int	dls_multicst_add(dls_channel_t, const uint8_t *);
91 extern int	dls_multicst_remove(dls_channel_t, const uint8_t *);
92 
93 extern mblk_t	*dls_header(dls_channel_t, const uint8_t *, uint16_t, uint_t,
94     mblk_t *);
95 extern int	dls_header_info(dls_channel_t, mblk_t *, mac_header_info_t *);
96 
97 typedef	void	(*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *, size_t);
98 
99 extern void	dls_rx_set(dls_channel_t, dls_rx_t, void *);
100 
101 extern mblk_t		*dls_tx(dls_channel_t, mblk_t *);
102 
103 extern boolean_t	dls_active_set(dls_channel_t);
104 extern void		dls_active_clear(dls_channel_t);
105 
106 #endif	/* _KERNEL */
107 
108 #ifdef	__cplusplus
109 }
110 #endif
111 
112 #endif	/* _SYS_DLS_H */
113