17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ba2e4443Sseb * Common Development and Distribution License (the "License"). 6ba2e4443Sseb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*da14cebeSEric Cheng 227c478bd9Sstevel@tonic-gate /* 23d62bc4baSyz147064 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_MAC_H 287c478bd9Sstevel@tonic-gate #define _SYS_MAC_H 297c478bd9Sstevel@tonic-gate 30605445d5Sdg199075 #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 327c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 337c478bd9Sstevel@tonic-gate #include <sys/stream.h> 34*da14cebeSEric Cheng #include <sys/mac_flow.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * MAC Services Module 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * MAC Information (text emitted by modinfo(1m)) 467c478bd9Sstevel@tonic-gate */ 47*da14cebeSEric Cheng #define MAC_INFO "MAC Services v1.20" 48ba2e4443Sseb 49ba2e4443Sseb /* 50ba2e4443Sseb * MAC-Type version identifier. This is used by mactype_alloc() and 51ba2e4443Sseb * mactype_register() to verify that incompatible MAC-Type plugins don't 52ba2e4443Sseb * register. 53ba2e4443Sseb */ 54ba2e4443Sseb #define MACTYPE_VERSION 0x1 55ba2e4443Sseb 56ba2e4443Sseb /* 57*da14cebeSEric Cheng * Opaque handle types 587c478bd9Sstevel@tonic-gate */ 59*da14cebeSEric Cheng typedef struct __mac_handle *mac_handle_t; 60*da14cebeSEric Cheng typedef struct __mac_resource_handle *mac_resource_handle_t; 61*da14cebeSEric Cheng typedef struct __mac_notify_handle *mac_notify_handle_t; 62*da14cebeSEric Cheng typedef struct __mac_tx_notify_handle *mac_tx_notify_handle_t; 63*da14cebeSEric Cheng typedef struct __mac_intr_handle *mac_intr_handle_t; 64*da14cebeSEric Cheng typedef struct __mac_ring_handle *mac_ring_handle_t; 65*da14cebeSEric Cheng typedef struct __mac_group_handle *mac_group_handle_t; 667c478bd9Sstevel@tonic-gate 67*da14cebeSEric Cheng #define DATALINK_INVALID_LINKID 0 68*da14cebeSEric Cheng #define DATALINK_ALL_LINKID 0 69*da14cebeSEric Cheng #define DATALINK_MAX_LINKID 0xffffffff 70*da14cebeSEric Cheng 71*da14cebeSEric Cheng #define MAC_MAX_MINOR 1000 72*da14cebeSEric Cheng 73*da14cebeSEric Cheng typedef uint32_t datalink_id_t; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate typedef enum { 767c478bd9Sstevel@tonic-gate LINK_STATE_UNKNOWN = -1, 777c478bd9Sstevel@tonic-gate LINK_STATE_DOWN, 787c478bd9Sstevel@tonic-gate LINK_STATE_UP 797c478bd9Sstevel@tonic-gate } link_state_t; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate typedef enum { 827c478bd9Sstevel@tonic-gate LINK_DUPLEX_UNKNOWN = 0, 837c478bd9Sstevel@tonic-gate LINK_DUPLEX_HALF, 847c478bd9Sstevel@tonic-gate LINK_DUPLEX_FULL 857c478bd9Sstevel@tonic-gate } link_duplex_t; 867c478bd9Sstevel@tonic-gate 87e7801d59Ssowmini typedef enum { 88e7801d59Ssowmini LINK_FLOWCTRL_NONE = 0, 89e7801d59Ssowmini LINK_FLOWCTRL_RX, 90e7801d59Ssowmini LINK_FLOWCTRL_TX, 91e7801d59Ssowmini LINK_FLOWCTRL_BI 92e7801d59Ssowmini } link_flowctrl_t; 93e7801d59Ssowmini 94*da14cebeSEric Cheng /* 95*da14cebeSEric Cheng * Maximum MAC address length 96*da14cebeSEric Cheng */ 97*da14cebeSEric Cheng #define MAXMACADDRLEN 20 98*da14cebeSEric Cheng 99*da14cebeSEric Cheng typedef enum { 100*da14cebeSEric Cheng MAC_LOGTYPE_LINK = 1, 101*da14cebeSEric Cheng MAC_LOGTYPE_FLOW 102*da14cebeSEric Cheng } mac_logtype_t; 1033fd94f8cSam223141 1043fd94f8cSam223141 /* 1053fd94f8cSam223141 * Encodings for public properties. 1063fd94f8cSam223141 * A most significant bit value of 1 indicates private property, intended 1073fd94f8cSam223141 * to allow private property implementations to use internal encodings 1083fd94f8cSam223141 * if desired. 1093fd94f8cSam223141 * 1103fd94f8cSam223141 * Note that there are 2 sets of parameters: the *_EN_* 1113fd94f8cSam223141 * values are those that the Administrator configures for autonegotiation. 1123fd94f8cSam223141 * The _ADV_* values are those that are currently exposed over the wire. 1133fd94f8cSam223141 */ 1143fd94f8cSam223141 #define MAXLINKPROPNAME 256 1153fd94f8cSam223141 #define MAC_PROP_DEFAULT 0x0001 1163fd94f8cSam223141 typedef enum { 1173fd94f8cSam223141 MAC_PROP_DUPLEX = 0x00000001, 1183fd94f8cSam223141 MAC_PROP_SPEED, 1193fd94f8cSam223141 MAC_PROP_STATUS, 1203fd94f8cSam223141 MAC_PROP_AUTONEG, 1213fd94f8cSam223141 MAC_PROP_EN_AUTONEG, 1223fd94f8cSam223141 MAC_PROP_MTU, 1233bc21d0aSAruna Ramakrishna - Sun Microsystems MAC_PROP_ZONE, 1243bc21d0aSAruna Ramakrishna - Sun Microsystems MAC_PROP_AUTOPUSH, 1253fd94f8cSam223141 MAC_PROP_FLOWCTRL, 1263fd94f8cSam223141 MAC_PROP_ADV_1000FDX_CAP, 1273fd94f8cSam223141 MAC_PROP_EN_1000FDX_CAP, 1283fd94f8cSam223141 MAC_PROP_ADV_1000HDX_CAP, 1293fd94f8cSam223141 MAC_PROP_EN_1000HDX_CAP, 1303fd94f8cSam223141 MAC_PROP_ADV_100FDX_CAP, 1313fd94f8cSam223141 MAC_PROP_EN_100FDX_CAP, 1323fd94f8cSam223141 MAC_PROP_ADV_100HDX_CAP, 1333fd94f8cSam223141 MAC_PROP_EN_100HDX_CAP, 1343fd94f8cSam223141 MAC_PROP_ADV_10FDX_CAP, 1353fd94f8cSam223141 MAC_PROP_EN_10FDX_CAP, 1363fd94f8cSam223141 MAC_PROP_ADV_10HDX_CAP, 1373fd94f8cSam223141 MAC_PROP_EN_10HDX_CAP, 1383fd94f8cSam223141 MAC_PROP_ADV_100T4_CAP, 1393fd94f8cSam223141 MAC_PROP_EN_100T4_CAP, 140bcb5c89dSSowmini Varadhan MAC_PROP_WL_ESSID, 141bcb5c89dSSowmini Varadhan MAC_PROP_WL_BSSID, 142bcb5c89dSSowmini Varadhan MAC_PROP_WL_BSSTYPE, 143bcb5c89dSSowmini Varadhan MAC_PROP_WL_LINKSTATUS, 144bcb5c89dSSowmini Varadhan MAC_PROP_WL_DESIRED_RATES, 145bcb5c89dSSowmini Varadhan MAC_PROP_WL_SUPPORTED_RATES, 146bcb5c89dSSowmini Varadhan MAC_PROP_WL_AUTH_MODE, 147bcb5c89dSSowmini Varadhan MAC_PROP_WL_ENCRYPTION, 148bcb5c89dSSowmini Varadhan MAC_PROP_WL_RSSI, 149bcb5c89dSSowmini Varadhan MAC_PROP_WL_PHY_CONFIG, 150bcb5c89dSSowmini Varadhan MAC_PROP_WL_CAPABILITY, 151bcb5c89dSSowmini Varadhan MAC_PROP_WL_WPA, 152bcb5c89dSSowmini Varadhan MAC_PROP_WL_SCANRESULTS, 153bcb5c89dSSowmini Varadhan MAC_PROP_WL_POWER_MODE, 154bcb5c89dSSowmini Varadhan MAC_PROP_WL_RADIO, 155bcb5c89dSSowmini Varadhan MAC_PROP_WL_ESS_LIST, 156bcb5c89dSSowmini Varadhan MAC_PROP_WL_KEY_TAB, 157bcb5c89dSSowmini Varadhan MAC_PROP_WL_CREATE_IBSS, 158bcb5c89dSSowmini Varadhan MAC_PROP_WL_SETOPTIE, 159bcb5c89dSSowmini Varadhan MAC_PROP_WL_DELKEY, 160bcb5c89dSSowmini Varadhan MAC_PROP_WL_KEY, 161bcb5c89dSSowmini Varadhan MAC_PROP_WL_MLME, 162*da14cebeSEric Cheng MAC_PROP_MAXBW, 163*da14cebeSEric Cheng MAC_PROP_PRIO, 164*da14cebeSEric Cheng MAC_PROP_BIND_CPU, 1653fd94f8cSam223141 MAC_PROP_PRIVATE = -1 1663fd94f8cSam223141 } mac_prop_id_t; 1673fd94f8cSam223141 168843e1988Sjohnlev /* 169afdda45fSVasumathi Sundaram - Sun Microsystems * Flags to figure out r/w status of legacy ndd props. 170afdda45fSVasumathi Sundaram - Sun Microsystems */ 171afdda45fSVasumathi Sundaram - Sun Microsystems #define MAC_PROP_PERM_READ 0x0001 172afdda45fSVasumathi Sundaram - Sun Microsystems #define MAC_PROP_PERM_WRITE 0x0010 173afdda45fSVasumathi Sundaram - Sun Microsystems #define MAC_PROP_MAP_KSTAT 0x0100 174afdda45fSVasumathi Sundaram - Sun Microsystems #define MAC_PROP_PERM_RW (MAC_PROP_PERM_READ|MAC_PROP_PERM_WRITE) 175afdda45fSVasumathi Sundaram - Sun Microsystems #define MAC_PROP_FLAGS_RK (MAC_PROP_PERM_READ|MAC_PROP_MAP_KSTAT) 176afdda45fSVasumathi Sundaram - Sun Microsystems 1777c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* 180ba2e4443Sseb * There are three ranges of statistics values. 0 to 1 - MAC_STAT_MIN are 181ba2e4443Sseb * interface statistics maintained by the mac module. MAC_STAT_MIN to 1 - 182ba2e4443Sseb * MACTYPE_STAT_MIN are common MAC statistics defined by the mac module and 183ba2e4443Sseb * maintained by each driver. MACTYPE_STAT_MIN and above are statistics 184ba2e4443Sseb * defined by MAC-Type plugins and maintained by each driver. 1857c478bd9Sstevel@tonic-gate */ 186ba2e4443Sseb #define MAC_STAT_MIN 1000 187ba2e4443Sseb #define MACTYPE_STAT_MIN 2000 188ba2e4443Sseb 189ba2e4443Sseb #define IS_MAC_STAT(stat) \ 190ba2e4443Sseb (stat >= MAC_STAT_MIN && stat < MACTYPE_STAT_MIN) 191ba2e4443Sseb #define IS_MACTYPE_STAT(stat) (stat >= MACTYPE_STAT_MIN) 192ba2e4443Sseb 1939b14cf1dSgd78059 /* 194d62bc4baSyz147064 * Statistics maintained by the mac module, and possibly populated as link 195d62bc4baSyz147064 * statistics. 196d62bc4baSyz147064 */ 197d62bc4baSyz147064 enum mac_mod_stat { 198d62bc4baSyz147064 MAC_STAT_LINK_STATE, 199d62bc4baSyz147064 MAC_STAT_LINK_UP, 200d62bc4baSyz147064 MAC_STAT_PROMISC 201d62bc4baSyz147064 }; 202d62bc4baSyz147064 203d62bc4baSyz147064 /* 2049b14cf1dSgd78059 * Do not reorder, and add only to the end of this list. 2059b14cf1dSgd78059 */ 206ba2e4443Sseb enum mac_driver_stat { 207ba2e4443Sseb /* MIB-II stats (RFC 1213 and RFC 1573) */ 208ba2e4443Sseb MAC_STAT_IFSPEED = MAC_STAT_MIN, 2097c478bd9Sstevel@tonic-gate MAC_STAT_MULTIRCV, 2107c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTRCV, 2117c478bd9Sstevel@tonic-gate MAC_STAT_MULTIXMT, 2127c478bd9Sstevel@tonic-gate MAC_STAT_BRDCSTXMT, 2137c478bd9Sstevel@tonic-gate MAC_STAT_NORCVBUF, 2147c478bd9Sstevel@tonic-gate MAC_STAT_IERRORS, 2157c478bd9Sstevel@tonic-gate MAC_STAT_UNKNOWNS, 2167c478bd9Sstevel@tonic-gate MAC_STAT_NOXMTBUF, 2177c478bd9Sstevel@tonic-gate MAC_STAT_OERRORS, 2187c478bd9Sstevel@tonic-gate MAC_STAT_COLLISIONS, 2197c478bd9Sstevel@tonic-gate MAC_STAT_RBYTES, 2207c478bd9Sstevel@tonic-gate MAC_STAT_IPACKETS, 2217c478bd9Sstevel@tonic-gate MAC_STAT_OBYTES, 2229b14cf1dSgd78059 MAC_STAT_OPACKETS, 2239b14cf1dSgd78059 MAC_STAT_UNDERFLOWS, 2249b14cf1dSgd78059 MAC_STAT_OVERFLOWS 2257c478bd9Sstevel@tonic-gate }; 2267c478bd9Sstevel@tonic-gate 2279b14cf1dSgd78059 #define MAC_NSTAT (MAC_STAT_OVERFLOWS - MAC_STAT_IFSPEED + 1) 228ba2e4443Sseb 229ba2e4443Sseb #define MAC_STAT_ISACOUNTER(_stat) ( \ 230ba2e4443Sseb (_stat) == MAC_STAT_MULTIRCV || \ 231ba2e4443Sseb (_stat) == MAC_STAT_BRDCSTRCV || \ 232ba2e4443Sseb (_stat) == MAC_STAT_MULTIXMT || \ 233ba2e4443Sseb (_stat) == MAC_STAT_BRDCSTXMT || \ 234ba2e4443Sseb (_stat) == MAC_STAT_NORCVBUF || \ 235ba2e4443Sseb (_stat) == MAC_STAT_IERRORS || \ 236ba2e4443Sseb (_stat) == MAC_STAT_UNKNOWNS || \ 237ba2e4443Sseb (_stat) == MAC_STAT_NOXMTBUF || \ 238ba2e4443Sseb (_stat) == MAC_STAT_OERRORS || \ 239ba2e4443Sseb (_stat) == MAC_STAT_COLLISIONS || \ 240ba2e4443Sseb (_stat) == MAC_STAT_RBYTES || \ 241ba2e4443Sseb (_stat) == MAC_STAT_IPACKETS || \ 242ba2e4443Sseb (_stat) == MAC_STAT_OBYTES || \ 2439b14cf1dSgd78059 (_stat) == MAC_STAT_OPACKETS || \ 2449b14cf1dSgd78059 (_stat) == MAC_STAT_UNDERFLOWS || \ 2459b14cf1dSgd78059 (_stat) == MAC_STAT_OVERFLOWS) 246ba2e4443Sseb 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * Immutable information. (This may not be modified after registration). 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate typedef struct mac_info_s { 2517c478bd9Sstevel@tonic-gate uint_t mi_media; 2520ba2cbe9Sxc151355 uint_t mi_nativemedia; 2537c478bd9Sstevel@tonic-gate uint_t mi_addr_length; 254ba2e4443Sseb uint8_t *mi_unicst_addr; 255ba2e4443Sseb uint8_t *mi_brdcst_addr; 2567c478bd9Sstevel@tonic-gate } mac_info_t; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate /* 259d62bc4baSyz147064 * Information for legacy devices. 260d62bc4baSyz147064 */ 261d62bc4baSyz147064 typedef struct mac_capab_legacy_s { 262d62bc4baSyz147064 /* 263d62bc4baSyz147064 * Notifications that the legacy device does not support. 264d62bc4baSyz147064 */ 265d62bc4baSyz147064 uint32_t ml_unsup_note; 266d62bc4baSyz147064 /* 267d62bc4baSyz147064 * dev_t of the legacy device; can be held to force attach. 268d62bc4baSyz147064 */ 269d62bc4baSyz147064 dev_t ml_dev; 270d62bc4baSyz147064 } mac_capab_legacy_t; 271d62bc4baSyz147064 272d62bc4baSyz147064 /* 273*da14cebeSEric Cheng * When VNICs are created on top of the NIC, there are two levels 274*da14cebeSEric Cheng * of MAC layer, a lower MAC, which is the MAC layer at the level of the 275*da14cebeSEric Cheng * physical NIC, and an upper MAC, which is the MAC layer at the level 276*da14cebeSEric Cheng * of the VNIC. Each VNIC maps to a MAC client at the lower MAC, and 277*da14cebeSEric Cheng * the SRS and classification is done at the lower MAC level. The upper 278*da14cebeSEric Cheng * MAC is therefore for the most part pass-through, and therefore 279*da14cebeSEric Cheng * special processing needs to be done at the upper MAC layer when 280*da14cebeSEric Cheng * dealing with a VNIC. 281678453a8Sspeer * 282*da14cebeSEric Cheng * This capability allows the MAC layer to detect when a VNIC is being 283*da14cebeSEric Cheng * access, and implement the required shortcuts. 284678453a8Sspeer */ 285678453a8Sspeer 286*da14cebeSEric Cheng typedef void *(*mac_client_handle_fn_t)(void *); 287678453a8Sspeer 288*da14cebeSEric Cheng typedef struct mac_capab_vnic_s { 289*da14cebeSEric Cheng void *mcv_arg; 290*da14cebeSEric Cheng mac_client_handle_fn_t mcv_mac_client_handle; 291*da14cebeSEric Cheng } mac_capab_vnic_t; 292678453a8Sspeer 293*da14cebeSEric Cheng typedef void (*mac_rename_fn_t)(const char *, void *); 294*da14cebeSEric Cheng typedef struct mac_capab_aggr_s { 295*da14cebeSEric Cheng mac_rename_fn_t mca_rename_fn; 296*da14cebeSEric Cheng int (*mca_unicst)(void *, const uint8_t *); 297*da14cebeSEric Cheng } mac_capab_aggr_t; 298678453a8Sspeer 2997c478bd9Sstevel@tonic-gate typedef enum { 3007c478bd9Sstevel@tonic-gate MAC_NOTE_LINK, 3017c478bd9Sstevel@tonic-gate MAC_NOTE_PROMISC, 3027c478bd9Sstevel@tonic-gate MAC_NOTE_UNICST, 3037c478bd9Sstevel@tonic-gate MAC_NOTE_TX, 3047c478bd9Sstevel@tonic-gate MAC_NOTE_RESOURCE, 3057c478bd9Sstevel@tonic-gate MAC_NOTE_DEVPROMISC, 306ba2e4443Sseb MAC_NOTE_FASTPATH_FLUSH, 307e7801d59Ssowmini MAC_NOTE_SDU_SIZE, 308d62bc4baSyz147064 MAC_NOTE_MARGIN, 309*da14cebeSEric Cheng MAC_NOTE_CAPAB_CHG, 3107c478bd9Sstevel@tonic-gate MAC_NNOTE /* must be the last entry */ 3117c478bd9Sstevel@tonic-gate } mac_notify_type_t; 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate typedef void (*mac_notify_t)(void *, mac_notify_type_t); 314*da14cebeSEric Cheng typedef void (*mac_rx_t)(void *, mac_resource_handle_t, mblk_t *, 315*da14cebeSEric Cheng boolean_t); 316*da14cebeSEric Cheng typedef mblk_t *(*mac_receive_t)(void *, int); 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate /* 3197c478bd9Sstevel@tonic-gate * MAC promiscuous types 3207c478bd9Sstevel@tonic-gate */ 3217c478bd9Sstevel@tonic-gate typedef enum { 3227c478bd9Sstevel@tonic-gate MAC_PROMISC = 0x01, /* MAC instance is promiscuous */ 3237c478bd9Sstevel@tonic-gate MAC_DEVPROMISC = 0x02 /* Device is promiscuous */ 3247c478bd9Sstevel@tonic-gate } mac_promisc_type_t; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * MAC resource types 3287c478bd9Sstevel@tonic-gate */ 3297c478bd9Sstevel@tonic-gate typedef enum { 3307c478bd9Sstevel@tonic-gate MAC_RX_FIFO = 1 3317c478bd9Sstevel@tonic-gate } mac_resource_type_t; 3327c478bd9Sstevel@tonic-gate 333*da14cebeSEric Cheng typedef int (*mac_intr_enable_t)(mac_intr_handle_t); 334*da14cebeSEric Cheng typedef int (*mac_intr_disable_t)(mac_intr_handle_t); 335*da14cebeSEric Cheng 336*da14cebeSEric Cheng typedef struct mac_intr_s { 337*da14cebeSEric Cheng mac_intr_handle_t mi_handle; 338*da14cebeSEric Cheng mac_intr_enable_t mi_enable; 339*da14cebeSEric Cheng mac_intr_disable_t mi_disable; 340*da14cebeSEric Cheng } mac_intr_t; 341*da14cebeSEric Cheng 3427c478bd9Sstevel@tonic-gate typedef struct mac_rx_fifo_s { 3437c478bd9Sstevel@tonic-gate mac_resource_type_t mrf_type; /* MAC_RX_FIFO */ 344*da14cebeSEric Cheng mac_intr_t mrf_intr; 345*da14cebeSEric Cheng mac_receive_t mrf_receive; 346*da14cebeSEric Cheng void *mrf_rx_arg; 347*da14cebeSEric Cheng uint32_t mrf_flow_priority; 348*da14cebeSEric Cheng /* 349*da14cebeSEric Cheng * The CPU this flow is to be processed on. With intrd and future 350*da14cebeSEric Cheng * things, we should know which CPU the flow needs to be processed 351*da14cebeSEric Cheng * and get a squeue assigned on that CPU. 352*da14cebeSEric Cheng */ 353*da14cebeSEric Cheng uint_t mrf_cpu_id; 3547c478bd9Sstevel@tonic-gate } mac_rx_fifo_t; 3557c478bd9Sstevel@tonic-gate 356*da14cebeSEric Cheng #define mrf_intr_handle mrf_intr.mi_handle 357*da14cebeSEric Cheng #define mrf_intr_enable mrf_intr.mi_enable 358*da14cebeSEric Cheng #define mrf_intr_disable mrf_intr.mi_disable 35998b1442aSmeem 3607c478bd9Sstevel@tonic-gate typedef union mac_resource_u { 3617c478bd9Sstevel@tonic-gate mac_resource_type_t mr_type; 3627c478bd9Sstevel@tonic-gate mac_rx_fifo_t mr_fifo; 3637c478bd9Sstevel@tonic-gate } mac_resource_t; 3647c478bd9Sstevel@tonic-gate 365ba2e4443Sseb typedef enum { 366ba2e4443Sseb MAC_ADDRTYPE_UNICAST, 367ba2e4443Sseb MAC_ADDRTYPE_MULTICAST, 368ba2e4443Sseb MAC_ADDRTYPE_BROADCAST 369ba2e4443Sseb } mac_addrtype_t; 370ba2e4443Sseb 371ba2e4443Sseb typedef struct mac_header_info_s { 372ba2e4443Sseb size_t mhi_hdrsize; 373ba2e4443Sseb size_t mhi_pktsize; 374ba2e4443Sseb const uint8_t *mhi_daddr; 375ba2e4443Sseb const uint8_t *mhi_saddr; 376ba2e4443Sseb uint32_t mhi_origsap; 377ba2e4443Sseb uint32_t mhi_bindsap; 378ba2e4443Sseb mac_addrtype_t mhi_dsttype; 379605445d5Sdg199075 uint16_t mhi_tci; 380*da14cebeSEric Cheng boolean_t mhi_istagged; 381ba2e4443Sseb } mac_header_info_t; 382ba2e4443Sseb 383ba2e4443Sseb /* 384*da14cebeSEric Cheng * Function pointer to match dls client signature. Should be same as 385*da14cebeSEric Cheng * dls_rx_t to allow a soft ring to bypass DLS layer and call a DLS 386*da14cebeSEric Cheng * client directly. 387*da14cebeSEric Cheng */ 388*da14cebeSEric Cheng typedef void (*mac_direct_rx_t)(void *, mac_resource_handle_t, 389*da14cebeSEric Cheng mblk_t *, mac_header_info_t *); 390*da14cebeSEric Cheng 391*da14cebeSEric Cheng typedef mac_resource_handle_t (*mac_resource_add_t)(void *, mac_resource_t *); 392*da14cebeSEric Cheng typedef int (*mac_resource_bind_t)(void *, 393*da14cebeSEric Cheng mac_resource_handle_t, processorid_t); 394*da14cebeSEric Cheng typedef void (*mac_resource_remove_t)(void *, void *); 395*da14cebeSEric Cheng typedef void (*mac_resource_quiesce_t)(void *, void *); 396*da14cebeSEric Cheng typedef void (*mac_resource_restart_t)(void *, void *); 397*da14cebeSEric Cheng typedef int (*mac_resource_modify_t)(void *, void *, 398*da14cebeSEric Cheng mac_resource_t *); 399*da14cebeSEric Cheng typedef void (*mac_change_upcall_t)(void *, mac_direct_rx_t, 400*da14cebeSEric Cheng void *); 401*da14cebeSEric Cheng 402*da14cebeSEric Cheng /* 403ba2e4443Sseb * MAC-Type plugin interfaces 404ba2e4443Sseb */ 405ba2e4443Sseb 406ba2e4443Sseb typedef int (*mtops_addr_verify_t)(const void *, void *); 407ba2e4443Sseb typedef boolean_t (*mtops_sap_verify_t)(uint32_t, uint32_t *, void *); 408ba2e4443Sseb typedef mblk_t *(*mtops_header_t)(const void *, const void *, 409ba2e4443Sseb uint32_t, void *, mblk_t *, size_t); 410ba2e4443Sseb typedef int (*mtops_header_info_t)(mblk_t *, void *, 411ba2e4443Sseb mac_header_info_t *); 412ba2e4443Sseb typedef boolean_t (*mtops_pdata_verify_t)(void *, size_t); 413ba2e4443Sseb typedef mblk_t *(*mtops_header_modify_t)(mblk_t *, void *); 4140d2a8e5eSgd78059 typedef void (*mtops_link_details_t)(char *, size_t, mac_handle_t, 4150d2a8e5eSgd78059 void *); 416ba2e4443Sseb 417ba2e4443Sseb typedef struct mactype_ops_s { 418ba2e4443Sseb uint_t mtops_ops; 419ba2e4443Sseb /* 420ba2e4443Sseb * mtops_unicst_verify() returns 0 if the given address is a valid 421ba2e4443Sseb * unicast address, or a non-zero errno otherwise. 422ba2e4443Sseb */ 423ba2e4443Sseb mtops_addr_verify_t mtops_unicst_verify; 424ba2e4443Sseb /* 425ba2e4443Sseb * mtops_multicst_verify() returns 0 if the given address is a 426ba2e4443Sseb * valid multicast address, or a non-zero errno otherwise. If the 427ba2e4443Sseb * media doesn't support multicast, ENOTSUP should be returned (for 428ba2e4443Sseb * example). 429ba2e4443Sseb */ 430ba2e4443Sseb mtops_addr_verify_t mtops_multicst_verify; 431ba2e4443Sseb /* 432ba2e4443Sseb * mtops_sap_verify() returns B_TRUE if the given SAP is a valid 433ba2e4443Sseb * SAP value, or B_FALSE otherwise. 434ba2e4443Sseb */ 435ba2e4443Sseb mtops_sap_verify_t mtops_sap_verify; 436ba2e4443Sseb /* 437ba2e4443Sseb * mtops_header() is used to allocate and construct a MAC header. 438ba2e4443Sseb */ 439ba2e4443Sseb mtops_header_t mtops_header; 440ba2e4443Sseb /* 441ba2e4443Sseb * mtops_header_info() is used to gather information on a given MAC 442ba2e4443Sseb * header. 443ba2e4443Sseb */ 444ba2e4443Sseb mtops_header_info_t mtops_header_info; 445ba2e4443Sseb /* 446ba2e4443Sseb * mtops_pdata_verify() is used to verify the validity of MAC 447ba2e4443Sseb * plugin data. It is called by mac_register() if the driver has 448ba2e4443Sseb * supplied MAC plugin data, and also by mac_pdata_update() when 449ba2e4443Sseb * drivers update the data. 450ba2e4443Sseb */ 451ba2e4443Sseb mtops_pdata_verify_t mtops_pdata_verify; 452ba2e4443Sseb /* 453ba2e4443Sseb * mtops_header_cook() is an optional callback that converts (or 454ba2e4443Sseb * "cooks") the given raw header (as sent by a raw DLPI consumer) 455ba2e4443Sseb * into one that is appropriate to send down to the MAC driver. 456ba2e4443Sseb * Following the example above, an Ethernet header sent down by a 457ba2e4443Sseb * DLPI consumer would be converted to whatever header the MAC 458ba2e4443Sseb * driver expects. 459ba2e4443Sseb */ 460ba2e4443Sseb mtops_header_modify_t mtops_header_cook; 461ba2e4443Sseb /* 462ba2e4443Sseb * mtops_header_uncook() is an optional callback that does the 463ba2e4443Sseb * opposite of mtops_header_cook(). It "uncooks" a given MAC 464ba2e4443Sseb * header (as received from the driver) for consumption by raw DLPI 465ba2e4443Sseb * consumers. For example, for a non-Ethernet plugin that wants 466ba2e4443Sseb * raw DLPI consumers to be fooled into thinking that the device 467ba2e4443Sseb * provides Ethernet access, this callback would modify the given 468ba2e4443Sseb * mblk_t such that the MAC header is converted to an Ethernet 469ba2e4443Sseb * header. 470ba2e4443Sseb */ 471ba2e4443Sseb mtops_header_modify_t mtops_header_uncook; 4720d2a8e5eSgd78059 /* 4730d2a8e5eSgd78059 * mtops_link_details() is an optional callback that provides 4740d2a8e5eSgd78059 * extended information about the link state. Its primary purpose 4750d2a8e5eSgd78059 * is to provide type-specific support for syslog contents on 4760d2a8e5eSgd78059 * link up events. If no implementation is provided, then a default 4770d2a8e5eSgd78059 * implementation will be used. 4780d2a8e5eSgd78059 */ 4790d2a8e5eSgd78059 mtops_link_details_t mtops_link_details; 480ba2e4443Sseb } mactype_ops_t; 481ba2e4443Sseb 482ba2e4443Sseb /* 483ba2e4443Sseb * mtops_ops exists for the plugin to enumerate the optional callback 484ba2e4443Sseb * entrypoints it has defined. This allows the mac module to define 485ba2e4443Sseb * additional plugin entrypoints in mactype_ops_t without breaking backward 486ba2e4443Sseb * compatibility with old plugins. 487ba2e4443Sseb */ 488ba2e4443Sseb #define MTOPS_PDATA_VERIFY 0x001 489ba2e4443Sseb #define MTOPS_HEADER_COOK 0x002 490ba2e4443Sseb #define MTOPS_HEADER_UNCOOK 0x004 4910d2a8e5eSgd78059 #define MTOPS_LINK_DETAILS 0x008 492ba2e4443Sseb 4934045d941Ssowmini /* 4944045d941Ssowmini * Provide mapping for legacy ndd ioctls relevant to that mactype. 4954045d941Ssowmini * Note that the ndd ioctls are obsolete, and may be removed in a future 4964045d941Ssowmini * release of Solaris. The ndd ioctls are not typically used in legacy 4974045d941Ssowmini * ethernet drivers. New datalink drivers of all link-types should use 4984045d941Ssowmini * dladm(1m) interfaces for administering tunables and not have to provide 4994045d941Ssowmini * a mapping. 5004045d941Ssowmini */ 5014045d941Ssowmini typedef struct mac_ndd_mapping_s { 5024045d941Ssowmini char *mp_name; 5034045d941Ssowmini union { 5044045d941Ssowmini mac_prop_id_t u_id; 5054045d941Ssowmini uint_t u_kstat; 5064045d941Ssowmini } u_mp_id; 5074045d941Ssowmini long mp_minval; 5084045d941Ssowmini long mp_maxval; 5094045d941Ssowmini size_t mp_valsize; 5104045d941Ssowmini int mp_flags; 5114045d941Ssowmini } mac_ndd_mapping_t; 5124045d941Ssowmini 5134045d941Ssowmini #define mp_prop_id u_mp_id.u_id 5144045d941Ssowmini #define mp_kstat u_mp_id.u_kstat 5154045d941Ssowmini 516*da14cebeSEric Cheng typedef struct mac_stat_info_s { 517*da14cebeSEric Cheng uint_t msi_stat; 518*da14cebeSEric Cheng char *msi_name; 519*da14cebeSEric Cheng uint_t msi_type; /* as defined in kstat_named_init(9F) */ 520*da14cebeSEric Cheng uint64_t msi_default; 521*da14cebeSEric Cheng } mac_stat_info_t; 522*da14cebeSEric Cheng 523ba2e4443Sseb typedef struct mactype_register_s { 524ba2e4443Sseb uint_t mtr_version; /* set by mactype_alloc() */ 525ba2e4443Sseb const char *mtr_ident; 526ba2e4443Sseb mactype_ops_t *mtr_ops; 527ba2e4443Sseb uint_t mtr_mactype; 5280ba2cbe9Sxc151355 uint_t mtr_nativetype; 529ba2e4443Sseb uint_t mtr_addrlen; 530ba2e4443Sseb uint8_t *mtr_brdcst_addr; 531ba2e4443Sseb mac_stat_info_t *mtr_stats; 532ba2e4443Sseb size_t mtr_statcount; 5334045d941Ssowmini mac_ndd_mapping_t *mtr_mapping; 5344045d941Ssowmini size_t mtr_mappingcount; 535ba2e4443Sseb } mactype_register_t; 536ba2e4443Sseb 537e7801d59Ssowmini typedef struct mac_prop_s { 538e7801d59Ssowmini mac_prop_id_t mp_id; 539e7801d59Ssowmini char *mp_name; 5404045d941Ssowmini uint_t mp_flags; 541e7801d59Ssowmini } mac_prop_t; 542e7801d59Ssowmini 5437c478bd9Sstevel@tonic-gate /* 544*da14cebeSEric Cheng * Driver interface functions. 5457c478bd9Sstevel@tonic-gate */ 546d62bc4baSyz147064 extern int mac_open_by_linkid(datalink_id_t, 547d62bc4baSyz147064 mac_handle_t *); 548d62bc4baSyz147064 extern int mac_open_by_linkname(const char *, 549d62bc4baSyz147064 mac_handle_t *); 550d62bc4baSyz147064 extern const char *mac_name(mac_handle_t); 551d62bc4baSyz147064 extern minor_t mac_minor(mac_handle_t); 552d62bc4baSyz147064 extern minor_t mac_minor_hold(boolean_t); 553d62bc4baSyz147064 extern void mac_minor_rele(minor_t); 554*da14cebeSEric Cheng extern void mac_sdu_get(mac_handle_t, uint_t *, uint_t *); 555*da14cebeSEric Cheng extern int mac_maxsdu_update(mac_handle_t, uint_t); 5567c478bd9Sstevel@tonic-gate 557ba2e4443Sseb extern void mac_unicst_update(mac_handle_t, 558ba2e4443Sseb const uint8_t *); 559ba2e4443Sseb extern void mac_resource_update(mac_handle_t); 560*da14cebeSEric Cheng extern void mac_capab_update(mac_handle_t); 561ba2e4443Sseb extern int mac_pdata_update(mac_handle_t, void *, 562ba2e4443Sseb size_t); 563d62bc4baSyz147064 extern boolean_t mac_margin_update(mac_handle_t, uint32_t); 564d62bc4baSyz147064 extern void mac_margin_get(mac_handle_t, uint32_t *); 565d62bc4baSyz147064 extern int mac_margin_remove(mac_handle_t, uint32_t); 566d62bc4baSyz147064 extern int mac_margin_add(mac_handle_t, uint32_t *, 567d62bc4baSyz147064 boolean_t); 568210db224Sericheng extern void mac_init_ops(struct dev_ops *, const char *); 569210db224Sericheng extern void mac_fini_ops(struct dev_ops *); 570d62bc4baSyz147064 extern uint32_t mac_no_notification(mac_handle_t); 571d62bc4baSyz147064 572ba2e4443Sseb extern mactype_register_t *mactype_alloc(uint_t); 573ba2e4443Sseb extern void mactype_free(mactype_register_t *); 574ba2e4443Sseb extern int mactype_register(mactype_register_t *); 575ba2e4443Sseb extern int mactype_unregister(const char *); 576*da14cebeSEric Cheng extern void mac_set_ring(void *, void *); 577*da14cebeSEric Cheng 578*da14cebeSEric Cheng extern void mac_start_logusage(mac_logtype_t, uint_t); 579*da14cebeSEric Cheng extern void mac_stop_logusage(mac_logtype_t); 580*da14cebeSEric Cheng 581*da14cebeSEric Cheng extern mac_handle_t mac_get_lower_mac_handle(mac_handle_t); 5827c478bd9Sstevel@tonic-gate 5837c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5867c478bd9Sstevel@tonic-gate } 5877c478bd9Sstevel@tonic-gate #endif 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate #endif /* _SYS_MAC_H */ 590