xref: /titanic_52/usr/src/uts/common/sys/dls_impl.h (revision 3125ebfc35130d243e775dc38a6a59be4df0b137)
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 	uint_t			dl_ddi_instance;
56 	mac_handle_t		dl_mh;
57 	const mac_info_t	*dl_mip;
58 	mac_rx_handle_t		dl_mrh;
59 	mac_txloop_handle_t	dl_mth;
60 	uint_t			dl_ref;
61 	uint_t			dl_macref;
62 	mod_hash_t		*dl_impl_hash;
63 	krwlock_t		dl_impl_lock;
64 	uint_t			dl_impl_count;
65 	mac_txloop_t		dl_txloop;
66 	kmutex_t		dl_promisc_lock;
67 	uint_t			dl_npromisc;
68 	uint_t			dl_nactive;
69 	uint32_t		dl_unknowns;
70 	kmutex_t		dl_lock;
71 };
72 
73 typedef struct dls_impl_s dls_impl_t;
74 typedef struct dls_head_s dls_head_t;
75 
76 typedef struct dls_vlan_s {
77 	char			dv_name[IFNAMSIZ];
78 	uint_t			dv_ref;
79 	dls_link_t		*dv_dlp;
80 	uint16_t		dv_id;
81 	kstat_t			*dv_ksp;
82 	minor_t			dv_minor;
83 	t_uscalar_t		dv_ppa;
84 	zoneid_t		dv_zid;
85 	dls_impl_t		*dv_impl_list;
86 } dls_vlan_t;
87 
88 struct dls_impl_s {
89 	dls_impl_t			*di_nextp;
90 	dls_head_t			*di_headp;
91 	dls_vlan_t			*di_dvp;
92 	mac_handle_t			di_mh;
93 	mac_notify_handle_t		di_mnh;
94 	const mac_info_t		*di_mip;
95 	krwlock_t			di_lock;
96 	uint16_t			di_sap;
97 	uint_t				di_promisc;
98 	dls_multicst_addr_t		*di_dmap;
99 	dls_rx_t			di_rx;
100 	void				*di_rx_arg;
101 	mac_resource_add_t		di_ring_add;
102 	const mac_txinfo_t		*di_txinfo;
103 	boolean_t			di_bound;
104 	boolean_t			di_removing;
105 	boolean_t			di_active;
106 	uint8_t				di_unicst_addr[MAXMACADDRLEN];
107 	soft_ring_t			**di_soft_ring_list;
108 	uint_t				di_soft_ring_size;
109 	int				di_soft_ring_fanout_type;
110 	zoneid_t			di_zid;
111 	dls_impl_t			*di_next_impl;
112 };
113 
114 struct dls_head_s {
115 	dls_impl_t			*dh_list;
116 	uint_t				dh_ref;
117 	mod_hash_key_t			dh_key;
118 };
119 
120 extern void		dls_link_init(void);
121 extern int		dls_link_fini(void);
122 extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
123 extern void		dls_link_rele(dls_link_t *);
124 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
125 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
126 extern int		dls_link_header_info(dls_link_t *, mblk_t *,
127     mac_header_info_t *);
128 extern int		dls_mac_hold(dls_link_t *);
129 extern void		dls_mac_rele(dls_link_t *);
130 
131 extern void		dls_mac_stat_create(dls_vlan_t *);
132 extern void		dls_mac_stat_destroy(dls_vlan_t *);
133 
134 extern void		dls_vlan_init(void);
135 extern int		dls_vlan_fini(void);
136 extern int		dls_vlan_create(const char *, const char *, uint_t,
137     uint16_t);
138 extern int		dls_vlan_destroy(const char *);
139 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
140 extern void		dls_vlan_rele(dls_vlan_t *);
141 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
142 extern dev_info_t	*dls_vlan_finddevinfo(dev_t);
143 extern int		dls_vlan_ppa_from_minor(minor_t, t_uscalar_t *);
144 extern int		dls_vlan_rele_by_name(const char *);
145 extern minor_t		dls_minor_hold(boolean_t);
146 extern void		dls_minor_rele(minor_t);
147 extern int		dls_vlan_setzoneid(char *, zoneid_t, boolean_t);
148 extern int		dls_vlan_getzoneid(char *, zoneid_t *);
149 extern void		dls_vlan_add_impl(dls_vlan_t *, dls_impl_t *);
150 extern void		dls_vlan_remove_impl(dls_vlan_t *, dls_impl_t *);
151 
152 extern void		dls_init(void);
153 extern int		dls_fini(void);
154 extern boolean_t	dls_accept(dls_impl_t *, mac_header_info_t *,
155     dls_rx_t *, void **);
156 extern boolean_t	dls_accept_loopback(dls_impl_t *, mac_header_info_t *,
157     dls_rx_t *, void **);
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _SYS_DLS_IMPL_H */
164