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 */ 218275SEric Cheng 220Sstevel@tonic-gate /* 2312163SRamaswamy.Tummala@Sun.COM * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_MAC_H 270Sstevel@tonic-gate #define _SYS_MAC_H 280Sstevel@tonic-gate 292760Sdg199075 #include <sys/types.h> 309107Sjames.d.carlson@sun.com #ifdef _KERNEL 310Sstevel@tonic-gate #include <sys/sunddi.h> 329107Sjames.d.carlson@sun.com #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate /* 350Sstevel@tonic-gate * MAC Services Module 360Sstevel@tonic-gate */ 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 440Sstevel@tonic-gate */ 4510654SGarrett.Damore@Sun.COM #define MAC_INFO "MAC Services" 462311Sseb 472311Sseb /* 482311Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 492311Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 502311Sseb * register. 512311Sseb */ 522311Sseb #define MACTYPE_VERSION 0x1 532311Sseb 542311Sseb /* 558275SEric Cheng * Opaque handle types 560Sstevel@tonic-gate */ 578275SEric Cheng typedef struct __mac_handle *mac_handle_t; 588275SEric Cheng typedef struct __mac_resource_handle *mac_resource_handle_t; 598275SEric Cheng typedef struct __mac_notify_handle *mac_notify_handle_t; 608275SEric Cheng typedef struct __mac_tx_notify_handle *mac_tx_notify_handle_t; 618275SEric Cheng typedef struct __mac_intr_handle *mac_intr_handle_t; 628275SEric Cheng typedef struct __mac_ring_handle *mac_ring_handle_t; 638275SEric Cheng typedef struct __mac_group_handle *mac_group_handle_t; 640Sstevel@tonic-gate 658275SEric Cheng #define DATALINK_INVALID_LINKID 0 668275SEric Cheng #define DATALINK_ALL_LINKID 0 678275SEric Cheng #define DATALINK_MAX_LINKID 0xffffffff 688275SEric Cheng 690Sstevel@tonic-gate typedef enum { 700Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 710Sstevel@tonic-gate LINK_STATE_DOWN, 720Sstevel@tonic-gate LINK_STATE_UP 730Sstevel@tonic-gate } link_state_t; 740Sstevel@tonic-gate 750Sstevel@tonic-gate typedef enum { 760Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 770Sstevel@tonic-gate LINK_DUPLEX_HALF, 780Sstevel@tonic-gate LINK_DUPLEX_FULL 790Sstevel@tonic-gate } link_duplex_t; 800Sstevel@tonic-gate 815903Ssowmini typedef enum { 825903Ssowmini LINK_FLOWCTRL_NONE = 0, 835903Ssowmini LINK_FLOWCTRL_RX, 845903Ssowmini LINK_FLOWCTRL_TX, 855903Ssowmini LINK_FLOWCTRL_BI 865903Ssowmini } link_flowctrl_t; 875903Ssowmini 888874SSebastien.Roy@Sun.COM typedef enum { 898874SSebastien.Roy@Sun.COM LINK_TAGMODE_VLANONLY = 0, 908874SSebastien.Roy@Sun.COM LINK_TAGMODE_NORMAL 918874SSebastien.Roy@Sun.COM } link_tagmode_t; 928874SSebastien.Roy@Sun.COM 938275SEric Cheng /* 9411878SVenu.Iyer@Sun.COM * Defines range of uint32_t values 959514SGirish.Moodalbail@Sun.COM */ 969514SGirish.Moodalbail@Sun.COM typedef struct mac_propval_uint32_range_s { 979514SGirish.Moodalbail@Sun.COM uint32_t mpur_min; 989514SGirish.Moodalbail@Sun.COM uint32_t mpur_max; 999514SGirish.Moodalbail@Sun.COM } mac_propval_uint32_range_t; 1009514SGirish.Moodalbail@Sun.COM 1019514SGirish.Moodalbail@Sun.COM /* 10211878SVenu.Iyer@Sun.COM * Data type of property values. 1039514SGirish.Moodalbail@Sun.COM */ 1049514SGirish.Moodalbail@Sun.COM typedef enum { 10511878SVenu.Iyer@Sun.COM MAC_PROPVAL_UINT8, 10611878SVenu.Iyer@Sun.COM MAC_PROPVAL_UINT32, 10711878SVenu.Iyer@Sun.COM MAC_PROPVAL_STR 1089514SGirish.Moodalbail@Sun.COM } mac_propval_type_t; 1099514SGirish.Moodalbail@Sun.COM 1109514SGirish.Moodalbail@Sun.COM /* 1119514SGirish.Moodalbail@Sun.COM * Captures possible values for a given property. A property can have 1129514SGirish.Moodalbail@Sun.COM * range of values (int32, int64, uint32, uint64, et al) or collection/ 1139514SGirish.Moodalbail@Sun.COM * enumeration of values (strings). 1149514SGirish.Moodalbail@Sun.COM * Can be used as a value-result parameter. 1159514SGirish.Moodalbail@Sun.COM */ 1169514SGirish.Moodalbail@Sun.COM typedef struct mac_propval_range_s { 1179514SGirish.Moodalbail@Sun.COM uint_t mpr_count; /* count of ranges */ 1189514SGirish.Moodalbail@Sun.COM mac_propval_type_t mpr_type; /* type of value */ 1199514SGirish.Moodalbail@Sun.COM union { 1209514SGirish.Moodalbail@Sun.COM mac_propval_uint32_range_t mpr_uint32[1]; 1219514SGirish.Moodalbail@Sun.COM } u; 1229514SGirish.Moodalbail@Sun.COM } mac_propval_range_t; 1239514SGirish.Moodalbail@Sun.COM 12411878SVenu.Iyer@Sun.COM #define mpr_range_uint32 u.mpr_uint32 1259514SGirish.Moodalbail@Sun.COM 1269514SGirish.Moodalbail@Sun.COM /* 1278275SEric Cheng * Maximum MAC address length 1288275SEric Cheng */ 1298275SEric Cheng #define MAXMACADDRLEN 20 1308275SEric Cheng 1318275SEric Cheng typedef enum { 1328275SEric Cheng MAC_LOGTYPE_LINK = 1, 1338275SEric Cheng MAC_LOGTYPE_FLOW 1348275SEric Cheng } mac_logtype_t; 1356789Sam223141 13611878SVenu.Iyer@Sun.COM #define MAXLINKPROPNAME 256 /* max property name len */ 1379514SGirish.Moodalbail@Sun.COM 1389514SGirish.Moodalbail@Sun.COM /* 13911878SVenu.Iyer@Sun.COM * Public properties. 14011878SVenu.Iyer@Sun.COM * 14111878SVenu.Iyer@Sun.COM * Note that there are 2 sets of parameters: the *_EN_* values are 14211878SVenu.Iyer@Sun.COM * those that the Administrator configures for autonegotiation. The 14311878SVenu.Iyer@Sun.COM * _ADV_* values are those that are currently exposed over the wire. 1449514SGirish.Moodalbail@Sun.COM */ 1456789Sam223141 typedef enum { 1466789Sam223141 MAC_PROP_DUPLEX = 0x00000001, 1476789Sam223141 MAC_PROP_SPEED, 1486789Sam223141 MAC_PROP_STATUS, 1496789Sam223141 MAC_PROP_AUTONEG, 1506789Sam223141 MAC_PROP_EN_AUTONEG, 1516789Sam223141 MAC_PROP_MTU, 1527342SAruna.Ramakrishna@Sun.COM MAC_PROP_ZONE, 1537342SAruna.Ramakrishna@Sun.COM MAC_PROP_AUTOPUSH, 1546789Sam223141 MAC_PROP_FLOWCTRL, 1556789Sam223141 MAC_PROP_ADV_1000FDX_CAP, 1566789Sam223141 MAC_PROP_EN_1000FDX_CAP, 1576789Sam223141 MAC_PROP_ADV_1000HDX_CAP, 1586789Sam223141 MAC_PROP_EN_1000HDX_CAP, 1596789Sam223141 MAC_PROP_ADV_100FDX_CAP, 1606789Sam223141 MAC_PROP_EN_100FDX_CAP, 1616789Sam223141 MAC_PROP_ADV_100HDX_CAP, 1626789Sam223141 MAC_PROP_EN_100HDX_CAP, 1636789Sam223141 MAC_PROP_ADV_10FDX_CAP, 1646789Sam223141 MAC_PROP_EN_10FDX_CAP, 1656789Sam223141 MAC_PROP_ADV_10HDX_CAP, 1666789Sam223141 MAC_PROP_EN_10HDX_CAP, 1676789Sam223141 MAC_PROP_ADV_100T4_CAP, 1686789Sam223141 MAC_PROP_EN_100T4_CAP, 16910616SSebastien.Roy@Sun.COM MAC_PROP_IPTUN_HOPLIMIT, 17010616SSebastien.Roy@Sun.COM MAC_PROP_IPTUN_ENCAPLIMIT, 1717663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ESSID, 1727663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_BSSID, 1737663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_BSSTYPE, 1747663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_LINKSTATUS, 1757663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_DESIRED_RATES, 1767663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SUPPORTED_RATES, 1777663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_AUTH_MODE, 1787663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ENCRYPTION, 1797663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_RSSI, 1807663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_PHY_CONFIG, 1817663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_CAPABILITY, 1827663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_WPA, 1837663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SCANRESULTS, 1847663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_POWER_MODE, 1857663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_RADIO, 1867663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ESS_LIST, 1877663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_KEY_TAB, 1887663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_CREATE_IBSS, 1897663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SETOPTIE, 1907663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_DELKEY, 1917663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_KEY, 1927663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_MLME, 1938874SSebastien.Roy@Sun.COM MAC_PROP_TAGMODE, 1949449Sxiuyan.wang@Sun.COM MAC_PROP_ADV_10GFDX_CAP, 1959449Sxiuyan.wang@Sun.COM MAC_PROP_EN_10GFDX_CAP, 19610491SRishi.Srivatsavai@Sun.COM MAC_PROP_PVID, 19710491SRishi.Srivatsavai@Sun.COM MAC_PROP_LLIMIT, 19810491SRishi.Srivatsavai@Sun.COM MAC_PROP_LDECAY, 19911878SVenu.Iyer@Sun.COM MAC_PROP_RESOURCE, 20011878SVenu.Iyer@Sun.COM MAC_PROP_RESOURCE_EFF, 20111878SVenu.Iyer@Sun.COM MAC_PROP_RXRINGSRANGE, 20211878SVenu.Iyer@Sun.COM MAC_PROP_TXRINGSRANGE, 20311878SVenu.Iyer@Sun.COM MAC_PROP_MAX_TX_RINGS_AVAIL, 20411878SVenu.Iyer@Sun.COM MAC_PROP_MAX_RX_RINGS_AVAIL, 20511878SVenu.Iyer@Sun.COM MAC_PROP_MAX_RXHWCLNT_AVAIL, 20611878SVenu.Iyer@Sun.COM MAC_PROP_MAX_TXHWCLNT_AVAIL, 20712163SRamaswamy.Tummala@Sun.COM MAC_PROP_IB_LINKMODE, 2086789Sam223141 MAC_PROP_PRIVATE = -1 2096789Sam223141 } mac_prop_id_t; 2106789Sam223141 2115084Sjohnlev /* 2128118SVasumathi.Sundaram@Sun.COM * Flags to figure out r/w status of legacy ndd props. 2138118SVasumathi.Sundaram@Sun.COM */ 2148118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_READ 0x0001 2158118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_WRITE 0x0010 2168118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_MAP_KSTAT 0x0100 2178118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_RW (MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE) 2188118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_FLAGS_RK (MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT) 2198118SVasumathi.Sundaram@Sun.COM 2200Sstevel@tonic-gate #ifdef _KERNEL 2210Sstevel@tonic-gate 2222311Sseb /* 2232311Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 2242311Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 2252311Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 2262311Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 2272311Sseb * defined by MAC-Type plugins and maintained by each driver. 2282311Sseb */ 2292311Sseb #define MAC_STAT_MIN 1000 2302311Sseb #define MACTYPE_STAT_MIN 2000 2312311Sseb 2322311Sseb #define IS_MAC_STAT(stat) \ 2332311Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 2342311Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 2352311Sseb 2364089Sgd78059 /* 2375895Syz147064 * Statistics maintained by the mac module, and possibly populated as link 2385895Syz147064 * statistics. 2395895Syz147064 */ 2405895Syz147064 enum mac_mod_stat { 2415895Syz147064 MAC_STAT_LINK_STATE, 2425895Syz147064 MAC_STAT_LINK_UP, 24310491SRishi.Srivatsavai@Sun.COM MAC_STAT_PROMISC, 24411878SVenu.Iyer@Sun.COM MAC_STAT_LOWLINK_STATE, 24511878SVenu.Iyer@Sun.COM MAC_STAT_HDROPS 2465895Syz147064 }; 2475895Syz147064 2485895Syz147064 /* 2494089Sgd78059 * Do not reorder, and add only to the end of this list. 2504089Sgd78059 */ 2512311Sseb enum mac_driver_stat { 2522311Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 2532311Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 2540Sstevel@tonic-gate MAC_STAT_MULTIRCV, 2550Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 2560Sstevel@tonic-gate MAC_STAT_MULTIXMT, 2570Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 2580Sstevel@tonic-gate MAC_STAT_NORCVBUF, 2590Sstevel@tonic-gate MAC_STAT_IERRORS, 2600Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 2610Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 2620Sstevel@tonic-gate MAC_STAT_OERRORS, 2630Sstevel@tonic-gate MAC_STAT_COLLISIONS, 2640Sstevel@tonic-gate MAC_STAT_RBYTES, 2650Sstevel@tonic-gate MAC_STAT_IPACKETS, 2660Sstevel@tonic-gate MAC_STAT_OBYTES, 2674089Sgd78059 MAC_STAT_OPACKETS, 2684089Sgd78059 MAC_STAT_UNDERFLOWS, 2694089Sgd78059 MAC_STAT_OVERFLOWS 2702311Sseb }; 2710Sstevel@tonic-gate 2724089Sgd78059 #define MAC_NSTAT (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1) 2730Sstevel@tonic-gate 2742311Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 2752311Sseb (_stat) == MAC_STAT_MULTIRCV || \ 2762311Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 2772311Sseb (_stat) == MAC_STAT_MULTIXMT || \ 2782311Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 2792311Sseb (_stat) == MAC_STAT_NORCVBUF || \ 2802311Sseb (_stat) == MAC_STAT_IERRORS || \ 2812311Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 2822311Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 2832311Sseb (_stat) == MAC_STAT_OERRORS || \ 2842311Sseb (_stat) == MAC_STAT_COLLISIONS || \ 2852311Sseb (_stat) == MAC_STAT_RBYTES || \ 2862311Sseb (_stat) == MAC_STAT_IPACKETS || \ 2872311Sseb (_stat) == MAC_STAT_OBYTES || \ 2884089Sgd78059 (_stat) == MAC_STAT_OPACKETS || \ 2894089Sgd78059 (_stat) == MAC_STAT_UNDERFLOWS || \ 2904089Sgd78059 (_stat) == MAC_STAT_OVERFLOWS) 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate /* 2930Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 2940Sstevel@tonic-gate */ 2950Sstevel@tonic-gate typedef struct mac_info_s { 2960Sstevel@tonic-gate uint_t mi_media; 2973147Sxc151355 uint_t mi_nativemedia; 2980Sstevel@tonic-gate uint_t mi_addr_length; 2992311Sseb uint8_t *mi_unicst_addr; 3002311Sseb uint8_t *mi_brdcst_addr; 3010Sstevel@tonic-gate } mac_info_t; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3048275SEric Cheng * When VNICs are created on top of the NIC, there are two levels 3058275SEric Cheng * of MAC layer, a lower MAC, which is the MAC layer at the level of the 3068275SEric Cheng * physical NIC, and an upper MAC, which is the MAC layer at the level 3078275SEric Cheng * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and 3088275SEric Cheng * the SRS and classification is done at the lower MAC level. The upper 3098275SEric Cheng * MAC is therefore for the most part pass-through, and therefore 3108275SEric Cheng * special processing needs to be done at the upper MAC layer when 3118275SEric Cheng * dealing with a VNIC. 3128275SEric Cheng * 3138275SEric Cheng * This capability allows the MAC layer to detect when a VNIC is being 3148275SEric Cheng * access, and implement the required shortcuts. 3150Sstevel@tonic-gate */ 3166495Sspeer 3178275SEric Cheng typedef void *(*mac_client_handle_fn_t)(void *); 3186495Sspeer 3198275SEric Cheng typedef struct mac_capab_vnic_s { 3208275SEric Cheng void *mcv_arg; 3218275SEric Cheng mac_client_handle_fn_t mcv_mac_client_handle; 3228275SEric Cheng } mac_capab_vnic_t; 3236495Sspeer 3248275SEric Cheng typedef void (*mac_rename_fn_t)(const char *, void *); 32511878SVenu.Iyer@Sun.COM typedef mblk_t *(*mac_tx_ring_fn_t)(void *, mblk_t *, uintptr_t, 32611878SVenu.Iyer@Sun.COM mac_ring_handle_t *); 3278275SEric Cheng typedef struct mac_capab_aggr_s { 3288275SEric Cheng mac_rename_fn_t mca_rename_fn; 3298275SEric Cheng int (*mca_unicst)(void *, const uint8_t *); 33011878SVenu.Iyer@Sun.COM mac_tx_ring_fn_t mca_find_tx_ring_fn; 33111878SVenu.Iyer@Sun.COM void *mca_arg; 3328275SEric Cheng } mac_capab_aggr_t; 3336495Sspeer 33410491SRishi.Srivatsavai@Sun.COM /* Bridge transmit and receive function signatures */ 33510491SRishi.Srivatsavai@Sun.COM typedef mblk_t *(*mac_bridge_tx_t)(mac_handle_t, mac_ring_handle_t, mblk_t *); 33610491SRishi.Srivatsavai@Sun.COM typedef void (*mac_bridge_rx_t)(mac_handle_t, mac_resource_handle_t, mblk_t *); 33710491SRishi.Srivatsavai@Sun.COM typedef void (*mac_bridge_ref_t)(mac_handle_t, boolean_t); 33810491SRishi.Srivatsavai@Sun.COM typedef link_state_t (*mac_bridge_ls_t)(mac_handle_t, link_state_t); 33910491SRishi.Srivatsavai@Sun.COM 34010491SRishi.Srivatsavai@Sun.COM /* must change mac_notify_cb_list[] in mac_provider.c if this is changed */ 3410Sstevel@tonic-gate typedef enum { 3420Sstevel@tonic-gate MAC_NOTE_LINK, 3430Sstevel@tonic-gate MAC_NOTE_UNICST, 3440Sstevel@tonic-gate MAC_NOTE_TX, 3450Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 3462311Sseb MAC_NOTE_FASTPATH_FLUSH, 3475903Ssowmini MAC_NOTE_SDU_SIZE, 34810616SSebastien.Roy@Sun.COM MAC_NOTE_DEST, 3495895Syz147064 MAC_NOTE_MARGIN, 3508275SEric Cheng MAC_NOTE_CAPAB_CHG, 35110491SRishi.Srivatsavai@Sun.COM MAC_NOTE_LOWLINK, 35212748SSowmini.Varadhan@oracle.COM MAC_NOTE_ALLOWED_IPS, 3530Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 3540Sstevel@tonic-gate } mac_notify_type_t; 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 3578275SEric Cheng typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *, 3588275SEric Cheng boolean_t); 3598275SEric Cheng typedef mblk_t *(*mac_receive_t)(void *, int); 3600Sstevel@tonic-gate 3610Sstevel@tonic-gate /* 3620Sstevel@tonic-gate * MAC resource types 3630Sstevel@tonic-gate */ 3640Sstevel@tonic-gate typedef enum { 3650Sstevel@tonic-gate MAC_RX_FIFO = 1 3660Sstevel@tonic-gate } mac_resource_type_t; 3670Sstevel@tonic-gate 3688275SEric Cheng typedef int (*mac_intr_enable_t)(mac_intr_handle_t); 3698275SEric Cheng typedef int (*mac_intr_disable_t)(mac_intr_handle_t); 3708275SEric Cheng 3718275SEric Cheng typedef struct mac_intr_s { 3728275SEric Cheng mac_intr_handle_t mi_handle; 3738275SEric Cheng mac_intr_enable_t mi_enable; 3748275SEric Cheng mac_intr_disable_t mi_disable; 37511878SVenu.Iyer@Sun.COM ddi_intr_handle_t mi_ddi_handle; 37611878SVenu.Iyer@Sun.COM boolean_t mi_ddi_shared; 3778275SEric Cheng } mac_intr_t; 3788275SEric Cheng 3790Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3800Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 3818275SEric Cheng mac_intr_t mrf_intr; 3828275SEric Cheng mac_receive_t mrf_receive; 3838275SEric Cheng void *mrf_rx_arg; 3848275SEric Cheng uint32_t mrf_flow_priority; 3858275SEric Cheng /* 3868275SEric Cheng * The CPU this flow is to be processed on. With intrd and future 3878275SEric Cheng * things, we should know which CPU the flow needs to be processed 3888275SEric Cheng * and get a squeue assigned on that CPU. 3898275SEric Cheng */ 3908275SEric Cheng uint_t mrf_cpu_id; 3910Sstevel@tonic-gate } mac_rx_fifo_t; 3920Sstevel@tonic-gate 3938275SEric Cheng #define mrf_intr_handle mrf_intr.mi_handle 3948275SEric Cheng #define mrf_intr_enable mrf_intr.mi_enable 3958275SEric Cheng #define mrf_intr_disable mrf_intr.mi_disable 39656Smeem 3970Sstevel@tonic-gate typedef union mac_resource_u { 3980Sstevel@tonic-gate mac_resource_type_t mr_type; 3990Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 4000Sstevel@tonic-gate } mac_resource_t; 4010Sstevel@tonic-gate 4022311Sseb typedef enum { 4032311Sseb MAC_ADDRTYPE_UNICAST, 4042311Sseb MAC_ADDRTYPE_MULTICAST, 4052311Sseb MAC_ADDRTYPE_BROADCAST 4062311Sseb } mac_addrtype_t; 4072311Sseb 4082311Sseb typedef struct mac_header_info_s { 4092311Sseb size_t mhi_hdrsize; 4102311Sseb size_t mhi_pktsize; 4112311Sseb const uint8_t *mhi_daddr; 4122311Sseb const uint8_t *mhi_saddr; 4132311Sseb uint32_t mhi_origsap; 4142311Sseb uint32_t mhi_bindsap; 4152311Sseb mac_addrtype_t mhi_dsttype; 4162760Sdg199075 uint16_t mhi_tci; 4178275SEric Cheng boolean_t mhi_istagged; 41810491SRishi.Srivatsavai@Sun.COM boolean_t mhi_ispvid; 4192311Sseb } mac_header_info_t; 4202311Sseb 4212311Sseb /* 4228275SEric Cheng * Function pointer to match dls client signature. Should be same as 4238275SEric Cheng * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS 4248275SEric Cheng * client directly. 4258275SEric Cheng */ 4268275SEric Cheng typedef void (*mac_direct_rx_t)(void *, mac_resource_handle_t, 4278275SEric Cheng mblk_t *, mac_header_info_t *); 4288275SEric Cheng 4298275SEric Cheng typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 4308275SEric Cheng typedef int (*mac_resource_bind_t)(void *, 4318275SEric Cheng mac_resource_handle_t, processorid_t); 4328275SEric Cheng typedef void (*mac_resource_remove_t)(void *, void *); 4338275SEric Cheng typedef void (*mac_resource_quiesce_t)(void *, void *); 4348275SEric Cheng typedef void (*mac_resource_restart_t)(void *, void *); 4358275SEric Cheng typedef int (*mac_resource_modify_t)(void *, void *, 4368275SEric Cheng mac_resource_t *); 4378275SEric Cheng typedef void (*mac_change_upcall_t)(void *, mac_direct_rx_t, 4388275SEric Cheng void *); 4398275SEric Cheng 4408275SEric Cheng /* 4412311Sseb * MAC-Type plugin interfaces 4422311Sseb */ 4432311Sseb 4442311Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 4452311Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 4462311Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 4472311Sseb uint32_t, void *, mblk_t *, size_t); 4482311Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 4492311Sseb mac_header_info_t *); 4502311Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 4512311Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 4524403Sgd78059 typedef void (*mtops_link_details_t)(char *, size_t, mac_handle_t, 4534403Sgd78059 void *); 4542311Sseb 4552311Sseb typedef struct mactype_ops_s { 4562311Sseb uint_t mtops_ops; 4572311Sseb /* 4582311Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 4592311Sseb * unicast address, or a non-zero errno otherwise. 4602311Sseb */ 4612311Sseb mtops_addr_verify_t mtops_unicst_verify; 4622311Sseb /* 4632311Sseb * mtops_multicst_verify() returns 0 if the given address is a 4642311Sseb * valid multicast address, or a non-zero errno otherwise. If the 4652311Sseb * media doesn't support multicast, ENOTSUP should be returned (for 4662311Sseb * example). 4672311Sseb */ 4682311Sseb mtops_addr_verify_t mtops_multicst_verify; 4692311Sseb /* 4702311Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 4712311Sseb * SAP value, or B_FALSE otherwise. 4722311Sseb */ 4732311Sseb mtops_sap_verify_t mtops_sap_verify; 4742311Sseb /* 4752311Sseb * mtops_header() is used to allocate and construct a MAC header. 4762311Sseb */ 4772311Sseb mtops_header_t mtops_header; 4782311Sseb /* 4792311Sseb * mtops_header_info() is used to gather information on a given MAC 4802311Sseb * header. 4812311Sseb */ 4822311Sseb mtops_header_info_t mtops_header_info; 4832311Sseb /* 4842311Sseb * mtops_pdata_verify() is used to verify the validity of MAC 4852311Sseb * plugin data. It is called by mac_register() if the driver has 4862311Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 4872311Sseb * drivers update the data. 4882311Sseb */ 4892311Sseb mtops_pdata_verify_t mtops_pdata_verify; 4902311Sseb /* 4912311Sseb * mtops_header_cook() is an optional callback that converts (or 4922311Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 4932311Sseb * into one that is appropriate to send down to the MAC driver. 4942311Sseb * Following the example above, an Ethernet header sent down by a 4952311Sseb * DLPI consumer would be converted to whatever header the MAC 4962311Sseb * driver expects. 4972311Sseb */ 4982311Sseb mtops_header_modify_t mtops_header_cook; 4992311Sseb /* 5002311Sseb * mtops_header_uncook() is an optional callback that does the 5012311Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 5022311Sseb * header (as received from the driver) for consumption by raw DLPI 5032311Sseb * consumers. For example, for a non-Ethernet plugin that wants 5042311Sseb * raw DLPI consumers to be fooled into thinking that the device 5052311Sseb * provides Ethernet access, this callback would modify the given 5062311Sseb * mblk_t such that the MAC header is converted to an Ethernet 5072311Sseb * header. 5082311Sseb */ 5092311Sseb mtops_header_modify_t mtops_header_uncook; 5104403Sgd78059 /* 5114403Sgd78059 * mtops_link_details() is an optional callback that provides 5124403Sgd78059 * extended information about the link state. Its primary purpose 5134403Sgd78059 * is to provide type-specific support for syslog contents on 5144403Sgd78059 * link up events. If no implementation is provided, then a default 5154403Sgd78059 * implementation will be used. 5164403Sgd78059 */ 5174403Sgd78059 mtops_link_details_t mtops_link_details; 5182311Sseb } mactype_ops_t; 5192311Sseb 5202311Sseb /* 5212311Sseb * mtops_ops exists for the plugin to enumerate the optional callback 5222311Sseb * entrypoints it has defined. This allows the mac module to define 5232311Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 5242311Sseb * compatibility with old plugins. 5252311Sseb */ 5262311Sseb #define MTOPS_PDATA_VERIFY 0x001 5272311Sseb #define MTOPS_HEADER_COOK 0x002 5282311Sseb #define MTOPS_HEADER_UNCOOK 0x004 5294403Sgd78059 #define MTOPS_LINK_DETAILS 0x008 5302311Sseb 5316512Ssowmini /* 5326512Ssowmini * Provide mapping for legacy ndd ioctls relevant to that mactype. 5336512Ssowmini * Note that the ndd ioctls are obsolete, and may be removed in a future 5346512Ssowmini * release of Solaris. The ndd ioctls are not typically used in legacy 5356512Ssowmini * ethernet drivers. New datalink drivers of all link-types should use 5366512Ssowmini * dladm(1m) interfaces for administering tunables and not have to provide 5376512Ssowmini * a mapping. 5386512Ssowmini */ 5396512Ssowmini typedef struct mac_ndd_mapping_s { 5406512Ssowmini char *mp_name; 5416512Ssowmini union { 5426512Ssowmini mac_prop_id_t u_id; 5436512Ssowmini uint_t u_kstat; 5446512Ssowmini } u_mp_id; 5456512Ssowmini long mp_minval; 5466512Ssowmini long mp_maxval; 5476512Ssowmini size_t mp_valsize; 5486512Ssowmini int mp_flags; 5496512Ssowmini } mac_ndd_mapping_t; 5506512Ssowmini 5516512Ssowmini #define mp_prop_id u_mp_id.u_id 5526512Ssowmini #define mp_kstat u_mp_id.u_kstat 5536512Ssowmini 5548275SEric Cheng typedef struct mac_stat_info_s { 5558275SEric Cheng uint_t msi_stat; 5568275SEric Cheng char *msi_name; 5578275SEric Cheng uint_t msi_type; /* as defined in kstat_named_init(9F) */ 5588275SEric Cheng uint64_t msi_default; 5598275SEric Cheng } mac_stat_info_t; 5608275SEric Cheng 5612311Sseb typedef struct mactype_register_s { 5622311Sseb uint_t mtr_version; /* set by mactype_alloc() */ 5632311Sseb const char *mtr_ident; 5642311Sseb mactype_ops_t *mtr_ops; 5652311Sseb uint_t mtr_mactype; 5663147Sxc151355 uint_t mtr_nativetype; 5672311Sseb uint_t mtr_addrlen; 5682311Sseb uint8_t *mtr_brdcst_addr; 5692311Sseb mac_stat_info_t *mtr_stats; 5702311Sseb size_t mtr_statcount; 5716512Ssowmini mac_ndd_mapping_t *mtr_mapping; 5726512Ssowmini size_t mtr_mappingcount; 5732311Sseb } mactype_register_t; 5742311Sseb 5750Sstevel@tonic-gate /* 5768275SEric Cheng * Driver interface functions. 5770Sstevel@tonic-gate */ 5785895Syz147064 extern int mac_open_by_linkid(datalink_id_t, 5795895Syz147064 mac_handle_t *); 5805895Syz147064 extern int mac_open_by_linkname(const char *, 5815895Syz147064 mac_handle_t *); 5825895Syz147064 extern const char *mac_name(mac_handle_t); 5835895Syz147064 extern minor_t mac_minor(mac_handle_t); 5845895Syz147064 extern minor_t mac_minor_hold(boolean_t); 5855895Syz147064 extern void mac_minor_rele(minor_t); 5868275SEric Cheng extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 587*13123SErik.Nordmark@Sun.COM extern void mac_sdu_get2(mac_handle_t, uint_t *, uint_t *, 588*13123SErik.Nordmark@Sun.COM uint_t *); 5898275SEric Cheng extern int mac_maxsdu_update(mac_handle_t, uint_t); 590*13123SErik.Nordmark@Sun.COM extern int mac_maxsdu_update2(mac_handle_t, uint_t, 591*13123SErik.Nordmark@Sun.COM uint_t); 59210639SDarren.Reed@Sun.COM extern uint_t mac_addr_len(mac_handle_t); 59310639SDarren.Reed@Sun.COM extern int mac_type(mac_handle_t); 59411665SDarren.Reed@Sun.COM extern int mac_nativetype(mac_handle_t); 5950Sstevel@tonic-gate 5962311Sseb extern void mac_unicst_update(mac_handle_t, 5975895Syz147064 const uint8_t *); 5988275SEric Cheng extern void mac_capab_update(mac_handle_t); 5992311Sseb extern int mac_pdata_update(mac_handle_t, void *, 6005895Syz147064 size_t); 6015895Syz147064 extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 6025895Syz147064 extern void mac_margin_get(mac_handle_t, uint32_t *); 6035895Syz147064 extern int mac_margin_remove(mac_handle_t, uint32_t); 6045895Syz147064 extern int mac_margin_add(mac_handle_t, uint32_t *, 6055895Syz147064 boolean_t); 6069073SCathy.Zhou@Sun.COM extern int mac_fastpath_disable(mac_handle_t); 6079073SCathy.Zhou@Sun.COM extern void mac_fastpath_enable(mac_handle_t); 60810491SRishi.Srivatsavai@Sun.COM extern void mac_no_active(mac_handle_t); 6095895Syz147064 6102311Sseb extern mactype_register_t *mactype_alloc(uint_t); 6112311Sseb extern void mactype_free(mactype_register_t *); 6122311Sseb extern int mactype_register(mactype_register_t *); 6132311Sseb extern int mactype_unregister(const char *); 6148275SEric Cheng 6159073SCathy.Zhou@Sun.COM extern int mac_start_logusage(mac_logtype_t, uint_t); 6168275SEric Cheng extern void mac_stop_logusage(mac_logtype_t); 6178275SEric Cheng 6188275SEric Cheng extern mac_handle_t mac_get_lower_mac_handle(mac_handle_t); 61911878SVenu.Iyer@Sun.COM extern boolean_t mac_is_vnic_primary(mac_handle_t); 6200Sstevel@tonic-gate 6218833SVenu.Iyer@Sun.COM /* 6228833SVenu.Iyer@Sun.COM * Packet hashing for distribution to multiple ports and rings. 6238833SVenu.Iyer@Sun.COM */ 6248833SVenu.Iyer@Sun.COM 6258833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L2 0x01 6268833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L3 0x02 6278833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L4 0x04 6288833SVenu.Iyer@Sun.COM 6298833SVenu.Iyer@Sun.COM extern uint64_t mac_pkt_hash(uint_t, mblk_t *, uint8_t, 6308833SVenu.Iyer@Sun.COM boolean_t); 6318833SVenu.Iyer@Sun.COM 63210491SRishi.Srivatsavai@Sun.COM /* 63310491SRishi.Srivatsavai@Sun.COM * Bridging linkage 63410491SRishi.Srivatsavai@Sun.COM */ 63510491SRishi.Srivatsavai@Sun.COM extern void mac_rx_common(mac_handle_t, 63610491SRishi.Srivatsavai@Sun.COM mac_resource_handle_t, mblk_t *); 63710491SRishi.Srivatsavai@Sun.COM extern int mac_bridge_set(mac_handle_t, mac_handle_t); 63810491SRishi.Srivatsavai@Sun.COM extern void mac_bridge_clear(mac_handle_t, mac_handle_t); 63910491SRishi.Srivatsavai@Sun.COM extern void mac_bridge_vectors(mac_bridge_tx_t, 64010491SRishi.Srivatsavai@Sun.COM mac_bridge_rx_t, mac_bridge_ref_t, 64110491SRishi.Srivatsavai@Sun.COM mac_bridge_ls_t); 64210491SRishi.Srivatsavai@Sun.COM 64310491SRishi.Srivatsavai@Sun.COM /* special case function for TRILL observability */ 64410491SRishi.Srivatsavai@Sun.COM extern void mac_trill_snoop(mac_handle_t, mblk_t *); 64510491SRishi.Srivatsavai@Sun.COM 6460Sstevel@tonic-gate #endif /* _KERNEL */ 6470Sstevel@tonic-gate 6480Sstevel@tonic-gate #ifdef __cplusplus 6490Sstevel@tonic-gate } 6500Sstevel@tonic-gate #endif 6510Sstevel@tonic-gate 6520Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 653