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 52311Sseb * Common Development and Distribution License (the "License"). 62311Sseb * 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 /* 228833SVenu.Iyer@Sun.COM * Copyright 2009 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 #include <sys/stream.h> 300Sstevel@tonic-gate #include <sys/dls.h> 318275SEric Cheng #include <sys/mac_provider.h> 328275SEric Cheng #include <sys/mac_client.h> 338275SEric Cheng #include <sys/mac_client_priv.h> 34269Sericheng #include <sys/modhash.h> 350Sstevel@tonic-gate #include <sys/kstat.h> 360Sstevel@tonic-gate #include <net/if.h> 3710639SDarren.Reed@Sun.COM #include <net/bpf.h> 3810639SDarren.Reed@Sun.COM #include <net/bpfdesc.h> 391184Skrgopi #include <sys/dlpi.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 458275SEric Cheng typedef struct dls_multicst_addr_s { 468275SEric Cheng struct dls_multicst_addr_s *dma_nextp; /* ds_rw_lock */ 478275SEric Cheng uint8_t dma_addr[MAXMACADDRLEN]; 488275SEric Cheng } dls_multicst_addr_t; 490Sstevel@tonic-gate 508275SEric Cheng struct dls_link_s { /* Protected by */ 518275SEric Cheng char dl_name[MAXNAMELEN]; /* SL */ 528275SEric Cheng uint_t dl_ddi_instance; /* SL */ 538275SEric Cheng mac_handle_t dl_mh; /* SL */ 548275SEric Cheng mac_client_handle_t dl_mch; /* SL */ 558275SEric Cheng mac_unicast_handle_t dl_mah; /* SL */ 568275SEric Cheng const mac_info_t *dl_mip; /* SL */ 578275SEric Cheng uint_t dl_ref; /* SL */ 588275SEric Cheng mod_hash_t *dl_str_hash; /* SL, modhash lock */ 598275SEric Cheng uint_t dl_impl_count; /* SL */ 608275SEric Cheng uint_t dl_nactive; /* SL */ 618275SEric Cheng uint32_t dl_unknowns; /* atomic */ 628275SEric Cheng zoneid_t dl_zid; 638275SEric Cheng uint_t dl_zone_ref; 648874SSebastien.Roy@Sun.COM link_tagmode_t dl_tagmode; /* atomic */ 65*11021SEric.Cheng@Sun.COM uint_t dl_nonip_cnt; /* SL */ 660Sstevel@tonic-gate }; 670Sstevel@tonic-gate 688275SEric Cheng typedef struct dls_head_s { 698275SEric Cheng kmutex_t dh_lock; 708275SEric Cheng struct dld_str_s *dh_list; /* dh_ref */ 718275SEric Cheng uint_t dh_ref; /* dh_lock */ 728275SEric Cheng mod_hash_key_t dh_key; /* SL */ 738275SEric Cheng kcondvar_t dh_cv; /* dh_lock */ 748275SEric Cheng uint_t dh_removing; /* dh_lock */ 758275SEric Cheng } dls_head_t; 76269Sericheng 778833SVenu.Iyer@Sun.COM extern mod_hash_t *i_dls_link_hash; 788833SVenu.Iyer@Sun.COM 790Sstevel@tonic-gate extern void dls_link_init(void); 800Sstevel@tonic-gate extern int dls_link_fini(void); 815733Syz147064 extern int dls_link_hold(const char *, dls_link_t **); 828275SEric Cheng extern int dls_link_hold_create(const char *, dls_link_t **); 838275SEric Cheng extern int dls_link_hold_by_dev(dev_t, dls_link_t **); 840Sstevel@tonic-gate extern void dls_link_rele(dls_link_t *); 858275SEric Cheng extern int dls_link_rele_by_name(const char *); 868275SEric Cheng extern void dls_link_add(dls_link_t *, uint32_t, dld_str_t *); 878275SEric Cheng extern void dls_link_remove(dls_link_t *, dld_str_t *); 8810639SDarren.Reed@Sun.COM extern int dls_link_getzid(const char *, zoneid_t *); 898275SEric Cheng extern int dls_link_setzid(const char *, zoneid_t); 908275SEric Cheng extern dev_info_t *dls_link_devinfo(dev_t); 918275SEric Cheng extern dev_t dls_link_dev(dls_link_t *); 928275SEric Cheng 938275SEric Cheng extern void i_dls_head_rele(dls_head_t *); 948275SEric Cheng extern int dls_mac_active_set(dls_link_t *i); 955895Syz147064 extern void dls_mac_active_clear(dls_link_t *); 960Sstevel@tonic-gate 978275SEric Cheng extern void dls_create_str_kstats(dld_str_t *); 988275SEric Cheng extern int dls_stat_update(kstat_t *, dls_link_t *, int); 995895Syz147064 extern int dls_stat_create(const char *, int, const char *, 10010616SSebastien.Roy@Sun.COM zoneid_t, int (*)(struct kstat *, int), void *, 10110616SSebastien.Roy@Sun.COM kstat_t **); 1025895Syz147064 1038275SEric Cheng extern int dls_devnet_open_by_dev(dev_t, dls_link_t **, 1045895Syz147064 dls_dl_handle_t *); 1058275SEric Cheng extern int dls_devnet_hold_link(datalink_id_t, dls_dl_handle_t *, 1068275SEric Cheng dls_link_t **); 1078275SEric Cheng extern void dls_devnet_rele_link(dls_dl_handle_t, dls_link_t *); 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate extern void dls_init(void); 1100Sstevel@tonic-gate extern int dls_fini(void); 1115733Syz147064 extern void dls_link_txloop(void *, mblk_t *); 1128275SEric Cheng extern boolean_t dls_accept(dld_str_t *, mac_header_info_t *, 1138275SEric Cheng dls_rx_t *, void **); 1148275SEric Cheng extern boolean_t dls_accept_loopback(dld_str_t *, mac_header_info_t *, 1155895Syz147064 dls_rx_t *, void **); 1168275SEric Cheng extern boolean_t dls_accept_promisc(dld_str_t *, mac_header_info_t *, 1178275SEric Cheng dls_rx_t *, void **, boolean_t); 1188275SEric Cheng extern void i_dls_link_rx(void *, mac_resource_handle_t, mblk_t *, 1198275SEric Cheng boolean_t); 1208275SEric Cheng extern void dls_rx_promisc(void *, mac_resource_handle_t, mblk_t *, 1218275SEric Cheng boolean_t); 1228275SEric Cheng extern void dls_rx_vlan_promisc(void *, mac_resource_handle_t, 1238275SEric Cheng mblk_t *, boolean_t); 1248275SEric Cheng extern int dls_active_set(dld_str_t *); 1259073SCathy.Zhou@Sun.COM extern void dls_active_clear(dld_str_t *, boolean_t); 1265895Syz147064 1275895Syz147064 extern void dls_mgmt_init(void); 1285895Syz147064 extern void dls_mgmt_fini(void); 1295895Syz147064 1305895Syz147064 extern int dls_mgmt_get_phydev(datalink_id_t, dev_t *); 1310Sstevel@tonic-gate 13210639SDarren.Reed@Sun.COM extern bpf_attach_fn_t dls_bpfattach_fn; 13310639SDarren.Reed@Sun.COM extern bpf_detach_fn_t dls_bpfdetach_fn; 13410639SDarren.Reed@Sun.COM extern void dls_set_bpfattach(bpf_attach_fn_t, bpf_detach_fn_t); 13510639SDarren.Reed@Sun.COM 1360Sstevel@tonic-gate #ifdef __cplusplus 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate #endif 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate #endif /* _SYS_DLS_IMPL_H */ 141