xref: /titanic_41/usr/src/uts/common/sys/dls.h (revision 10a4fa49f51ed9ae1c857a626de6ce9ebf41661a)
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  * Check the legality of a DLSAP value. The following values are allowed,
55  * as specified by PSARC 2003/150:
56  *
57  * 0							802 semantics
58  * ETHERTYPE_802_MIN (1536)..ETHERTYPE_MAX (65535)	ethertype semantics
59  * 1..ETHERMTU (1500)					802 semantics, for
60  *							DL_ETHER only.
61  */
62 #define	SAP_LEGAL(type, sap) \
63 	(((sap) >= ETHERTYPE_802_MIN && (sap) < ETHERTYPE_MAX) || \
64 	((sap) == 0) || \
65 	((sap) <= ETHERMTU && (type) == DL_ETHER))
66 
67 /*
68  * Macros for converting a ppa to an instance#, vlan ID, or minor.
69  */
70 #define	DLS_PPA2INST(ppa)	((int)((ppa) % 1000))
71 #define	DLS_PPA2VID(ppa)	((uint16_t)((ppa) / 1000))
72 #define	DLS_PPA2MINOR(ppa)	((minor_t)((DLS_PPA2INST(ppa)) + 1))
73 
74 /*
75  * Converts a minor to an instance#; makes sense only when minor <= 1000.
76  */
77 #define	DLS_MINOR2INST(minor)	((int)((minor) - 1))
78 
79 #ifdef	_KERNEL
80 
81 extern int	dls_create(const char *, const char *, uint_t);
82 extern int	dls_destroy(const char *);
83 
84 typedef	struct dls_t	*dls_channel_t;
85 
86 extern int	dls_open(const char *, dls_channel_t *);
87 extern void	dls_close(dls_channel_t);
88 
89 extern mac_handle_t	dls_mac(dls_channel_t);
90 extern uint16_t		dls_vid(dls_channel_t);
91 
92 #define	DLS_SAP_LLC	0
93 #define	DLS_SAP_PROMISC	(1 << 16)
94 
95 extern int	dls_bind(dls_channel_t, uint16_t);
96 extern void	dls_unbind(dls_channel_t);
97 
98 #define	DLS_PROMISC_SAP		0x00000001
99 #define	DLS_PROMISC_MULTI	0x00000002
100 #define	DLS_PROMISC_PHYS	0x00000004
101 
102 extern int	dls_promisc(dls_channel_t, uint32_t);
103 
104 extern int	dls_multicst_add(dls_channel_t, const uint8_t *);
105 extern int	dls_multicst_remove(dls_channel_t, const uint8_t *);
106 
107 extern mblk_t	*dls_header(dls_channel_t, const uint8_t *, uint16_t, uint_t);
108 
109 typedef struct dls_header_info {
110 	size_t		dhi_length;
111 	const uint8_t	*dhi_daddr;
112 	const uint8_t	*dhi_saddr;
113 	uint16_t	dhi_ethertype;
114 	uint16_t	dhi_vid;
115 	boolean_t	dhi_isgroup;
116 } dls_header_info_t;
117 
118 extern void	dls_header_info(dls_channel_t, mblk_t *, dls_header_info_t *);
119 
120 typedef	void	(*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *, size_t);
121 
122 extern void	dls_rx_set(dls_channel_t, dls_rx_t, void *);
123 
124 extern mblk_t		*dls_tx(dls_channel_t, mblk_t *);
125 
126 extern boolean_t	dls_active_set(dls_channel_t);
127 extern void		dls_active_clear(dls_channel_t);
128 
129 #endif	/* _KERNEL */
130 
131 #ifdef	__cplusplus
132 }
133 #endif
134 
135 #endif	/* _SYS_DLS_H */
136