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