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; 62*8874SSebastien.Roy@Sun.COM link_tagmode_t dl_tagmode; /* atomic */ 630Sstevel@tonic-gate }; 640Sstevel@tonic-gate 658275SEric Cheng typedef struct dls_head_s { 668275SEric Cheng kmutex_t dh_lock; 678275SEric Cheng struct dld_str_s *dh_list; /* dh_ref */ 688275SEric Cheng uint_t dh_ref; /* dh_lock */ 698275SEric Cheng mod_hash_key_t dh_key; /* SL */ 708275SEric Cheng kcondvar_t dh_cv; /* dh_lock */ 718275SEric Cheng uint_t dh_removing; /* dh_lock */ 728275SEric Cheng } dls_head_t; 73269Sericheng 748833SVenu.Iyer@Sun.COM extern mod_hash_t *i_dls_link_hash; 758833SVenu.Iyer@Sun.COM 760Sstevel@tonic-gate extern void dls_link_init(void); 770Sstevel@tonic-gate extern int dls_link_fini(void); 785733Syz147064 extern int dls_link_hold(const char *, dls_link_t **); 798275SEric Cheng extern int dls_link_hold_create(const char *, dls_link_t **); 808275SEric Cheng extern int dls_link_hold_by_dev(dev_t, dls_link_t **); 810Sstevel@tonic-gate extern void dls_link_rele(dls_link_t *); 828275SEric Cheng extern int dls_link_rele_by_name(const char *); 838275SEric Cheng extern void dls_link_add(dls_link_t *, uint32_t, dld_str_t *); 848275SEric Cheng extern void dls_link_remove(dls_link_t *, dld_str_t *); 852311Sseb extern int dls_link_header_info(dls_link_t *, mblk_t *, 865895Syz147064 mac_header_info_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 *, 985895Syz147064 int (*)(struct kstat *, int), void *, kstat_t **); 995895Syz147064 1008275SEric Cheng extern int dls_devnet_open_by_dev(dev_t, dls_link_t **, 1015895Syz147064 dls_dl_handle_t *); 1028275SEric Cheng extern int dls_devnet_hold_link(datalink_id_t, dls_dl_handle_t *, 1038275SEric Cheng dls_link_t **); 1048275SEric Cheng extern void dls_devnet_rele_link(dls_dl_handle_t, dls_link_t *); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate extern void dls_init(void); 1070Sstevel@tonic-gate extern int dls_fini(void); 1085733Syz147064 extern void dls_link_txloop(void *, mblk_t *); 1098275SEric Cheng extern boolean_t dls_accept(dld_str_t *, mac_header_info_t *, 1108275SEric Cheng dls_rx_t *, void **); 1118275SEric Cheng extern boolean_t dls_accept_loopback(dld_str_t *, mac_header_info_t *, 1125895Syz147064 dls_rx_t *, void **); 1138275SEric Cheng extern boolean_t dls_accept_promisc(dld_str_t *, mac_header_info_t *, 1148275SEric Cheng dls_rx_t *, void **, boolean_t); 1158275SEric Cheng extern void i_dls_link_rx(void *, mac_resource_handle_t, mblk_t *, 1168275SEric Cheng boolean_t); 1178275SEric Cheng extern void dls_rx_promisc(void *, mac_resource_handle_t, mblk_t *, 1188275SEric Cheng boolean_t); 1198275SEric Cheng extern void dls_rx_vlan_promisc(void *, mac_resource_handle_t, 1208275SEric Cheng mblk_t *, boolean_t); 1218275SEric Cheng extern int dls_active_set(dld_str_t *); 1228275SEric Cheng extern void dls_active_clear(dld_str_t *); 1235895Syz147064 1245895Syz147064 extern void dls_mgmt_init(void); 1255895Syz147064 extern void dls_mgmt_fini(void); 1265895Syz147064 1275895Syz147064 extern int dls_mgmt_get_phydev(datalink_id_t, dev_t *); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate #ifdef __cplusplus 1300Sstevel@tonic-gate } 1310Sstevel@tonic-gate #endif 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #endif /* _SYS_DLS_IMPL_H */ 134