xref: /titanic_44/usr/src/uts/common/sys/dls.h (revision 9df12a23948bd40cbe37ce88d84e272c3894e675)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_DLS_H
28 #define	_SYS_DLS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/stream.h>
34 #include <sys/mac.h>
35 
36 /*
37  * Data-Link Services Module
38  */
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Module name.
46  */
47 #define	DLS_MODULE_NAME	"dls"
48 
49 /*
50  * Data-Link Services Information (text emitted by modinfo(1m))
51  */
52 #define	DLS_INFO	"Data-Link Services v%I%"
53 
54 /*
55  * Check the legality of a DLSAP value. The following values are allowed,
56  * as specified by PSARC 2003/150:
57  *
58  * 0							802 semantics
59  * ETHERTYPE_802_MIN (1536)..ETHERTYPE_MAX (65535)	ethertype semantics
60  * 1..ETHERMTU (1500)					802 semantics, for
61  *							DL_ETHER only.
62  */
63 #define	SAP_LEGAL(type, sap) \
64 	(((sap) >= ETHERTYPE_802_MIN && (sap) < ETHERTYPE_MAX) || \
65 	((sap) == 0) || \
66 	((sap) <= ETHERMTU && (type) == DL_ETHER))
67 
68 /*
69  * Macros for converting ppas to instance #s and to Vlan IDs.
70  */
71 #define	DLS_PPA2INST(ppa)	((int)((ppa) % 1000))
72 #define	DLS_PPA2VID(ppa)	((uint16_t)((ppa) / 1000))
73 
74 #ifdef	_KERNEL
75 
76 extern int	dls_create(const char *, const char *, uint_t);
77 extern int	dls_destroy(const char *);
78 
79 typedef	struct dls_t	*dls_channel_t;
80 
81 extern int	dls_open(const char *, dls_channel_t *);
82 extern void	dls_close(dls_channel_t);
83 
84 extern mac_handle_t	dls_mac(dls_channel_t);
85 extern uint16_t		dls_vid(dls_channel_t);
86 
87 #define	DLS_SAP_LLC	0
88 #define	DLS_SAP_PROMISC	(1 << 16)
89 
90 extern int	dls_bind(dls_channel_t, uint16_t);
91 extern void	dls_unbind(dls_channel_t);
92 
93 #define	DLS_PROMISC_SAP		0x00000001
94 #define	DLS_PROMISC_MULTI	0x00000002
95 #define	DLS_PROMISC_PHYS	0x00000004
96 
97 extern int	dls_promisc(dls_channel_t, uint32_t);
98 
99 extern int	dls_multicst_add(dls_channel_t, const uint8_t *);
100 extern int	dls_multicst_remove(dls_channel_t, const uint8_t *);
101 
102 extern mblk_t	*dls_header(dls_channel_t, const uint8_t *, uint16_t, uint_t);
103 
104 typedef struct dls_header_info {
105 	size_t		dhi_length;
106 	const uint8_t	*dhi_daddr;
107 	const uint8_t	*dhi_saddr;
108 	uint16_t	dhi_ethertype;
109 	uint16_t	dhi_vid;
110 	boolean_t	dhi_isgroup;
111 } dls_header_info_t;
112 
113 extern void	dls_header_info(dls_channel_t, mblk_t *, dls_header_info_t *);
114 
115 typedef	void	(*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *, size_t);
116 
117 extern void	dls_rx_set(dls_channel_t, dls_rx_t, void *);
118 
119 extern mblk_t		*dls_tx(dls_channel_t, mblk_t *);
120 
121 extern boolean_t	dls_active_set(dls_channel_t);
122 extern void		dls_active_clear(dls_channel_t);
123 
124 #endif	/* _KERNEL */
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif	/* _SYS_DLS_H */
131