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 51852Syz147064 * Common Development and Distribution License (the "License"). 61852Syz147064 * 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 /* 221852Syz147064 * 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_MAC_IMPL_H 270Sstevel@tonic-gate #define _SYS_MAC_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/mac.h> 32*2311Sseb #include <net/if.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 38*2311Sseb /* 39*2311Sseb * Statistics of class MAC_INTERFACE_STAT, maintained internally by the mac 40*2311Sseb * module. 41*2311Sseb */ 42*2311Sseb enum mac_interface_stat { 43*2311Sseb MAC_STAT_LINK_STATE, 44*2311Sseb MAC_STAT_LINK_UP, 45*2311Sseb MAC_STAT_PROMISC, 46*2311Sseb 47*2311Sseb MAC_INTERFACE_NSTAT /* Must be the last entry */ 48*2311Sseb }; 49*2311Sseb 500Sstevel@tonic-gate typedef struct mac_multicst_addr_s mac_multicst_addr_t; 510Sstevel@tonic-gate 520Sstevel@tonic-gate struct mac_multicst_addr_s { 530Sstevel@tonic-gate mac_multicst_addr_t *mma_nextp; 540Sstevel@tonic-gate uint_t mma_ref; 55*2311Sseb uint8_t mma_addr[MAXMACADDRLEN]; 560Sstevel@tonic-gate }; 570Sstevel@tonic-gate 580Sstevel@tonic-gate typedef struct mac_notify_fn_s mac_notify_fn_t; 590Sstevel@tonic-gate 600Sstevel@tonic-gate struct mac_notify_fn_s { 610Sstevel@tonic-gate mac_notify_fn_t *mnf_nextp; 620Sstevel@tonic-gate mac_notify_t mnf_fn; 630Sstevel@tonic-gate void *mnf_arg; 640Sstevel@tonic-gate }; 650Sstevel@tonic-gate 660Sstevel@tonic-gate typedef struct mac_rx_fn_s mac_rx_fn_t; 670Sstevel@tonic-gate 680Sstevel@tonic-gate struct mac_rx_fn_s { 690Sstevel@tonic-gate mac_rx_fn_t *mrf_nextp; 700Sstevel@tonic-gate mac_rx_t mrf_fn; 710Sstevel@tonic-gate void *mrf_arg; 720Sstevel@tonic-gate }; 730Sstevel@tonic-gate 740Sstevel@tonic-gate typedef struct mac_txloop_fn_s mac_txloop_fn_t; 750Sstevel@tonic-gate 760Sstevel@tonic-gate struct mac_txloop_fn_s { 770Sstevel@tonic-gate mac_txloop_fn_t *mtf_nextp; 780Sstevel@tonic-gate mac_txloop_t mtf_fn; 790Sstevel@tonic-gate void *mtf_arg; 800Sstevel@tonic-gate }; 810Sstevel@tonic-gate 82*2311Sseb typedef struct mactype_s { 83*2311Sseb const char *mt_ident; 84*2311Sseb uint32_t mt_ref; 85*2311Sseb uint_t mt_type; 86*2311Sseb size_t mt_addr_length; 87*2311Sseb uint8_t *mt_brdcst_addr; 88*2311Sseb mactype_ops_t mt_ops; 89*2311Sseb mac_stat_info_t *mt_stats; /* array of mac_stat_info_t elements */ 90*2311Sseb size_t mt_statcount; /* number of elements in mt_stats */ 91*2311Sseb } mactype_t; 920Sstevel@tonic-gate 93*2311Sseb /* 94*2311Sseb * Each registered MAC is associated with a mac_t structure. 95*2311Sseb */ 96*2311Sseb typedef struct mac_impl_s { 97*2311Sseb char mi_name[LIFNAMSIZ]; 98*2311Sseb const char *mi_drvname; 99*2311Sseb uint_t mi_instance; 100*2311Sseb void *mi_driver; /* Driver private data */ 101*2311Sseb mac_info_t mi_info; 102*2311Sseb mactype_t *mi_type; 103*2311Sseb void *mi_pdata; 104*2311Sseb size_t mi_pdata_size; 105*2311Sseb mac_callbacks_t *mi_callbacks; 106*2311Sseb dev_info_t *mi_dip; 1070Sstevel@tonic-gate uint32_t mi_ref; 1081852Syz147064 boolean_t mi_disabled; 1090Sstevel@tonic-gate krwlock_t mi_state_lock; 1100Sstevel@tonic-gate uint_t mi_active; 1110Sstevel@tonic-gate krwlock_t mi_data_lock; 112*2311Sseb link_state_t mi_linkstate; 1130Sstevel@tonic-gate uint_t mi_promisc; 1140Sstevel@tonic-gate uint_t mi_devpromisc; 115*2311Sseb uint8_t mi_addr[MAXMACADDRLEN]; 116*2311Sseb uint8_t mi_dstaddr[MAXMACADDRLEN]; 1170Sstevel@tonic-gate mac_multicst_addr_t *mi_mmap; 1180Sstevel@tonic-gate krwlock_t mi_notify_lock; 1190Sstevel@tonic-gate mac_notify_fn_t *mi_mnfp; 1201852Syz147064 kmutex_t mi_notify_ref_lock; 1211852Syz147064 uint32_t mi_notify_ref; 1221852Syz147064 kcondvar_t mi_notify_cv; 1230Sstevel@tonic-gate krwlock_t mi_rx_lock; 1240Sstevel@tonic-gate mac_rx_fn_t *mi_mrfp; 1250Sstevel@tonic-gate krwlock_t mi_txloop_lock; 1260Sstevel@tonic-gate mac_txloop_fn_t *mi_mtfp; 1270Sstevel@tonic-gate krwlock_t mi_resource_lock; 1280Sstevel@tonic-gate mac_resource_add_t mi_resource_add; 1290Sstevel@tonic-gate void *mi_resource_add_arg; 1300Sstevel@tonic-gate kstat_t *mi_ksp; 131*2311Sseb uint_t mi_kstat_count; 1320Sstevel@tonic-gate kmutex_t mi_activelink_lock; 1330Sstevel@tonic-gate boolean_t mi_activelink; 13456Smeem mac_txinfo_t mi_txinfo; 13556Smeem mac_txinfo_t mi_txloopinfo; 136*2311Sseb } mac_impl_t; 137*2311Sseb 138*2311Sseb #define mi_getstat mi_callbacks->mc_getstat 139*2311Sseb #define mi_start mi_callbacks->mc_start 140*2311Sseb #define mi_stop mi_callbacks->mc_stop 141*2311Sseb #define mi_setpromisc mi_callbacks->mc_setpromisc 142*2311Sseb #define mi_multicst mi_callbacks->mc_multicst 143*2311Sseb #define mi_unicst mi_callbacks->mc_unicst 144*2311Sseb #define mi_resources mi_callbacks->mc_resources 145*2311Sseb #define mi_tx mi_callbacks->mc_tx 146*2311Sseb #define mi_ioctl mi_callbacks->mc_ioctl 147*2311Sseb #define mi_getcapab mi_callbacks->mc_getcapab 1480Sstevel@tonic-gate 1491852Syz147064 typedef struct mac_notify_task_arg { 1501852Syz147064 mac_impl_t *mnt_mip; 1511852Syz147064 mac_notify_type_t mnt_type; 1521852Syz147064 } mac_notify_task_arg_t; 1531852Syz147064 1540Sstevel@tonic-gate extern void mac_init(void); 1550Sstevel@tonic-gate extern int mac_fini(void); 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate extern void mac_stat_create(mac_impl_t *); 1580Sstevel@tonic-gate extern void mac_stat_destroy(mac_impl_t *); 159*2311Sseb extern uint64_t mac_stat_default(mac_impl_t *, uint_t); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate #ifdef __cplusplus 1620Sstevel@tonic-gate } 1630Sstevel@tonic-gate #endif 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate #endif /* _SYS_MAC_IMPL_H */ 166