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> 322311Sseb #include <net/if.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 382311Sseb /* 39*2412Sseb * Statistics maintained internally by the mac module. 402311Sseb */ 41*2412Sseb enum mac_mod_stat { 422311Sseb MAC_STAT_LINK_STATE, 432311Sseb MAC_STAT_LINK_UP, 44*2412Sseb MAC_STAT_PROMISC 452311Sseb }; 462311Sseb 470Sstevel@tonic-gate typedef struct mac_multicst_addr_s mac_multicst_addr_t; 480Sstevel@tonic-gate 490Sstevel@tonic-gate struct mac_multicst_addr_s { 500Sstevel@tonic-gate mac_multicst_addr_t *mma_nextp; 510Sstevel@tonic-gate uint_t mma_ref; 522311Sseb uint8_t mma_addr[MAXMACADDRLEN]; 530Sstevel@tonic-gate }; 540Sstevel@tonic-gate 550Sstevel@tonic-gate typedef struct mac_notify_fn_s mac_notify_fn_t; 560Sstevel@tonic-gate 570Sstevel@tonic-gate struct mac_notify_fn_s { 580Sstevel@tonic-gate mac_notify_fn_t *mnf_nextp; 590Sstevel@tonic-gate mac_notify_t mnf_fn; 600Sstevel@tonic-gate void *mnf_arg; 610Sstevel@tonic-gate }; 620Sstevel@tonic-gate 630Sstevel@tonic-gate typedef struct mac_rx_fn_s mac_rx_fn_t; 640Sstevel@tonic-gate 650Sstevel@tonic-gate struct mac_rx_fn_s { 660Sstevel@tonic-gate mac_rx_fn_t *mrf_nextp; 670Sstevel@tonic-gate mac_rx_t mrf_fn; 680Sstevel@tonic-gate void *mrf_arg; 690Sstevel@tonic-gate }; 700Sstevel@tonic-gate 710Sstevel@tonic-gate typedef struct mac_txloop_fn_s mac_txloop_fn_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate struct mac_txloop_fn_s { 740Sstevel@tonic-gate mac_txloop_fn_t *mtf_nextp; 750Sstevel@tonic-gate mac_txloop_t mtf_fn; 760Sstevel@tonic-gate void *mtf_arg; 770Sstevel@tonic-gate }; 780Sstevel@tonic-gate 792311Sseb typedef struct mactype_s { 802311Sseb const char *mt_ident; 812311Sseb uint32_t mt_ref; 822311Sseb uint_t mt_type; 832311Sseb size_t mt_addr_length; 842311Sseb uint8_t *mt_brdcst_addr; 852311Sseb mactype_ops_t mt_ops; 862311Sseb mac_stat_info_t *mt_stats; /* array of mac_stat_info_t elements */ 872311Sseb size_t mt_statcount; /* number of elements in mt_stats */ 882311Sseb } mactype_t; 890Sstevel@tonic-gate 902311Sseb /* 912311Sseb * Each registered MAC is associated with a mac_t structure. 922311Sseb */ 932311Sseb typedef struct mac_impl_s { 942311Sseb char mi_name[LIFNAMSIZ]; 952311Sseb const char *mi_drvname; 962311Sseb uint_t mi_instance; 972311Sseb void *mi_driver; /* Driver private data */ 982311Sseb mac_info_t mi_info; 992311Sseb mactype_t *mi_type; 1002311Sseb void *mi_pdata; 1012311Sseb size_t mi_pdata_size; 1022311Sseb mac_callbacks_t *mi_callbacks; 1032311Sseb dev_info_t *mi_dip; 1040Sstevel@tonic-gate uint32_t mi_ref; 1051852Syz147064 boolean_t mi_disabled; 1060Sstevel@tonic-gate krwlock_t mi_state_lock; 1070Sstevel@tonic-gate uint_t mi_active; 1080Sstevel@tonic-gate krwlock_t mi_data_lock; 1092311Sseb link_state_t mi_linkstate; 1100Sstevel@tonic-gate uint_t mi_promisc; 1110Sstevel@tonic-gate uint_t mi_devpromisc; 1122311Sseb uint8_t mi_addr[MAXMACADDRLEN]; 1132311Sseb uint8_t mi_dstaddr[MAXMACADDRLEN]; 1140Sstevel@tonic-gate mac_multicst_addr_t *mi_mmap; 1150Sstevel@tonic-gate krwlock_t mi_notify_lock; 1160Sstevel@tonic-gate mac_notify_fn_t *mi_mnfp; 1171852Syz147064 kmutex_t mi_notify_ref_lock; 1181852Syz147064 uint32_t mi_notify_ref; 1191852Syz147064 kcondvar_t mi_notify_cv; 1200Sstevel@tonic-gate krwlock_t mi_rx_lock; 1210Sstevel@tonic-gate mac_rx_fn_t *mi_mrfp; 1220Sstevel@tonic-gate krwlock_t mi_txloop_lock; 1230Sstevel@tonic-gate mac_txloop_fn_t *mi_mtfp; 1240Sstevel@tonic-gate krwlock_t mi_resource_lock; 1250Sstevel@tonic-gate mac_resource_add_t mi_resource_add; 1260Sstevel@tonic-gate void *mi_resource_add_arg; 1270Sstevel@tonic-gate kstat_t *mi_ksp; 1282311Sseb uint_t mi_kstat_count; 1290Sstevel@tonic-gate kmutex_t mi_activelink_lock; 1300Sstevel@tonic-gate boolean_t mi_activelink; 13156Smeem mac_txinfo_t mi_txinfo; 13256Smeem mac_txinfo_t mi_txloopinfo; 1332311Sseb } mac_impl_t; 1342311Sseb 1352311Sseb #define mi_getstat mi_callbacks->mc_getstat 1362311Sseb #define mi_start mi_callbacks->mc_start 1372311Sseb #define mi_stop mi_callbacks->mc_stop 1382311Sseb #define mi_setpromisc mi_callbacks->mc_setpromisc 1392311Sseb #define mi_multicst mi_callbacks->mc_multicst 1402311Sseb #define mi_unicst mi_callbacks->mc_unicst 1412311Sseb #define mi_resources mi_callbacks->mc_resources 1422311Sseb #define mi_tx mi_callbacks->mc_tx 1432311Sseb #define mi_ioctl mi_callbacks->mc_ioctl 1442311Sseb #define mi_getcapab mi_callbacks->mc_getcapab 1450Sstevel@tonic-gate 1461852Syz147064 typedef struct mac_notify_task_arg { 1471852Syz147064 mac_impl_t *mnt_mip; 1481852Syz147064 mac_notify_type_t mnt_type; 1491852Syz147064 } mac_notify_task_arg_t; 1501852Syz147064 1510Sstevel@tonic-gate extern void mac_init(void); 1520Sstevel@tonic-gate extern int mac_fini(void); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate extern void mac_stat_create(mac_impl_t *); 1550Sstevel@tonic-gate extern void mac_stat_destroy(mac_impl_t *); 1562311Sseb extern uint64_t mac_stat_default(mac_impl_t *, uint_t); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate #ifdef __cplusplus 1590Sstevel@tonic-gate } 1600Sstevel@tonic-gate #endif 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate #endif /* _SYS_MAC_IMPL_H */ 163