xref: /titanic_51/usr/src/uts/common/sys/dls_impl.h (revision fbbfbc6ee66f60ad88ebd18c6c030797335354f4)
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 2009 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 #include <sys/stream.h>
30 #include <sys/dls.h>
31 #include <sys/mac_provider.h>
32 #include <sys/mac_client.h>
33 #include <sys/mac_client_priv.h>
34 #include <sys/modhash.h>
35 #include <sys/kstat.h>
36 #include <net/if.h>
37 #include <net/bpf.h>
38 #include <net/bpfdesc.h>
39 #include <sys/dlpi.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 typedef struct dls_multicst_addr_s {
46 	struct dls_multicst_addr_s	*dma_nextp;		/* ds_rw_lock */
47 	uint8_t				dma_addr[MAXMACADDRLEN];
48 } dls_multicst_addr_t;
49 
50 struct dls_link_s {				/* Protected by */
51 	char			dl_name[MAXNAMELEN];	/* SL */
52 	uint_t			dl_ddi_instance;	/* SL */
53 	mac_handle_t		dl_mh;			/* SL */
54 	mac_client_handle_t	dl_mch;			/* SL */
55 	mac_unicast_handle_t	dl_mah;			/* SL */
56 	const mac_info_t	*dl_mip;		/* SL */
57 	uint_t			dl_ref;			/* SL */
58 	mod_hash_t		*dl_str_hash;		/* SL, modhash lock */
59 	uint_t			dl_impl_count;		/* SL */
60 	uint_t			dl_nactive;		/* SL */
61 	uint32_t		dl_unknowns;		/* atomic */
62 	zoneid_t		dl_zid;
63 	uint_t			dl_zone_ref;
64 	link_tagmode_t		dl_tagmode;		/* atomic */
65 };
66 
67 typedef struct dls_head_s {
68 	kmutex_t		dh_lock;
69 	struct dld_str_s	*dh_list;		/* dh_ref */
70 	uint_t			dh_ref;			/* dh_lock */
71 	mod_hash_key_t		dh_key;			/* SL */
72 	kcondvar_t		dh_cv;			/* dh_lock */
73 	uint_t			dh_removing;		/* dh_lock */
74 } dls_head_t;
75 
76 extern mod_hash_t	*i_dls_link_hash;
77 
78 extern void		dls_link_init(void);
79 extern int		dls_link_fini(void);
80 extern int		dls_link_hold(const char *, dls_link_t **);
81 extern int		dls_link_hold_create(const char *, dls_link_t **);
82 extern int		dls_link_hold_by_dev(dev_t, dls_link_t **);
83 extern void		dls_link_rele(dls_link_t *);
84 extern int		dls_link_rele_by_name(const char *);
85 extern void		dls_link_add(dls_link_t *, uint32_t, dld_str_t *);
86 extern void		dls_link_remove(dls_link_t *, dld_str_t *);
87 extern int		dls_link_header_info(dls_link_t *, mblk_t *,
88 			    mac_header_info_t *);
89 extern int		dls_link_getzid(const char *, zoneid_t *);
90 extern int		dls_link_setzid(const char *, zoneid_t);
91 extern dev_info_t	*dls_link_devinfo(dev_t);
92 extern dev_t		dls_link_dev(dls_link_t *);
93 
94 extern void		i_dls_head_rele(dls_head_t *);
95 extern int		dls_mac_active_set(dls_link_t *i);
96 extern void		dls_mac_active_clear(dls_link_t *);
97 
98 extern void		dls_create_str_kstats(dld_str_t *);
99 extern int		dls_stat_update(kstat_t *, dls_link_t *, int);
100 extern int		dls_stat_create(const char *, int, const char *,
101 			    zoneid_t, int (*)(struct kstat *, int), void *,
102 			    kstat_t **);
103 
104 extern int		dls_devnet_open_by_dev(dev_t, dls_link_t **,
105 			    dls_dl_handle_t *);
106 extern int		dls_devnet_hold_link(datalink_id_t, dls_dl_handle_t *,
107 			    dls_link_t **);
108 extern void		dls_devnet_rele_link(dls_dl_handle_t, dls_link_t *);
109 
110 extern void		dls_init(void);
111 extern int		dls_fini(void);
112 extern void		dls_link_txloop(void *, mblk_t *);
113 extern boolean_t	dls_accept(dld_str_t *, mac_header_info_t *,
114 			    dls_rx_t *, void **);
115 extern boolean_t	dls_accept_loopback(dld_str_t *, mac_header_info_t *,
116 			    dls_rx_t *, void **);
117 extern boolean_t	dls_accept_promisc(dld_str_t *, mac_header_info_t *,
118 			    dls_rx_t *, void **, boolean_t);
119 extern void		i_dls_link_rx(void *, mac_resource_handle_t, mblk_t *,
120 			    boolean_t);
121 extern void		dls_rx_promisc(void *, mac_resource_handle_t, mblk_t *,
122 			    boolean_t);
123 extern void		dls_rx_vlan_promisc(void *, mac_resource_handle_t,
124 			    mblk_t *, boolean_t);
125 extern int		dls_active_set(dld_str_t *);
126 extern void		dls_active_clear(dld_str_t *, boolean_t);
127 
128 extern void		dls_mgmt_init(void);
129 extern void		dls_mgmt_fini(void);
130 
131 extern int		dls_mgmt_get_phydev(datalink_id_t, dev_t *);
132 
133 extern bpf_attach_fn_t	dls_bpfattach_fn;
134 extern bpf_detach_fn_t	dls_bpfdetach_fn;
135 extern void		dls_set_bpfattach(bpf_attach_fn_t, bpf_detach_fn_t);
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_DLS_IMPL_H */
142