xref: /titanic_50/usr/src/uts/common/sys/dls_impl.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_IMPL_H
27 #define	_SYS_DLS_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/stream.h>
32 #include <sys/dls.h>
33 #include <sys/mac.h>
34 #include <sys/modhash.h>
35 #include <sys/kstat.h>
36 #include <net/if.h>
37 #include <sys/dlpi.h>
38 #include <sys/dls_soft_ring.h>
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 typedef struct dls_multicst_addr_s	dls_multicst_addr_t;
45 
46 struct dls_multicst_addr_s {
47 	dls_multicst_addr_t	*dma_nextp;
48 	uint8_t			dma_addr[MAXMACADDRLEN];
49 };
50 
51 typedef	struct dls_link_s	dls_link_t;
52 
53 struct dls_link_s {
54 	char			dl_name[MAXNAMELEN];
55 	mac_handle_t		dl_mh;
56 	const mac_info_t	*dl_mip;
57 	mac_rx_handle_t		dl_mrh;
58 	mac_txloop_handle_t	dl_mth;
59 	uint_t			dl_ref;
60 	uint_t			dl_macref;
61 	mod_hash_t		*dl_impl_hash;
62 	krwlock_t		dl_impl_lock;
63 	uint_t			dl_impl_count;
64 	kmutex_t		dl_promisc_lock;
65 	uint_t			dl_npromisc;
66 	uint_t			dl_nactive;
67 	uint32_t		dl_unknowns;
68 	kmutex_t		dl_lock;
69 };
70 
71 typedef struct dls_impl_s dls_impl_t;
72 typedef struct dls_head_s dls_head_t;
73 
74 typedef struct dls_vlan_s {
75 	char			dv_name[IFNAMSIZ];
76 	uint_t			dv_ref;
77 	dls_link_t		*dv_dlp;
78 	uint16_t		dv_id;
79 	kstat_t			*dv_ksp;
80 	minor_t			dv_minor;
81 	t_uscalar_t		dv_ppa;
82 	zoneid_t		dv_zid;
83 	dls_impl_t		*dv_impl_list;
84 } dls_vlan_t;
85 
86 struct dls_impl_s {
87 	dls_impl_t			*di_nextp;
88 	dls_head_t			*di_headp;
89 	dls_vlan_t			*di_dvp;
90 	mac_handle_t			di_mh;
91 	mac_notify_handle_t		di_mnh;
92 	const mac_info_t		*di_mip;
93 	krwlock_t			di_lock;
94 	uint16_t			di_sap;
95 	uint_t				di_promisc;
96 	dls_multicst_addr_t		*di_dmap;
97 	dls_rx_t			di_rx;
98 	void				*di_rx_arg;
99 	mac_resource_add_t		di_ring_add;
100 	const mac_txinfo_t		*di_txinfo;
101 	boolean_t			di_bound;
102 	boolean_t			di_removing;
103 	boolean_t			di_active;
104 	uint8_t				di_unicst_addr[MAXMACADDRLEN];
105 	soft_ring_t			**di_soft_ring_list;
106 	uint_t				di_soft_ring_size;
107 	zoneid_t			di_zid;
108 	dls_impl_t			*di_next_impl;
109 };
110 
111 struct dls_head_s {
112 	dls_impl_t			*dh_list;
113 	uint_t				dh_ref;
114 	mod_hash_key_t			dh_key;
115 };
116 
117 extern void		dls_link_init(void);
118 extern int		dls_link_fini(void);
119 extern int		dls_link_hold(const char *, dls_link_t **);
120 extern void		dls_link_rele(dls_link_t *);
121 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
122 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
123 extern int		dls_link_header_info(dls_link_t *, mblk_t *,
124     mac_header_info_t *);
125 extern int		dls_mac_hold(dls_link_t *);
126 extern void		dls_mac_rele(dls_link_t *);
127 
128 extern void		dls_mac_stat_create(dls_vlan_t *);
129 extern void		dls_mac_stat_destroy(dls_vlan_t *);
130 
131 extern void		dls_vlan_init(void);
132 extern int		dls_vlan_fini(void);
133 extern int		dls_vlan_create(const char *, const char *, uint16_t);
134 extern int		dls_vlan_destroy(const char *);
135 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
136 extern void		dls_vlan_rele(dls_vlan_t *);
137 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
138 extern dev_info_t	*dls_vlan_finddevinfo(dev_t);
139 extern int		dls_vlan_ppa_from_minor(minor_t, t_uscalar_t *);
140 extern int		dls_vlan_rele_by_name(const char *);
141 extern minor_t		dls_minor_hold(boolean_t);
142 extern void		dls_minor_rele(minor_t);
143 extern int		dls_vlan_setzoneid(char *, zoneid_t, boolean_t);
144 extern int		dls_vlan_getzoneid(char *, zoneid_t *);
145 extern void		dls_vlan_add_impl(dls_vlan_t *, dls_impl_t *);
146 extern void		dls_vlan_remove_impl(dls_vlan_t *, dls_impl_t *);
147 
148 extern void		dls_init(void);
149 extern int		dls_fini(void);
150 extern void		dls_link_txloop(void *, mblk_t *);
151 extern boolean_t	dls_accept(dls_impl_t *, mac_header_info_t *,
152     dls_rx_t *, void **);
153 extern boolean_t	dls_accept_loopback(dls_impl_t *, mac_header_info_t *,
154     dls_rx_t *, void **);
155 
156 #ifdef	__cplusplus
157 }
158 #endif
159 
160 #endif	/* _SYS_DLS_IMPL_H */
161