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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_MAC_H 280Sstevel@tonic-gate #define _SYS_MAC_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/ddi.h> 330Sstevel@tonic-gate #include <sys/sunddi.h> 340Sstevel@tonic-gate #include <sys/stream.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* 370Sstevel@tonic-gate * MAC Services Module 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 450Sstevel@tonic-gate * Module name. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate #define MAC_MODULE_NAME "mac" 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 500Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate #define MAC_INFO "MAC Services v%I%" 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * Statistics 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate #define XCVR_UNDEFINED 0 590Sstevel@tonic-gate #define XCVR_NONE 1 600Sstevel@tonic-gate #define XCVR_10 2 610Sstevel@tonic-gate #define XCVR_100T4 3 620Sstevel@tonic-gate #define XCVR_100X 4 630Sstevel@tonic-gate #define XCVR_100T2 5 640Sstevel@tonic-gate #define XCVR_1000X 6 650Sstevel@tonic-gate #define XCVR_1000T 7 660Sstevel@tonic-gate 670Sstevel@tonic-gate typedef enum { 680Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 690Sstevel@tonic-gate LINK_STATE_DOWN, 700Sstevel@tonic-gate LINK_STATE_UP 710Sstevel@tonic-gate } link_state_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate typedef enum { 740Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 750Sstevel@tonic-gate LINK_DUPLEX_HALF, 760Sstevel@tonic-gate LINK_DUPLEX_FULL 770Sstevel@tonic-gate } link_duplex_t; 780Sstevel@tonic-gate 790Sstevel@tonic-gate #ifdef _KERNEL 800Sstevel@tonic-gate 810Sstevel@tonic-gate enum mac_stat { 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * PSARC 1997/198 (MIB-II kstats) 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate MAC_STAT_IFSPEED, 860Sstevel@tonic-gate MAC_STAT_MULTIRCV, 870Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 880Sstevel@tonic-gate MAC_STAT_MULTIXMT, 890Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 900Sstevel@tonic-gate MAC_STAT_NORCVBUF, 910Sstevel@tonic-gate MAC_STAT_IERRORS, 920Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 930Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 940Sstevel@tonic-gate MAC_STAT_OERRORS, 950Sstevel@tonic-gate MAC_STAT_COLLISIONS, 960Sstevel@tonic-gate MAC_STAT_RBYTES, 970Sstevel@tonic-gate MAC_STAT_IPACKETS, 980Sstevel@tonic-gate MAC_STAT_OBYTES, 990Sstevel@tonic-gate MAC_STAT_OPACKETS, 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* 1020Sstevel@tonic-gate * PSARC 1997/247 (RFC 1643 kstats) 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate MAC_STAT_ALIGN_ERRORS, 1050Sstevel@tonic-gate MAC_STAT_FCS_ERRORS, 1060Sstevel@tonic-gate MAC_STAT_FIRST_COLLISIONS, 1070Sstevel@tonic-gate MAC_STAT_MULTI_COLLISIONS, 1080Sstevel@tonic-gate MAC_STAT_SQE_ERRORS, 1090Sstevel@tonic-gate MAC_STAT_DEFER_XMTS, 1100Sstevel@tonic-gate MAC_STAT_TX_LATE_COLLISIONS, 1110Sstevel@tonic-gate MAC_STAT_EX_COLLISIONS, 1120Sstevel@tonic-gate MAC_STAT_MACXMT_ERRORS, 1130Sstevel@tonic-gate MAC_STAT_CARRIER_ERRORS, 1140Sstevel@tonic-gate MAC_STAT_TOOLONG_ERRORS, 1150Sstevel@tonic-gate MAC_STAT_MACRCV_ERRORS, 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* 1180Sstevel@tonic-gate * PSARC 2003/581 (MII/GMII kstats) 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate MAC_STAT_XCVR_ADDR, 1210Sstevel@tonic-gate MAC_STAT_XCVR_ID, 1220Sstevel@tonic-gate MAC_STAT_XCVR_INUSE, 1230Sstevel@tonic-gate MAC_STAT_CAP_1000FDX, 1240Sstevel@tonic-gate MAC_STAT_CAP_1000HDX, 1250Sstevel@tonic-gate MAC_STAT_CAP_100FDX, 1260Sstevel@tonic-gate MAC_STAT_CAP_100HDX, 1270Sstevel@tonic-gate MAC_STAT_CAP_10FDX, 1280Sstevel@tonic-gate MAC_STAT_CAP_10HDX, 1290Sstevel@tonic-gate MAC_STAT_CAP_ASMPAUSE, 1300Sstevel@tonic-gate MAC_STAT_CAP_PAUSE, 1310Sstevel@tonic-gate MAC_STAT_CAP_AUTONEG, 1320Sstevel@tonic-gate MAC_STAT_ADV_CAP_1000FDX, 1330Sstevel@tonic-gate MAC_STAT_ADV_CAP_1000HDX, 1340Sstevel@tonic-gate MAC_STAT_ADV_CAP_100FDX, 1350Sstevel@tonic-gate MAC_STAT_ADV_CAP_100HDX, 1360Sstevel@tonic-gate MAC_STAT_ADV_CAP_10FDX, 1370Sstevel@tonic-gate MAC_STAT_ADV_CAP_10HDX, 1380Sstevel@tonic-gate MAC_STAT_ADV_CAP_ASMPAUSE, 1390Sstevel@tonic-gate MAC_STAT_ADV_CAP_PAUSE, 1400Sstevel@tonic-gate MAC_STAT_ADV_CAP_AUTONEG, 1410Sstevel@tonic-gate MAC_STAT_LP_CAP_1000FDX, 1420Sstevel@tonic-gate MAC_STAT_LP_CAP_1000HDX, 1430Sstevel@tonic-gate MAC_STAT_LP_CAP_100FDX, 1440Sstevel@tonic-gate MAC_STAT_LP_CAP_100HDX, 1450Sstevel@tonic-gate MAC_STAT_LP_CAP_10FDX, 1460Sstevel@tonic-gate MAC_STAT_LP_CAP_10HDX, 1470Sstevel@tonic-gate MAC_STAT_LP_CAP_ASMPAUSE, 1480Sstevel@tonic-gate MAC_STAT_LP_CAP_PAUSE, 1490Sstevel@tonic-gate MAC_STAT_LP_CAP_AUTONEG, 1500Sstevel@tonic-gate MAC_STAT_LINK_ASMPAUSE, 1510Sstevel@tonic-gate MAC_STAT_LINK_PAUSE, 1520Sstevel@tonic-gate MAC_STAT_LINK_AUTONEG, 1530Sstevel@tonic-gate MAC_STAT_LINK_DUPLEX, 1540Sstevel@tonic-gate MAC_NSTAT /* must be the last entry */ 1550Sstevel@tonic-gate }; 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* 1580Sstevel@tonic-gate * Maximum MAC address length 1590Sstevel@tonic-gate */ 1600Sstevel@tonic-gate #define MAXADDRLEN 20 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate /* 1630Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 1640Sstevel@tonic-gate */ 1650Sstevel@tonic-gate typedef struct mac_info_s { 1660Sstevel@tonic-gate uint_t mi_media; 1670Sstevel@tonic-gate uint_t mi_sdu_min; 1680Sstevel@tonic-gate uint_t mi_sdu_max; 1690Sstevel@tonic-gate uint32_t mi_cksum; 1700Sstevel@tonic-gate uint32_t mi_poll; 1710Sstevel@tonic-gate uint_t mi_addr_length; 1720Sstevel@tonic-gate uint8_t mi_unicst_addr[MAXADDRLEN]; 1730Sstevel@tonic-gate uint8_t mi_brdcst_addr[MAXADDRLEN]; 1740Sstevel@tonic-gate boolean_t mi_stat[MAC_NSTAT]; 1750Sstevel@tonic-gate } mac_info_t; 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate #define MAC_STAT_MIB(_mi_stat) \ 1780Sstevel@tonic-gate { \ 1790Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IFSPEED] = B_TRUE; \ 1800Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTIRCV] = B_TRUE; \ 1810Sstevel@tonic-gate (_mi_stat)[MAC_STAT_BRDCSTRCV] = B_TRUE; \ 1820Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTIXMT] = B_TRUE; \ 1830Sstevel@tonic-gate (_mi_stat)[MAC_STAT_BRDCSTXMT] = B_TRUE; \ 1840Sstevel@tonic-gate (_mi_stat)[MAC_STAT_NORCVBUF] = B_TRUE; \ 1850Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IERRORS] = B_TRUE; \ 1860Sstevel@tonic-gate (_mi_stat)[MAC_STAT_UNKNOWNS] = B_TRUE; \ 1870Sstevel@tonic-gate (_mi_stat)[MAC_STAT_NOXMTBUF] = B_TRUE; \ 1880Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OERRORS] = B_TRUE; \ 1890Sstevel@tonic-gate (_mi_stat)[MAC_STAT_COLLISIONS] = B_TRUE; \ 1900Sstevel@tonic-gate (_mi_stat)[MAC_STAT_RBYTES] = B_TRUE; \ 1910Sstevel@tonic-gate (_mi_stat)[MAC_STAT_IPACKETS] = B_TRUE; \ 1920Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OBYTES] = B_TRUE; \ 1930Sstevel@tonic-gate (_mi_stat)[MAC_STAT_OPACKETS] = B_TRUE; \ 1940Sstevel@tonic-gate } 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate #define MAC_STAT_ETHER(_mi_stat) \ 1970Sstevel@tonic-gate { \ 1980Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ALIGN_ERRORS] = B_TRUE; \ 1990Sstevel@tonic-gate (_mi_stat)[MAC_STAT_FCS_ERRORS] = B_TRUE; \ 2000Sstevel@tonic-gate (_mi_stat)[MAC_STAT_FIRST_COLLISIONS] = B_TRUE; \ 2010Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MULTI_COLLISIONS] = B_TRUE; \ 2020Sstevel@tonic-gate (_mi_stat)[MAC_STAT_SQE_ERRORS] = B_TRUE; \ 2030Sstevel@tonic-gate (_mi_stat)[MAC_STAT_DEFER_XMTS] = B_TRUE; \ 2040Sstevel@tonic-gate (_mi_stat)[MAC_STAT_TX_LATE_COLLISIONS] = B_TRUE; \ 2050Sstevel@tonic-gate (_mi_stat)[MAC_STAT_EX_COLLISIONS] = B_TRUE; \ 2060Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MACXMT_ERRORS] = B_TRUE; \ 2070Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CARRIER_ERRORS] = B_TRUE; \ 2080Sstevel@tonic-gate (_mi_stat)[MAC_STAT_TOOLONG_ERRORS] = B_TRUE; \ 2090Sstevel@tonic-gate (_mi_stat)[MAC_STAT_MACRCV_ERRORS] = B_TRUE; \ 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate #define MAC_STAT_MII(_mi_stat) \ 2130Sstevel@tonic-gate { \ 2140Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_ADDR] = B_TRUE; \ 2150Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_ID] = B_TRUE; \ 2160Sstevel@tonic-gate (_mi_stat)[MAC_STAT_XCVR_INUSE] = B_TRUE; \ 2170Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_1000FDX] = B_TRUE; \ 2180Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_1000HDX] = B_TRUE; \ 2190Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_100FDX] = B_TRUE; \ 2200Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_100HDX] = B_TRUE; \ 2210Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_10FDX] = B_TRUE; \ 2220Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_10HDX] = B_TRUE; \ 2230Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_ASMPAUSE] = B_TRUE; \ 2240Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_PAUSE] = B_TRUE; \ 2250Sstevel@tonic-gate (_mi_stat)[MAC_STAT_CAP_AUTONEG] = B_TRUE; \ 2260Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_1000FDX] = B_TRUE; \ 2270Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_1000HDX] = B_TRUE; \ 2280Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_100FDX] = B_TRUE; \ 2290Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_100HDX] = B_TRUE; \ 2300Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_10FDX] = B_TRUE; \ 2310Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_10HDX] = B_TRUE; \ 2320Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_ASMPAUSE] = B_TRUE; \ 2330Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_PAUSE] = B_TRUE; \ 2340Sstevel@tonic-gate (_mi_stat)[MAC_STAT_ADV_CAP_AUTONEG] = B_TRUE; \ 2350Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_1000FDX] = B_TRUE; \ 2360Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_1000HDX] = B_TRUE; \ 2370Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_100FDX] = B_TRUE; \ 2380Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_100HDX] = B_TRUE; \ 2390Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_10FDX] = B_TRUE; \ 2400Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_10HDX] = B_TRUE; \ 2410Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_ASMPAUSE] = B_TRUE; \ 2420Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_PAUSE] = B_TRUE; \ 2430Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LP_CAP_AUTONEG] = B_TRUE; \ 2440Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_ASMPAUSE] = B_TRUE; \ 2450Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_PAUSE] = B_TRUE; \ 2460Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_AUTONEG] = B_TRUE; \ 2470Sstevel@tonic-gate (_mi_stat)[MAC_STAT_LINK_DUPLEX] = B_TRUE; \ 2480Sstevel@tonic-gate } 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate /* 2510Sstevel@tonic-gate * MAC version identifer (for debugging) 2520Sstevel@tonic-gate */ 2530Sstevel@tonic-gate #define MAC_IDENT "%I%" 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate /* 2560Sstevel@tonic-gate * MAC driver entry point types. 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate typedef uint64_t (*mac_stat_t)(void *, enum mac_stat); 2590Sstevel@tonic-gate typedef int (*mac_start_t)(void *); 2600Sstevel@tonic-gate typedef void (*mac_stop_t)(void *); 2610Sstevel@tonic-gate typedef int (*mac_promisc_t)(void *, boolean_t); 2620Sstevel@tonic-gate typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 2630Sstevel@tonic-gate typedef int (*mac_unicst_t)(void *, const uint8_t *); 2640Sstevel@tonic-gate typedef void (*mac_resources_t)(void *); 2650Sstevel@tonic-gate typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 2660Sstevel@tonic-gate typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate /* 2690Sstevel@tonic-gate * MAC extensions. (Currently there are non defined). 2700Sstevel@tonic-gate */ 2710Sstevel@tonic-gate typedef struct mac_ext_s mac_ext_t; 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate /* 2740Sstevel@tonic-gate * MAC implementation private data. 2750Sstevel@tonic-gate */ 2760Sstevel@tonic-gate typedef struct mac_impl_s mac_impl_t; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate /* 2790Sstevel@tonic-gate * MAC structure: supplied by the driver. 2800Sstevel@tonic-gate */ 2810Sstevel@tonic-gate typedef struct mac { 2820Sstevel@tonic-gate const char *m_ident; /* MAC_IDENT */ 2830Sstevel@tonic-gate mac_ext_t *m_extp; 2840Sstevel@tonic-gate mac_impl_t *m_impl; /* MAC private data */ 2850Sstevel@tonic-gate void *m_driver; /* Driver private data */ 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate dev_info_t *m_dip; 2880Sstevel@tonic-gate uint_t m_port; 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate mac_info_t m_info; 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate mac_stat_t m_stat; 2930Sstevel@tonic-gate mac_start_t m_start; 2940Sstevel@tonic-gate mac_stop_t m_stop; 2950Sstevel@tonic-gate mac_promisc_t m_promisc; 2960Sstevel@tonic-gate mac_multicst_t m_multicst; 2970Sstevel@tonic-gate mac_unicst_t m_unicst; 2980Sstevel@tonic-gate mac_resources_t m_resources; 2990Sstevel@tonic-gate mac_ioctl_t m_ioctl; 3000Sstevel@tonic-gate mac_tx_t m_tx; 3010Sstevel@tonic-gate } mac_t; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * Construct the name of a MAC interface. 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate #define MAC_NAME(_name, _dev, _port) \ 3070Sstevel@tonic-gate (void) snprintf((_name), MAXNAMELEN - 1, "%s/%u", (_dev), (_port)) 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate /* 3100Sstevel@tonic-gate * Opaque handle types. 3110Sstevel@tonic-gate */ 3120Sstevel@tonic-gate typedef struct __mac_handle *mac_handle_t; 3130Sstevel@tonic-gate typedef struct __mac_notify_handle *mac_notify_handle_t; 3140Sstevel@tonic-gate typedef struct __mac_rx_handle *mac_rx_handle_t; 3150Sstevel@tonic-gate typedef struct __mac_txloop_handle *mac_txloop_handle_t; 3160Sstevel@tonic-gate typedef struct __mac_resource_handle *mac_resource_handle_t; 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate /* 3190Sstevel@tonic-gate * MAC interface callback types. 3200Sstevel@tonic-gate */ 3210Sstevel@tonic-gate typedef enum { 3220Sstevel@tonic-gate MAC_NOTE_LINK, 3230Sstevel@tonic-gate MAC_NOTE_PROMISC, 3240Sstevel@tonic-gate MAC_NOTE_UNICST, 3250Sstevel@tonic-gate MAC_NOTE_TX, 3260Sstevel@tonic-gate MAC_NOTE_RESOURCE, 3270Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 3280Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 3290Sstevel@tonic-gate } mac_notify_type_t; 3300Sstevel@tonic-gate 3310Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 3320Sstevel@tonic-gate typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *); 3330Sstevel@tonic-gate typedef void (*mac_txloop_t)(void *, mblk_t *); 3340Sstevel@tonic-gate typedef void (*mac_blank_t)(void *, time_t, uint_t); 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate /* 3370Sstevel@tonic-gate * MAC promiscuous types 3380Sstevel@tonic-gate */ 3390Sstevel@tonic-gate typedef enum { 3400Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 3410Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 3420Sstevel@tonic-gate } mac_promisc_type_t; 3430Sstevel@tonic-gate 3440Sstevel@tonic-gate /* 3450Sstevel@tonic-gate * MAC resource types 3460Sstevel@tonic-gate */ 3470Sstevel@tonic-gate typedef enum { 3480Sstevel@tonic-gate MAC_RX_FIFO = 1 3490Sstevel@tonic-gate } mac_resource_type_t; 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3520Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 3530Sstevel@tonic-gate mac_blank_t mrf_blank; 3540Sstevel@tonic-gate void *mrf_arg; 3550Sstevel@tonic-gate time_t mrf_normal_blank_time; 3560Sstevel@tonic-gate uint_t mrf_normal_pkt_count; 3570Sstevel@tonic-gate } mac_rx_fifo_t; 3580Sstevel@tonic-gate 35956Smeem typedef struct mac_txinfo_s { 36056Smeem mac_tx_t mt_fn; 36156Smeem void *mt_arg; 36256Smeem } mac_txinfo_t; 36356Smeem 3640Sstevel@tonic-gate typedef union mac_resource_u { 3650Sstevel@tonic-gate mac_resource_type_t mr_type; 3660Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 3670Sstevel@tonic-gate } mac_resource_t; 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate /* 3720Sstevel@tonic-gate * Client interface functions. 3730Sstevel@tonic-gate */ 3740Sstevel@tonic-gate extern int mac_open(const char *, uint_t, mac_handle_t *); 3750Sstevel@tonic-gate extern void mac_close(mac_handle_t); 3760Sstevel@tonic-gate extern const mac_info_t *mac_info(mac_handle_t); 377*269Sericheng extern boolean_t mac_info_get(const char *, mac_info_t *); 3780Sstevel@tonic-gate extern uint64_t mac_stat_get(mac_handle_t, enum mac_stat); 3790Sstevel@tonic-gate extern int mac_start(mac_handle_t); 3800Sstevel@tonic-gate extern void mac_stop(mac_handle_t); 3810Sstevel@tonic-gate extern int mac_promisc_set(mac_handle_t, boolean_t, 3820Sstevel@tonic-gate mac_promisc_type_t); 3830Sstevel@tonic-gate extern boolean_t mac_promisc_get(mac_handle_t, 3840Sstevel@tonic-gate mac_promisc_type_t); 3850Sstevel@tonic-gate extern int mac_multicst_add(mac_handle_t, const uint8_t *); 3860Sstevel@tonic-gate extern int mac_multicst_remove(mac_handle_t, 3870Sstevel@tonic-gate const uint8_t *); 3880Sstevel@tonic-gate extern int mac_unicst_set(mac_handle_t, const uint8_t *); 3890Sstevel@tonic-gate extern void mac_unicst_get(mac_handle_t, uint8_t *); 3900Sstevel@tonic-gate extern void mac_resources(mac_handle_t); 3910Sstevel@tonic-gate extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 39256Smeem extern const mac_txinfo_t *mac_tx_get(mac_handle_t); 3930Sstevel@tonic-gate extern link_state_t mac_link_get(mac_handle_t); 3940Sstevel@tonic-gate extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, 3950Sstevel@tonic-gate void *); 3960Sstevel@tonic-gate extern void mac_notify_remove(mac_handle_t, 3970Sstevel@tonic-gate mac_notify_handle_t); 3980Sstevel@tonic-gate extern void mac_notify(mac_handle_t); 3990Sstevel@tonic-gate extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *); 4000Sstevel@tonic-gate extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t); 4010Sstevel@tonic-gate extern mblk_t *mac_txloop(void *, mblk_t *); 4020Sstevel@tonic-gate extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t, 4030Sstevel@tonic-gate void *); 4040Sstevel@tonic-gate extern void mac_txloop_remove(mac_handle_t, 4050Sstevel@tonic-gate mac_txloop_handle_t); 4060Sstevel@tonic-gate extern boolean_t mac_active_set(mac_handle_t); 4070Sstevel@tonic-gate extern void mac_active_clear(mac_handle_t); 4080Sstevel@tonic-gate extern void mac_resource_set(mac_handle_t, 4090Sstevel@tonic-gate mac_resource_add_t, void *); 410*269Sericheng extern dev_info_t *mac_devinfo_get(mac_handle_t); 4110Sstevel@tonic-gate 4120Sstevel@tonic-gate /* 4130Sstevel@tonic-gate * Driver interface functions. 4140Sstevel@tonic-gate */ 4150Sstevel@tonic-gate extern int mac_register(mac_t *); 4160Sstevel@tonic-gate extern int mac_unregister(mac_t *); 4170Sstevel@tonic-gate extern void mac_rx(mac_t *, mac_resource_handle_t, 4180Sstevel@tonic-gate mblk_t *); 4190Sstevel@tonic-gate extern void mac_link_update(mac_t *, link_state_t); 4200Sstevel@tonic-gate extern void mac_unicst_update(mac_t *, const uint8_t *); 4210Sstevel@tonic-gate extern void mac_tx_update(mac_t *); 4220Sstevel@tonic-gate extern void mac_resource_update(mac_t *); 4230Sstevel@tonic-gate extern mac_resource_handle_t mac_resource_add(mac_t *, mac_resource_t *); 4240Sstevel@tonic-gate extern void mac_multicst_refresh(mac_t *, mac_multicst_t, 4250Sstevel@tonic-gate void *, boolean_t); 4260Sstevel@tonic-gate extern void mac_unicst_refresh(mac_t *, mac_unicst_t, 4270Sstevel@tonic-gate void *); 4280Sstevel@tonic-gate extern void mac_promisc_refresh(mac_t *, mac_promisc_t, 4290Sstevel@tonic-gate void *); 430*269Sericheng extern void mac_init_ops(struct dev_ops *, const char *); 431*269Sericheng extern void mac_fini_ops(struct dev_ops *); 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate #endif /* _KERNEL */ 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate #ifdef __cplusplus 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate #endif 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 440