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 /* 238833SVenu.Iyer@Sun.COM * Copyright 2009 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 302760Sdg199075 #include <sys/types.h> 319107Sjames.d.carlson@sun.com #ifdef _KERNEL 320Sstevel@tonic-gate #include <sys/sunddi.h> 339107Sjames.d.carlson@sun.com #endif 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 */ 468275SEric Cheng #define MAC_INFO "MAC Services v1.20" 472311Sseb 482311Sseb /* 492311Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 502311Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 512311Sseb * register. 522311Sseb */ 532311Sseb #define MACTYPE_VERSION 0x1 542311Sseb 552311Sseb /* 568275SEric Cheng * Opaque handle types 570Sstevel@tonic-gate */ 588275SEric Cheng typedef struct __mac_handle *mac_handle_t; 598275SEric Cheng typedef struct __mac_resource_handle *mac_resource_handle_t; 608275SEric Cheng typedef struct __mac_notify_handle *mac_notify_handle_t; 618275SEric Cheng typedef struct __mac_tx_notify_handle *mac_tx_notify_handle_t; 628275SEric Cheng typedef struct __mac_intr_handle *mac_intr_handle_t; 638275SEric Cheng typedef struct __mac_ring_handle *mac_ring_handle_t; 648275SEric Cheng typedef struct __mac_group_handle *mac_group_handle_t; 650Sstevel@tonic-gate 668275SEric Cheng #define DATALINK_INVALID_LINKID 0 678275SEric Cheng #define DATALINK_ALL_LINKID 0 688275SEric Cheng #define DATALINK_MAX_LINKID 0xffffffff 698275SEric Cheng 708275SEric Cheng #define MAC_MAX_MINOR 1000 718275SEric Cheng 720Sstevel@tonic-gate typedef enum { 730Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 740Sstevel@tonic-gate LINK_STATE_DOWN, 750Sstevel@tonic-gate LINK_STATE_UP 760Sstevel@tonic-gate } link_state_t; 770Sstevel@tonic-gate 780Sstevel@tonic-gate typedef enum { 790Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 800Sstevel@tonic-gate LINK_DUPLEX_HALF, 810Sstevel@tonic-gate LINK_DUPLEX_FULL 820Sstevel@tonic-gate } link_duplex_t; 830Sstevel@tonic-gate 845903Ssowmini typedef enum { 855903Ssowmini LINK_FLOWCTRL_NONE = 0, 865903Ssowmini LINK_FLOWCTRL_RX, 875903Ssowmini LINK_FLOWCTRL_TX, 885903Ssowmini LINK_FLOWCTRL_BI 895903Ssowmini } link_flowctrl_t; 905903Ssowmini 918874SSebastien.Roy@Sun.COM typedef enum { 928874SSebastien.Roy@Sun.COM LINK_TAGMODE_VLANONLY = 0, 938874SSebastien.Roy@Sun.COM LINK_TAGMODE_NORMAL 948874SSebastien.Roy@Sun.COM } link_tagmode_t; 958874SSebastien.Roy@Sun.COM 968275SEric Cheng /* 979514SGirish.Moodalbail@Sun.COM * Defines range of uint32 values 989514SGirish.Moodalbail@Sun.COM */ 999514SGirish.Moodalbail@Sun.COM typedef struct mac_propval_uint32_range_s { 1009514SGirish.Moodalbail@Sun.COM uint32_t mpur_min; 1019514SGirish.Moodalbail@Sun.COM uint32_t mpur_max; 1029514SGirish.Moodalbail@Sun.COM } mac_propval_uint32_range_t; 1039514SGirish.Moodalbail@Sun.COM 1049514SGirish.Moodalbail@Sun.COM /* 1059514SGirish.Moodalbail@Sun.COM * Data type of the value 1069514SGirish.Moodalbail@Sun.COM */ 1079514SGirish.Moodalbail@Sun.COM typedef enum { 1089514SGirish.Moodalbail@Sun.COM MAC_PROPVAL_UINT32 = 0x1 1099514SGirish.Moodalbail@Sun.COM } mac_propval_type_t; 1109514SGirish.Moodalbail@Sun.COM 1119514SGirish.Moodalbail@Sun.COM /* 1129514SGirish.Moodalbail@Sun.COM * Captures possible values for a given property. A property can have 1139514SGirish.Moodalbail@Sun.COM * range of values (int32, int64, uint32, uint64, et al) or collection/ 1149514SGirish.Moodalbail@Sun.COM * enumeration of values (strings). 1159514SGirish.Moodalbail@Sun.COM * Can be used as a value-result parameter. 1169514SGirish.Moodalbail@Sun.COM * 1179514SGirish.Moodalbail@Sun.COM * See PSARC 2009/235 for more information. 1189514SGirish.Moodalbail@Sun.COM */ 1199514SGirish.Moodalbail@Sun.COM typedef struct mac_propval_range_s { 1209514SGirish.Moodalbail@Sun.COM uint_t mpr_count; /* count of ranges */ 1219514SGirish.Moodalbail@Sun.COM mac_propval_type_t mpr_type; /* type of value */ 1229514SGirish.Moodalbail@Sun.COM union { 1239514SGirish.Moodalbail@Sun.COM mac_propval_uint32_range_t mpr_uint32[1]; 1249514SGirish.Moodalbail@Sun.COM } u; 1259514SGirish.Moodalbail@Sun.COM } mac_propval_range_t; 1269514SGirish.Moodalbail@Sun.COM 1279514SGirish.Moodalbail@Sun.COM #define range_uint32 u.mpr_uint32 1289514SGirish.Moodalbail@Sun.COM 1299514SGirish.Moodalbail@Sun.COM /* 1308275SEric Cheng * Maximum MAC address length 1318275SEric Cheng */ 1328275SEric Cheng #define MAXMACADDRLEN 20 1338275SEric Cheng 1348275SEric Cheng typedef enum { 1358275SEric Cheng MAC_LOGTYPE_LINK = 1, 1368275SEric Cheng MAC_LOGTYPE_FLOW 1378275SEric Cheng } mac_logtype_t; 1386789Sam223141 1396789Sam223141 /* 1406789Sam223141 * Encodings for public properties. 1416789Sam223141 * A most significant bit value of 1 indicates private property, intended 1426789Sam223141 * to allow private property implementations to use internal encodings 1436789Sam223141 * if desired. 1446789Sam223141 * 1456789Sam223141 * Note that there are 2 sets of parameters: the *_EN_* 1466789Sam223141 * values are those that the Administrator configures for autonegotiation. 1476789Sam223141 * The _ADV_* values are those that are currently exposed over the wire. 1486789Sam223141 */ 1496789Sam223141 #define MAXLINKPROPNAME 256 1509514SGirish.Moodalbail@Sun.COM #define MAC_PROP_DEFAULT 0x0001 /* default property value */ 1519514SGirish.Moodalbail@Sun.COM 1529514SGirish.Moodalbail@Sun.COM /* 1539514SGirish.Moodalbail@Sun.COM * Indicates the linkprop framework is interested in knowing the list of 1549514SGirish.Moodalbail@Sun.COM * possible property values. When used to obtain possible values for a 1559514SGirish.Moodalbail@Sun.COM * property, one may have to change all the drivers. See PSARC 2009/235. 1569514SGirish.Moodalbail@Sun.COM */ 1579514SGirish.Moodalbail@Sun.COM #define MAC_PROP_POSSIBLE 0x0002 /* possible property values */ 1589514SGirish.Moodalbail@Sun.COM 1596789Sam223141 typedef enum { 1606789Sam223141 MAC_PROP_DUPLEX = 0x00000001, 1616789Sam223141 MAC_PROP_SPEED, 1626789Sam223141 MAC_PROP_STATUS, 1636789Sam223141 MAC_PROP_AUTONEG, 1646789Sam223141 MAC_PROP_EN_AUTONEG, 1656789Sam223141 MAC_PROP_MTU, 1667342SAruna.Ramakrishna@Sun.COM MAC_PROP_ZONE, 1677342SAruna.Ramakrishna@Sun.COM MAC_PROP_AUTOPUSH, 1686789Sam223141 MAC_PROP_FLOWCTRL, 1696789Sam223141 MAC_PROP_ADV_1000FDX_CAP, 1706789Sam223141 MAC_PROP_EN_1000FDX_CAP, 1716789Sam223141 MAC_PROP_ADV_1000HDX_CAP, 1726789Sam223141 MAC_PROP_EN_1000HDX_CAP, 1736789Sam223141 MAC_PROP_ADV_100FDX_CAP, 1746789Sam223141 MAC_PROP_EN_100FDX_CAP, 1756789Sam223141 MAC_PROP_ADV_100HDX_CAP, 1766789Sam223141 MAC_PROP_EN_100HDX_CAP, 1776789Sam223141 MAC_PROP_ADV_10FDX_CAP, 1786789Sam223141 MAC_PROP_EN_10FDX_CAP, 1796789Sam223141 MAC_PROP_ADV_10HDX_CAP, 1806789Sam223141 MAC_PROP_EN_10HDX_CAP, 1816789Sam223141 MAC_PROP_ADV_100T4_CAP, 1826789Sam223141 MAC_PROP_EN_100T4_CAP, 1837663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ESSID, 1847663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_BSSID, 1857663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_BSSTYPE, 1867663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_LINKSTATUS, 1877663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_DESIRED_RATES, 1887663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SUPPORTED_RATES, 1897663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_AUTH_MODE, 1907663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ENCRYPTION, 1917663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_RSSI, 1927663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_PHY_CONFIG, 1937663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_CAPABILITY, 1947663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_WPA, 1957663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SCANRESULTS, 1967663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_POWER_MODE, 1977663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_RADIO, 1987663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_ESS_LIST, 1997663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_KEY_TAB, 2007663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_CREATE_IBSS, 2017663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_SETOPTIE, 2027663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_DELKEY, 2037663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_KEY, 2047663SSowmini.Varadhan@Sun.COM MAC_PROP_WL_MLME, 2058275SEric Cheng MAC_PROP_MAXBW, 2068275SEric Cheng MAC_PROP_PRIO, 2078275SEric Cheng MAC_PROP_BIND_CPU, 2088874SSebastien.Roy@Sun.COM MAC_PROP_TAGMODE, 2099449Sxiuyan.wang@Sun.COM MAC_PROP_ADV_10GFDX_CAP, 2109449Sxiuyan.wang@Sun.COM MAC_PROP_EN_10GFDX_CAP, 211*10491SRishi.Srivatsavai@Sun.COM MAC_PROP_PVID, 212*10491SRishi.Srivatsavai@Sun.COM MAC_PROP_LLIMIT, 213*10491SRishi.Srivatsavai@Sun.COM MAC_PROP_LDECAY, 2146789Sam223141 MAC_PROP_PRIVATE = -1 2156789Sam223141 } mac_prop_id_t; 2166789Sam223141 2175084Sjohnlev /* 2188118SVasumathi.Sundaram@Sun.COM * Flags to figure out r/w status of legacy ndd props. 2198118SVasumathi.Sundaram@Sun.COM */ 2208118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_READ 0x0001 2218118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_WRITE 0x0010 2228118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_MAP_KSTAT 0x0100 2238118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_PERM_RW (MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE) 2248118SVasumathi.Sundaram@Sun.COM #define MAC_PROP_FLAGS_RK (MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT) 2258118SVasumathi.Sundaram@Sun.COM 2260Sstevel@tonic-gate #ifdef _KERNEL 2270Sstevel@tonic-gate 2282311Sseb /* 2292311Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 2302311Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 2312311Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 2322311Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 2332311Sseb * defined by MAC-Type plugins and maintained by each driver. 2342311Sseb */ 2352311Sseb #define MAC_STAT_MIN 1000 2362311Sseb #define MACTYPE_STAT_MIN 2000 2372311Sseb 2382311Sseb #define IS_MAC_STAT(stat) \ 2392311Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 2402311Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 2412311Sseb 2424089Sgd78059 /* 2435895Syz147064 * Statistics maintained by the mac module, and possibly populated as link 2445895Syz147064 * statistics. 2455895Syz147064 */ 2465895Syz147064 enum mac_mod_stat { 2475895Syz147064 MAC_STAT_LINK_STATE, 2485895Syz147064 MAC_STAT_LINK_UP, 249*10491SRishi.Srivatsavai@Sun.COM MAC_STAT_PROMISC, 250*10491SRishi.Srivatsavai@Sun.COM MAC_STAT_LOWLINK_STATE 2515895Syz147064 }; 2525895Syz147064 2535895Syz147064 /* 2544089Sgd78059 * Do not reorder, and add only to the end of this list. 2554089Sgd78059 */ 2562311Sseb enum mac_driver_stat { 2572311Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 2582311Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 2590Sstevel@tonic-gate MAC_STAT_MULTIRCV, 2600Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 2610Sstevel@tonic-gate MAC_STAT_MULTIXMT, 2620Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 2630Sstevel@tonic-gate MAC_STAT_NORCVBUF, 2640Sstevel@tonic-gate MAC_STAT_IERRORS, 2650Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 2660Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 2670Sstevel@tonic-gate MAC_STAT_OERRORS, 2680Sstevel@tonic-gate MAC_STAT_COLLISIONS, 2690Sstevel@tonic-gate MAC_STAT_RBYTES, 2700Sstevel@tonic-gate MAC_STAT_IPACKETS, 2710Sstevel@tonic-gate MAC_STAT_OBYTES, 2724089Sgd78059 MAC_STAT_OPACKETS, 2734089Sgd78059 MAC_STAT_UNDERFLOWS, 2744089Sgd78059 MAC_STAT_OVERFLOWS 2752311Sseb }; 2760Sstevel@tonic-gate 2774089Sgd78059 #define MAC_NSTAT (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1) 2780Sstevel@tonic-gate 2792311Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 2802311Sseb (_stat) == MAC_STAT_MULTIRCV || \ 2812311Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 2822311Sseb (_stat) == MAC_STAT_MULTIXMT || \ 2832311Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 2842311Sseb (_stat) == MAC_STAT_NORCVBUF || \ 2852311Sseb (_stat) == MAC_STAT_IERRORS || \ 2862311Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 2872311Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 2882311Sseb (_stat) == MAC_STAT_OERRORS || \ 2892311Sseb (_stat) == MAC_STAT_COLLISIONS || \ 2902311Sseb (_stat) == MAC_STAT_RBYTES || \ 2912311Sseb (_stat) == MAC_STAT_IPACKETS || \ 2922311Sseb (_stat) == MAC_STAT_OBYTES || \ 2934089Sgd78059 (_stat) == MAC_STAT_OPACKETS || \ 2944089Sgd78059 (_stat) == MAC_STAT_UNDERFLOWS || \ 2954089Sgd78059 (_stat) == MAC_STAT_OVERFLOWS) 2960Sstevel@tonic-gate 2970Sstevel@tonic-gate /* 2980Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 2990Sstevel@tonic-gate */ 3000Sstevel@tonic-gate typedef struct mac_info_s { 3010Sstevel@tonic-gate uint_t mi_media; 3023147Sxc151355 uint_t mi_nativemedia; 3030Sstevel@tonic-gate uint_t mi_addr_length; 3042311Sseb uint8_t *mi_unicst_addr; 3052311Sseb uint8_t *mi_brdcst_addr; 3060Sstevel@tonic-gate } mac_info_t; 3070Sstevel@tonic-gate 3080Sstevel@tonic-gate /* 3098275SEric Cheng * When VNICs are created on top of the NIC, there are two levels 3108275SEric Cheng * of MAC layer, a lower MAC, which is the MAC layer at the level of the 3118275SEric Cheng * physical NIC, and an upper MAC, which is the MAC layer at the level 3128275SEric Cheng * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and 3138275SEric Cheng * the SRS and classification is done at the lower MAC level. The upper 3148275SEric Cheng * MAC is therefore for the most part pass-through, and therefore 3158275SEric Cheng * special processing needs to be done at the upper MAC layer when 3168275SEric Cheng * dealing with a VNIC. 3178275SEric Cheng * 3188275SEric Cheng * This capability allows the MAC layer to detect when a VNIC is being 3198275SEric Cheng * access, and implement the required shortcuts. 3200Sstevel@tonic-gate */ 3216495Sspeer 3228275SEric Cheng typedef void *(*mac_client_handle_fn_t)(void *); 3236495Sspeer 3248275SEric Cheng typedef struct mac_capab_vnic_s { 3258275SEric Cheng void *mcv_arg; 3268275SEric Cheng mac_client_handle_fn_t mcv_mac_client_handle; 3278275SEric Cheng } mac_capab_vnic_t; 3286495Sspeer 3298275SEric Cheng typedef void (*mac_rename_fn_t)(const char *, void *); 3308275SEric Cheng typedef struct mac_capab_aggr_s { 3318275SEric Cheng mac_rename_fn_t mca_rename_fn; 3328275SEric Cheng int (*mca_unicst)(void *, const uint8_t *); 3338275SEric Cheng } mac_capab_aggr_t; 3346495Sspeer 335*10491SRishi.Srivatsavai@Sun.COM /* Bridge transmit and receive function signatures */ 336*10491SRishi.Srivatsavai@Sun.COM typedef mblk_t *(*mac_bridge_tx_t)(mac_handle_t, mac_ring_handle_t, mblk_t *); 337*10491SRishi.Srivatsavai@Sun.COM typedef void (*mac_bridge_rx_t)(mac_handle_t, mac_resource_handle_t, mblk_t *); 338*10491SRishi.Srivatsavai@Sun.COM typedef void (*mac_bridge_ref_t)(mac_handle_t, boolean_t); 339*10491SRishi.Srivatsavai@Sun.COM typedef link_state_t (*mac_bridge_ls_t)(mac_handle_t, link_state_t); 340*10491SRishi.Srivatsavai@Sun.COM 341*10491SRishi.Srivatsavai@Sun.COM /* must change mac_notify_cb_list[] in mac_provider.c if this is changed */ 3420Sstevel@tonic-gate typedef enum { 3430Sstevel@tonic-gate MAC_NOTE_LINK, 3440Sstevel@tonic-gate MAC_NOTE_UNICST, 3450Sstevel@tonic-gate MAC_NOTE_TX, 3460Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 3472311Sseb MAC_NOTE_FASTPATH_FLUSH, 3485903Ssowmini MAC_NOTE_SDU_SIZE, 3495895Syz147064 MAC_NOTE_MARGIN, 3508275SEric Cheng MAC_NOTE_CAPAB_CHG, 351*10491SRishi.Srivatsavai@Sun.COM MAC_NOTE_LOWLINK, 3520Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 3530Sstevel@tonic-gate } mac_notify_type_t; 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 3568275SEric Cheng typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *, 3578275SEric Cheng boolean_t); 3588275SEric Cheng typedef mblk_t *(*mac_receive_t)(void *, int); 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* 3610Sstevel@tonic-gate * MAC resource types 3620Sstevel@tonic-gate */ 3630Sstevel@tonic-gate typedef enum { 3640Sstevel@tonic-gate MAC_RX_FIFO = 1 3650Sstevel@tonic-gate } mac_resource_type_t; 3660Sstevel@tonic-gate 3678275SEric Cheng typedef int (*mac_intr_enable_t)(mac_intr_handle_t); 3688275SEric Cheng typedef int (*mac_intr_disable_t)(mac_intr_handle_t); 3698275SEric Cheng 3708275SEric Cheng typedef struct mac_intr_s { 3718275SEric Cheng mac_intr_handle_t mi_handle; 3728275SEric Cheng mac_intr_enable_t mi_enable; 3738275SEric Cheng mac_intr_disable_t mi_disable; 3748275SEric Cheng } mac_intr_t; 3758275SEric Cheng 3760Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3770Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 3788275SEric Cheng mac_intr_t mrf_intr; 3798275SEric Cheng mac_receive_t mrf_receive; 3808275SEric Cheng void *mrf_rx_arg; 3818275SEric Cheng uint32_t mrf_flow_priority; 3828275SEric Cheng /* 3838275SEric Cheng * The CPU this flow is to be processed on. With intrd and future 3848275SEric Cheng * things, we should know which CPU the flow needs to be processed 3858275SEric Cheng * and get a squeue assigned on that CPU. 3868275SEric Cheng */ 3878275SEric Cheng uint_t mrf_cpu_id; 3880Sstevel@tonic-gate } mac_rx_fifo_t; 3890Sstevel@tonic-gate 3908275SEric Cheng #define mrf_intr_handle mrf_intr.mi_handle 3918275SEric Cheng #define mrf_intr_enable mrf_intr.mi_enable 3928275SEric Cheng #define mrf_intr_disable mrf_intr.mi_disable 39356Smeem 3940Sstevel@tonic-gate typedef union mac_resource_u { 3950Sstevel@tonic-gate mac_resource_type_t mr_type; 3960Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 3970Sstevel@tonic-gate } mac_resource_t; 3980Sstevel@tonic-gate 3992311Sseb typedef enum { 4002311Sseb MAC_ADDRTYPE_UNICAST, 4012311Sseb MAC_ADDRTYPE_MULTICAST, 4022311Sseb MAC_ADDRTYPE_BROADCAST 4032311Sseb } mac_addrtype_t; 4042311Sseb 4052311Sseb typedef struct mac_header_info_s { 4062311Sseb size_t mhi_hdrsize; 4072311Sseb size_t mhi_pktsize; 4082311Sseb const uint8_t *mhi_daddr; 4092311Sseb const uint8_t *mhi_saddr; 4102311Sseb uint32_t mhi_origsap; 4112311Sseb uint32_t mhi_bindsap; 4122311Sseb mac_addrtype_t mhi_dsttype; 4132760Sdg199075 uint16_t mhi_tci; 4148275SEric Cheng boolean_t mhi_istagged; 415*10491SRishi.Srivatsavai@Sun.COM boolean_t mhi_ispvid; 4162311Sseb } mac_header_info_t; 4172311Sseb 4182311Sseb /* 4198275SEric Cheng * Function pointer to match dls client signature. Should be same as 4208275SEric Cheng * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS 4218275SEric Cheng * client directly. 4228275SEric Cheng */ 4238275SEric Cheng typedef void (*mac_direct_rx_t)(void *, mac_resource_handle_t, 4248275SEric Cheng mblk_t *, mac_header_info_t *); 4258275SEric Cheng 4268275SEric Cheng typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 4278275SEric Cheng typedef int (*mac_resource_bind_t)(void *, 4288275SEric Cheng mac_resource_handle_t, processorid_t); 4298275SEric Cheng typedef void (*mac_resource_remove_t)(void *, void *); 4308275SEric Cheng typedef void (*mac_resource_quiesce_t)(void *, void *); 4318275SEric Cheng typedef void (*mac_resource_restart_t)(void *, void *); 4328275SEric Cheng typedef int (*mac_resource_modify_t)(void *, void *, 4338275SEric Cheng mac_resource_t *); 4348275SEric Cheng typedef void (*mac_change_upcall_t)(void *, mac_direct_rx_t, 4358275SEric Cheng void *); 4368275SEric Cheng 4378275SEric Cheng /* 4382311Sseb * MAC-Type plugin interfaces 4392311Sseb */ 4402311Sseb 4412311Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 4422311Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 4432311Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 4442311Sseb uint32_t, void *, mblk_t *, size_t); 4452311Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 4462311Sseb mac_header_info_t *); 4472311Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 4482311Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 4494403Sgd78059 typedef void (*mtops_link_details_t)(char *, size_t, mac_handle_t, 4504403Sgd78059 void *); 4512311Sseb 4522311Sseb typedef struct mactype_ops_s { 4532311Sseb uint_t mtops_ops; 4542311Sseb /* 4552311Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 4562311Sseb * unicast address, or a non-zero errno otherwise. 4572311Sseb */ 4582311Sseb mtops_addr_verify_t mtops_unicst_verify; 4592311Sseb /* 4602311Sseb * mtops_multicst_verify() returns 0 if the given address is a 4612311Sseb * valid multicast address, or a non-zero errno otherwise. If the 4622311Sseb * media doesn't support multicast, ENOTSUP should be returned (for 4632311Sseb * example). 4642311Sseb */ 4652311Sseb mtops_addr_verify_t mtops_multicst_verify; 4662311Sseb /* 4672311Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 4682311Sseb * SAP value, or B_FALSE otherwise. 4692311Sseb */ 4702311Sseb mtops_sap_verify_t mtops_sap_verify; 4712311Sseb /* 4722311Sseb * mtops_header() is used to allocate and construct a MAC header. 4732311Sseb */ 4742311Sseb mtops_header_t mtops_header; 4752311Sseb /* 4762311Sseb * mtops_header_info() is used to gather information on a given MAC 4772311Sseb * header. 4782311Sseb */ 4792311Sseb mtops_header_info_t mtops_header_info; 4802311Sseb /* 4812311Sseb * mtops_pdata_verify() is used to verify the validity of MAC 4822311Sseb * plugin data. It is called by mac_register() if the driver has 4832311Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 4842311Sseb * drivers update the data. 4852311Sseb */ 4862311Sseb mtops_pdata_verify_t mtops_pdata_verify; 4872311Sseb /* 4882311Sseb * mtops_header_cook() is an optional callback that converts (or 4892311Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 4902311Sseb * into one that is appropriate to send down to the MAC driver. 4912311Sseb * Following the example above, an Ethernet header sent down by a 4922311Sseb * DLPI consumer would be converted to whatever header the MAC 4932311Sseb * driver expects. 4942311Sseb */ 4952311Sseb mtops_header_modify_t mtops_header_cook; 4962311Sseb /* 4972311Sseb * mtops_header_uncook() is an optional callback that does the 4982311Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 4992311Sseb * header (as received from the driver) for consumption by raw DLPI 5002311Sseb * consumers. For example, for a non-Ethernet plugin that wants 5012311Sseb * raw DLPI consumers to be fooled into thinking that the device 5022311Sseb * provides Ethernet access, this callback would modify the given 5032311Sseb * mblk_t such that the MAC header is converted to an Ethernet 5042311Sseb * header. 5052311Sseb */ 5062311Sseb mtops_header_modify_t mtops_header_uncook; 5074403Sgd78059 /* 5084403Sgd78059 * mtops_link_details() is an optional callback that provides 5094403Sgd78059 * extended information about the link state. Its primary purpose 5104403Sgd78059 * is to provide type-specific support for syslog contents on 5114403Sgd78059 * link up events. If no implementation is provided, then a default 5124403Sgd78059 * implementation will be used. 5134403Sgd78059 */ 5144403Sgd78059 mtops_link_details_t mtops_link_details; 5152311Sseb } mactype_ops_t; 5162311Sseb 5172311Sseb /* 5182311Sseb * mtops_ops exists for the plugin to enumerate the optional callback 5192311Sseb * entrypoints it has defined. This allows the mac module to define 5202311Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 5212311Sseb * compatibility with old plugins. 5222311Sseb */ 5232311Sseb #define MTOPS_PDATA_VERIFY 0x001 5242311Sseb #define MTOPS_HEADER_COOK 0x002 5252311Sseb #define MTOPS_HEADER_UNCOOK 0x004 5264403Sgd78059 #define MTOPS_LINK_DETAILS 0x008 5272311Sseb 5286512Ssowmini /* 5296512Ssowmini * Provide mapping for legacy ndd ioctls relevant to that mactype. 5306512Ssowmini * Note that the ndd ioctls are obsolete, and may be removed in a future 5316512Ssowmini * release of Solaris. The ndd ioctls are not typically used in legacy 5326512Ssowmini * ethernet drivers. New datalink drivers of all link-types should use 5336512Ssowmini * dladm(1m) interfaces for administering tunables and not have to provide 5346512Ssowmini * a mapping. 5356512Ssowmini */ 5366512Ssowmini typedef struct mac_ndd_mapping_s { 5376512Ssowmini char *mp_name; 5386512Ssowmini union { 5396512Ssowmini mac_prop_id_t u_id; 5406512Ssowmini uint_t u_kstat; 5416512Ssowmini } u_mp_id; 5426512Ssowmini long mp_minval; 5436512Ssowmini long mp_maxval; 5446512Ssowmini size_t mp_valsize; 5456512Ssowmini int mp_flags; 5466512Ssowmini } mac_ndd_mapping_t; 5476512Ssowmini 5486512Ssowmini #define mp_prop_id u_mp_id.u_id 5496512Ssowmini #define mp_kstat u_mp_id.u_kstat 5506512Ssowmini 5518275SEric Cheng typedef struct mac_stat_info_s { 5528275SEric Cheng uint_t msi_stat; 5538275SEric Cheng char *msi_name; 5548275SEric Cheng uint_t msi_type; /* as defined in kstat_named_init(9F) */ 5558275SEric Cheng uint64_t msi_default; 5568275SEric Cheng } mac_stat_info_t; 5578275SEric Cheng 5582311Sseb typedef struct mactype_register_s { 5592311Sseb uint_t mtr_version; /* set by mactype_alloc() */ 5602311Sseb const char *mtr_ident; 5612311Sseb mactype_ops_t *mtr_ops; 5622311Sseb uint_t mtr_mactype; 5633147Sxc151355 uint_t mtr_nativetype; 5642311Sseb uint_t mtr_addrlen; 5652311Sseb uint8_t *mtr_brdcst_addr; 5662311Sseb mac_stat_info_t *mtr_stats; 5672311Sseb size_t mtr_statcount; 5686512Ssowmini mac_ndd_mapping_t *mtr_mapping; 5696512Ssowmini size_t mtr_mappingcount; 5702311Sseb } mactype_register_t; 5712311Sseb 5725903Ssowmini typedef struct mac_prop_s { 5735903Ssowmini mac_prop_id_t mp_id; 5745903Ssowmini char *mp_name; 5756512Ssowmini uint_t mp_flags; 5765903Ssowmini } mac_prop_t; 5775903Ssowmini 5780Sstevel@tonic-gate /* 5798275SEric Cheng * Driver interface functions. 5800Sstevel@tonic-gate */ 5815895Syz147064 extern int mac_open_by_linkid(datalink_id_t, 5825895Syz147064 mac_handle_t *); 5835895Syz147064 extern int mac_open_by_linkname(const char *, 5845895Syz147064 mac_handle_t *); 5855895Syz147064 extern const char *mac_name(mac_handle_t); 5865895Syz147064 extern minor_t mac_minor(mac_handle_t); 5875895Syz147064 extern minor_t mac_minor_hold(boolean_t); 5885895Syz147064 extern void mac_minor_rele(minor_t); 5898275SEric Cheng extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 5908275SEric Cheng extern int mac_maxsdu_update(mac_handle_t, uint_t); 5910Sstevel@tonic-gate 5922311Sseb extern void mac_unicst_update(mac_handle_t, 5935895Syz147064 const uint8_t *); 5948275SEric Cheng extern void mac_capab_update(mac_handle_t); 5952311Sseb extern int mac_pdata_update(mac_handle_t, void *, 5965895Syz147064 size_t); 5975895Syz147064 extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 5985895Syz147064 extern void mac_margin_get(mac_handle_t, uint32_t *); 5995895Syz147064 extern int mac_margin_remove(mac_handle_t, uint32_t); 6005895Syz147064 extern int mac_margin_add(mac_handle_t, uint32_t *, 6015895Syz147064 boolean_t); 6029073SCathy.Zhou@Sun.COM extern int mac_fastpath_disable(mac_handle_t); 6039073SCathy.Zhou@Sun.COM extern void mac_fastpath_enable(mac_handle_t); 604*10491SRishi.Srivatsavai@Sun.COM extern void mac_no_active(mac_handle_t); 6055895Syz147064 6062311Sseb extern mactype_register_t *mactype_alloc(uint_t); 6072311Sseb extern void mactype_free(mactype_register_t *); 6082311Sseb extern int mactype_register(mactype_register_t *); 6092311Sseb extern int mactype_unregister(const char *); 6108275SEric Cheng 6119073SCathy.Zhou@Sun.COM extern int mac_start_logusage(mac_logtype_t, uint_t); 6128275SEric Cheng extern void mac_stop_logusage(mac_logtype_t); 6138275SEric Cheng 6148275SEric Cheng extern mac_handle_t mac_get_lower_mac_handle(mac_handle_t); 6150Sstevel@tonic-gate 6168833SVenu.Iyer@Sun.COM /* 6178833SVenu.Iyer@Sun.COM * Packet hashing for distribution to multiple ports and rings. 6188833SVenu.Iyer@Sun.COM */ 6198833SVenu.Iyer@Sun.COM 6208833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L2 0x01 6218833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L3 0x02 6228833SVenu.Iyer@Sun.COM #define MAC_PKT_HASH_L4 0x04 6238833SVenu.Iyer@Sun.COM 6248833SVenu.Iyer@Sun.COM extern uint64_t mac_pkt_hash(uint_t, mblk_t *, uint8_t, 6258833SVenu.Iyer@Sun.COM boolean_t); 6268833SVenu.Iyer@Sun.COM 627*10491SRishi.Srivatsavai@Sun.COM /* 628*10491SRishi.Srivatsavai@Sun.COM * Bridging linkage 629*10491SRishi.Srivatsavai@Sun.COM */ 630*10491SRishi.Srivatsavai@Sun.COM extern void mac_rx_common(mac_handle_t, 631*10491SRishi.Srivatsavai@Sun.COM mac_resource_handle_t, mblk_t *); 632*10491SRishi.Srivatsavai@Sun.COM extern int mac_bridge_set(mac_handle_t, mac_handle_t); 633*10491SRishi.Srivatsavai@Sun.COM extern void mac_bridge_clear(mac_handle_t, mac_handle_t); 634*10491SRishi.Srivatsavai@Sun.COM extern void mac_bridge_vectors(mac_bridge_tx_t, 635*10491SRishi.Srivatsavai@Sun.COM mac_bridge_rx_t, mac_bridge_ref_t, 636*10491SRishi.Srivatsavai@Sun.COM mac_bridge_ls_t); 637*10491SRishi.Srivatsavai@Sun.COM 638*10491SRishi.Srivatsavai@Sun.COM /* special case function for TRILL observability */ 639*10491SRishi.Srivatsavai@Sun.COM extern void mac_trill_snoop(mac_handle_t, mblk_t *); 640*10491SRishi.Srivatsavai@Sun.COM 6410Sstevel@tonic-gate #endif /* _KERNEL */ 6420Sstevel@tonic-gate 6430Sstevel@tonic-gate #ifdef __cplusplus 6440Sstevel@tonic-gate } 6450Sstevel@tonic-gate #endif 6460Sstevel@tonic-gate 6470Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 648