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 /* 223448Sdh155122 * Copyright 2007 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; 482311Sseb 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]; 550Sstevel@tonic-gate mac_handle_t dl_mh; 560Sstevel@tonic-gate const mac_info_t *dl_mip; 570Sstevel@tonic-gate mac_rx_handle_t dl_mrh; 580Sstevel@tonic-gate mac_txloop_handle_t dl_mth; 590Sstevel@tonic-gate uint_t dl_ref; 600Sstevel@tonic-gate uint_t dl_macref; 61269Sericheng mod_hash_t *dl_impl_hash; 62269Sericheng krwlock_t dl_impl_lock; 63269Sericheng uint_t dl_impl_count; 6456Smeem kmutex_t dl_promisc_lock; 650Sstevel@tonic-gate uint_t dl_npromisc; 660Sstevel@tonic-gate uint_t dl_nactive; 670Sstevel@tonic-gate uint32_t dl_unknowns; 680Sstevel@tonic-gate kmutex_t dl_lock; 690Sstevel@tonic-gate }; 700Sstevel@tonic-gate 713448Sdh155122 typedef struct dls_impl_s dls_impl_t; 723448Sdh155122 typedef struct dls_head_s dls_head_t; 733448Sdh155122 740Sstevel@tonic-gate typedef struct dls_vlan_s { 750Sstevel@tonic-gate char dv_name[IFNAMSIZ]; 760Sstevel@tonic-gate uint_t dv_ref; 770Sstevel@tonic-gate dls_link_t *dv_dlp; 780Sstevel@tonic-gate uint16_t dv_id; 790Sstevel@tonic-gate kstat_t *dv_ksp; 803448Sdh155122 minor_t dv_minor; 813448Sdh155122 t_uscalar_t dv_ppa; 823448Sdh155122 zoneid_t dv_zid; 833448Sdh155122 dls_impl_t *dv_impl_list; 840Sstevel@tonic-gate } dls_vlan_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate struct dls_impl_s { 870Sstevel@tonic-gate dls_impl_t *di_nextp; 88269Sericheng dls_head_t *di_headp; 890Sstevel@tonic-gate dls_vlan_t *di_dvp; 900Sstevel@tonic-gate mac_handle_t di_mh; 910Sstevel@tonic-gate mac_notify_handle_t di_mnh; 920Sstevel@tonic-gate const mac_info_t *di_mip; 930Sstevel@tonic-gate krwlock_t di_lock; 940Sstevel@tonic-gate uint16_t di_sap; 950Sstevel@tonic-gate uint_t di_promisc; 960Sstevel@tonic-gate dls_multicst_addr_t *di_dmap; 970Sstevel@tonic-gate dls_rx_t di_rx; 980Sstevel@tonic-gate void *di_rx_arg; 991184Skrgopi mac_resource_add_t di_ring_add; 10056Smeem const mac_txinfo_t *di_txinfo; 1010Sstevel@tonic-gate boolean_t di_bound; 1020Sstevel@tonic-gate boolean_t di_removing; 1030Sstevel@tonic-gate boolean_t di_active; 1042311Sseb uint8_t di_unicst_addr[MAXMACADDRLEN]; 1051184Skrgopi soft_ring_t **di_soft_ring_list; 1061184Skrgopi uint_t di_soft_ring_size; 1073448Sdh155122 zoneid_t di_zid; 1083448Sdh155122 dls_impl_t *di_next_impl; 1090Sstevel@tonic-gate }; 1100Sstevel@tonic-gate 111269Sericheng struct dls_head_s { 112269Sericheng dls_impl_t *dh_list; 113269Sericheng uint_t dh_ref; 114269Sericheng mod_hash_key_t dh_key; 115269Sericheng }; 116269Sericheng 1170Sstevel@tonic-gate extern void dls_link_init(void); 1180Sstevel@tonic-gate extern int dls_link_fini(void); 119*5733Syz147064 extern int dls_link_hold(const char *, dls_link_t **); 1200Sstevel@tonic-gate extern void dls_link_rele(dls_link_t *); 1210Sstevel@tonic-gate extern void dls_link_add(dls_link_t *, uint32_t, dls_impl_t *); 1220Sstevel@tonic-gate extern void dls_link_remove(dls_link_t *, dls_impl_t *); 1232311Sseb extern int dls_link_header_info(dls_link_t *, mblk_t *, 1242760Sdg199075 mac_header_info_t *); 1250Sstevel@tonic-gate extern int dls_mac_hold(dls_link_t *); 1260Sstevel@tonic-gate extern void dls_mac_rele(dls_link_t *); 1270Sstevel@tonic-gate 1281184Skrgopi extern void dls_mac_stat_create(dls_vlan_t *); 1291184Skrgopi extern void dls_mac_stat_destroy(dls_vlan_t *); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate extern void dls_vlan_init(void); 1320Sstevel@tonic-gate extern int dls_vlan_fini(void); 133*5733Syz147064 extern int dls_vlan_create(const char *, const char *, uint16_t); 1340Sstevel@tonic-gate extern int dls_vlan_destroy(const char *); 135269Sericheng extern int dls_vlan_hold(const char *, dls_vlan_t **, boolean_t); 1360Sstevel@tonic-gate extern void dls_vlan_rele(dls_vlan_t *); 137269Sericheng extern int dls_vlan_walk(int (*)(dls_vlan_t *, void *), void *); 1383448Sdh155122 extern dev_info_t *dls_vlan_finddevinfo(dev_t); 1393448Sdh155122 extern int dls_vlan_ppa_from_minor(minor_t, t_uscalar_t *); 1403448Sdh155122 extern int dls_vlan_rele_by_name(const char *); 1413448Sdh155122 extern minor_t dls_minor_hold(boolean_t); 1423448Sdh155122 extern void dls_minor_rele(minor_t); 1433448Sdh155122 extern int dls_vlan_setzoneid(char *, zoneid_t, boolean_t); 1443448Sdh155122 extern int dls_vlan_getzoneid(char *, zoneid_t *); 1453448Sdh155122 extern void dls_vlan_add_impl(dls_vlan_t *, dls_impl_t *); 1463448Sdh155122 extern void dls_vlan_remove_impl(dls_vlan_t *, dls_impl_t *); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate extern void dls_init(void); 1490Sstevel@tonic-gate extern int dls_fini(void); 150*5733Syz147064 extern void dls_link_txloop(void *, mblk_t *); 1512311Sseb extern boolean_t dls_accept(dls_impl_t *, mac_header_info_t *, 152449Sericheng dls_rx_t *, void **); 1532760Sdg199075 extern boolean_t dls_accept_loopback(dls_impl_t *, mac_header_info_t *, 1542760Sdg199075 dls_rx_t *, void **); 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate #ifdef __cplusplus 1570Sstevel@tonic-gate } 1580Sstevel@tonic-gate #endif 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate #endif /* _SYS_DLS_IMPL_H */ 161