xref: /illumos-gate/usr/src/uts/common/sys/dls_impl.h (revision f808c858)
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 2006 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_vlan_s {
74 	char			dv_name[IFNAMSIZ];
75 	uint_t			dv_ref;
76 	dls_link_t		*dv_dlp;
77 	uint16_t		dv_id;
78 	kstat_t			*dv_ksp;
79 } dls_vlan_t;
80 
81 typedef struct dls_impl_s dls_impl_t;
82 typedef struct dls_head_s dls_head_t;
83 
84 struct dls_impl_s {
85 	dls_impl_t			*di_nextp;
86 	dls_head_t			*di_headp;
87 	dls_vlan_t			*di_dvp;
88 	mac_handle_t			di_mh;
89 	mac_notify_handle_t		di_mnh;
90 	const mac_info_t		*di_mip;
91 	krwlock_t			di_lock;
92 	uint16_t			di_sap;
93 	uint_t				di_promisc;
94 	dls_multicst_addr_t		*di_dmap;
95 	dls_rx_t			di_rx;
96 	void				*di_rx_arg;
97 	mac_resource_add_t		di_ring_add;
98 	const mac_txinfo_t		*di_txinfo;
99 	boolean_t			di_bound;
100 	boolean_t			di_removing;
101 	boolean_t			di_active;
102 	uint8_t				di_unicst_addr[MAXMACADDRLEN];
103 	soft_ring_t			**di_soft_ring_list;
104 	uint_t				di_soft_ring_size;
105 	int				di_soft_ring_fanout_type;
106 };
107 
108 struct dls_head_s {
109 	dls_impl_t			*dh_list;
110 	uint_t				dh_ref;
111 	mod_hash_key_t			dh_key;
112 };
113 
114 extern void		dls_link_init(void);
115 extern int		dls_link_fini(void);
116 extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
117 extern void		dls_link_rele(dls_link_t *);
118 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
119 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
120 extern int		dls_link_header_info(dls_link_t *, mblk_t *,
121     mac_header_info_t *, uint16_t *);
122 extern int		dls_mac_hold(dls_link_t *);
123 extern void		dls_mac_rele(dls_link_t *);
124 
125 extern void		dls_mac_stat_create(dls_vlan_t *);
126 extern void		dls_mac_stat_destroy(dls_vlan_t *);
127 
128 extern void		dls_vlan_init(void);
129 extern int		dls_vlan_fini(void);
130 extern int		dls_vlan_create(const char *, const char *, uint_t,
131     uint16_t);
132 extern int		dls_vlan_destroy(const char *);
133 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
134 extern void		dls_vlan_rele(dls_vlan_t *);
135 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
136 
137 extern void		dls_init(void);
138 extern int		dls_fini(void);
139 extern boolean_t	dls_accept(dls_impl_t *, mac_header_info_t *,
140     dls_rx_t *, void **);
141 extern boolean_t	dls_accept_loopback(dls_impl_t *, dls_rx_t *, void **);
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_DLS_IMPL_H */
148