xref: /titanic_50/usr/src/uts/common/sys/dls_impl.h (revision dfb96a4f56fb431b915bc67e5d9d5c8d4f4f6679)
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 	zoneid_t			di_zid;
110 	dls_impl_t			*di_next_impl;
111 };
112 
113 struct dls_head_s {
114 	dls_impl_t			*dh_list;
115 	uint_t				dh_ref;
116 	mod_hash_key_t			dh_key;
117 };
118 
119 extern void		dls_link_init(void);
120 extern int		dls_link_fini(void);
121 extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
122 extern void		dls_link_rele(dls_link_t *);
123 extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
124 extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
125 extern int		dls_link_header_info(dls_link_t *, mblk_t *,
126     mac_header_info_t *);
127 extern int		dls_mac_hold(dls_link_t *);
128 extern void		dls_mac_rele(dls_link_t *);
129 
130 extern void		dls_mac_stat_create(dls_vlan_t *);
131 extern void		dls_mac_stat_destroy(dls_vlan_t *);
132 
133 extern void		dls_vlan_init(void);
134 extern int		dls_vlan_fini(void);
135 extern int		dls_vlan_create(const char *, const char *, uint_t,
136     uint16_t);
137 extern int		dls_vlan_destroy(const char *);
138 extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
139 extern void		dls_vlan_rele(dls_vlan_t *);
140 extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
141 extern dev_info_t	*dls_vlan_finddevinfo(dev_t);
142 extern int		dls_vlan_ppa_from_minor(minor_t, t_uscalar_t *);
143 extern int		dls_vlan_rele_by_name(const char *);
144 extern minor_t		dls_minor_hold(boolean_t);
145 extern void		dls_minor_rele(minor_t);
146 extern int		dls_vlan_setzoneid(char *, zoneid_t, boolean_t);
147 extern int		dls_vlan_getzoneid(char *, zoneid_t *);
148 extern void		dls_vlan_add_impl(dls_vlan_t *, dls_impl_t *);
149 extern void		dls_vlan_remove_impl(dls_vlan_t *, dls_impl_t *);
150 
151 extern void		dls_init(void);
152 extern int		dls_fini(void);
153 extern boolean_t	dls_accept(dls_impl_t *, mac_header_info_t *,
154     dls_rx_t *, void **);
155 extern boolean_t	dls_accept_loopback(dls_impl_t *, mac_header_info_t *,
156     dls_rx_t *, void **);
157 
158 #ifdef	__cplusplus
159 }
160 #endif
161 
162 #endif	/* _SYS_DLS_IMPL_H */
163