1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_MAC_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_MAC_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/stream.h> 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * MAC Services Module 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 41*7c478bd9Sstevel@tonic-gate extern "C" { 42*7c478bd9Sstevel@tonic-gate #endif 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * Module name. 46*7c478bd9Sstevel@tonic-gate */ 47*7c478bd9Sstevel@tonic-gate #define MAC_MODULE_NAME "mac" 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate /* 50*7c478bd9Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate #define MAC_INFO "MAC Services v%I%" 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * Statistics 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define XCVR_UNDEFINED 0 59*7c478bd9Sstevel@tonic-gate #define XCVR_NONE 1 60*7c478bd9Sstevel@tonic-gate #define XCVR_10 2 61*7c478bd9Sstevel@tonic-gate #define XCVR_100T4 3 62*7c478bd9Sstevel@tonic-gate #define XCVR_100X 4 63*7c478bd9Sstevel@tonic-gate #define XCVR_100T2 5 64*7c478bd9Sstevel@tonic-gate #define XCVR_1000X 6 65*7c478bd9Sstevel@tonic-gate #define XCVR_1000T 7 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate typedef enum { 68*7c478bd9Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 69*7c478bd9Sstevel@tonic-gate LINK_STATE_DOWN, 70*7c478bd9Sstevel@tonic-gate LINK_STATE_UP 71*7c478bd9Sstevel@tonic-gate } link_state_t; 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate typedef enum { 74*7c478bd9Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 75*7c478bd9Sstevel@tonic-gate LINK_DUPLEX_HALF, 76*7c478bd9Sstevel@tonic-gate LINK_DUPLEX_FULL 77*7c478bd9Sstevel@tonic-gate } link_duplex_t; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate enum mac_stat { 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * PSARC 1997/198 (MIB-II kstats) 84*7c478bd9Sstevel@tonic-gate */ 85*7c478bd9Sstevel@tonic-gate MAC_STAT_IFSPEED, 86*7c478bd9Sstevel@tonic-gate MAC_STAT_MULTIRCV, 87*7c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 88*7c478bd9Sstevel@tonic-gate MAC_STAT_MULTIXMT, 89*7c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 90*7c478bd9Sstevel@tonic-gate MAC_STAT_NORCVBUF, 91*7c478bd9Sstevel@tonic-gate MAC_STAT_IERRORS, 92*7c478bd9Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 93*7c478bd9Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 94*7c478bd9Sstevel@tonic-gate MAC_STAT_OERRORS, 95*7c478bd9Sstevel@tonic-gate MAC_STAT_COLLISIONS, 96*7c478bd9Sstevel@tonic-gate MAC_STAT_RBYTES, 97*7c478bd9Sstevel@tonic-gate MAC_STAT_IPACKETS, 98*7c478bd9Sstevel@tonic-gate MAC_STAT_OBYTES, 99*7c478bd9Sstevel@tonic-gate MAC_STAT_OPACKETS, 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate /* 102*7c478bd9Sstevel@tonic-gate * PSARC 1997/247 (RFC 1643 kstats) 103*7c478bd9Sstevel@tonic-gate */ 104*7c478bd9Sstevel@tonic-gate MAC_STAT_ALIGN_ERRORS, 105*7c478bd9Sstevel@tonic-gate MAC_STAT_FCS_ERRORS, 106*7c478bd9Sstevel@tonic-gate MAC_STAT_FIRST_COLLISIONS, 107*7c478bd9Sstevel@tonic-gate MAC_STAT_MULTI_COLLISIONS, 108*7c478bd9Sstevel@tonic-gate MAC_STAT_SQE_ERRORS, 109*7c478bd9Sstevel@tonic-gate MAC_STAT_DEFER_XMTS, 110*7c478bd9Sstevel@tonic-gate MAC_STAT_TX_LATE_COLLISIONS, 111*7c478bd9Sstevel@tonic-gate MAC_STAT_EX_COLLISIONS, 112*7c478bd9Sstevel@tonic-gate MAC_STAT_MACXMT_ERRORS, 113*7c478bd9Sstevel@tonic-gate MAC_STAT_CARRIER_ERRORS, 114*7c478bd9Sstevel@tonic-gate MAC_STAT_TOOLONG_ERRORS, 115*7c478bd9Sstevel@tonic-gate MAC_STAT_MACRCV_ERRORS, 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate /* 118*7c478bd9Sstevel@tonic-gate * PSARC 2003/581 (MII/GMII kstats) 119*7c478bd9Sstevel@tonic-gate */ 120*7c478bd9Sstevel@tonic-gate MAC_STAT_XCVR_ADDR, 121*7c478bd9Sstevel@tonic-gate MAC_STAT_XCVR_ID, 122*7c478bd9Sstevel@tonic-gate MAC_STAT_XCVR_INUSE, 123*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_1000FDX, 124*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_1000HDX, 125*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_100FDX, 126*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_100HDX, 127*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_10FDX, 128*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_10HDX, 129*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_ASMPAUSE, 130*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_PAUSE, 131*7c478bd9Sstevel@tonic-gate MAC_STAT_CAP_AUTONEG, 132*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_1000FDX, 133*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_1000HDX, 134*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_100FDX, 135*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_100HDX, 136*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_10FDX, 137*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_10HDX, 138*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_ASMPAUSE, 139*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_PAUSE, 140*7c478bd9Sstevel@tonic-gate MAC_STAT_ADV_CAP_AUTONEG, 141*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_1000FDX, 142*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_1000HDX, 143*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_100FDX, 144*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_100HDX, 145*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_10FDX, 146*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_10HDX, 147*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_ASMPAUSE, 148*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_PAUSE, 149*7c478bd9Sstevel@tonic-gate MAC_STAT_LP_CAP_AUTONEG, 150*7c478bd9Sstevel@tonic-gate MAC_STAT_LINK_ASMPAUSE, 151*7c478bd9Sstevel@tonic-gate MAC_STAT_LINK_PAUSE, 152*7c478bd9Sstevel@tonic-gate MAC_STAT_LINK_AUTONEG, 153*7c478bd9Sstevel@tonic-gate MAC_STAT_LINK_DUPLEX, 154*7c478bd9Sstevel@tonic-gate MAC_NSTAT /* must be the last entry */ 155*7c478bd9Sstevel@tonic-gate }; 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate /* 158*7c478bd9Sstevel@tonic-gate * Maximum MAC address length 159*7c478bd9Sstevel@tonic-gate */ 160*7c478bd9Sstevel@tonic-gate #define MAXADDRLEN 20 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* 163*7c478bd9Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 164*7c478bd9Sstevel@tonic-gate */ 165*7c478bd9Sstevel@tonic-gate typedef struct mac_info_s { 166*7c478bd9Sstevel@tonic-gate uint_t mi_media; 167*7c478bd9Sstevel@tonic-gate uint_t mi_sdu_min; 168*7c478bd9Sstevel@tonic-gate uint_t mi_sdu_max; 169*7c478bd9Sstevel@tonic-gate uint32_t mi_cksum; 170*7c478bd9Sstevel@tonic-gate uint32_t mi_poll; 171*7c478bd9Sstevel@tonic-gate uint_t mi_addr_length; 172*7c478bd9Sstevel@tonic-gate uint8_t mi_unicst_addr[MAXADDRLEN]; 173*7c478bd9Sstevel@tonic-gate uint8_t mi_brdcst_addr[MAXADDRLEN]; 174*7c478bd9Sstevel@tonic-gate boolean_t mi_stat[MAC_NSTAT]; 175*7c478bd9Sstevel@tonic-gate } mac_info_t; 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate #define MAC_STAT_MIB(_mi_stat) \ 178*7c478bd9Sstevel@tonic-gate { \ 179*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IFSPEED] = B_TRUE; \ 180*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTIRCV] = B_TRUE; \ 181*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_BRDCSTRCV] = B_TRUE; \ 182*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTIXMT] = B_TRUE; \ 183*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_BRDCSTXMT] = B_TRUE; \ 184*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_NORCVBUF] = B_TRUE; \ 185*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IERRORS] = B_TRUE; \ 186*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_UNKNOWNS] = B_TRUE; \ 187*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_NOXMTBUF] = B_TRUE; \ 188*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OERRORS] = B_TRUE; \ 189*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_COLLISIONS] = B_TRUE; \ 190*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_RBYTES] = B_TRUE; \ 191*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IPACKETS] = B_TRUE; \ 192*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OBYTES] = B_TRUE; \ 193*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OPACKETS] = B_TRUE; \ 194*7c478bd9Sstevel@tonic-gate } 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate #define MAC_STAT_ETHER(_mi_stat) \ 197*7c478bd9Sstevel@tonic-gate { \ 198*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ALIGN_ERRORS] = B_TRUE; \ 199*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_FCS_ERRORS] = B_TRUE; \ 200*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_FIRST_COLLISIONS] = B_TRUE; \ 201*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTI_COLLISIONS] = B_TRUE; \ 202*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_SQE_ERRORS] = B_TRUE; \ 203*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_DEFER_XMTS] = B_TRUE; \ 204*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_TX_LATE_COLLISIONS] = B_TRUE; \ 205*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_EX_COLLISIONS] = B_TRUE; \ 206*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MACXMT_ERRORS] = B_TRUE; \ 207*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CARRIER_ERRORS] = B_TRUE; \ 208*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_TOOLONG_ERRORS] = B_TRUE; \ 209*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MACRCV_ERRORS] = B_TRUE; \ 210*7c478bd9Sstevel@tonic-gate } 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate #define MAC_STAT_MII(_mi_stat) \ 213*7c478bd9Sstevel@tonic-gate { \ 214*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_ADDR] = B_TRUE; \ 215*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_ID] = B_TRUE; \ 216*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_INUSE] = B_TRUE; \ 217*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_1000FDX] = B_TRUE; \ 218*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_1000HDX] = B_TRUE; \ 219*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_100FDX] = B_TRUE; \ 220*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_100HDX] = B_TRUE; \ 221*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_10FDX] = B_TRUE; \ 222*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_10HDX] = B_TRUE; \ 223*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_ASMPAUSE] = B_TRUE; \ 224*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_PAUSE] = B_TRUE; \ 225*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_AUTONEG] = B_TRUE; \ 226*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_1000FDX] = B_TRUE; \ 227*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_1000HDX] = B_TRUE; \ 228*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_100FDX] = B_TRUE; \ 229*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_100HDX] = B_TRUE; \ 230*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_10FDX] = B_TRUE; \ 231*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_10HDX] = B_TRUE; \ 232*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_ASMPAUSE] = B_TRUE; \ 233*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_PAUSE] = B_TRUE; \ 234*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_AUTONEG] = B_TRUE; \ 235*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_1000FDX] = B_TRUE; \ 236*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_1000HDX] = B_TRUE; \ 237*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_100FDX] = B_TRUE; \ 238*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_100HDX] = B_TRUE; \ 239*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_10FDX] = B_TRUE; \ 240*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_10HDX] = B_TRUE; \ 241*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_ASMPAUSE] = B_TRUE; \ 242*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_PAUSE] = B_TRUE; \ 243*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_AUTONEG] = B_TRUE; \ 244*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_ASMPAUSE] = B_TRUE; \ 245*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_PAUSE] = B_TRUE; \ 246*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_AUTONEG] = B_TRUE; \ 247*7c478bd9Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_DUPLEX] = B_TRUE; \ 248*7c478bd9Sstevel@tonic-gate } 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate /* 251*7c478bd9Sstevel@tonic-gate * MAC version identifer (for debugging) 252*7c478bd9Sstevel@tonic-gate */ 253*7c478bd9Sstevel@tonic-gate #define MAC_IDENT "%I%" 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate /* 256*7c478bd9Sstevel@tonic-gate * MAC driver entry point types. 257*7c478bd9Sstevel@tonic-gate */ 258*7c478bd9Sstevel@tonic-gate typedef uint64_t (*mac_stat_t)(void *, enum mac_stat); 259*7c478bd9Sstevel@tonic-gate typedef int (*mac_start_t)(void *); 260*7c478bd9Sstevel@tonic-gate typedef void (*mac_stop_t)(void *); 261*7c478bd9Sstevel@tonic-gate typedef int (*mac_promisc_t)(void *, boolean_t); 262*7c478bd9Sstevel@tonic-gate typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 263*7c478bd9Sstevel@tonic-gate typedef int (*mac_unicst_t)(void *, const uint8_t *); 264*7c478bd9Sstevel@tonic-gate typedef void (*mac_resources_t)(void *); 265*7c478bd9Sstevel@tonic-gate typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 266*7c478bd9Sstevel@tonic-gate typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate /* 269*7c478bd9Sstevel@tonic-gate * MAC extensions. (Currently there are non defined). 270*7c478bd9Sstevel@tonic-gate */ 271*7c478bd9Sstevel@tonic-gate typedef struct mac_ext_s mac_ext_t; 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate /* 274*7c478bd9Sstevel@tonic-gate * MAC implementation private data. 275*7c478bd9Sstevel@tonic-gate */ 276*7c478bd9Sstevel@tonic-gate typedef struct mac_impl_s mac_impl_t; 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate /* 279*7c478bd9Sstevel@tonic-gate * MAC structure: supplied by the driver. 280*7c478bd9Sstevel@tonic-gate */ 281*7c478bd9Sstevel@tonic-gate typedef struct mac { 282*7c478bd9Sstevel@tonic-gate const char *m_ident; /* MAC_IDENT */ 283*7c478bd9Sstevel@tonic-gate mac_ext_t *m_extp; 284*7c478bd9Sstevel@tonic-gate mac_impl_t *m_impl; /* MAC private data */ 285*7c478bd9Sstevel@tonic-gate void *m_driver; /* Driver private data */ 286*7c478bd9Sstevel@tonic-gate 287*7c478bd9Sstevel@tonic-gate dev_info_t *m_dip; 288*7c478bd9Sstevel@tonic-gate uint_t m_port; 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate mac_info_t m_info; 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate mac_stat_t m_stat; 293*7c478bd9Sstevel@tonic-gate mac_start_t m_start; 294*7c478bd9Sstevel@tonic-gate mac_stop_t m_stop; 295*7c478bd9Sstevel@tonic-gate mac_promisc_t m_promisc; 296*7c478bd9Sstevel@tonic-gate mac_multicst_t m_multicst; 297*7c478bd9Sstevel@tonic-gate mac_unicst_t m_unicst; 298*7c478bd9Sstevel@tonic-gate mac_resources_t m_resources; 299*7c478bd9Sstevel@tonic-gate mac_ioctl_t m_ioctl; 300*7c478bd9Sstevel@tonic-gate mac_tx_t m_tx; 301*7c478bd9Sstevel@tonic-gate } mac_t; 302*7c478bd9Sstevel@tonic-gate 303*7c478bd9Sstevel@tonic-gate /* 304*7c478bd9Sstevel@tonic-gate * Construct the name of a MAC interface. 305*7c478bd9Sstevel@tonic-gate */ 306*7c478bd9Sstevel@tonic-gate #define MAC_NAME(_name, _dev, _port) \ 307*7c478bd9Sstevel@tonic-gate (void) snprintf((_name), MAXNAMELEN - 1, "%s/%u", (_dev), (_port)) 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate /* 310*7c478bd9Sstevel@tonic-gate * Opaque handle types. 311*7c478bd9Sstevel@tonic-gate */ 312*7c478bd9Sstevel@tonic-gate typedef struct __mac_handle *mac_handle_t; 313*7c478bd9Sstevel@tonic-gate typedef struct __mac_notify_handle *mac_notify_handle_t; 314*7c478bd9Sstevel@tonic-gate typedef struct __mac_rx_handle *mac_rx_handle_t; 315*7c478bd9Sstevel@tonic-gate typedef struct __mac_txloop_handle *mac_txloop_handle_t; 316*7c478bd9Sstevel@tonic-gate typedef struct __mac_resource_handle *mac_resource_handle_t; 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate /* 319*7c478bd9Sstevel@tonic-gate * MAC interface callback types. 320*7c478bd9Sstevel@tonic-gate */ 321*7c478bd9Sstevel@tonic-gate typedef enum { 322*7c478bd9Sstevel@tonic-gate MAC_NOTE_LINK, 323*7c478bd9Sstevel@tonic-gate MAC_NOTE_PROMISC, 324*7c478bd9Sstevel@tonic-gate MAC_NOTE_UNICST, 325*7c478bd9Sstevel@tonic-gate MAC_NOTE_TX, 326*7c478bd9Sstevel@tonic-gate MAC_NOTE_RESOURCE, 327*7c478bd9Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 328*7c478bd9Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 329*7c478bd9Sstevel@tonic-gate } mac_notify_type_t; 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 332*7c478bd9Sstevel@tonic-gate typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *); 333*7c478bd9Sstevel@tonic-gate typedef void (*mac_txloop_t)(void *, mblk_t *); 334*7c478bd9Sstevel@tonic-gate typedef void (*mac_blank_t)(void *, time_t, uint_t); 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate /* 337*7c478bd9Sstevel@tonic-gate * MAC promiscuous types 338*7c478bd9Sstevel@tonic-gate */ 339*7c478bd9Sstevel@tonic-gate typedef enum { 340*7c478bd9Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 341*7c478bd9Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 342*7c478bd9Sstevel@tonic-gate } mac_promisc_type_t; 343*7c478bd9Sstevel@tonic-gate 344*7c478bd9Sstevel@tonic-gate /* 345*7c478bd9Sstevel@tonic-gate * MAC resource types 346*7c478bd9Sstevel@tonic-gate */ 347*7c478bd9Sstevel@tonic-gate typedef enum { 348*7c478bd9Sstevel@tonic-gate MAC_RX_FIFO = 1 349*7c478bd9Sstevel@tonic-gate } mac_resource_type_t; 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 352*7c478bd9Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 353*7c478bd9Sstevel@tonic-gate mac_blank_t mrf_blank; 354*7c478bd9Sstevel@tonic-gate void *mrf_arg; 355*7c478bd9Sstevel@tonic-gate time_t mrf_normal_blank_time; 356*7c478bd9Sstevel@tonic-gate uint_t mrf_normal_pkt_count; 357*7c478bd9Sstevel@tonic-gate } mac_rx_fifo_t; 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate typedef union mac_resource_u { 360*7c478bd9Sstevel@tonic-gate mac_resource_type_t mr_type; 361*7c478bd9Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 362*7c478bd9Sstevel@tonic-gate } mac_resource_t; 363*7c478bd9Sstevel@tonic-gate 364*7c478bd9Sstevel@tonic-gate typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 365*7c478bd9Sstevel@tonic-gate 366*7c478bd9Sstevel@tonic-gate /* 367*7c478bd9Sstevel@tonic-gate * Client interface functions. 368*7c478bd9Sstevel@tonic-gate */ 369*7c478bd9Sstevel@tonic-gate extern int mac_open(const char *, uint_t, mac_handle_t *); 370*7c478bd9Sstevel@tonic-gate extern void mac_close(mac_handle_t); 371*7c478bd9Sstevel@tonic-gate extern const mac_info_t *mac_info(mac_handle_t); 372*7c478bd9Sstevel@tonic-gate extern uint64_t mac_stat_get(mac_handle_t, enum mac_stat); 373*7c478bd9Sstevel@tonic-gate extern int mac_start(mac_handle_t); 374*7c478bd9Sstevel@tonic-gate extern void mac_stop(mac_handle_t); 375*7c478bd9Sstevel@tonic-gate extern int mac_promisc_set(mac_handle_t, boolean_t, 376*7c478bd9Sstevel@tonic-gate mac_promisc_type_t); 377*7c478bd9Sstevel@tonic-gate extern boolean_t mac_promisc_get(mac_handle_t, 378*7c478bd9Sstevel@tonic-gate mac_promisc_type_t); 379*7c478bd9Sstevel@tonic-gate extern int mac_multicst_add(mac_handle_t, const uint8_t *); 380*7c478bd9Sstevel@tonic-gate extern int mac_multicst_remove(mac_handle_t, 381*7c478bd9Sstevel@tonic-gate const uint8_t *); 382*7c478bd9Sstevel@tonic-gate extern int mac_unicst_set(mac_handle_t, const uint8_t *); 383*7c478bd9Sstevel@tonic-gate extern void mac_unicst_get(mac_handle_t, uint8_t *); 384*7c478bd9Sstevel@tonic-gate extern void mac_resources(mac_handle_t); 385*7c478bd9Sstevel@tonic-gate extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 386*7c478bd9Sstevel@tonic-gate extern void mac_tx_get(mac_handle_t, mac_tx_t *, void **); 387*7c478bd9Sstevel@tonic-gate extern link_state_t mac_link_get(mac_handle_t); 388*7c478bd9Sstevel@tonic-gate extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, 389*7c478bd9Sstevel@tonic-gate void *); 390*7c478bd9Sstevel@tonic-gate extern void mac_notify_remove(mac_handle_t, 391*7c478bd9Sstevel@tonic-gate mac_notify_handle_t); 392*7c478bd9Sstevel@tonic-gate extern void mac_notify(mac_handle_t); 393*7c478bd9Sstevel@tonic-gate extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *); 394*7c478bd9Sstevel@tonic-gate extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t); 395*7c478bd9Sstevel@tonic-gate extern mblk_t *mac_txloop(void *, mblk_t *); 396*7c478bd9Sstevel@tonic-gate extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t, 397*7c478bd9Sstevel@tonic-gate void *); 398*7c478bd9Sstevel@tonic-gate extern void mac_txloop_remove(mac_handle_t, 399*7c478bd9Sstevel@tonic-gate mac_txloop_handle_t); 400*7c478bd9Sstevel@tonic-gate extern boolean_t mac_active_set(mac_handle_t); 401*7c478bd9Sstevel@tonic-gate extern void mac_active_clear(mac_handle_t); 402*7c478bd9Sstevel@tonic-gate extern void mac_resource_set(mac_handle_t, 403*7c478bd9Sstevel@tonic-gate mac_resource_add_t, void *); 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* 406*7c478bd9Sstevel@tonic-gate * Driver interface functions. 407*7c478bd9Sstevel@tonic-gate */ 408*7c478bd9Sstevel@tonic-gate extern int mac_register(mac_t *); 409*7c478bd9Sstevel@tonic-gate extern int mac_unregister(mac_t *); 410*7c478bd9Sstevel@tonic-gate extern void mac_rx(mac_t *, mac_resource_handle_t, 411*7c478bd9Sstevel@tonic-gate mblk_t *); 412*7c478bd9Sstevel@tonic-gate extern void mac_link_update(mac_t *, link_state_t); 413*7c478bd9Sstevel@tonic-gate extern void mac_unicst_update(mac_t *, const uint8_t *); 414*7c478bd9Sstevel@tonic-gate extern void mac_tx_update(mac_t *); 415*7c478bd9Sstevel@tonic-gate extern void mac_resource_update(mac_t *); 416*7c478bd9Sstevel@tonic-gate extern mac_resource_handle_t mac_resource_add(mac_t *, mac_resource_t *); 417*7c478bd9Sstevel@tonic-gate extern void mac_multicst_refresh(mac_t *, mac_multicst_t, 418*7c478bd9Sstevel@tonic-gate void *, boolean_t); 419*7c478bd9Sstevel@tonic-gate extern void mac_unicst_refresh(mac_t *, mac_unicst_t, 420*7c478bd9Sstevel@tonic-gate void *); 421*7c478bd9Sstevel@tonic-gate extern void mac_promisc_refresh(mac_t *, mac_promisc_t, 422*7c478bd9Sstevel@tonic-gate void *); 423*7c478bd9Sstevel@tonic-gate 424*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 425*7c478bd9Sstevel@tonic-gate 426*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427*7c478bd9Sstevel@tonic-gate } 428*7c478bd9Sstevel@tonic-gate #endif 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 431