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 52311Sseb * Common Development and Distribution License (the "License"). 62311Sseb * 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 /* 222311Sseb * 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_H 270Sstevel@tonic-gate #define _SYS_MAC_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/ddi.h> 320Sstevel@tonic-gate #include <sys/sunddi.h> 330Sstevel@tonic-gate #include <sys/stream.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * MAC Services Module 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 450Sstevel@tonic-gate */ 460Sstevel@tonic-gate #define MAC_INFO "MAC Services v%I%" 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 492311Sseb * MAC version identifier. This is used by mac_alloc() mac_register() to 502311Sseb * verify that incompatible drivers don't register. 512311Sseb */ 522311Sseb #define MAC_VERSION 0x1 532311Sseb 542311Sseb /* 552311Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 562311Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 572311Sseb * register. 582311Sseb */ 592311Sseb #define MACTYPE_VERSION 0x1 602311Sseb 612311Sseb /* 620Sstevel@tonic-gate * Statistics 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate 650Sstevel@tonic-gate #define XCVR_UNDEFINED 0 660Sstevel@tonic-gate #define XCVR_NONE 1 670Sstevel@tonic-gate #define XCVR_10 2 680Sstevel@tonic-gate #define XCVR_100T4 3 690Sstevel@tonic-gate #define XCVR_100X 4 700Sstevel@tonic-gate #define XCVR_100T2 5 710Sstevel@tonic-gate #define XCVR_1000X 6 720Sstevel@tonic-gate #define XCVR_1000T 7 730Sstevel@tonic-gate 740Sstevel@tonic-gate typedef enum { 750Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 760Sstevel@tonic-gate LINK_STATE_DOWN, 770Sstevel@tonic-gate LINK_STATE_UP 780Sstevel@tonic-gate } link_state_t; 790Sstevel@tonic-gate 800Sstevel@tonic-gate typedef enum { 810Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 820Sstevel@tonic-gate LINK_DUPLEX_HALF, 830Sstevel@tonic-gate LINK_DUPLEX_FULL 840Sstevel@tonic-gate } link_duplex_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate #ifdef _KERNEL 870Sstevel@tonic-gate 882311Sseb typedef struct mac_stat_info_s { 892311Sseb uint_t msi_stat; 902311Sseb char *msi_name; 912311Sseb uint_t msi_type; /* as defined in kstat_named_init(9F) */ 922311Sseb uint64_t msi_default; 932311Sseb } mac_stat_info_t; 942311Sseb 952311Sseb /* 962311Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 972311Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 982311Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 992311Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 1002311Sseb * defined by MAC-Type plugins and maintained by each driver. 1012311Sseb */ 1022311Sseb #define MAC_STAT_MIN 1000 1032311Sseb #define MACTYPE_STAT_MIN 2000 1042311Sseb 1052311Sseb #define IS_MAC_STAT(stat) \ 1062311Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 1072311Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 1082311Sseb 1092311Sseb enum mac_driver_stat { 1102311Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 1112311Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 1120Sstevel@tonic-gate MAC_STAT_MULTIRCV, 1130Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 1140Sstevel@tonic-gate MAC_STAT_MULTIXMT, 1150Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 1160Sstevel@tonic-gate MAC_STAT_NORCVBUF, 1170Sstevel@tonic-gate MAC_STAT_IERRORS, 1180Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 1190Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 1200Sstevel@tonic-gate MAC_STAT_OERRORS, 1210Sstevel@tonic-gate MAC_STAT_COLLISIONS, 1220Sstevel@tonic-gate MAC_STAT_RBYTES, 1230Sstevel@tonic-gate MAC_STAT_IPACKETS, 1240Sstevel@tonic-gate MAC_STAT_OBYTES, 1252311Sseb MAC_STAT_OPACKETS 1262311Sseb }; 1270Sstevel@tonic-gate 1282311Sseb #define MAC_NSTAT (MAC_STAT_OPACKETS - MAC_STAT_IFSPEED + 1) 1290Sstevel@tonic-gate 1302311Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 1312311Sseb (_stat) == MAC_STAT_MULTIRCV || \ 1322311Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 1332311Sseb (_stat) == MAC_STAT_MULTIXMT || \ 1342311Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 1352311Sseb (_stat) == MAC_STAT_NORCVBUF || \ 1362311Sseb (_stat) == MAC_STAT_IERRORS || \ 1372311Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 1382311Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 1392311Sseb (_stat) == MAC_STAT_OERRORS || \ 1402311Sseb (_stat) == MAC_STAT_COLLISIONS || \ 1412311Sseb (_stat) == MAC_STAT_RBYTES || \ 1422311Sseb (_stat) == MAC_STAT_IPACKETS || \ 1432311Sseb (_stat) == MAC_STAT_OBYTES || \ 1442311Sseb (_stat) == MAC_STAT_OPACKETS) 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate /* 1470Sstevel@tonic-gate * Maximum MAC address length 1480Sstevel@tonic-gate */ 1492311Sseb #define MAXMACADDRLEN 20 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate typedef struct mac_info_s { 1550Sstevel@tonic-gate uint_t mi_media; 1560Sstevel@tonic-gate uint_t mi_sdu_min; 1570Sstevel@tonic-gate uint_t mi_sdu_max; 1580Sstevel@tonic-gate uint_t mi_addr_length; 1592311Sseb uint8_t *mi_unicst_addr; 1602311Sseb uint8_t *mi_brdcst_addr; 1610Sstevel@tonic-gate } mac_info_t; 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* 1642311Sseb * MAC layer capabilities. These capabilities are handled by the drivers' 1652311Sseb * mc_capab_get() callbacks. Some capabilities require the driver to fill 1662311Sseb * in a given data structure, and others are simply boolean capabilities. 1672311Sseb * Note that capability values must be powers of 2 so that consumers and 1682311Sseb * providers of this interface can keep track of which capabilities they 1692311Sseb * care about by keeping a bitfield of these things around somewhere. 1700Sstevel@tonic-gate */ 1712311Sseb typedef enum { 1722311Sseb MAC_CAPAB_HCKSUM = 0x01, /* data is a uint32_t for the txflags */ 173*2331Skrgopi MAC_CAPAB_POLL = 0x02, /* boolean only, no data */ 174*2331Skrgopi MAC_CAPAB_MULTIADDRESS = 0x03 /* data is multiaddress_capab_t */ 1752311Sseb /* add new capabilities here */ 1762311Sseb } mac_capab_t; 1770Sstevel@tonic-gate 178*2331Skrgopi typedef int mac_addr_slot_t; 179*2331Skrgopi 180*2331Skrgopi /* mma_flags values */ 181*2331Skrgopi #define MMAC_SLOT_USED 0x1 /* address slot used */ 182*2331Skrgopi #define MMAC_SLOT_UNUSED 0x2 /* free address slot */ 183*2331Skrgopi #define MMAC_VENDOR_ADDR 0x4 /* address returned is vendor supplied */ 184*2331Skrgopi 185*2331Skrgopi typedef struct mac_multi_address_s { 186*2331Skrgopi mac_addr_slot_t mma_slot; /* slot for add/remove/get/set */ 187*2331Skrgopi uint_t mma_addrlen; 188*2331Skrgopi uint8_t mma_addr[MAXMACADDRLEN]; 189*2331Skrgopi uint_t mma_flags; 190*2331Skrgopi } mac_multi_addr_t; 191*2331Skrgopi 192*2331Skrgopi typedef int (*maddr_reserve_t)(void *, mac_multi_addr_t *); 193*2331Skrgopi typedef int (*maddr_add_t)(void *, mac_multi_addr_t *); 194*2331Skrgopi typedef int (*maddr_remove_t)(void *, mac_addr_slot_t); 195*2331Skrgopi typedef int (*maddr_modify_t)(void *, mac_multi_addr_t *); 196*2331Skrgopi typedef int (*maddr_get_t)(void *, mac_multi_addr_t *); 197*2331Skrgopi 198*2331Skrgopi /* maddr_flag values */ 199*2331Skrgopi #define MADDR_VENDOR_ADDR 0x01 /* addr returned is vendor supplied */ 200*2331Skrgopi 201*2331Skrgopi /* multiple mac address: add/remove/set/get mac address */ 202*2331Skrgopi typedef struct multiaddress_capab_s { 203*2331Skrgopi int maddr_naddr; /* total addresses */ 204*2331Skrgopi int maddr_naddrfree; /* free address slots */ 205*2331Skrgopi uint_t maddr_flag; /* MADDR_VENDOR_ADDR bit can be set */ 206*2331Skrgopi /* driver entry points */ 207*2331Skrgopi void *maddr_handle; /* cookie to be used for the calls */ 208*2331Skrgopi maddr_reserve_t maddr_reserve; /* reserve a factory address */ 209*2331Skrgopi maddr_add_t maddr_add; /* add a new unicst address */ 210*2331Skrgopi maddr_remove_t maddr_remove; /* remove an added address */ 211*2331Skrgopi maddr_modify_t maddr_modify; /* modify an added address */ 212*2331Skrgopi maddr_get_t maddr_get; /* get address from specified slot */ 213*2331Skrgopi } multiaddress_capab_t; 214*2331Skrgopi 2150Sstevel@tonic-gate /* 2160Sstevel@tonic-gate * MAC driver entry point types. 2170Sstevel@tonic-gate */ 2182311Sseb typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 2190Sstevel@tonic-gate typedef int (*mac_start_t)(void *); 2200Sstevel@tonic-gate typedef void (*mac_stop_t)(void *); 2212311Sseb typedef int (*mac_setpromisc_t)(void *, boolean_t); 2220Sstevel@tonic-gate typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 2230Sstevel@tonic-gate typedef int (*mac_unicst_t)(void *, const uint8_t *); 2242311Sseb typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 2250Sstevel@tonic-gate typedef void (*mac_resources_t)(void *); 2260Sstevel@tonic-gate typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 2272311Sseb typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate /* 2302311Sseb * Drivers must set all of these callbacks except for mc_resources, 2312311Sseb * mc_ioctl, and mc_getcapab, which are optional. If any of these optional 2322311Sseb * callbacks are set, their appropriate flags must be set in mc_callbacks. 2332311Sseb * Any future additions to this list must also be accompanied by an 2342311Sseb * associated mc_callbacks flag so that the framework can grow without 2352311Sseb * affecting the binary compatibility of the interface. 2360Sstevel@tonic-gate */ 2372311Sseb typedef struct mac_callbacks_s { 2382311Sseb uint_t mc_callbacks; /* Denotes which callbacks are set */ 2392311Sseb mac_getstat_t mc_getstat; /* Get the value of a statistic */ 2402311Sseb mac_start_t mc_start; /* Start the device */ 2412311Sseb mac_stop_t mc_stop; /* Stop the device */ 2422311Sseb mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 2432311Sseb mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 2442311Sseb mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 2452311Sseb mac_tx_t mc_tx; /* Transmit a packet */ 2462311Sseb mac_resources_t mc_resources; /* Get the device resources */ 2472311Sseb mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 2482311Sseb mac_getcapab_t mc_getcapab; /* Get capability information */ 2492311Sseb } mac_callbacks_t; 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* 2522311Sseb * Flags for mc_callbacks. Requiring drivers to set the flags associated 2532311Sseb * with optional callbacks initialized in the structure allows the mac 2542311Sseb * module to add optional callbacks in the future without requiring drivers 2552311Sseb * to recompile. 2560Sstevel@tonic-gate */ 2572311Sseb #define MC_RESOURCES 0x001 2582311Sseb #define MC_IOCTL 0x002 2592311Sseb #define MC_GETCAPAB 0x004 2602311Sseb 2612311Sseb typedef struct mac_register_s { 2622311Sseb uint_t m_version; /* set by mac_alloc() */ 2632311Sseb const char *m_type_ident; 2642311Sseb void *m_driver; /* Driver private data */ 2652311Sseb dev_info_t *m_dip; 2662311Sseb uint_t m_instance; 2672311Sseb uint8_t *m_src_addr; 2682311Sseb uint8_t *m_dst_addr; 2692311Sseb mac_callbacks_t *m_callbacks; 2702311Sseb uint_t m_min_sdu; 2712311Sseb uint_t m_max_sdu; 2722311Sseb void *m_pdata; 2732311Sseb size_t m_pdata_size; 2742311Sseb } mac_register_t; 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate /* 2770Sstevel@tonic-gate * Opaque handle types. 2780Sstevel@tonic-gate */ 2792311Sseb typedef struct mac_t *mac_handle_t; 2800Sstevel@tonic-gate typedef struct __mac_notify_handle *mac_notify_handle_t; 2810Sstevel@tonic-gate typedef struct __mac_rx_handle *mac_rx_handle_t; 2820Sstevel@tonic-gate typedef struct __mac_txloop_handle *mac_txloop_handle_t; 2830Sstevel@tonic-gate typedef struct __mac_resource_handle *mac_resource_handle_t; 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate /* 2860Sstevel@tonic-gate * MAC interface callback types. 2870Sstevel@tonic-gate */ 2880Sstevel@tonic-gate typedef enum { 2890Sstevel@tonic-gate MAC_NOTE_LINK, 2900Sstevel@tonic-gate MAC_NOTE_PROMISC, 2910Sstevel@tonic-gate MAC_NOTE_UNICST, 2920Sstevel@tonic-gate MAC_NOTE_TX, 2930Sstevel@tonic-gate MAC_NOTE_RESOURCE, 2940Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 2952311Sseb MAC_NOTE_FASTPATH_FLUSH, 2960Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 2970Sstevel@tonic-gate } mac_notify_type_t; 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 3000Sstevel@tonic-gate typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *); 3010Sstevel@tonic-gate typedef void (*mac_txloop_t)(void *, mblk_t *); 3020Sstevel@tonic-gate typedef void (*mac_blank_t)(void *, time_t, uint_t); 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* 3050Sstevel@tonic-gate * MAC promiscuous types 3060Sstevel@tonic-gate */ 3070Sstevel@tonic-gate typedef enum { 3080Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 3090Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 3100Sstevel@tonic-gate } mac_promisc_type_t; 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate /* 3130Sstevel@tonic-gate * MAC resource types 3140Sstevel@tonic-gate */ 3150Sstevel@tonic-gate typedef enum { 3160Sstevel@tonic-gate MAC_RX_FIFO = 1 3170Sstevel@tonic-gate } mac_resource_type_t; 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3200Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 3210Sstevel@tonic-gate mac_blank_t mrf_blank; 3220Sstevel@tonic-gate void *mrf_arg; 3230Sstevel@tonic-gate time_t mrf_normal_blank_time; 3240Sstevel@tonic-gate uint_t mrf_normal_pkt_count; 3250Sstevel@tonic-gate } mac_rx_fifo_t; 3260Sstevel@tonic-gate 32756Smeem typedef struct mac_txinfo_s { 32856Smeem mac_tx_t mt_fn; 32956Smeem void *mt_arg; 33056Smeem } mac_txinfo_t; 33156Smeem 3320Sstevel@tonic-gate typedef union mac_resource_u { 3330Sstevel@tonic-gate mac_resource_type_t mr_type; 3340Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 3350Sstevel@tonic-gate } mac_resource_t; 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 3380Sstevel@tonic-gate 3392311Sseb typedef enum { 3402311Sseb MAC_ADDRTYPE_UNICAST, 3412311Sseb MAC_ADDRTYPE_MULTICAST, 3422311Sseb MAC_ADDRTYPE_BROADCAST 3432311Sseb } mac_addrtype_t; 3442311Sseb 3452311Sseb typedef struct mac_header_info_s { 3462311Sseb size_t mhi_hdrsize; 3472311Sseb size_t mhi_pktsize; 3482311Sseb const uint8_t *mhi_daddr; 3492311Sseb const uint8_t *mhi_saddr; 3502311Sseb uint32_t mhi_origsap; 3512311Sseb uint32_t mhi_bindsap; 3522311Sseb mac_addrtype_t mhi_dsttype; 3532311Sseb } mac_header_info_t; 3542311Sseb 3552311Sseb /* 3562311Sseb * MAC-Type plugin interfaces 3572311Sseb */ 3582311Sseb 3592311Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 3602311Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 3612311Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 3622311Sseb uint32_t, void *, mblk_t *, size_t); 3632311Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 3642311Sseb mac_header_info_t *); 3652311Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 3662311Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 3672311Sseb 3682311Sseb typedef struct mactype_ops_s { 3692311Sseb uint_t mtops_ops; 3702311Sseb /* 3712311Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 3722311Sseb * unicast address, or a non-zero errno otherwise. 3732311Sseb */ 3742311Sseb mtops_addr_verify_t mtops_unicst_verify; 3752311Sseb /* 3762311Sseb * mtops_multicst_verify() returns 0 if the given address is a 3772311Sseb * valid multicast address, or a non-zero errno otherwise. If the 3782311Sseb * media doesn't support multicast, ENOTSUP should be returned (for 3792311Sseb * example). 3802311Sseb */ 3812311Sseb mtops_addr_verify_t mtops_multicst_verify; 3822311Sseb /* 3832311Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 3842311Sseb * SAP value, or B_FALSE otherwise. 3852311Sseb */ 3862311Sseb mtops_sap_verify_t mtops_sap_verify; 3872311Sseb /* 3882311Sseb * mtops_header() is used to allocate and construct a MAC header. 3892311Sseb */ 3902311Sseb mtops_header_t mtops_header; 3912311Sseb /* 3922311Sseb * mtops_header_info() is used to gather information on a given MAC 3932311Sseb * header. 3942311Sseb */ 3952311Sseb mtops_header_info_t mtops_header_info; 3962311Sseb /* 3972311Sseb * mtops_pdata_verify() is used to verify the validity of MAC 3982311Sseb * plugin data. It is called by mac_register() if the driver has 3992311Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 4002311Sseb * drivers update the data. 4012311Sseb */ 4022311Sseb mtops_pdata_verify_t mtops_pdata_verify; 4032311Sseb /* 4042311Sseb * mtops_header_cook() is an optional callback that converts (or 4052311Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 4062311Sseb * into one that is appropriate to send down to the MAC driver. 4072311Sseb * Following the example above, an Ethernet header sent down by a 4082311Sseb * DLPI consumer would be converted to whatever header the MAC 4092311Sseb * driver expects. 4102311Sseb */ 4112311Sseb mtops_header_modify_t mtops_header_cook; 4122311Sseb /* 4132311Sseb * mtops_header_uncook() is an optional callback that does the 4142311Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 4152311Sseb * header (as received from the driver) for consumption by raw DLPI 4162311Sseb * consumers. For example, for a non-Ethernet plugin that wants 4172311Sseb * raw DLPI consumers to be fooled into thinking that the device 4182311Sseb * provides Ethernet access, this callback would modify the given 4192311Sseb * mblk_t such that the MAC header is converted to an Ethernet 4202311Sseb * header. 4212311Sseb */ 4222311Sseb mtops_header_modify_t mtops_header_uncook; 4232311Sseb } mactype_ops_t; 4242311Sseb 4252311Sseb /* 4262311Sseb * mtops_ops exists for the plugin to enumerate the optional callback 4272311Sseb * entrypoints it has defined. This allows the mac module to define 4282311Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 4292311Sseb * compatibility with old plugins. 4302311Sseb */ 4312311Sseb #define MTOPS_PDATA_VERIFY 0x001 4322311Sseb #define MTOPS_HEADER_COOK 0x002 4332311Sseb #define MTOPS_HEADER_UNCOOK 0x004 4342311Sseb 4352311Sseb typedef struct mactype_register_s { 4362311Sseb uint_t mtr_version; /* set by mactype_alloc() */ 4372311Sseb const char *mtr_ident; 4382311Sseb mactype_ops_t *mtr_ops; 4392311Sseb uint_t mtr_mactype; 4402311Sseb uint_t mtr_addrlen; 4412311Sseb uint8_t *mtr_brdcst_addr; 4422311Sseb mac_stat_info_t *mtr_stats; 4432311Sseb size_t mtr_statcount; 4442311Sseb } mactype_register_t; 4452311Sseb 4460Sstevel@tonic-gate /* 4470Sstevel@tonic-gate * Client interface functions. 4480Sstevel@tonic-gate */ 4490Sstevel@tonic-gate extern int mac_open(const char *, uint_t, mac_handle_t *); 4500Sstevel@tonic-gate extern void mac_close(mac_handle_t); 4510Sstevel@tonic-gate extern const mac_info_t *mac_info(mac_handle_t); 452269Sericheng extern boolean_t mac_info_get(const char *, mac_info_t *); 4532311Sseb extern uint64_t mac_stat_get(mac_handle_t, uint_t); 4540Sstevel@tonic-gate extern int mac_start(mac_handle_t); 4550Sstevel@tonic-gate extern void mac_stop(mac_handle_t); 4560Sstevel@tonic-gate extern int mac_promisc_set(mac_handle_t, boolean_t, 4570Sstevel@tonic-gate mac_promisc_type_t); 4580Sstevel@tonic-gate extern boolean_t mac_promisc_get(mac_handle_t, 4590Sstevel@tonic-gate mac_promisc_type_t); 4600Sstevel@tonic-gate extern int mac_multicst_add(mac_handle_t, const uint8_t *); 4610Sstevel@tonic-gate extern int mac_multicst_remove(mac_handle_t, 4620Sstevel@tonic-gate const uint8_t *); 463*2331Skrgopi extern boolean_t mac_unicst_verify(mac_handle_t, 464*2331Skrgopi const uint8_t *, uint_t); 4650Sstevel@tonic-gate extern int mac_unicst_set(mac_handle_t, const uint8_t *); 4660Sstevel@tonic-gate extern void mac_unicst_get(mac_handle_t, uint8_t *); 4672311Sseb extern void mac_dest_get(mac_handle_t, uint8_t *); 4680Sstevel@tonic-gate extern void mac_resources(mac_handle_t); 4690Sstevel@tonic-gate extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 47056Smeem extern const mac_txinfo_t *mac_tx_get(mac_handle_t); 4710Sstevel@tonic-gate extern link_state_t mac_link_get(mac_handle_t); 4720Sstevel@tonic-gate extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, 4730Sstevel@tonic-gate void *); 4740Sstevel@tonic-gate extern void mac_notify_remove(mac_handle_t, 4750Sstevel@tonic-gate mac_notify_handle_t); 4760Sstevel@tonic-gate extern void mac_notify(mac_handle_t); 4770Sstevel@tonic-gate extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *); 4780Sstevel@tonic-gate extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t); 4790Sstevel@tonic-gate extern mblk_t *mac_txloop(void *, mblk_t *); 4800Sstevel@tonic-gate extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t, 4810Sstevel@tonic-gate void *); 4820Sstevel@tonic-gate extern void mac_txloop_remove(mac_handle_t, 4830Sstevel@tonic-gate mac_txloop_handle_t); 4840Sstevel@tonic-gate extern boolean_t mac_active_set(mac_handle_t); 4850Sstevel@tonic-gate extern void mac_active_clear(mac_handle_t); 4860Sstevel@tonic-gate extern void mac_resource_set(mac_handle_t, 4870Sstevel@tonic-gate mac_resource_add_t, void *); 488269Sericheng extern dev_info_t *mac_devinfo_get(mac_handle_t); 4892311Sseb extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t, 4902311Sseb void *); 4912311Sseb extern boolean_t mac_sap_verify(mac_handle_t, uint32_t, 4922311Sseb uint32_t *); 4932311Sseb extern mblk_t *mac_header(mac_handle_t, const uint8_t *, 4942311Sseb uint32_t, mblk_t *, size_t); 4952311Sseb extern int mac_header_info(mac_handle_t, mblk_t *, 4962311Sseb mac_header_info_t *); 4972311Sseb extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *); 4982311Sseb extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *); 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate /* 5010Sstevel@tonic-gate * Driver interface functions. 5020Sstevel@tonic-gate */ 5032311Sseb extern mac_register_t *mac_alloc(uint_t); 5042311Sseb extern void mac_free(mac_register_t *); 5052311Sseb extern int mac_register(mac_register_t *, mac_handle_t *); 5062311Sseb extern int mac_unregister(mac_handle_t); 5072311Sseb extern void mac_rx(mac_handle_t, mac_resource_handle_t, 5080Sstevel@tonic-gate mblk_t *); 5092311Sseb extern void mac_link_update(mac_handle_t, link_state_t); 5102311Sseb extern void mac_unicst_update(mac_handle_t, 5112311Sseb const uint8_t *); 5122311Sseb extern void mac_tx_update(mac_handle_t); 5132311Sseb extern void mac_resource_update(mac_handle_t); 5142311Sseb extern mac_resource_handle_t mac_resource_add(mac_handle_t, 5152311Sseb mac_resource_t *); 5162311Sseb extern int mac_pdata_update(mac_handle_t, void *, 5172311Sseb size_t); 5182311Sseb extern void mac_multicst_refresh(mac_handle_t, 5192311Sseb mac_multicst_t, void *, boolean_t); 5202311Sseb extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 5210Sstevel@tonic-gate void *); 5222311Sseb extern void mac_promisc_refresh(mac_handle_t, 5232311Sseb mac_setpromisc_t, void *); 524269Sericheng extern void mac_init_ops(struct dev_ops *, const char *); 525269Sericheng extern void mac_fini_ops(struct dev_ops *); 5262311Sseb extern mactype_register_t *mactype_alloc(uint_t); 5272311Sseb extern void mactype_free(mactype_register_t *); 5282311Sseb extern int mactype_register(mactype_register_t *); 5292311Sseb extern int mactype_unregister(const char *); 5300Sstevel@tonic-gate 5310Sstevel@tonic-gate #endif /* _KERNEL */ 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate #ifdef __cplusplus 5340Sstevel@tonic-gate } 5350Sstevel@tonic-gate #endif 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 538