xref: /titanic_41/usr/src/uts/common/sys/dls_impl.h (revision f2b7ce3eb6db75966c27b08fa312c3158f8dfabf)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_DLS_IMPL_H
28 #define	_SYS_DLS_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/stream.h>
33 #include <sys/dls.h>
34 #include <sys/mac.h>
35 #include <sys/modhash.h>
36 #include <sys/kstat.h>
37 #include <net/if.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 typedef struct dls_multicst_addr_s	dls_multicst_addr_t;
44 
45 struct dls_multicst_addr_s {
46 	dls_multicst_addr_t	*dma_nextp;
47 	uint8_t			dma_addr[MAXADDRLEN];
48 };
49 
50 typedef	struct dls_link_s	dls_link_t;
51 
52 struct dls_link_s {
53 	char			dl_name[MAXNAMELEN];
54 	char			dl_dev[MAXNAMELEN];
55 	uint_t			dl_port;
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_loopback;
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 typedef mblk_t		*(*dls_priv_header_t)(dls_impl_t *,
85     const uint8_t *, uint16_t, uint_t);
86 typedef void		(*dls_priv_header_info_t)(dls_impl_t *,
87     mblk_t *, dls_header_info_t *);
88 
89 struct dls_impl_s {
90 	dls_impl_t			*di_nextp;
91 	dls_head_t			*di_headp;
92 	dls_vlan_t			*di_dvp;
93 	mac_handle_t			di_mh;
94 	mac_notify_handle_t		di_mnh;
95 	const mac_info_t		*di_mip;
96 	krwlock_t			di_lock;
97 	uint16_t			di_sap;
98 	uint_t				di_promisc;
99 	dls_multicst_addr_t		*di_dmap;
100 	dls_rx_t			di_rx;
101 	void				*di_rx_arg;
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[MAXADDRLEN];
107 	dls_priv_header_t		di_header;
108 	dls_priv_header_info_t		di_header_info;
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 *, uint_t, 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_mac_hold(dls_link_t *);
124 extern void		dls_mac_rele(dls_link_t *);
125 
126 extern void		dls_stat_create(dls_vlan_t *);
127 extern void		dls_stat_destroy(dls_vlan_t *);
128 
129 extern void		dls_vlan_init(void);
130 extern int		dls_vlan_fini(void);
131 extern int		dls_vlan_create(const char *, const char *, uint_t,
132     uint16_t);
133 extern int		dls_vlan_destroy(const char *);
134 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
135 extern void		dls_vlan_rele(dls_vlan_t *);
136 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
137 
138 extern void		dls_init(void);
139 extern int		dls_fini(void);
140 extern boolean_t	dls_accept(dls_impl_t *, const uint8_t *);
141 extern boolean_t	dls_accept_loopback(dls_impl_t *, const uint8_t *);
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_DLS_IMPL_H */
148