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> 371184Skrgopi #include <sys/dlpi.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 438275SEric Cheng typedef struct dls_multicst_addr_s { 448275SEric Cheng struct dls_multicst_addr_s *dma_nextp; /* ds_rw_lock */ 458275SEric Cheng uint8_t dma_addr[MAXMACADDRLEN]; 468275SEric Cheng } dls_multicst_addr_t; 470Sstevel@tonic-gate 488275SEric Cheng struct dls_link_s { /* Protected by */ 498275SEric Cheng char dl_name[MAXNAMELEN]; /* SL */ 508275SEric Cheng uint_t dl_ddi_instance; /* SL */ 518275SEric Cheng mac_handle_t dl_mh; /* SL */ 528275SEric Cheng mac_client_handle_t dl_mch; /* SL */ 538275SEric Cheng mac_unicast_handle_t dl_mah; /* SL */ 548275SEric Cheng const mac_info_t *dl_mip; /* SL */ 558275SEric Cheng uint_t dl_ref; /* SL */ 568275SEric Cheng mod_hash_t *dl_str_hash; /* SL, modhash lock */ 578275SEric Cheng uint_t dl_impl_count; /* SL */ 588275SEric Cheng uint_t dl_nactive; /* SL */ 598275SEric Cheng uint32_t dl_unknowns; /* atomic */ 608275SEric Cheng zoneid_t dl_zid; 618275SEric Cheng uint_t dl_zone_ref; 628874SSebastien.Roy@Sun.COM link_tagmode_t dl_tagmode; /* atomic */ 63*11021SEric.Cheng@Sun.COM uint_t dl_nonip_cnt; /* SL */ 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 668275SEric Cheng typedef struct dls_head_s { 678275SEric Cheng kmutex_t dh_lock; 688275SEric Cheng struct dld_str_s *dh_list; /* dh_ref */ 698275SEric Cheng uint_t dh_ref; /* dh_lock */ 708275SEric Cheng mod_hash_key_t dh_key; /* SL */ 718275SEric Cheng kcondvar_t dh_cv; /* dh_lock */ 728275SEric Cheng uint_t dh_removing; /* dh_lock */ 738275SEric Cheng } dls_head_t; 74269Sericheng 758833SVenu.Iyer@Sun.COM extern mod_hash_t *i_dls_link_hash; 768833SVenu.Iyer@Sun.COM 770Sstevel@tonic-gate extern void dls_link_init(void); 780Sstevel@tonic-gate extern int dls_link_fini(void); 795733Syz147064 extern int dls_link_hold(const char *, dls_link_t **); 808275SEric Cheng extern int dls_link_hold_create(const char *, dls_link_t **); 818275SEric Cheng extern int dls_link_hold_by_dev(dev_t, dls_link_t **); 820Sstevel@tonic-gate extern void dls_link_rele(dls_link_t *); 838275SEric Cheng extern int dls_link_rele_by_name(const char *); 848275SEric Cheng extern void dls_link_add(dls_link_t *, uint32_t, dld_str_t *); 858275SEric Cheng extern void dls_link_remove(dls_link_t *, dld_str_t *); 8610639SDarren.Reed@Sun.COM extern int dls_link_getzid(const char *, zoneid_t *); 878275SEric Cheng extern int dls_link_setzid(const char *, zoneid_t); 888275SEric Cheng extern dev_info_t *dls_link_devinfo(dev_t); 898275SEric Cheng extern dev_t dls_link_dev(dls_link_t *); 908275SEric Cheng 918275SEric Cheng extern void i_dls_head_rele(dls_head_t *); 928275SEric Cheng extern int dls_mac_active_set(dls_link_t *i); 935895Syz147064 extern void dls_mac_active_clear(dls_link_t *); 940Sstevel@tonic-gate 958275SEric Cheng extern void dls_create_str_kstats(dld_str_t *); 968275SEric Cheng extern int dls_stat_update(kstat_t *, dls_link_t *, int); 975895Syz147064 extern int dls_stat_create(const char *, int, const char *, 9810616SSebastien.Roy@Sun.COM zoneid_t, int (*)(struct kstat *, int), void *, 9910616SSebastien.Roy@Sun.COM kstat_t **); 1005895Syz147064 1018275SEric Cheng extern int dls_devnet_open_by_dev(dev_t, dls_link_t **, 1025895Syz147064 dls_dl_handle_t *); 1038275SEric Cheng extern int dls_devnet_hold_link(datalink_id_t, dls_dl_handle_t *, 1048275SEric Cheng dls_link_t **); 1058275SEric Cheng extern void dls_devnet_rele_link(dls_dl_handle_t, dls_link_t *); 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate extern void dls_init(void); 1080Sstevel@tonic-gate extern int dls_fini(void); 1095733Syz147064 extern void dls_link_txloop(void *, mblk_t *); 1108275SEric Cheng extern boolean_t dls_accept(dld_str_t *, mac_header_info_t *, 1118275SEric Cheng dls_rx_t *, void **); 1128275SEric Cheng extern boolean_t dls_accept_loopback(dld_str_t *, mac_header_info_t *, 1135895Syz147064 dls_rx_t *, void **); 1148275SEric Cheng extern boolean_t dls_accept_promisc(dld_str_t *, mac_header_info_t *, 1158275SEric Cheng dls_rx_t *, void **, boolean_t); 1168275SEric Cheng extern void i_dls_link_rx(void *, mac_resource_handle_t, mblk_t *, 1178275SEric Cheng boolean_t); 1188275SEric Cheng extern void dls_rx_promisc(void *, mac_resource_handle_t, mblk_t *, 1198275SEric Cheng boolean_t); 1208275SEric Cheng extern void dls_rx_vlan_promisc(void *, mac_resource_handle_t, 1218275SEric Cheng mblk_t *, boolean_t); 1228275SEric Cheng extern int dls_active_set(dld_str_t *); 1239073SCathy.Zhou@Sun.COM extern void dls_active_clear(dld_str_t *, boolean_t); 1245895Syz147064 1255895Syz147064 extern void dls_mgmt_init(void); 1265895Syz147064 extern void dls_mgmt_fini(void); 1275895Syz147064 1285895Syz147064 extern int dls_mgmt_get_phydev(datalink_id_t, dev_t *); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate #ifdef __cplusplus 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate #endif 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate #endif /* _SYS_DLS_IMPL_H */ 135