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 /* 223448Sdh155122 * Copyright 2007 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 312760Sdg199075 #include <sys/types.h> 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 * MAC Information (text emitted by modinfo(1m)) 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate #define MAC_INFO "MAC Services v%I%" 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 502311Sseb * MAC version identifier. This is used by mac_alloc() mac_register() to 512311Sseb * verify that incompatible drivers don't register. 522311Sseb */ 532311Sseb #define MAC_VERSION 0x1 542311Sseb 552311Sseb /* 562311Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 572311Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 582311Sseb * register. 592311Sseb */ 602311Sseb #define MACTYPE_VERSION 0x1 612311Sseb 622311Sseb /* 630Sstevel@tonic-gate * Statistics 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate 660Sstevel@tonic-gate #define XCVR_UNDEFINED 0 670Sstevel@tonic-gate #define XCVR_NONE 1 680Sstevel@tonic-gate #define XCVR_10 2 690Sstevel@tonic-gate #define XCVR_100T4 3 700Sstevel@tonic-gate #define XCVR_100X 4 710Sstevel@tonic-gate #define XCVR_100T2 5 720Sstevel@tonic-gate #define XCVR_1000X 6 730Sstevel@tonic-gate #define XCVR_1000T 7 740Sstevel@tonic-gate 750Sstevel@tonic-gate typedef enum { 760Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 770Sstevel@tonic-gate LINK_STATE_DOWN, 780Sstevel@tonic-gate LINK_STATE_UP 790Sstevel@tonic-gate } link_state_t; 800Sstevel@tonic-gate 810Sstevel@tonic-gate typedef enum { 820Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 830Sstevel@tonic-gate LINK_DUPLEX_HALF, 840Sstevel@tonic-gate LINK_DUPLEX_FULL 850Sstevel@tonic-gate } link_duplex_t; 860Sstevel@tonic-gate 870Sstevel@tonic-gate #ifdef _KERNEL 880Sstevel@tonic-gate 892311Sseb typedef struct mac_stat_info_s { 902311Sseb uint_t msi_stat; 912311Sseb char *msi_name; 922311Sseb uint_t msi_type; /* as defined in kstat_named_init(9F) */ 932311Sseb uint64_t msi_default; 942311Sseb } mac_stat_info_t; 952311Sseb 962311Sseb /* 972311Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 982311Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 992311Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 1002311Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 1012311Sseb * defined by MAC-Type plugins and maintained by each driver. 1022311Sseb */ 1032311Sseb #define MAC_STAT_MIN 1000 1042311Sseb #define MACTYPE_STAT_MIN 2000 1052311Sseb 1062311Sseb #define IS_MAC_STAT(stat) \ 1072311Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 1082311Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 1092311Sseb 1104089Sgd78059 /* 1114089Sgd78059 * Do not reorder, and add only to the end of this list. 1124089Sgd78059 */ 1132311Sseb enum mac_driver_stat { 1142311Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 1152311Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 1160Sstevel@tonic-gate MAC_STAT_MULTIRCV, 1170Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 1180Sstevel@tonic-gate MAC_STAT_MULTIXMT, 1190Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 1200Sstevel@tonic-gate MAC_STAT_NORCVBUF, 1210Sstevel@tonic-gate MAC_STAT_IERRORS, 1220Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 1230Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 1240Sstevel@tonic-gate MAC_STAT_OERRORS, 1250Sstevel@tonic-gate MAC_STAT_COLLISIONS, 1260Sstevel@tonic-gate MAC_STAT_RBYTES, 1270Sstevel@tonic-gate MAC_STAT_IPACKETS, 1280Sstevel@tonic-gate MAC_STAT_OBYTES, 1294089Sgd78059 MAC_STAT_OPACKETS, 1304089Sgd78059 MAC_STAT_UNDERFLOWS, 1314089Sgd78059 MAC_STAT_OVERFLOWS 1322311Sseb }; 1330Sstevel@tonic-gate 1344089Sgd78059 #define MAC_NSTAT (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1) 1350Sstevel@tonic-gate 1362311Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 1372311Sseb (_stat) == MAC_STAT_MULTIRCV || \ 1382311Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 1392311Sseb (_stat) == MAC_STAT_MULTIXMT || \ 1402311Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 1412311Sseb (_stat) == MAC_STAT_NORCVBUF || \ 1422311Sseb (_stat) == MAC_STAT_IERRORS || \ 1432311Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 1442311Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 1452311Sseb (_stat) == MAC_STAT_OERRORS || \ 1462311Sseb (_stat) == MAC_STAT_COLLISIONS || \ 1472311Sseb (_stat) == MAC_STAT_RBYTES || \ 1482311Sseb (_stat) == MAC_STAT_IPACKETS || \ 1492311Sseb (_stat) == MAC_STAT_OBYTES || \ 1504089Sgd78059 (_stat) == MAC_STAT_OPACKETS || \ 1514089Sgd78059 (_stat) == MAC_STAT_UNDERFLOWS || \ 1524089Sgd78059 (_stat) == MAC_STAT_OVERFLOWS) 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate /* 1550Sstevel@tonic-gate * Maximum MAC address length 1560Sstevel@tonic-gate */ 1572311Sseb #define MAXMACADDRLEN 20 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate typedef struct mac_info_s { 1630Sstevel@tonic-gate uint_t mi_media; 1643147Sxc151355 uint_t mi_nativemedia; 1650Sstevel@tonic-gate uint_t mi_sdu_min; 1660Sstevel@tonic-gate uint_t mi_sdu_max; 1670Sstevel@tonic-gate uint_t mi_addr_length; 1682311Sseb uint8_t *mi_unicst_addr; 1692311Sseb uint8_t *mi_brdcst_addr; 1700Sstevel@tonic-gate } mac_info_t; 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate /* 1733115Syl150051 * LSO capability 1743115Syl150051 */ 1753115Syl150051 typedef struct lso_basic_tcp_ipv4_s { 1763115Syl150051 t_uscalar_t lso_max; /* maximum payload */ 1773115Syl150051 } lso_basic_tcp_ipv4_t; 1783115Syl150051 1793115Syl150051 /* 1803115Syl150051 * Future LSO capabilities can be added at the end of the mac_capab_lso_t. 1813115Syl150051 * When such capability is added to the GLDv3 framework, the size of the 1823115Syl150051 * mac_capab_lso_t it allocates and passes to the drivers increases. Older 1833115Syl150051 * drivers wil access only the (upper) sections of that structure, that is the 1843115Syl150051 * sections carrying the capabilities they understand. This ensures the 1853115Syl150051 * interface can be safely extended in a binary compatible way. 1863115Syl150051 */ 1873115Syl150051 typedef struct mac_capab_lso_s { 1883115Syl150051 t_uscalar_t lso_flags; 1893115Syl150051 lso_basic_tcp_ipv4_t lso_basic_tcp_ipv4; 1903115Syl150051 /* Add future lso capabilities here */ 1913115Syl150051 } mac_capab_lso_t; 1923115Syl150051 1933115Syl150051 /* 1942311Sseb * MAC layer capabilities. These capabilities are handled by the drivers' 1952311Sseb * mc_capab_get() callbacks. Some capabilities require the driver to fill 1962311Sseb * in a given data structure, and others are simply boolean capabilities. 1972311Sseb * Note that capability values must be powers of 2 so that consumers and 1982311Sseb * providers of this interface can keep track of which capabilities they 1992311Sseb * care about by keeping a bitfield of these things around somewhere. 2000Sstevel@tonic-gate */ 2012311Sseb typedef enum { 2022311Sseb MAC_CAPAB_HCKSUM = 0x01, /* data is a uint32_t for the txflags */ 2032331Skrgopi MAC_CAPAB_POLL = 0x02, /* boolean only, no data */ 2043115Syl150051 MAC_CAPAB_MULTIADDRESS = 0x04, /* data is multiaddress_capab_t */ 2053115Syl150051 MAC_CAPAB_LSO = 0x08 /* data is mac_capab_lso_t */ 2062311Sseb /* add new capabilities here */ 2072311Sseb } mac_capab_t; 2080Sstevel@tonic-gate 2092331Skrgopi typedef int mac_addr_slot_t; 2102331Skrgopi 2112331Skrgopi /* mma_flags values */ 2122331Skrgopi #define MMAC_SLOT_USED 0x1 /* address slot used */ 2132331Skrgopi #define MMAC_SLOT_UNUSED 0x2 /* free address slot */ 2142331Skrgopi #define MMAC_VENDOR_ADDR 0x4 /* address returned is vendor supplied */ 2152331Skrgopi 2162331Skrgopi typedef struct mac_multi_address_s { 2172331Skrgopi mac_addr_slot_t mma_slot; /* slot for add/remove/get/set */ 2182331Skrgopi uint_t mma_addrlen; 2192331Skrgopi uint8_t mma_addr[MAXMACADDRLEN]; 2202331Skrgopi uint_t mma_flags; 2212331Skrgopi } mac_multi_addr_t; 2222331Skrgopi 2232331Skrgopi typedef int (*maddr_reserve_t)(void *, mac_multi_addr_t *); 2242331Skrgopi typedef int (*maddr_add_t)(void *, mac_multi_addr_t *); 2252331Skrgopi typedef int (*maddr_remove_t)(void *, mac_addr_slot_t); 2262331Skrgopi typedef int (*maddr_modify_t)(void *, mac_multi_addr_t *); 2272331Skrgopi typedef int (*maddr_get_t)(void *, mac_multi_addr_t *); 2282331Skrgopi 2292331Skrgopi /* maddr_flag values */ 2302331Skrgopi #define MADDR_VENDOR_ADDR 0x01 /* addr returned is vendor supplied */ 2312331Skrgopi 2322331Skrgopi /* multiple mac address: add/remove/set/get mac address */ 2332331Skrgopi typedef struct multiaddress_capab_s { 2342331Skrgopi int maddr_naddr; /* total addresses */ 2352331Skrgopi int maddr_naddrfree; /* free address slots */ 2362331Skrgopi uint_t maddr_flag; /* MADDR_VENDOR_ADDR bit can be set */ 2372331Skrgopi /* driver entry points */ 2382331Skrgopi void *maddr_handle; /* cookie to be used for the calls */ 2392331Skrgopi maddr_reserve_t maddr_reserve; /* reserve a factory address */ 2402331Skrgopi maddr_add_t maddr_add; /* add a new unicst address */ 2412331Skrgopi maddr_remove_t maddr_remove; /* remove an added address */ 2422331Skrgopi maddr_modify_t maddr_modify; /* modify an added address */ 2432331Skrgopi maddr_get_t maddr_get; /* get address from specified slot */ 2442331Skrgopi } multiaddress_capab_t; 2452331Skrgopi 2460Sstevel@tonic-gate /* 2470Sstevel@tonic-gate * MAC driver entry point types. 2480Sstevel@tonic-gate */ 2492311Sseb typedef int (*mac_getstat_t)(void *, uint_t, uint64_t *); 2500Sstevel@tonic-gate typedef int (*mac_start_t)(void *); 2510Sstevel@tonic-gate typedef void (*mac_stop_t)(void *); 2522311Sseb typedef int (*mac_setpromisc_t)(void *, boolean_t); 2530Sstevel@tonic-gate typedef int (*mac_multicst_t)(void *, boolean_t, const uint8_t *); 2540Sstevel@tonic-gate typedef int (*mac_unicst_t)(void *, const uint8_t *); 2552311Sseb typedef void (*mac_ioctl_t)(void *, queue_t *, mblk_t *); 2560Sstevel@tonic-gate typedef void (*mac_resources_t)(void *); 2570Sstevel@tonic-gate typedef mblk_t *(*mac_tx_t)(void *, mblk_t *); 2582311Sseb typedef boolean_t (*mac_getcapab_t)(void *, mac_capab_t, void *); 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate /* 2612311Sseb * Drivers must set all of these callbacks except for mc_resources, 2622311Sseb * mc_ioctl, and mc_getcapab, which are optional. If any of these optional 2632311Sseb * callbacks are set, their appropriate flags must be set in mc_callbacks. 2642311Sseb * Any future additions to this list must also be accompanied by an 2652311Sseb * associated mc_callbacks flag so that the framework can grow without 2662311Sseb * affecting the binary compatibility of the interface. 2670Sstevel@tonic-gate */ 2682311Sseb typedef struct mac_callbacks_s { 2692311Sseb uint_t mc_callbacks; /* Denotes which callbacks are set */ 2702311Sseb mac_getstat_t mc_getstat; /* Get the value of a statistic */ 2712311Sseb mac_start_t mc_start; /* Start the device */ 2722311Sseb mac_stop_t mc_stop; /* Stop the device */ 2732311Sseb mac_setpromisc_t mc_setpromisc; /* Enable or disable promiscuous mode */ 2742311Sseb mac_multicst_t mc_multicst; /* Enable or disable a multicast addr */ 2752311Sseb mac_unicst_t mc_unicst; /* Set the unicast MAC address */ 2762311Sseb mac_tx_t mc_tx; /* Transmit a packet */ 2772311Sseb mac_resources_t mc_resources; /* Get the device resources */ 2782311Sseb mac_ioctl_t mc_ioctl; /* Process an unknown ioctl */ 2792311Sseb mac_getcapab_t mc_getcapab; /* Get capability information */ 2802311Sseb } mac_callbacks_t; 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate /* 2832311Sseb * Flags for mc_callbacks. Requiring drivers to set the flags associated 2842311Sseb * with optional callbacks initialized in the structure allows the mac 2852311Sseb * module to add optional callbacks in the future without requiring drivers 2862311Sseb * to recompile. 2870Sstevel@tonic-gate */ 2882311Sseb #define MC_RESOURCES 0x001 2892311Sseb #define MC_IOCTL 0x002 2902311Sseb #define MC_GETCAPAB 0x004 2912311Sseb 2922311Sseb typedef struct mac_register_s { 2932311Sseb uint_t m_version; /* set by mac_alloc() */ 2942311Sseb const char *m_type_ident; 2952311Sseb void *m_driver; /* Driver private data */ 2962311Sseb dev_info_t *m_dip; 2972311Sseb uint_t m_instance; 2982311Sseb uint8_t *m_src_addr; 2992311Sseb uint8_t *m_dst_addr; 3002311Sseb mac_callbacks_t *m_callbacks; 3012311Sseb uint_t m_min_sdu; 3022311Sseb uint_t m_max_sdu; 3032311Sseb void *m_pdata; 3042311Sseb size_t m_pdata_size; 3052311Sseb } mac_register_t; 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate /* 3080Sstevel@tonic-gate * Opaque handle types. 3090Sstevel@tonic-gate */ 3102311Sseb typedef struct mac_t *mac_handle_t; 3110Sstevel@tonic-gate typedef struct __mac_notify_handle *mac_notify_handle_t; 3120Sstevel@tonic-gate typedef struct __mac_rx_handle *mac_rx_handle_t; 3130Sstevel@tonic-gate typedef struct __mac_txloop_handle *mac_txloop_handle_t; 3140Sstevel@tonic-gate typedef struct __mac_resource_handle *mac_resource_handle_t; 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate /* 3170Sstevel@tonic-gate * MAC interface callback types. 3180Sstevel@tonic-gate */ 3190Sstevel@tonic-gate typedef enum { 3200Sstevel@tonic-gate MAC_NOTE_LINK, 3210Sstevel@tonic-gate MAC_NOTE_PROMISC, 3220Sstevel@tonic-gate MAC_NOTE_UNICST, 3230Sstevel@tonic-gate MAC_NOTE_TX, 3240Sstevel@tonic-gate MAC_NOTE_RESOURCE, 3250Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 3262311Sseb MAC_NOTE_FASTPATH_FLUSH, 3270Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 3280Sstevel@tonic-gate } mac_notify_type_t; 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 3310Sstevel@tonic-gate typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *); 3320Sstevel@tonic-gate typedef void (*mac_txloop_t)(void *, mblk_t *); 3330Sstevel@tonic-gate typedef void (*mac_blank_t)(void *, time_t, uint_t); 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate /* 3360Sstevel@tonic-gate * MAC promiscuous types 3370Sstevel@tonic-gate */ 3380Sstevel@tonic-gate typedef enum { 3390Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 3400Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 3410Sstevel@tonic-gate } mac_promisc_type_t; 3420Sstevel@tonic-gate 3430Sstevel@tonic-gate /* 3440Sstevel@tonic-gate * MAC resource types 3450Sstevel@tonic-gate */ 3460Sstevel@tonic-gate typedef enum { 3470Sstevel@tonic-gate MAC_RX_FIFO = 1 3480Sstevel@tonic-gate } mac_resource_type_t; 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3510Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 3520Sstevel@tonic-gate mac_blank_t mrf_blank; 3530Sstevel@tonic-gate void *mrf_arg; 3540Sstevel@tonic-gate time_t mrf_normal_blank_time; 3550Sstevel@tonic-gate uint_t mrf_normal_pkt_count; 3560Sstevel@tonic-gate } mac_rx_fifo_t; 3570Sstevel@tonic-gate 35856Smeem typedef struct mac_txinfo_s { 35956Smeem mac_tx_t mt_fn; 36056Smeem void *mt_arg; 36156Smeem } mac_txinfo_t; 36256Smeem 3630Sstevel@tonic-gate typedef union mac_resource_u { 3640Sstevel@tonic-gate mac_resource_type_t mr_type; 3650Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 3660Sstevel@tonic-gate } mac_resource_t; 3670Sstevel@tonic-gate 3680Sstevel@tonic-gate typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 3690Sstevel@tonic-gate 3702311Sseb typedef enum { 3712311Sseb MAC_ADDRTYPE_UNICAST, 3722311Sseb MAC_ADDRTYPE_MULTICAST, 3732311Sseb MAC_ADDRTYPE_BROADCAST 3742311Sseb } mac_addrtype_t; 3752311Sseb 3762311Sseb typedef struct mac_header_info_s { 3772311Sseb size_t mhi_hdrsize; 3782311Sseb size_t mhi_pktsize; 3792311Sseb const uint8_t *mhi_daddr; 3802311Sseb const uint8_t *mhi_saddr; 3812311Sseb uint32_t mhi_origsap; 3822311Sseb uint32_t mhi_bindsap; 3832311Sseb mac_addrtype_t mhi_dsttype; 3842760Sdg199075 boolean_t mhi_istagged; 3852760Sdg199075 uint16_t mhi_tci; 3862311Sseb } mac_header_info_t; 3872311Sseb 3882311Sseb /* 3892311Sseb * MAC-Type plugin interfaces 3902311Sseb */ 3912311Sseb 3922311Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 3932311Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 3942311Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 3952311Sseb uint32_t, void *, mblk_t *, size_t); 3962311Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 3972311Sseb mac_header_info_t *); 3982311Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 3992311Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 400*4403Sgd78059 typedef void (*mtops_link_details_t)(char *, size_t, mac_handle_t, 401*4403Sgd78059 void *); 4022311Sseb 4032311Sseb typedef struct mactype_ops_s { 4042311Sseb uint_t mtops_ops; 4052311Sseb /* 4062311Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 4072311Sseb * unicast address, or a non-zero errno otherwise. 4082311Sseb */ 4092311Sseb mtops_addr_verify_t mtops_unicst_verify; 4102311Sseb /* 4112311Sseb * mtops_multicst_verify() returns 0 if the given address is a 4122311Sseb * valid multicast address, or a non-zero errno otherwise. If the 4132311Sseb * media doesn't support multicast, ENOTSUP should be returned (for 4142311Sseb * example). 4152311Sseb */ 4162311Sseb mtops_addr_verify_t mtops_multicst_verify; 4172311Sseb /* 4182311Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 4192311Sseb * SAP value, or B_FALSE otherwise. 4202311Sseb */ 4212311Sseb mtops_sap_verify_t mtops_sap_verify; 4222311Sseb /* 4232311Sseb * mtops_header() is used to allocate and construct a MAC header. 4242311Sseb */ 4252311Sseb mtops_header_t mtops_header; 4262311Sseb /* 4272311Sseb * mtops_header_info() is used to gather information on a given MAC 4282311Sseb * header. 4292311Sseb */ 4302311Sseb mtops_header_info_t mtops_header_info; 4312311Sseb /* 4322311Sseb * mtops_pdata_verify() is used to verify the validity of MAC 4332311Sseb * plugin data. It is called by mac_register() if the driver has 4342311Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 4352311Sseb * drivers update the data. 4362311Sseb */ 4372311Sseb mtops_pdata_verify_t mtops_pdata_verify; 4382311Sseb /* 4392311Sseb * mtops_header_cook() is an optional callback that converts (or 4402311Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 4412311Sseb * into one that is appropriate to send down to the MAC driver. 4422311Sseb * Following the example above, an Ethernet header sent down by a 4432311Sseb * DLPI consumer would be converted to whatever header the MAC 4442311Sseb * driver expects. 4452311Sseb */ 4462311Sseb mtops_header_modify_t mtops_header_cook; 4472311Sseb /* 4482311Sseb * mtops_header_uncook() is an optional callback that does the 4492311Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 4502311Sseb * header (as received from the driver) for consumption by raw DLPI 4512311Sseb * consumers. For example, for a non-Ethernet plugin that wants 4522311Sseb * raw DLPI consumers to be fooled into thinking that the device 4532311Sseb * provides Ethernet access, this callback would modify the given 4542311Sseb * mblk_t such that the MAC header is converted to an Ethernet 4552311Sseb * header. 4562311Sseb */ 4572311Sseb mtops_header_modify_t mtops_header_uncook; 458*4403Sgd78059 /* 459*4403Sgd78059 * mtops_link_details() is an optional callback that provides 460*4403Sgd78059 * extended information about the link state. Its primary purpose 461*4403Sgd78059 * is to provide type-specific support for syslog contents on 462*4403Sgd78059 * link up events. If no implementation is provided, then a default 463*4403Sgd78059 * implementation will be used. 464*4403Sgd78059 */ 465*4403Sgd78059 mtops_link_details_t mtops_link_details; 4662311Sseb } mactype_ops_t; 4672311Sseb 4682311Sseb /* 4692311Sseb * mtops_ops exists for the plugin to enumerate the optional callback 4702311Sseb * entrypoints it has defined. This allows the mac module to define 4712311Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 4722311Sseb * compatibility with old plugins. 4732311Sseb */ 4742311Sseb #define MTOPS_PDATA_VERIFY 0x001 4752311Sseb #define MTOPS_HEADER_COOK 0x002 4762311Sseb #define MTOPS_HEADER_UNCOOK 0x004 477*4403Sgd78059 #define MTOPS_LINK_DETAILS 0x008 4782311Sseb 4792311Sseb typedef struct mactype_register_s { 4802311Sseb uint_t mtr_version; /* set by mactype_alloc() */ 4812311Sseb const char *mtr_ident; 4822311Sseb mactype_ops_t *mtr_ops; 4832311Sseb uint_t mtr_mactype; 4843147Sxc151355 uint_t mtr_nativetype; 4852311Sseb uint_t mtr_addrlen; 4862311Sseb uint8_t *mtr_brdcst_addr; 4872311Sseb mac_stat_info_t *mtr_stats; 4882311Sseb size_t mtr_statcount; 4892311Sseb } mactype_register_t; 4902311Sseb 4910Sstevel@tonic-gate /* 4920Sstevel@tonic-gate * Client interface functions. 4930Sstevel@tonic-gate */ 4940Sstevel@tonic-gate extern int mac_open(const char *, uint_t, mac_handle_t *); 4950Sstevel@tonic-gate extern void mac_close(mac_handle_t); 4960Sstevel@tonic-gate extern const mac_info_t *mac_info(mac_handle_t); 497269Sericheng extern boolean_t mac_info_get(const char *, mac_info_t *); 4982311Sseb extern uint64_t mac_stat_get(mac_handle_t, uint_t); 4990Sstevel@tonic-gate extern int mac_start(mac_handle_t); 5000Sstevel@tonic-gate extern void mac_stop(mac_handle_t); 5010Sstevel@tonic-gate extern int mac_promisc_set(mac_handle_t, boolean_t, 5020Sstevel@tonic-gate mac_promisc_type_t); 5030Sstevel@tonic-gate extern boolean_t mac_promisc_get(mac_handle_t, 5040Sstevel@tonic-gate mac_promisc_type_t); 5050Sstevel@tonic-gate extern int mac_multicst_add(mac_handle_t, const uint8_t *); 5060Sstevel@tonic-gate extern int mac_multicst_remove(mac_handle_t, 5070Sstevel@tonic-gate const uint8_t *); 5082331Skrgopi extern boolean_t mac_unicst_verify(mac_handle_t, 5092331Skrgopi const uint8_t *, uint_t); 5100Sstevel@tonic-gate extern int mac_unicst_set(mac_handle_t, const uint8_t *); 5110Sstevel@tonic-gate extern void mac_unicst_get(mac_handle_t, uint8_t *); 5122311Sseb extern void mac_dest_get(mac_handle_t, uint8_t *); 5130Sstevel@tonic-gate extern void mac_resources(mac_handle_t); 5140Sstevel@tonic-gate extern void mac_ioctl(mac_handle_t, queue_t *, mblk_t *); 51556Smeem extern const mac_txinfo_t *mac_tx_get(mac_handle_t); 5160Sstevel@tonic-gate extern link_state_t mac_link_get(mac_handle_t); 5170Sstevel@tonic-gate extern mac_notify_handle_t mac_notify_add(mac_handle_t, mac_notify_t, 5180Sstevel@tonic-gate void *); 5190Sstevel@tonic-gate extern void mac_notify_remove(mac_handle_t, 5200Sstevel@tonic-gate mac_notify_handle_t); 5210Sstevel@tonic-gate extern void mac_notify(mac_handle_t); 5220Sstevel@tonic-gate extern mac_rx_handle_t mac_rx_add(mac_handle_t, mac_rx_t, void *); 5230Sstevel@tonic-gate extern void mac_rx_remove(mac_handle_t, mac_rx_handle_t); 5240Sstevel@tonic-gate extern mblk_t *mac_txloop(void *, mblk_t *); 5250Sstevel@tonic-gate extern mac_txloop_handle_t mac_txloop_add(mac_handle_t, mac_txloop_t, 5260Sstevel@tonic-gate void *); 5270Sstevel@tonic-gate extern void mac_txloop_remove(mac_handle_t, 5280Sstevel@tonic-gate mac_txloop_handle_t); 5290Sstevel@tonic-gate extern boolean_t mac_active_set(mac_handle_t); 5300Sstevel@tonic-gate extern void mac_active_clear(mac_handle_t); 5310Sstevel@tonic-gate extern void mac_resource_set(mac_handle_t, 5320Sstevel@tonic-gate mac_resource_add_t, void *); 533269Sericheng extern dev_info_t *mac_devinfo_get(mac_handle_t); 5342311Sseb extern boolean_t mac_capab_get(mac_handle_t, mac_capab_t, 5352311Sseb void *); 5362311Sseb extern boolean_t mac_sap_verify(mac_handle_t, uint32_t, 5372311Sseb uint32_t *); 5382311Sseb extern mblk_t *mac_header(mac_handle_t, const uint8_t *, 5392311Sseb uint32_t, mblk_t *, size_t); 5402311Sseb extern int mac_header_info(mac_handle_t, mblk_t *, 5412311Sseb mac_header_info_t *); 5422311Sseb extern mblk_t *mac_header_cook(mac_handle_t, mblk_t *); 5432311Sseb extern mblk_t *mac_header_uncook(mac_handle_t, mblk_t *); 5440Sstevel@tonic-gate 5450Sstevel@tonic-gate /* 5460Sstevel@tonic-gate * Driver interface functions. 5470Sstevel@tonic-gate */ 5482311Sseb extern mac_register_t *mac_alloc(uint_t); 5492311Sseb extern void mac_free(mac_register_t *); 5502311Sseb extern int mac_register(mac_register_t *, mac_handle_t *); 5512311Sseb extern int mac_unregister(mac_handle_t); 5522311Sseb extern void mac_rx(mac_handle_t, mac_resource_handle_t, 5530Sstevel@tonic-gate mblk_t *); 5542311Sseb extern void mac_link_update(mac_handle_t, link_state_t); 5552311Sseb extern void mac_unicst_update(mac_handle_t, 5562311Sseb const uint8_t *); 5572311Sseb extern void mac_tx_update(mac_handle_t); 5582311Sseb extern void mac_resource_update(mac_handle_t); 5592311Sseb extern mac_resource_handle_t mac_resource_add(mac_handle_t, 5602311Sseb mac_resource_t *); 5612311Sseb extern int mac_pdata_update(mac_handle_t, void *, 5622311Sseb size_t); 5632311Sseb extern void mac_multicst_refresh(mac_handle_t, 5642311Sseb mac_multicst_t, void *, boolean_t); 5652311Sseb extern void mac_unicst_refresh(mac_handle_t, mac_unicst_t, 5660Sstevel@tonic-gate void *); 5672311Sseb extern void mac_promisc_refresh(mac_handle_t, 5682311Sseb mac_setpromisc_t, void *); 569269Sericheng extern void mac_init_ops(struct dev_ops *, const char *); 570269Sericheng extern void mac_fini_ops(struct dev_ops *); 5712311Sseb extern mactype_register_t *mactype_alloc(uint_t); 5722311Sseb extern void mactype_free(mactype_register_t *); 5732311Sseb extern int mactype_register(mactype_register_t *); 5742311Sseb extern int mactype_unregister(const char *); 5753448Sdh155122 extern int mac_vlan_create(mac_handle_t, const char *, 5763448Sdh155122 minor_t); 5773448Sdh155122 extern void mac_vlan_remove(mac_handle_t, const char *); 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate #endif /* _KERNEL */ 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate #ifdef __cplusplus 5820Sstevel@tonic-gate } 5830Sstevel@tonic-gate #endif 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 586