xref: /onnv-gate/usr/src/uts/common/sys/dls_impl.h (revision 2311:2d86e52dcdf0)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2311Sseb  * Common Development and Distribution License (the "License").
6*2311Sseb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2311Sseb  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_DLS_IMPL_H
270Sstevel@tonic-gate #define	_SYS_DLS_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/stream.h>
320Sstevel@tonic-gate #include <sys/dls.h>
330Sstevel@tonic-gate #include <sys/mac.h>
34269Sericheng #include <sys/modhash.h>
350Sstevel@tonic-gate #include <sys/kstat.h>
360Sstevel@tonic-gate #include <net/if.h>
371184Skrgopi #include <sys/dlpi.h>
381184Skrgopi #include <sys/dls_soft_ring.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef	__cplusplus
410Sstevel@tonic-gate extern "C" {
420Sstevel@tonic-gate #endif
430Sstevel@tonic-gate 
440Sstevel@tonic-gate typedef struct dls_multicst_addr_s	dls_multicst_addr_t;
450Sstevel@tonic-gate 
460Sstevel@tonic-gate struct dls_multicst_addr_s {
470Sstevel@tonic-gate 	dls_multicst_addr_t	*dma_nextp;
48*2311Sseb 	uint8_t			dma_addr[MAXMACADDRLEN];
490Sstevel@tonic-gate };
500Sstevel@tonic-gate 
510Sstevel@tonic-gate typedef	struct dls_link_s	dls_link_t;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate struct dls_link_s {
540Sstevel@tonic-gate 	char			dl_name[MAXNAMELEN];
55*2311Sseb 	uint_t			dl_ddi_instance;
560Sstevel@tonic-gate 	mac_handle_t		dl_mh;
570Sstevel@tonic-gate 	const mac_info_t	*dl_mip;
580Sstevel@tonic-gate 	mac_rx_handle_t		dl_mrh;
590Sstevel@tonic-gate 	mac_txloop_handle_t	dl_mth;
600Sstevel@tonic-gate 	uint_t			dl_ref;
610Sstevel@tonic-gate 	uint_t			dl_macref;
62269Sericheng 	mod_hash_t		*dl_impl_hash;
63269Sericheng 	krwlock_t		dl_impl_lock;
64269Sericheng 	uint_t			dl_impl_count;
65*2311Sseb 	mac_txloop_t		dl_txloop;
6656Smeem 	kmutex_t		dl_promisc_lock;
670Sstevel@tonic-gate 	uint_t			dl_npromisc;
680Sstevel@tonic-gate 	uint_t			dl_nactive;
690Sstevel@tonic-gate 	uint32_t		dl_unknowns;
700Sstevel@tonic-gate 	kmutex_t		dl_lock;
710Sstevel@tonic-gate };
720Sstevel@tonic-gate 
730Sstevel@tonic-gate typedef struct dls_vlan_s {
740Sstevel@tonic-gate 	char			dv_name[IFNAMSIZ];
750Sstevel@tonic-gate 	uint_t			dv_ref;
760Sstevel@tonic-gate 	dls_link_t		*dv_dlp;
770Sstevel@tonic-gate 	uint16_t		dv_id;
780Sstevel@tonic-gate 	kstat_t			*dv_ksp;
790Sstevel@tonic-gate } dls_vlan_t;
800Sstevel@tonic-gate 
810Sstevel@tonic-gate typedef struct dls_impl_s dls_impl_t;
82269Sericheng typedef struct dls_head_s dls_head_t;
830Sstevel@tonic-gate 
840Sstevel@tonic-gate struct dls_impl_s {
850Sstevel@tonic-gate 	dls_impl_t			*di_nextp;
86269Sericheng 	dls_head_t			*di_headp;
870Sstevel@tonic-gate 	dls_vlan_t			*di_dvp;
880Sstevel@tonic-gate 	mac_handle_t			di_mh;
890Sstevel@tonic-gate 	mac_notify_handle_t		di_mnh;
900Sstevel@tonic-gate 	const mac_info_t		*di_mip;
910Sstevel@tonic-gate 	krwlock_t			di_lock;
920Sstevel@tonic-gate 	uint16_t			di_sap;
930Sstevel@tonic-gate 	uint_t				di_promisc;
940Sstevel@tonic-gate 	dls_multicst_addr_t		*di_dmap;
950Sstevel@tonic-gate 	dls_rx_t			di_rx;
960Sstevel@tonic-gate 	void				*di_rx_arg;
971184Skrgopi 	mac_resource_add_t		di_ring_add;
9856Smeem 	const mac_txinfo_t		*di_txinfo;
990Sstevel@tonic-gate 	boolean_t			di_bound;
1000Sstevel@tonic-gate 	boolean_t			di_removing;
1010Sstevel@tonic-gate 	boolean_t			di_active;
102*2311Sseb 	uint8_t				di_unicst_addr[MAXMACADDRLEN];
1031184Skrgopi 	soft_ring_t			**di_soft_ring_list;
1041184Skrgopi 	uint_t				di_soft_ring_size;
1051184Skrgopi 	int				di_soft_ring_fanout_type;
1060Sstevel@tonic-gate };
1070Sstevel@tonic-gate 
108269Sericheng struct dls_head_s {
109269Sericheng 	dls_impl_t			*dh_list;
110269Sericheng 	uint_t				dh_ref;
111269Sericheng 	mod_hash_key_t			dh_key;
112269Sericheng };
113269Sericheng 
1140Sstevel@tonic-gate extern void		dls_link_init(void);
1150Sstevel@tonic-gate extern int		dls_link_fini(void);
1160Sstevel@tonic-gate extern int		dls_link_hold(const char *, uint_t, dls_link_t **);
1170Sstevel@tonic-gate extern void		dls_link_rele(dls_link_t *);
1180Sstevel@tonic-gate extern void		dls_link_add(dls_link_t *, uint32_t, dls_impl_t *);
1190Sstevel@tonic-gate extern void		dls_link_remove(dls_link_t *, dls_impl_t *);
120*2311Sseb extern int		dls_link_header_info(dls_link_t *, mblk_t *,
121*2311Sseb     mac_header_info_t *, uint16_t *);
1220Sstevel@tonic-gate extern int		dls_mac_hold(dls_link_t *);
1230Sstevel@tonic-gate extern void		dls_mac_rele(dls_link_t *);
1240Sstevel@tonic-gate 
1251184Skrgopi extern void		dls_mac_stat_create(dls_vlan_t *);
1261184Skrgopi extern void		dls_mac_stat_destroy(dls_vlan_t *);
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate extern void		dls_vlan_init(void);
1290Sstevel@tonic-gate extern int		dls_vlan_fini(void);
1300Sstevel@tonic-gate extern int		dls_vlan_create(const char *, const char *, uint_t,
1310Sstevel@tonic-gate     uint16_t);
1320Sstevel@tonic-gate extern int		dls_vlan_destroy(const char *);
133269Sericheng extern int		dls_vlan_hold(const char *, dls_vlan_t **, boolean_t);
1340Sstevel@tonic-gate extern void		dls_vlan_rele(dls_vlan_t *);
135269Sericheng extern int		dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *);
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate extern void		dls_init(void);
1380Sstevel@tonic-gate extern int		dls_fini(void);
139*2311Sseb extern boolean_t	dls_accept(dls_impl_t *, mac_header_info_t *,
140449Sericheng     dls_rx_t *, void **);
141*2311Sseb extern boolean_t	dls_accept_loopback(dls_impl_t *, dls_rx_t *, void **);
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate #ifdef	__cplusplus
1440Sstevel@tonic-gate }
1450Sstevel@tonic-gate #endif
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate #endif	/* _SYS_DLS_IMPL_H */
148