xref: /illumos-gate/usr/src/uts/common/sys/dls.h (revision 1b09309c5ebed5c0bf14e2b396bf626c5aa30034)
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 2009 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 #include <sys/types.h>
30 #include <sys/stream.h>
31 #include <sys/mac_client.h>
32 #include <sys/dls_mgmt.h>
33 
34 /*
35  * Data-Link Services Module
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Module name.
44  */
45 #define	DLS_MODULE_NAME	"dls"
46 
47 /*
48  * Data-Link Services Information (text emitted by modinfo(1m))
49  */
50 #define	DLS_INFO	"Data-Link Services"
51 
52 /*
53  * Macros for converting ppas to instance #s, Vlan ID, or minor.
54  */
55 #define	DLS_PPA2INST(ppa)	((int)((ppa) % 1000))
56 #define	DLS_PPA2VID(ppa)	((uint16_t)((ppa) / 1000))
57 #define	DLS_PPA2MINOR(ppa)	((minor_t)((DLS_PPA2INST(ppa)) + 1))
58 
59 /*
60  * Maps a (VID, INST) pair to ppa
61  */
62 #define	DLS_VIDINST2PPA(vid, inst)	((minor_t)((vid) * 1000 + (inst)))
63 
64 /*
65  * Converts a minor to an instance#; makes sense only when minor <= 1000.
66  */
67 #define	DLS_MINOR2INST(minor)	((int)((minor) - 1))
68 
69 #ifdef	_KERNEL
70 
71 #define	DLS_MAX_PPA	999
72 #define	DLS_MAX_MINOR	(DLS_MAX_PPA + 1)
73 
74 typedef void    (*dls_rx_t)(void *, mac_resource_handle_t, mblk_t *,
75 		    mac_header_info_t *);
76 
77 typedef struct dld_str_s	dld_str_t;
78 typedef struct dls_devnet_s	*dls_dl_handle_t;
79 typedef struct dls_dev_t	*dls_dev_handle_t;
80 typedef struct dls_link_s	dls_link_t;
81 
82 #define	DLS_SAP_LLC	0
83 #define	DLS_SAP_PROMISC	(1 << 16)
84 
85 #define	DLS_PROMISC_SAP		0x00000001
86 #define	DLS_PROMISC_MULTI	0x00000002
87 #define	DLS_PROMISC_PHYS	0x00000004
88 #define	DLS_PROMISC_RX_ONLY	0x00000008
89 
90 extern int	dls_open(dls_link_t *, dls_dl_handle_t, dld_str_t *);
91 extern void	dls_close(dld_str_t *);
92 extern int	dls_bind(dld_str_t *, uint32_t);
93 extern void	dls_unbind(dld_str_t *);
94 
95 extern int	dls_promisc(dld_str_t *, uint32_t);
96 
97 extern int	dls_multicst_add(dld_str_t *, const uint8_t *);
98 extern int	dls_multicst_remove(dld_str_t *, const uint8_t *);
99 
100 extern mblk_t	*dls_header(dld_str_t *, const uint8_t *,
101 		    uint16_t, uint_t, mblk_t **);
102 
103 extern void	dls_rx_set(dld_str_t *, dls_rx_t, void *);
104 extern dld_str_t *dls_rx_get(char *, flow_desc_t *, size_t *);
105 
106 extern void	str_notify(void *, mac_notify_type_t);
107 
108 extern int		dls_devnet_open(const char *,
109 			    dls_dl_handle_t *, dev_t *);
110 extern void		dls_devnet_close(dls_dl_handle_t);
111 extern boolean_t	dls_devnet_rebuild();
112 
113 extern int		dls_devnet_rename(datalink_id_t, datalink_id_t,
114 			    const char *);
115 extern int		dls_devnet_create(mac_handle_t, datalink_id_t,
116 			    zoneid_t);
117 extern int		dls_devnet_destroy(mac_handle_t, datalink_id_t *,
118 			    boolean_t);
119 extern int		dls_devnet_recreate(mac_handle_t, datalink_id_t);
120 extern int		dls_devnet_hold_tmp(datalink_id_t, dls_dl_handle_t *);
121 extern void		dls_devnet_rele_tmp(dls_dl_handle_t);
122 extern int		dls_devnet_hold_by_dev(dev_t, dls_dl_handle_t *);
123 extern void		dls_devnet_rele(dls_dl_handle_t);
124 extern void		dls_devnet_prop_task_wait(dls_dl_handle_t);
125 
126 extern const char	*dls_devnet_link(dls_dl_handle_t);
127 extern const char	*dls_devnet_mac(dls_dl_handle_t);
128 extern uint16_t		dls_devnet_vid(dls_dl_handle_t);
129 extern datalink_id_t	dls_devnet_linkid(dls_dl_handle_t);
130 extern int		dls_devnet_dev2linkid(dev_t, datalink_id_t *);
131 extern int		dls_devnet_phydev(datalink_id_t, dev_t *);
132 extern int		dls_devnet_setzid(dls_dl_handle_t, zoneid_t);
133 extern zoneid_t		dls_devnet_getzid(dls_dl_handle_t);
134 extern zoneid_t		dls_devnet_getownerzid(dls_dl_handle_t);
135 extern boolean_t	dls_devnet_islinkvisible(datalink_id_t, zoneid_t);
136 
137 extern int		dls_mgmt_door_set(boolean_t);
138 extern int		dls_mgmt_create(const char *, dev_t, datalink_class_t,
139 			    uint32_t, boolean_t, datalink_id_t *);
140 extern int		dls_mgmt_destroy(datalink_id_t, boolean_t);
141 extern int		dls_mgmt_update(const char *, uint32_t, boolean_t,
142 			    uint32_t *, datalink_id_t *);
143 extern int		dls_mgmt_get_linkinfo(datalink_id_t, char *,
144 			    datalink_class_t *, uint32_t *, uint32_t *);
145 extern int		dls_mgmt_get_linkid(const char *, datalink_id_t *);
146 extern datalink_id_t	dls_mgmt_get_next(datalink_id_t, datalink_class_t,
147 			    datalink_media_t, uint32_t);
148 extern int		dls_devnet_macname2linkid(const char *,
149 			    datalink_id_t *);
150 
151 #endif	/* _KERNEL */
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif	/* _SYS_DLS_H */
158