xref: /titanic_50/usr/src/uts/common/sys/dls.h (revision 551bc2a66868b5cb5be6b70ab9f55515e77a39a9)
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 2007 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  * Maps a (VID, INST) pair to ppa
62  */
63 #define	DLS_VIDINST2PPA(vid, inst)	((minor_t)((vid) * 1000 + (inst)))
64 
65 /*
66  * Converts a minor to an instance#; makes sense only when minor <= 1000.
67  */
68 #define	DLS_MINOR2INST(minor)	((int)((minor) - 1))
69 
70 #ifdef	_KERNEL
71 
72 extern int	dls_create(const char *, const char *);
73 extern int	dls_destroy(const char *);
74 
75 typedef	struct dls_t	*dls_channel_t;
76 
77 extern int	dls_open(const char *, dls_channel_t *);
78 extern void	dls_close(dls_channel_t);
79 
80 extern mac_handle_t	dls_mac(dls_channel_t);
81 extern uint16_t		dls_vid(dls_channel_t);
82 
83 #define	DLS_SAP_LLC	0
84 #define	DLS_SAP_PROMISC	(1 << 16)
85 
86 extern int	dls_bind(dls_channel_t, uint32_t);
87 extern void	dls_unbind(dls_channel_t);
88 
89 #define	DLS_PROMISC_SAP		0x00000001
90 #define	DLS_PROMISC_MULTI	0x00000002
91 #define	DLS_PROMISC_PHYS	0x00000004
92 
93 extern int	dls_promisc(dls_channel_t, uint32_t);
94 
95 extern int	dls_multicst_add(dls_channel_t, const uint8_t *);
96 extern int	dls_multicst_remove(dls_channel_t, const uint8_t *);
97 
98 extern mblk_t	*dls_header(dls_channel_t, const uint8_t *, uint16_t, uint_t,
99     mblk_t **);
100 extern int	dls_header_info(dls_channel_t, mblk_t *, mac_header_info_t *);
101 
102 typedef	void	(*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *,
103     mac_header_info_t *);
104 
105 extern void	dls_rx_set(dls_channel_t, dls_rx_t, void *);
106 
107 extern mblk_t		*dls_tx(dls_channel_t, mblk_t *);
108 
109 extern boolean_t	dls_active_set(dls_channel_t);
110 extern void		dls_active_clear(dls_channel_t);
111 
112 extern dev_info_t	*dls_finddevinfo(dev_t);
113 extern int		dls_ppa_from_minor(minor_t, t_uscalar_t *);
114 #endif	/* _KERNEL */
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif	/* _SYS_DLS_H */
121