xref: /titanic_51/usr/src/uts/common/sys/dls_impl.h (revision a77d64af7813dad3dad148a9974e0ec7b80d1f43)
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/ght.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 	ghte_t			dl_hte;
61 	uint_t			dl_ref;
62 	uint_t			dl_macref;
63 	ght_t			dl_impl_hash;
64 	mac_txloop_t		dl_loopback;
65 	kmutex_t		dl_promisc_lock;
66 	uint_t			dl_npromisc;
67 	uint_t			dl_nactive;
68 	uint32_t		dl_unknowns;
69 	kmutex_t		dl_lock;
70 };
71 
72 typedef struct dls_vlan_s {
73 	char			dv_name[IFNAMSIZ];
74 	ghte_t			dv_hte;
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 
83 typedef mblk_t		*(*dls_priv_header_t)(dls_impl_t *,
84     const uint8_t *, uint16_t, uint_t);
85 typedef void		(*dls_priv_header_info_t)(dls_impl_t *,
86     mblk_t *, dls_header_info_t *);
87 
88 struct dls_impl_s {
89 	dls_impl_t			*di_nextp;
90 	dls_vlan_t			*di_dvp;
91 	mac_handle_t			di_mh;
92 	mac_notify_handle_t		di_mnh;
93 	const mac_info_t		*di_mip;
94 	krwlock_t			di_lock;
95 	uint16_t			di_sap;
96 	ghte_t				di_hte;
97 	uint_t				di_promisc;
98 	dls_multicst_addr_t		*di_dmap;
99 	dls_rx_t			di_rx;
100 	void				*di_rx_arg;
101 	const mac_txinfo_t		*di_txinfo;
102 	boolean_t			di_bound;
103 	boolean_t			di_removing;
104 	boolean_t			di_active;
105 	uint8_t				di_unicst_addr[MAXADDRLEN];
106 	dls_priv_header_t		di_header;
107 	dls_priv_header_info_t		di_header_info;
108 };
109 
110 extern void		dls_link_init(void);
111 extern int		dls_link_fini(void);
112 extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
113 extern void		dls_link_rele(dls_link_t *);
114 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
115 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
116 extern int		dls_mac_hold(dls_link_t *);
117 extern void		dls_mac_rele(dls_link_t *);
118 
119 extern void		dls_stat_create(dls_vlan_t *);
120 extern void		dls_stat_destroy(dls_vlan_t *);
121 
122 extern void		dls_vlan_init(void);
123 extern int		dls_vlan_fini(void);
124 extern int		dls_vlan_create(const char *, const char *, uint_t,
125     uint16_t);
126 extern int		dls_vlan_destroy(const char *);
127 extern int		dls_vlan_hold(const char *, dls_vlan_t **);
128 extern void		dls_vlan_rele(dls_vlan_t *);
129 
130 extern void		dls_init(void);
131 extern int		dls_fini(void);
132 extern boolean_t	dls_accept(dls_impl_t *, const uint8_t *);
133 extern boolean_t	dls_accept_loopback(dls_impl_t *, const uint8_t *);
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif	/* _SYS_DLS_IMPL_H */
140