xref: /titanic_50/usr/src/uts/common/sys/dls_impl.h (revision 0167b58cea98965c58fab4be4e690b6e456f7440)
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 #include <sys/dlpi.h>
39 #include <sys/dls_soft_ring.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct dls_multicst_addr_s	dls_multicst_addr_t;
46 
47 struct dls_multicst_addr_s {
48 	dls_multicst_addr_t	*dma_nextp;
49 	uint8_t			dma_addr[MAXADDRLEN];
50 };
51 
52 typedef	struct dls_link_s	dls_link_t;
53 
54 struct dls_link_s {
55 	char			dl_name[MAXNAMELEN];
56 	char			dl_dev[MAXNAMELEN];
57 	uint_t			dl_port;
58 	mac_handle_t		dl_mh;
59 	const mac_info_t	*dl_mip;
60 	mac_rx_handle_t		dl_mrh;
61 	mac_txloop_handle_t	dl_mth;
62 	uint_t			dl_ref;
63 	uint_t			dl_macref;
64 	mod_hash_t		*dl_impl_hash;
65 	krwlock_t		dl_impl_lock;
66 	uint_t			dl_impl_count;
67 	mac_txloop_t		dl_loopback;
68 	kmutex_t		dl_promisc_lock;
69 	uint_t			dl_npromisc;
70 	uint_t			dl_nactive;
71 	uint32_t		dl_unknowns;
72 	kmutex_t		dl_lock;
73 };
74 
75 typedef struct dls_vlan_s {
76 	char			dv_name[IFNAMSIZ];
77 	uint_t			dv_ref;
78 	dls_link_t		*dv_dlp;
79 	uint16_t		dv_id;
80 	kstat_t			*dv_ksp;
81 } dls_vlan_t;
82 
83 typedef struct dls_impl_s dls_impl_t;
84 typedef struct dls_head_s dls_head_t;
85 
86 typedef mblk_t		*(*dls_priv_header_t)(dls_impl_t *,
87     const uint8_t *, uint16_t, uint_t);
88 typedef void		(*dls_priv_header_info_t)(dls_impl_t *,
89     mblk_t *, dls_header_info_t *);
90 
91 struct dls_impl_s {
92 	dls_impl_t			*di_nextp;
93 	dls_head_t			*di_headp;
94 	dls_vlan_t			*di_dvp;
95 	mac_handle_t			di_mh;
96 	mac_notify_handle_t		di_mnh;
97 	const mac_info_t		*di_mip;
98 	krwlock_t			di_lock;
99 	uint16_t			di_sap;
100 	uint_t				di_promisc;
101 	dls_multicst_addr_t		*di_dmap;
102 	dls_rx_t			di_rx;
103 	void				*di_rx_arg;
104 	mac_resource_add_t		di_ring_add;
105 	const mac_txinfo_t		*di_txinfo;
106 	boolean_t			di_bound;
107 	boolean_t			di_removing;
108 	boolean_t			di_active;
109 	uint8_t				di_unicst_addr[MAXADDRLEN];
110 	dls_priv_header_t		di_header;
111 	dls_priv_header_info_t		di_header_info;
112 	soft_ring_t			**di_soft_ring_list;
113 	uint_t				di_soft_ring_size;
114 	int				di_soft_ring_fanout_type;
115 };
116 
117 struct dls_head_s {
118 	dls_impl_t			*dh_list;
119 	uint_t				dh_ref;
120 	mod_hash_key_t			dh_key;
121 };
122 
123 extern void		dls_link_init(void);
124 extern int		dls_link_fini(void);
125 extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
126 extern void		dls_link_rele(dls_link_t *);
127 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
128 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
129 extern int		dls_mac_hold(dls_link_t *);
130 extern void		dls_mac_rele(dls_link_t *);
131 
132 extern void		dls_mac_stat_create(dls_vlan_t *);
133 extern void		dls_mac_stat_destroy(dls_vlan_t *);
134 
135 extern void		dls_vlan_init(void);
136 extern int		dls_vlan_fini(void);
137 extern int		dls_vlan_create(const char *, const char *, uint_t,
138     uint16_t);
139 extern int		dls_vlan_destroy(const char *);
140 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
141 extern void		dls_vlan_rele(dls_vlan_t *);
142 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
143 
144 extern void		dls_init(void);
145 extern int		dls_fini(void);
146 extern boolean_t	dls_accept(dls_impl_t *, const uint8_t *,
147     dls_rx_t *, void **);
148 extern boolean_t	dls_accept_loopback(dls_impl_t *, const uint8_t *,
149     dls_rx_t *, void **);
150 
151 #ifdef	__cplusplus
152 }
153 #endif
154 
155 #endif	/* _SYS_DLS_IMPL_H */
156