xref: /titanic_52/usr/src/uts/common/sys/dls.h (revision 69112edd987c28fa551d4f8d9362a84a45365f17)
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 
89 extern int	dls_open(dls_link_t *, dls_dl_handle_t, dld_str_t *);
90 extern void	dls_close(dld_str_t *);
91 extern int	dls_bind(dld_str_t *, uint32_t);
92 extern void	dls_unbind(dld_str_t *);
93 
94 extern int	dls_promisc(dld_str_t *, uint32_t);
95 
96 extern int	dls_multicst_add(dld_str_t *, const uint8_t *);
97 extern int	dls_multicst_remove(dld_str_t *, const uint8_t *);
98 
99 extern mblk_t	*dls_header(dld_str_t *, const uint8_t *,
100 		    uint16_t, uint_t, mblk_t **);
101 
102 extern void	dls_rx_set(dld_str_t *, dls_rx_t, void *);
103 extern dld_str_t *dls_rx_get(char *, flow_desc_t *, size_t *);
104 
105 extern void	str_notify(void *, mac_notify_type_t);
106 
107 extern int		dls_devnet_open(const char *,
108 			    dls_dl_handle_t *, dev_t *);
109 extern void		dls_devnet_close(dls_dl_handle_t);
110 extern boolean_t	dls_devnet_rebuild();
111 
112 extern int		dls_devnet_rename(datalink_id_t, datalink_id_t,
113 			    const char *);
114 extern int		dls_devnet_create(mac_handle_t, datalink_id_t,
115 			    zoneid_t);
116 extern int		dls_devnet_destroy(mac_handle_t, datalink_id_t *,
117 			    boolean_t);
118 extern int		dls_devnet_recreate(mac_handle_t, datalink_id_t);
119 extern int		dls_devnet_hold_tmp(datalink_id_t, dls_dl_handle_t *);
120 extern void		dls_devnet_rele_tmp(dls_dl_handle_t);
121 extern int		dls_devnet_hold_by_dev(dev_t, dls_dl_handle_t *);
122 extern void		dls_devnet_rele(dls_dl_handle_t);
123 extern void		dls_devnet_prop_task_wait(dls_dl_handle_t);
124 
125 extern const char	*dls_devnet_mac(dls_dl_handle_t);
126 extern uint16_t		dls_devnet_vid(dls_dl_handle_t);
127 extern datalink_id_t	dls_devnet_linkid(dls_dl_handle_t);
128 extern int		dls_devnet_dev2linkid(dev_t, datalink_id_t *);
129 extern int		dls_devnet_phydev(datalink_id_t, dev_t *);
130 extern int		dls_devnet_setzid(dls_dl_handle_t, zoneid_t);
131 extern zoneid_t		dls_devnet_getzid(dls_dl_handle_t);
132 extern zoneid_t		dls_devnet_getownerzid(dls_dl_handle_t);
133 extern boolean_t	dls_devnet_islinkvisible(datalink_id_t, zoneid_t);
134 
135 extern int		dls_mgmt_door_set(boolean_t);
136 extern int		dls_mgmt_create(const char *, dev_t, datalink_class_t,
137 			    uint32_t, boolean_t, datalink_id_t *);
138 extern int		dls_mgmt_destroy(datalink_id_t, boolean_t);
139 extern int		dls_mgmt_update(const char *, uint32_t, boolean_t,
140 			    uint32_t *, datalink_id_t *);
141 extern int		dls_mgmt_get_linkinfo(datalink_id_t, char *,
142 			    datalink_class_t *, uint32_t *, uint32_t *);
143 extern int		dls_mgmt_get_linkid(const char *, datalink_id_t *);
144 extern datalink_id_t	dls_mgmt_get_next(datalink_id_t, datalink_class_t,
145 			    datalink_media_t, uint32_t);
146 extern int		dls_devnet_macname2linkid(const char *,
147 			    datalink_id_t *);
148 
149 #endif	/* _KERNEL */
150 
151 #ifdef	__cplusplus
152 }
153 #endif
154 
155 #endif	/* _SYS_DLS_H */
156